github.com/tacshi/go-ethereum@v0.0.0-20230616113857-84a434e20921/params/config_arbitrum.go (about)

     1  // Copyright 2016 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package params
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/tacshi/go-ethereum/common"
    23  )
    24  
    25  type ArbitrumChainParams struct {
    26  	EnableArbOS               bool
    27  	AllowDebugPrecompiles     bool
    28  	DataAvailabilityCommittee bool
    29  	InitialArbOSVersion       uint64
    30  	InitialChainOwner         common.Address
    31  	GenesisBlockNum           uint64
    32  }
    33  
    34  func (c *ChainConfig) IsArbitrum() bool {
    35  	return c.ArbitrumChainParams.EnableArbOS
    36  }
    37  
    38  func (c *ChainConfig) IsArbitrumNitro(num *big.Int) bool {
    39  	return c.IsArbitrum() && isBlockForked(new(big.Int).SetUint64(c.ArbitrumChainParams.GenesisBlockNum), num)
    40  }
    41  
    42  func (c *ChainConfig) DebugMode() bool {
    43  	return c.ArbitrumChainParams.AllowDebugPrecompiles
    44  }
    45  
    46  func (c *ChainConfig) checkArbitrumCompatible(newcfg *ChainConfig, head *big.Int) *ConfigCompatError {
    47  	if c.IsArbitrum() != newcfg.IsArbitrum() {
    48  		// This difference applies to the entire chain, so report that the genesis block is where the difference appears.
    49  		return newBlockCompatError("isArbitrum", common.Big0, common.Big0)
    50  	}
    51  	if !c.IsArbitrum() {
    52  		return nil
    53  	}
    54  	cArb := &c.ArbitrumChainParams
    55  	newArb := &newcfg.ArbitrumChainParams
    56  	if cArb.GenesisBlockNum != newArb.GenesisBlockNum {
    57  		return newBlockCompatError("genesisblocknum", new(big.Int).SetUint64(cArb.GenesisBlockNum), new(big.Int).SetUint64(newArb.GenesisBlockNum))
    58  	}
    59  	return nil
    60  }
    61  
    62  func ArbitrumOneParams() ArbitrumChainParams {
    63  	return ArbitrumChainParams{
    64  		EnableArbOS:               true,
    65  		AllowDebugPrecompiles:     false,
    66  		DataAvailabilityCommittee: false,
    67  		InitialArbOSVersion:       6,
    68  		InitialChainOwner:         common.HexToAddress("0xd345e41ae2cb00311956aa7109fc801ae8c81a52"),
    69  	}
    70  }
    71  
    72  func ArbitrumNovaParams() ArbitrumChainParams {
    73  	return ArbitrumChainParams{
    74  		EnableArbOS:               true,
    75  		AllowDebugPrecompiles:     false,
    76  		DataAvailabilityCommittee: true,
    77  		InitialArbOSVersion:       1,
    78  		InitialChainOwner:         common.HexToAddress("0x9C040726F2A657226Ed95712245DeE84b650A1b5"),
    79  	}
    80  }
    81  
    82  func ArbitrumRollupGoerliTestnetParams() ArbitrumChainParams {
    83  	return ArbitrumChainParams{
    84  		EnableArbOS:               true,
    85  		AllowDebugPrecompiles:     false,
    86  		DataAvailabilityCommittee: false,
    87  		InitialArbOSVersion:       2,
    88  		InitialChainOwner:         common.HexToAddress("0x186B56023d42B2B4E7616589a5C62EEf5FCa21DD"),
    89  	}
    90  }
    91  
    92  func ArbitrumRinkebyTestParams() ArbitrumChainParams {
    93  	return ArbitrumChainParams{
    94  		EnableArbOS:               true,
    95  		AllowDebugPrecompiles:     false,
    96  		DataAvailabilityCommittee: false,
    97  		InitialArbOSVersion:       3,
    98  		InitialChainOwner:         common.HexToAddress("0x06C7DBC804D7BcD881D7b86b667893736b8e0Be2"),
    99  	}
   100  }
   101  
   102  func ArbitrumDevTestParams() ArbitrumChainParams {
   103  	return ArbitrumChainParams{
   104  		EnableArbOS:               true,
   105  		AllowDebugPrecompiles:     true,
   106  		DataAvailabilityCommittee: false,
   107  		InitialArbOSVersion:       11,
   108  		InitialChainOwner:         common.Address{},
   109  	}
   110  }
   111  
   112  func ArbitrumDevTestDASParams() ArbitrumChainParams {
   113  	return ArbitrumChainParams{
   114  		EnableArbOS:               true,
   115  		AllowDebugPrecompiles:     true,
   116  		DataAvailabilityCommittee: true,
   117  		InitialArbOSVersion:       11,
   118  		InitialChainOwner:         common.Address{},
   119  	}
   120  }
   121  
   122  func ArbitrumAnytrustGoerliTestnetParams() ArbitrumChainParams {
   123  	return ArbitrumChainParams{
   124  		EnableArbOS:               true,
   125  		AllowDebugPrecompiles:     false,
   126  		DataAvailabilityCommittee: true,
   127  		InitialArbOSVersion:       2,
   128  		InitialChainOwner:         common.HexToAddress("0x186B56023d42B2B4E7616589a5C62EEf5FCa21DD"),
   129  	}
   130  }
   131  
   132  func DisableArbitrumParams() ArbitrumChainParams {
   133  	return ArbitrumChainParams{
   134  		EnableArbOS:               false,
   135  		AllowDebugPrecompiles:     false,
   136  		DataAvailabilityCommittee: false,
   137  		InitialArbOSVersion:       0,
   138  		InitialChainOwner:         common.Address{},
   139  	}
   140  }
   141  
   142  func ArbitrumOneChainConfig() *ChainConfig {
   143  	return &ChainConfig{
   144  		ChainID:             big.NewInt(42161),
   145  		HomesteadBlock:      big.NewInt(0),
   146  		DAOForkBlock:        nil,
   147  		DAOForkSupport:      true,
   148  		EIP150Block:         big.NewInt(0),
   149  		EIP150Hash:          common.Hash{},
   150  		EIP155Block:         big.NewInt(0),
   151  		EIP158Block:         big.NewInt(0),
   152  		ByzantiumBlock:      big.NewInt(0),
   153  		ConstantinopleBlock: big.NewInt(0),
   154  		PetersburgBlock:     big.NewInt(0),
   155  		IstanbulBlock:       big.NewInt(0),
   156  		MuirGlacierBlock:    big.NewInt(0),
   157  		BerlinBlock:         big.NewInt(0),
   158  		LondonBlock:         big.NewInt(0),
   159  		ArbitrumChainParams: ArbitrumOneParams(),
   160  		Clique: &CliqueConfig{
   161  			Period: 0,
   162  			Epoch:  0,
   163  		},
   164  	}
   165  }
   166  
   167  func ArbitrumNovaChainConfig() *ChainConfig {
   168  	return &ChainConfig{
   169  		ChainID:             big.NewInt(42170),
   170  		HomesteadBlock:      big.NewInt(0),
   171  		DAOForkBlock:        nil,
   172  		DAOForkSupport:      true,
   173  		EIP150Block:         big.NewInt(0),
   174  		EIP150Hash:          common.Hash{},
   175  		EIP155Block:         big.NewInt(0),
   176  		EIP158Block:         big.NewInt(0),
   177  		ByzantiumBlock:      big.NewInt(0),
   178  		ConstantinopleBlock: big.NewInt(0),
   179  		PetersburgBlock:     big.NewInt(0),
   180  		IstanbulBlock:       big.NewInt(0),
   181  		MuirGlacierBlock:    big.NewInt(0),
   182  		BerlinBlock:         big.NewInt(0),
   183  		LondonBlock:         big.NewInt(0),
   184  		ArbitrumChainParams: ArbitrumNovaParams(),
   185  		Clique: &CliqueConfig{
   186  			Period: 0,
   187  			Epoch:  0,
   188  		},
   189  	}
   190  }
   191  
   192  func ArbitrumRollupGoerliTestnetChainConfig() *ChainConfig {
   193  	return &ChainConfig{
   194  		ChainID:             big.NewInt(421613),
   195  		HomesteadBlock:      big.NewInt(0),
   196  		DAOForkBlock:        nil,
   197  		DAOForkSupport:      true,
   198  		EIP150Block:         big.NewInt(0),
   199  		EIP150Hash:          common.Hash{},
   200  		EIP155Block:         big.NewInt(0),
   201  		EIP158Block:         big.NewInt(0),
   202  		ByzantiumBlock:      big.NewInt(0),
   203  		ConstantinopleBlock: big.NewInt(0),
   204  		PetersburgBlock:     big.NewInt(0),
   205  		IstanbulBlock:       big.NewInt(0),
   206  		MuirGlacierBlock:    big.NewInt(0),
   207  		BerlinBlock:         big.NewInt(0),
   208  		LondonBlock:         big.NewInt(0),
   209  		ArbitrumChainParams: ArbitrumRollupGoerliTestnetParams(),
   210  		Clique: &CliqueConfig{
   211  			Period: 0,
   212  			Epoch:  0,
   213  		},
   214  	}
   215  }
   216  
   217  func ArbitrumDevTestChainConfig() *ChainConfig {
   218  	return &ChainConfig{
   219  		ChainID:             big.NewInt(412346),
   220  		HomesteadBlock:      big.NewInt(0),
   221  		DAOForkBlock:        nil,
   222  		DAOForkSupport:      true,
   223  		EIP150Block:         big.NewInt(0),
   224  		EIP150Hash:          common.Hash{},
   225  		EIP155Block:         big.NewInt(0),
   226  		EIP158Block:         big.NewInt(0),
   227  		ByzantiumBlock:      big.NewInt(0),
   228  		ConstantinopleBlock: big.NewInt(0),
   229  		PetersburgBlock:     big.NewInt(0),
   230  		IstanbulBlock:       big.NewInt(0),
   231  		MuirGlacierBlock:    big.NewInt(0),
   232  		BerlinBlock:         big.NewInt(0),
   233  		LondonBlock:         big.NewInt(0),
   234  		ArbitrumChainParams: ArbitrumDevTestParams(),
   235  		Clique: &CliqueConfig{
   236  			Period: 0,
   237  			Epoch:  0,
   238  		},
   239  	}
   240  }
   241  
   242  func ArbitrumDevTestDASChainConfig() *ChainConfig {
   243  	return &ChainConfig{
   244  		ChainID:             big.NewInt(412347),
   245  		HomesteadBlock:      big.NewInt(0),
   246  		DAOForkBlock:        nil,
   247  		DAOForkSupport:      true,
   248  		EIP150Block:         big.NewInt(0),
   249  		EIP150Hash:          common.Hash{},
   250  		EIP155Block:         big.NewInt(0),
   251  		EIP158Block:         big.NewInt(0),
   252  		ByzantiumBlock:      big.NewInt(0),
   253  		ConstantinopleBlock: big.NewInt(0),
   254  		PetersburgBlock:     big.NewInt(0),
   255  		IstanbulBlock:       big.NewInt(0),
   256  		MuirGlacierBlock:    big.NewInt(0),
   257  		BerlinBlock:         big.NewInt(0),
   258  		LondonBlock:         big.NewInt(0),
   259  		ArbitrumChainParams: ArbitrumDevTestDASParams(),
   260  		Clique: &CliqueConfig{
   261  			Period: 0,
   262  			Epoch:  0,
   263  		},
   264  	}
   265  }
   266  
   267  func ArbitrumAnytrustGoerliTestnetChainConfig() *ChainConfig {
   268  	return &ChainConfig{
   269  		ChainID:             big.NewInt(421703),
   270  		HomesteadBlock:      big.NewInt(0),
   271  		DAOForkBlock:        nil,
   272  		DAOForkSupport:      true,
   273  		EIP150Block:         big.NewInt(0),
   274  		EIP150Hash:          common.Hash{},
   275  		EIP155Block:         big.NewInt(0),
   276  		EIP158Block:         big.NewInt(0),
   277  		ByzantiumBlock:      big.NewInt(0),
   278  		ConstantinopleBlock: big.NewInt(0),
   279  		PetersburgBlock:     big.NewInt(0),
   280  		IstanbulBlock:       big.NewInt(0),
   281  		MuirGlacierBlock:    big.NewInt(0),
   282  		BerlinBlock:         big.NewInt(0),
   283  		LondonBlock:         big.NewInt(0),
   284  		ArbitrumChainParams: ArbitrumAnytrustGoerliTestnetParams(),
   285  		Clique: &CliqueConfig{
   286  			Period: 0,
   287  			Epoch:  0,
   288  		},
   289  	}
   290  }
   291  
   292  func ArbitrumRinkebyTestnetChainConfig() *ChainConfig {
   293  	return &ChainConfig{
   294  		ChainID:             big.NewInt(421611),
   295  		HomesteadBlock:      big.NewInt(0),
   296  		DAOForkBlock:        nil,
   297  		DAOForkSupport:      true,
   298  		EIP150Block:         big.NewInt(0),
   299  		EIP150Hash:          common.Hash{},
   300  		EIP155Block:         big.NewInt(0),
   301  		EIP158Block:         big.NewInt(0),
   302  		ByzantiumBlock:      big.NewInt(0),
   303  		ConstantinopleBlock: big.NewInt(0),
   304  		PetersburgBlock:     big.NewInt(0),
   305  		IstanbulBlock:       big.NewInt(0),
   306  		MuirGlacierBlock:    big.NewInt(0),
   307  		BerlinBlock:         big.NewInt(0),
   308  		LondonBlock:         big.NewInt(0),
   309  		ArbitrumChainParams: ArbitrumRinkebyTestParams(),
   310  		Clique: &CliqueConfig{
   311  			Period: 0,
   312  			Epoch:  0,
   313  		},
   314  	}
   315  }
   316  
   317  var ArbitrumSupportedChainConfigs = []*ChainConfig{
   318  	ArbitrumOneChainConfig(),
   319  	ArbitrumNovaChainConfig(),
   320  	ArbitrumRollupGoerliTestnetChainConfig(),
   321  	ArbitrumDevTestChainConfig(),
   322  	ArbitrumDevTestDASChainConfig(),
   323  	ArbitrumAnytrustGoerliTestnetChainConfig(),
   324  	ArbitrumRinkebyTestnetChainConfig(),
   325  }