Skip to content

Commit

Permalink
Merge pull request ethereum#32 from OffchainLabs/arbitrum-params
Browse files Browse the repository at this point in the history
Arbitrum Params
  • Loading branch information
rachel-bousfield authored Jan 7, 2022
2 parents f796d1a + c06d16c commit a59852c
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (st *StateTransition) transitionDbImpl() (*ExecutionResult, error) {
// 6. caller has enough balance to cover asset transfer for **topmost** call

// There are no tips in L2
if st.evm.ChainConfig().Arbitrum && st.gasPrice.Cmp(st.evm.Context.BaseFee) == -1 {
if st.evm.ChainConfig().IsArbitrum() && st.gasPrice.Cmp(st.evm.Context.BaseFee) == -1 {
st.gasPrice = st.evm.Context.BaseFee
}

Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
default:
signer = FrontierSigner{}
}
if config.IsArbitrum(blockNumber) {
if config.IsArbitrum() {
signer = NewArbitrumSigner(signer)
}
return signer
Expand Down
14 changes: 5 additions & 9 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, false}
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, EthereumParams()}

// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, false}
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, EthereumParams()}

TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, false}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, EthereumParams()}

TestRules = TestChainConfig.Rules(new(big.Int))
)
Expand Down Expand Up @@ -357,7 +357,7 @@ type ChainConfig struct {
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`

Arbitrum bool `json:"abitrum,omitempty`
ArbitrumChainParams ArbitrumChainParams `json:"abitrum,omitempty`
}

// EthashConfig is the consensus engine configs for proof-of-work based sealing.
Expand Down Expand Up @@ -485,10 +485,6 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
}

func (c *ChainConfig) IsArbitrum(_ *big.Int) bool {
return c.Arbitrum
}

// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError {
Expand Down Expand Up @@ -691,6 +687,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
IsIstanbul: c.IsIstanbul(num),
IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num),
IsArbitrum: c.IsArbitrum(num),
IsArbitrum: c.IsArbitrum(),
}
}
111 changes: 111 additions & 0 deletions params/config_arbitrum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package params

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
)

type ArbitrumChainParams struct {
EnableArbOS bool
AllowDebugPrecompiles bool
DataAvailabilityCommittee bool
}

func (c *ChainConfig) IsArbitrum() bool {
return c.ArbitrumChainParams.EnableArbOS
}

func (c *ChainConfig) DebugMode() bool {
return c.ArbitrumChainParams.AllowDebugPrecompiles
}

func ArbitrumOneParams() ArbitrumChainParams {
return ArbitrumChainParams{
EnableArbOS: true,
AllowDebugPrecompiles: false,
DataAvailabilityCommittee: false,
}
}

func ArbitrumTestParams() ArbitrumChainParams {
return ArbitrumChainParams{
EnableArbOS: true,
AllowDebugPrecompiles: true,
DataAvailabilityCommittee: false,
}
}

func EthereumParams() ArbitrumChainParams {
return ArbitrumChainParams{
EnableArbOS: false,
AllowDebugPrecompiles: false,
DataAvailabilityCommittee: false,
}
}

func ArbitrumOneChainConfig() *ChainConfig {
return &ChainConfig{
ChainID: big.NewInt(412345),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.Hash{},
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArbitrumChainParams: ArbitrumOneParams(),
Clique: &CliqueConfig{
Period: 0,
Epoch: 0,
},
}
}

func ArbitrumTestChainConfig() *ChainConfig {
return &ChainConfig{
ChainID: big.NewInt(412345),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.Hash{},
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArbitrumChainParams: ArbitrumTestParams(),
Clique: &CliqueConfig{
Period: 0,
Epoch: 0,
},
}
}

0 comments on commit a59852c

Please sign in to comment.