Skip to content

Commit

Permalink
feat: update upcoming fork names (#680)
Browse files Browse the repository at this point in the history
* feat: update upcoming fork names

* bump version

* Apply suggestions from code review

Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com>

* bump version

---------

Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com>
  • Loading branch information
Thegaram and NazariiDenha authored Mar 26, 2024
1 parent 411889e commit 0f0cd99
Show file tree
Hide file tree
Showing 27 changed files with 92 additions and 70 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
head := b.blockchain.CurrentHeader()
if !b.blockchain.Config().IsBanach(head.Number) {
if !b.blockchain.Config().IsCurie(head.Number) {
// If there's no basefee, then it must be a non-1559 execution
if call.GasPrice == nil {
call.GasPrice = new(big.Int)
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add

func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but banach is not active yet")
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but curie is not active yet")
}
// Normalize value
value := opts.Value
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func Transition(ctx *cli.Context) error {
return NewError(ErrorJson, fmt.Errorf("failed signing transactions: %v", err))
}
// Sanity check, to not `panic` in state_transition
if chainConfig.IsBanach(big.NewInt(int64(prestate.Env.Number))) {
if chainConfig.IsCurie(big.NewInt(int64(prestate.Env.Number))) {
if prestate.Env.BaseFee == nil {
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
if header.GasUsed > header.GasLimit {
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
}
if !chain.Config().IsBanach(header.Number) {
if !chain.Config().IsCurie(header.Number) {
// Verify BaseFee not present before EIP-1559 fork.
if header.BaseFee != nil {
return fmt.Errorf("invalid baseFee before fork: have %d, want <nil>", header.BaseFee)
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
}
// Verify the block's gas usage and (if applicable) verify the base fee.
if !chain.Config().IsBanach(header.Number) {
if !chain.Config().IsCurie(header.Number) {
// Verify BaseFee not present before EIP-1559 fork.
if header.BaseFee != nil {
return fmt.Errorf("invalid baseFee before fork: have %d, expected 'nil'", header.BaseFee)
Expand Down
8 changes: 4 additions & 4 deletions consensus/misc/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {

func config() *params.ChainConfig {
config := copyConfig(params.TestChainConfig)
config.LondonBlock = big.NewInt(3)
config.BanachBlock = big.NewInt(5)
config.BernoulliBlock = big.NewInt(3)
config.CurieBlock = big.NewInt(5)
return config
}

Expand All @@ -67,13 +67,13 @@ func TestBlockGasLimits(t *testing.T) {
gasLimit uint64
ok bool
}{
// Transitions from non-banach to banach
// Transitions from non-curie to curie
{10000000, 4, 10000000, true}, // No change
{10000000, 4, 10009764, true}, // Upper limit
{10000000, 4, 10009765, false}, // Upper +1
{10000000, 4, 9990236, true}, // Lower limit
{10000000, 4, 9990235, false}, // Lower limit -1
// Banach to Banach
// Curie to Curie
{20000000, 5, 20000000, true},
{20000000, 5, 20019530, true}, // Upper limit
{20000000, 5, 20019531, false}, // Upper limit +1
Expand Down
2 changes: 1 addition & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
Number: new(big.Int).Add(parent.Number(), common.Big1),
Time: time,
}
if chain.Config().IsBanach(header.Number) {
if chain.Config().IsCurie(header.Number) {
parentL1BaseFee := fees.GetL1BaseFee(state)
header.BaseFee = misc.CalcBaseFee(chain.Config(), parent.Header(), parentL1BaseFee)
}
Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if g.Difficulty == nil {
head.Difficulty = params.GenesisDifficulty
}
if g.Config != nil && g.Config.IsBanach(common.Big0) {
if g.Config != nil && g.Config.IsCurie(common.Big0) {
if g.BaseFee != nil {
head.BaseFee = g.BaseFee
} else {
Expand Down
8 changes: 5 additions & 3 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func TestStateProcessorErrors(t *testing.T) {
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
BanachBlock: big.NewInt(0),
BernoulliBlock: big.NewInt(0),
CurieBlock: big.NewInt(0),
Ethash: new(params.EthashConfig),
}
signer = types.LatestSigner(config)
Expand Down Expand Up @@ -333,7 +334,8 @@ func TestStateProcessorErrors(t *testing.T) {
ArrowGlacierBlock: big.NewInt(0),
ArchimedesBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
BanachBlock: big.NewInt(0),
BernoulliBlock: big.NewInt(0),
CurieBlock: big.NewInt(0),
},
Alloc: GenesisAlloc{
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
Expand Down Expand Up @@ -398,7 +400,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
UncleHash: types.EmptyUncleHash,
}

if config.IsBanach(header.Number) {
if config.IsCurie(header.Number) {
parentL1BaseFee := big.NewInt(1000000000) // 1 gwei
header.BaseFee = misc.CalcBaseFee(config, parent.Header(), parentL1BaseFee)
}
Expand Down
4 changes: 2 additions & 2 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (st *StateTransition) preCheck() error {
}
}
// Make sure that transaction gasFeeCap is greater than the baseFee (post london)
// Note: Logically, this should be `IsBanach`, but we keep `IsLondon` to ensure backward compatibility.
// Note: Logically, this should be `IsCurie`, but we keep `IsLondon` to ensure backward compatibility.
if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) {
// Skip the checks if gas fields are zero and baseFee was explicitly disabled (eth_call)
if !st.evm.Config.NoBaseFee || st.gasFeeCap.BitLen() > 0 || st.gasTipCap.BitLen() > 0 {
Expand Down Expand Up @@ -414,7 +414,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
effectiveTip := st.gasPrice

// only burn the base fee if the fee vault is not enabled
if rules.IsBanach && !st.evm.ChainConfig().Scroll.FeeVaultEnabled() {
if rules.IsCurie && !st.evm.ChainConfig().Scroll.FeeVaultEnabled() {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
}

Expand Down
6 changes: 3 additions & 3 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
// because of another transaction (e.g. higher gas price).
if reset != nil {
pool.demoteUnexecutables()
if reset.newHead != nil && pool.chainconfig.IsBanach(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) {
if reset.newHead != nil && pool.chainconfig.IsCurie(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) {
l1BaseFee := fees.GetL1BaseFee(pool.currentState)
pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead, l1BaseFee)
pool.priced.SetBaseFee(pendingBaseFee)
Expand Down Expand Up @@ -1357,8 +1357,8 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
next := new(big.Int).Add(newHead.Number, big.NewInt(1))
pool.istanbul = pool.chainconfig.IsIstanbul(next)

pool.eip2718 = pool.chainconfig.IsBanach(next)
pool.eip1559 = pool.chainconfig.IsBanach(next)
pool.eip2718 = pool.chainconfig.IsCurie(next)
pool.eip1559 = pool.chainconfig.IsCurie(next)
pool.shanghai = pool.chainconfig.IsShanghai(next)
}

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 @@ -40,7 +40,7 @@ type sigCache struct {
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
var signer Signer
switch {
case config.IsBanach(blockNumber):
case config.IsCurie(blockNumber):
signer = NewLondonSignerWithEIP4844(config.ChainID)
case config.IsLondon(blockNumber):
signer = NewLondonSignerWithEIP4844(config.ChainID)
Expand Down
16 changes: 8 additions & 8 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ var PrecompiledContractsArchimedes = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
}

// PrecompiledContractsBanach contains the default set of pre-compiled Ethereum
// contracts used in the Banach release. Same as Archimedes but with sha256hash enabled again
var PrecompiledContractsBanach = map[common.Address]PrecompiledContract{
// PrecompiledContractsBernoulli contains the default set of pre-compiled Ethereum
// contracts used in the Bernoulli release. Same as Archimedes but with sha256hash enabled again
var PrecompiledContractsBernoulli = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{1}): &ecrecover{},
common.BytesToAddress([]byte{2}): &sha256hash{},
common.BytesToAddress([]byte{3}): &ripemd160hashDisabled{},
Expand All @@ -140,7 +140,7 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
}

var (
PrecompiledAddressesBanach []common.Address
PrecompiledAddressesBernoulli []common.Address
PrecompiledAddressesArchimedes []common.Address
PrecompiledAddressesBerlin []common.Address
PrecompiledAddressesIstanbul []common.Address
Expand All @@ -164,16 +164,16 @@ func init() {
for k := range PrecompiledContractsArchimedes {
PrecompiledAddressesArchimedes = append(PrecompiledAddressesArchimedes, k)
}
for k := range PrecompiledContractsBanach {
PrecompiledAddressesBanach = append(PrecompiledAddressesBanach, k)
for k := range PrecompiledContractsBernoulli {
PrecompiledAddressesBernoulli = append(PrecompiledAddressesBernoulli, k)
}
}

// ActivePrecompiles returns the precompiles enabled with the current configuration.
func ActivePrecompiles(rules params.Rules) []common.Address {
switch {
case rules.IsBanach:
return PrecompiledAddressesBanach
case rules.IsBernoulli:
return PrecompiledAddressesBernoulli
case rules.IsArchimedes:
return PrecompiledAddressesArchimedes
case rules.IsBerlin:
Expand Down
4 changes: 2 additions & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type (
func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
var precompiles map[common.Address]PrecompiledContract
switch {
case evm.chainRules.IsBanach:
precompiles = PrecompiledContractsBanach
case evm.chainRules.IsBernoulli:
precompiles = PrecompiledContractsBernoulli
case evm.chainRules.IsArchimedes:
precompiles = PrecompiledContractsArchimedes
case evm.chainRules.IsBerlin:
Expand Down
4 changes: 2 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
if cfg.JumpTable[STOP] == nil {
var jt JumpTable
switch {
case evm.chainRules.IsBanach:
jt = banachInstructionSet
case evm.chainRules.IsCurie:
jt = curieInstructionSet
case evm.chainRules.IsShanghai:
jt = shanghaiInstructionSet
case evm.chainRules.IsLondon:
Expand Down
8 changes: 4 additions & 4 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ var (
berlinInstructionSet = newBerlinInstructionSet()
londonInstructionSet = newLondonInstructionSet()
shanghaiInstructionSet = newShanghaiInstructionSet()
banachInstructionSet = newBanachInstructionSet()
curieInstructionSet = newCurieInstructionSet()
)

// JumpTable contains the EVM opcodes supported at a given fork.
type JumpTable [256]*operation

// newBanachInstructionSet returns the frontier, homestead, byzantium,
// contantinople, istanbul, petersburg, berlin, london, shanghai, and banach instructions.
func newBanachInstructionSet() JumpTable {
// newCurieInstructionSet returns the frontier, homestead, byzantium,
// contantinople, istanbul, petersburg, berlin, london, shanghai, and curie instructions.
func newCurieInstructionSet() JumpTable {
instructionSet := newShanghaiInstructionSet()
enable3198(&instructionSet) // Base fee opcode https://eips.ethereum.org/EIPS/eip-3198
return instructionSet
Expand Down
4 changes: 3 additions & 1 deletion core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func setDefaults(cfg *Config) {
BerlinBlock: new(big.Int),
LondonBlock: new(big.Int),
ArchimedesBlock: new(big.Int),
BanachBlock: new(big.Int),
ShanghaiBlock: new(big.Int),
BernoulliBlock: new(big.Int),
CurieBlock: new(big.Int),
}
}

Expand Down
4 changes: 2 additions & 2 deletions eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (api *consensusAPI) AssembleBlock(params assembleBlockParams) (*executableD
Extra: []byte{},
Time: params.Timestamp,
}
if config := api.eth.BlockChain().Config(); config.IsBanach(header.Number) {
if config := api.eth.BlockChain().Config(); config.IsCurie(header.Number) {
stateDb, err := api.eth.BlockChain().StateAt(parent.Root())
if err != nil {
return nil, err
Expand Down Expand Up @@ -273,7 +273,7 @@ func insertBlockParamsToBlock(config *chainParams.ChainConfig, parent *types.Hea
GasUsed: params.GasUsed,
Time: params.Timestamp,
}
if config.IsBanach(number) {
if config.IsCurie(number) {
header.BaseFee = misc.CalcBaseFee(config, parent, parentL1BaseFee)
}
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */)
Expand Down
2 changes: 1 addition & 1 deletion eth/gasprice/feehistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (oracle *Oracle) processBlock(bf *blockFees, percentiles []float64) {
if bf.results.baseFee = bf.header.BaseFee; bf.results.baseFee == nil {
bf.results.baseFee = new(big.Int)
}
if chainconfig.IsBanach(big.NewInt(int64(bf.blockNumber + 1))) {
if chainconfig.IsCurie(big.NewInt(int64(bf.blockNumber + 1))) {
state, err := oracle.backend.StateAt(bf.header.Root)
if err != nil || state == nil {
log.Error("State not found", "number", bf.header.Number, "hash", bf.header.Hash().Hex(), "state", state, "err", err)
Expand Down
3 changes: 2 additions & 1 deletion eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool) *testBacke
config.ArrowGlacierBlock = londonBlock
config.ArchimedesBlock = londonBlock
config.ShanghaiBlock = londonBlock
config.BanachBlock = londonBlock
config.BernoulliBlock = londonBlock
config.CurieBlock = londonBlock
engine := ethash.NewFaker()
db := rawdb.NewMemoryDatabase()
genesis, err := gspec.Commit(db)
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
"l1Fee": (*hexutil.Big)(receipt.L1Fee),
}
// Assign the effective gas price paid
if !s.b.ChainConfig().IsBanach(bigblock) {
if !s.b.ChainConfig().IsCurie(bigblock) {
fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
} else {
header, err := s.b.HeaderByHash(ctx, blockHash)
Expand Down
10 changes: 5 additions & 5 deletions internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
// After banach, default to 1559 unless gasPrice is set
// After curie, default to 1559 unless gasPrice is set
head := b.CurrentHeader()
// If user specifies both maxPriorityfee and maxFee, then we do not
// need to consult the chain for defaults. It's definitely a Banach tx.
// need to consult the chain for defaults. It's definitely a Curie tx.
if args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil {
// In this clause, user left some fields unspecified.
if b.ChainConfig().IsBanach(head.Number) && args.GasPrice == nil {
if b.ChainConfig().IsCurie(head.Number) && args.GasPrice == nil {
if args.MaxPriorityFeePerGas == nil {
tip, err := b.SuggestGasTipCap(ctx)
if err != nil {
Expand All @@ -110,14 +110,14 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
}
} else {
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
return errors.New("maxFeePerGas or maxPriorityFeePerGas specified but banach is not active yet")
return errors.New("maxFeePerGas or maxPriorityFeePerGas specified but curie is not active yet")
}
if args.GasPrice == nil {
price, err := b.SuggestGasTipCap(ctx)
if err != nil {
return err
}
if b.ChainConfig().IsBanach(head.Number) {
if b.ChainConfig().IsCurie(head.Number) {
// The legacy tx gas price suggestion should not add 2x base fee
// because all fees are consumed, so it would result in a spiral
// upwards.
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
Time: uint64(timestamp),
}
// Set baseFee if we are on an EIP-1559 chain
if w.chainConfig.IsBanach(header.Number) {
if w.chainConfig.IsCurie(header.Number) {
state, err := w.chain.StateAt(parent.Root())
if err != nil {
log.Error("Failed to create mining context", "err", err)
Expand Down
Loading

0 comments on commit 0f0cd99

Please sign in to comment.