From e3f49f037e2efd1d5d7031b06adf465caa1d4ecd Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 18 Aug 2023 08:00:20 -0600 Subject: [PATCH 01/31] wip Signed-off-by: meows --- params/config_classic.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/params/config_classic.go b/params/config_classic.go index 471ddb5c9e..91a356ee5d 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -94,6 +94,9 @@ var ( EIP3529FBlock: big.NewInt(14_525_000), EIP3541FBlock: big.NewInt(14_525_000), + EIP4399FBlock: big.NewInt(18_000_000), + EIP3651FTime: + RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), 2500000: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"), From efdf7b3f782df0cc7e4888694eeb8208fd7c55a3 Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 18 Aug 2023 09:11:04 -0600 Subject: [PATCH 02/31] params/types/coregeth,params/types/ctypes,params/types/genesisT,params/types/goethereum: install Shanghai=Spiral block number based iface methods ETC plans to install most EIPs associated with ETH's Shanghai fork, but ETC doesn't use PoS so activation by block time, so this adds supporting block-based activation methods for those features. Still TODO is to actually implement the associated conditionals where the Getters are used in the code to actually turn the new features on. Date: 2023-08-18 09:11:04-06:00 Signed-off-by: meows --- params/types/coregeth/chain_config.go | 7 +++ .../coregeth/chain_config_configurator.go | 51 +++++++++++++++++++ params/types/ctypes/configurator_iface.go | 12 +++++ params/types/genesisT/genesis.go | 40 +++++++++++++++ .../goethereum/goethereum_configurator.go | 45 ++++++++++++++++ 5 files changed, 155 insertions(+) diff --git a/params/types/coregeth/chain_config.go b/params/types/coregeth/chain_config.go index 2a0900a161..f885ec2601 100644 --- a/params/types/coregeth/chain_config.go +++ b/params/types/coregeth/chain_config.go @@ -225,6 +225,13 @@ type CoreGethChainConfig struct { EIP4895FTime *uint64 `json:"eip4895FTime,omitempty"` // EIP-4895: Beacon chain push withdrawals as operations EIP6049FTime *uint64 `json:"eip6049FTime,omitempty"` // EIP-6049: Deprecate SELFDESTRUCT. Note: EIP-6049 does not change the behavior of SELFDESTRUCT in and of itself, but formally announces client developers' intention of changing it in future upgrades. It is recommended that software which exposes the SELFDESTRUCT opcode to users warn them about an upcoming change in semantics. + // Shanghai with block activations + EIP3651FBlock *uint64 `json:"eip3651FBlock,omitempty"` // EIP-3651: Warm COINBASE + EIP3855FBlock *uint64 `json:"eip3855FBlock,omitempty"` // EIP-3855: PUSH0 instruction + EIP3860FBlock *uint64 `json:"eip3860FBlock,omitempty"` // EIP-3860: Limit and meter initcode + EIP4895FBlock *uint64 `json:"eip4895FBlock,omitempty"` // EIP-4895: Beacon chain push withdrawals as operations + EIP6049FBlock *uint64 `json:"eip6049FBlock,omitempty"` // EIP-6049: Deprecate SELFDESTRUCT. Note: EIP-6049 does not change the behavior of SELFDESTRUCT in and of itself, but formally announces client developers' intention of changing it in future upgrades. It is recommended that software which exposes the SELFDESTRUCT opcode to users warn them about an upcoming change in semantics. + // Cancun EIP4844FTime *uint64 `json:"eip4844FTime,omitempty"` // EIP-4844: Shard Blob Transactions https://eips.ethereum.org/EIPS/eip-4844 diff --git a/params/types/coregeth/chain_config_configurator.go b/params/types/coregeth/chain_config_configurator.go index e8fb5e0eb0..99463ab8c4 100644 --- a/params/types/coregeth/chain_config_configurator.go +++ b/params/types/coregeth/chain_config_configurator.go @@ -564,6 +564,57 @@ func (c *CoreGethChainConfig) SetEIP6049TransitionTime(n *uint64) error { return nil } +// Shanghai by block +// EIP3651: Warm COINBASE +func (c *CoreGethChainConfig) GetEIP3651Transition() *uint64 { + return c.EIP3651FBlock +} + +func (c *CoreGethChainConfig) SetEIP3651Transition(n *uint64) error { + c.EIP6049FBlock = n + return nil +} + +// GetEIP3855Transition EIP3855: PUSH0 instruction +func (c *CoreGethChainConfig) GetEIP3855Transition() *uint64 { + return c.EIP3855FBlock +} + +func (c *CoreGethChainConfig) SetEIP3855Transition(n *uint64) error { + c.EIP6049FBlock = n + return nil +} + +// GetEIP3860Transition EIP3860: Limit and meter initcode +func (c *CoreGethChainConfig) GetEIP3860Transition() *uint64 { + return c.EIP3860FBlock +} + +func (c *CoreGethChainConfig) SetEIP3860Transition(n *uint64) error { + c.EIP6049FBlock = n + return nil +} + +// GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations +func (c *CoreGethChainConfig) GetEIP4895Transition() *uint64 { + return c.EIP4895FBlock +} + +func (c *CoreGethChainConfig) SetEIP4895Transition(n *uint64) error { + c.EIP6049FBlock = n + return nil +} + +// GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT +func (c *CoreGethChainConfig) GetEIP6049Transition() *uint64 { + return c.EIP6049FBlock +} + +func (c *CoreGethChainConfig) SetEIP6049Transition(n *uint64) error { + c.EIP6049FBlock = n + return nil +} + // GetEIP4844TransitionTime EIP4844: Shard Blob Transactions func (c *CoreGethChainConfig) GetEIP4844TransitionTime() *uint64 { return c.EIP4844FTime diff --git a/params/types/ctypes/configurator_iface.go b/params/types/ctypes/configurator_iface.go index 9f3e00cd09..8b496b00cb 100644 --- a/params/types/ctypes/configurator_iface.go +++ b/params/types/ctypes/configurator_iface.go @@ -196,6 +196,18 @@ type ProtocolSpecifier interface { GetEIP6049TransitionTime() *uint64 SetEIP6049TransitionTime(n *uint64) error + // Shanghai expressed as block activation numbers: + GetEIP3651Transition() *uint64 + SetEIP3651Transition(n *uint64) error + GetEIP3855Transition() *uint64 + SetEIP3855Transition(n *uint64) error + GetEIP3860Transition() *uint64 + SetEIP3860Transition(n *uint64) error + GetEIP4895Transition() *uint64 + SetEIP4895Transition(n *uint64) error + GetEIP6049Transition() *uint64 + SetEIP6049Transition(n *uint64) error + // GetMergeVirtualTransition is a Virtual fork after The Merge to use as a network splitter GetMergeVirtualTransition() *uint64 SetMergeVirtualTransition(n *uint64) error diff --git a/params/types/genesisT/genesis.go b/params/types/genesisT/genesis.go index 406fea0d6f..17b5027ef4 100644 --- a/params/types/genesisT/genesis.go +++ b/params/types/genesisT/genesis.go @@ -122,6 +122,46 @@ func (g *Genesis) SetEIP4844TransitionTime(n *uint64) error { return g.Config.SetEIP4844TransitionTime(n) } +func (g *Genesis) GetEIP3651Transition() *uint64 { + return g.Config.GetEIP3651Transition() +} + +func (g *Genesis) SetEIP3651Transition(n *uint64) error { + return g.Config.SetEIP3651Transition(n) +} + +func (g *Genesis) GetEIP3855Transition() *uint64 { + return g.Config.GetEIP3855Transition() +} + +func (g *Genesis) SetEIP3855Transition(n *uint64) error { + return g.Config.SetEIP3855Transition(n) +} + +func (g *Genesis) GetEIP3860Transition() *uint64 { + return g.Config.GetEIP3860Transition() +} + +func (g *Genesis) SetEIP3860Transition(n *uint64) error { + return g.Config.SetEIP3860Transition(n) +} + +func (g *Genesis) GetEIP4895Transition() *uint64 { + return g.Config.GetEIP4895Transition() +} + +func (g *Genesis) SetEIP4895Transition(n *uint64) error { + return g.Config.SetEIP4895Transition(n) +} + +func (g *Genesis) GetEIP6049Transition() *uint64 { + return g.Config.GetEIP6049Transition() +} + +func (g *Genesis) SetEIP6049Transition(n *uint64) error { + return g.Config.SetEIP6049Transition(n) +} + func (g *Genesis) IsEnabledByTime(fn func() *uint64, n *uint64) bool { return g.Config.IsEnabledByTime(fn, n) } diff --git a/params/types/goethereum/goethereum_configurator.go b/params/types/goethereum/goethereum_configurator.go index c0d0e961dc..0d7d21c8f1 100644 --- a/params/types/goethereum/goethereum_configurator.go +++ b/params/types/goethereum/goethereum_configurator.go @@ -592,6 +592,51 @@ func (c *ChainConfig) SetEIP6049TransitionTime(n *uint64) error { return nil } +// EIP3651: Warm COINBASE +func (c *ChainConfig) GetEIP3651Transition() *uint64 { + return nil +} + +func (c *ChainConfig) SetEIP3651Transition(n *uint64) error { + return ctypes.ErrUnsupportedConfigFatal +} + +// GetEIP3855Transition EIP3855: PUSH0 instruction +func (c *ChainConfig) GetEIP3855Transition() *uint64 { + return nil +} + +func (c *ChainConfig) SetEIP3855Transition(n *uint64) error { + return ctypes.ErrUnsupportedConfigFatal +} + +// GetEIP3860Transition EIP3860: Limit and meter initcode +func (c *ChainConfig) GetEIP3860Transition() *uint64 { + return nil +} + +func (c *ChainConfig) SetEIP3860Transition(n *uint64) error { + return ctypes.ErrUnsupportedConfigFatal +} + +// GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations +func (c *ChainConfig) GetEIP4895Transition() *uint64 { + return nil +} + +func (c *ChainConfig) SetEIP4895Transition(n *uint64) error { + return ctypes.ErrUnsupportedConfigFatal +} + +// GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT +func (c *ChainConfig) GetEIP6049Transition() *uint64 { + return nil +} + +func (c *ChainConfig) SetEIP6049Transition(n *uint64) error { + return ctypes.ErrUnsupportedConfigFatal +} + // GetEIP4844TransitionTime EIP4844: Shard Block Transactions func (c *ChainConfig) GetEIP4844TransitionTime() *uint64 { return c.CancunTime From 4f6ac6fcd92441d0a316aae1a0f1ebdc2896174c Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 18 Aug 2023 19:28:32 -0600 Subject: [PATCH 03/31] params: (typo) remove spurious and meaningless line Date: 2023-08-18 19:28:32-06:00 Signed-off-by: meows --- params/config_classic.go | 1 - 1 file changed, 1 deletion(-) diff --git a/params/config_classic.go b/params/config_classic.go index 91a356ee5d..b9682dc4ba 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -95,7 +95,6 @@ var ( EIP3541FBlock: big.NewInt(14_525_000), EIP4399FBlock: big.NewInt(18_000_000), - EIP3651FTime: RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), From 7d916b3720f183e9efad134439e857c3f29ff8ba Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 18 Aug 2023 19:30:17 -0600 Subject: [PATCH 04/31] params/types/coregeth: fix feature-block type: uint64/big.Int Blocks are big ints. Times are uint64s. I am 73% certain this covers all cases. Date: 2023-08-18 19:30:17-06:00 Signed-off-by: meows --- params/types/coregeth/chain_config.go | 10 +++++----- .../coregeth/chain_config_configurator.go | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/params/types/coregeth/chain_config.go b/params/types/coregeth/chain_config.go index f885ec2601..2cec7c54b2 100644 --- a/params/types/coregeth/chain_config.go +++ b/params/types/coregeth/chain_config.go @@ -226,11 +226,11 @@ type CoreGethChainConfig struct { EIP6049FTime *uint64 `json:"eip6049FTime,omitempty"` // EIP-6049: Deprecate SELFDESTRUCT. Note: EIP-6049 does not change the behavior of SELFDESTRUCT in and of itself, but formally announces client developers' intention of changing it in future upgrades. It is recommended that software which exposes the SELFDESTRUCT opcode to users warn them about an upcoming change in semantics. // Shanghai with block activations - EIP3651FBlock *uint64 `json:"eip3651FBlock,omitempty"` // EIP-3651: Warm COINBASE - EIP3855FBlock *uint64 `json:"eip3855FBlock,omitempty"` // EIP-3855: PUSH0 instruction - EIP3860FBlock *uint64 `json:"eip3860FBlock,omitempty"` // EIP-3860: Limit and meter initcode - EIP4895FBlock *uint64 `json:"eip4895FBlock,omitempty"` // EIP-4895: Beacon chain push withdrawals as operations - EIP6049FBlock *uint64 `json:"eip6049FBlock,omitempty"` // EIP-6049: Deprecate SELFDESTRUCT. Note: EIP-6049 does not change the behavior of SELFDESTRUCT in and of itself, but formally announces client developers' intention of changing it in future upgrades. It is recommended that software which exposes the SELFDESTRUCT opcode to users warn them about an upcoming change in semantics. + EIP3651FBlock *big.Int `json:"eip3651FBlock,omitempty"` // EIP-3651: Warm COINBASE + EIP3855FBlock *big.Int `json:"eip3855FBlock,omitempty"` // EIP-3855: PUSH0 instruction + EIP3860FBlock *big.Int `json:"eip3860FBlock,omitempty"` // EIP-3860: Limit and meter initcode + EIP4895FBlock *big.Int `json:"eip4895FBlock,omitempty"` // EIP-4895: Beacon chain push withdrawals as operations + EIP6049FBlock *big.Int `json:"eip6049FBlock,omitempty"` // EIP-6049: Deprecate SELFDESTRUCT. Note: EIP-6049 does not change the behavior of SELFDESTRUCT in and of itself, but formally announces client developers' intention of changing it in future upgrades. It is recommended that software which exposes the SELFDESTRUCT opcode to users warn them about an upcoming change in semantics. // Cancun EIP4844FTime *uint64 `json:"eip4844FTime,omitempty"` // EIP-4844: Shard Blob Transactions https://eips.ethereum.org/EIPS/eip-4844 diff --git a/params/types/coregeth/chain_config_configurator.go b/params/types/coregeth/chain_config_configurator.go index 99463ab8c4..daae683dde 100644 --- a/params/types/coregeth/chain_config_configurator.go +++ b/params/types/coregeth/chain_config_configurator.go @@ -567,51 +567,51 @@ func (c *CoreGethChainConfig) SetEIP6049TransitionTime(n *uint64) error { // Shanghai by block // EIP3651: Warm COINBASE func (c *CoreGethChainConfig) GetEIP3651Transition() *uint64 { - return c.EIP3651FBlock + return bigNewU64(c.EIP3651FBlock) } func (c *CoreGethChainConfig) SetEIP3651Transition(n *uint64) error { - c.EIP6049FBlock = n + c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) return nil } // GetEIP3855Transition EIP3855: PUSH0 instruction func (c *CoreGethChainConfig) GetEIP3855Transition() *uint64 { - return c.EIP3855FBlock + return bigNewU64(c.EIP3855FBlock) } func (c *CoreGethChainConfig) SetEIP3855Transition(n *uint64) error { - c.EIP6049FBlock = n + c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) return nil } // GetEIP3860Transition EIP3860: Limit and meter initcode func (c *CoreGethChainConfig) GetEIP3860Transition() *uint64 { - return c.EIP3860FBlock + return bigNewU64(c.EIP3860FBlock) } func (c *CoreGethChainConfig) SetEIP3860Transition(n *uint64) error { - c.EIP6049FBlock = n + c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) return nil } // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations func (c *CoreGethChainConfig) GetEIP4895Transition() *uint64 { - return c.EIP4895FBlock + return bigNewU64(c.EIP4895FBlock) } func (c *CoreGethChainConfig) SetEIP4895Transition(n *uint64) error { - c.EIP6049FBlock = n + c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) return nil } // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT func (c *CoreGethChainConfig) GetEIP6049Transition() *uint64 { - return c.EIP6049FBlock + return bigNewU64(c.EIP6049FBlock) } func (c *CoreGethChainConfig) SetEIP6049Transition(n *uint64) error { - c.EIP6049FBlock = n + c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) return nil } From 3f264ac1d42a5eb751c9b937620413bafc5522a5 Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 18 Aug 2023 19:50:22 -0600 Subject: [PATCH 05/31] core,core/vm/runtime,params,tests: GetEIP3651Transition Date: 2023-08-18 19:50:22-06:00 Signed-off-by: meows --- core/state_transition.go | 3 ++- core/vm/runtime/runtime.go | 9 ++++++--- params/config_classic.go | 2 +- tests/state_test.go | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 80882be08a..385f42e071 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -361,7 +361,8 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { eip3860f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3860TransitionTime, &st.evm.Context.Time) // EIP-3651: Warm coinbase - eip3651f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3651TransitionTime, &st.evm.Context.Time) + eip3651f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3651TransitionTime, &st.evm.Context.Time) || + st.evm.ChainConfig().IsEnabled(st.evm.ChainConfig().GetEIP3651Transition, st.evm.Context.BlockNumber) ) // Check clauses 4-5, subtract intrinsic gas if everything is correct diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 762ba263c1..f1089d64de 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -123,7 +123,8 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { // Shanghai // EIP-3651: Warm coinbase - eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) + eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) || + cfg.ChainConfig.IsEnabled(cfg.ChainConfig.GetEIP3651Transition, vmenv.Context.BlockNumber) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) @@ -164,7 +165,8 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) { // Shanghai // EIP-3651: Warm coinbase - eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) + eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) || + cfg.ChainConfig.IsEnabled(cfg.ChainConfig.GetEIP3651Transition, vmenv.Context.BlockNumber) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) @@ -199,7 +201,8 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er // Shanghai // EIP-3651: Warm coinbase - eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) + eip3651f = cfg.ChainConfig.IsEnabledByTime(cfg.ChainConfig.GetEIP3651TransitionTime, &vmenv.Context.Time) || + cfg.ChainConfig.IsEnabled(cfg.ChainConfig.GetEIP3651Transition, vmenv.Context.BlockNumber) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) diff --git a/params/config_classic.go b/params/config_classic.go index b9682dc4ba..c2f6a7169f 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -95,7 +95,7 @@ var ( EIP3541FBlock: big.NewInt(14_525_000), EIP4399FBlock: big.NewInt(18_000_000), - +$ RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), 2500000: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"), diff --git a/tests/state_test.go b/tests/state_test.go index 7cb15174b5..a85aa522f9 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -281,7 +281,8 @@ func runBenchmark(b *testing.B, t *StateTest) { // Shanghai // EIP-3651: Warm coinbase - eip3651f = config.IsEnabledByTime(config.GetEIP3651TransitionTime, &evm.Context.Time) + eip3651f = config.IsEnabledByTime(config.GetEIP3651TransitionTime, &evm.Context.Time) || + config.IsEnabled(config.GetEIP3651Transition, evm.Context.BlockNumber) ) b.ResetTimer() for n := 0; n < b.N; n++ { From 1fe13b89c6ab840cb71a3996fb6e66d19ec91b16 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 07:24:31 -0600 Subject: [PATCH 06/31] core,eth/catalyst: SetEIP3651Transition Date: 2023-08-19 07:24:31-06:00 Signed-off-by: meows --- core/genesis.go | 2 ++ eth/catalyst/api_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index 01cf443818..edb57e2dac 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -91,6 +91,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen applyOverrides := func(config ctypes.ChainConfigurator) { if config != nil { + // Block-based overrides are not provided because Shanghai is + // ETH-network specific and that protocol is defined exclusively in time-based forks. if overrides != nil && overrides.OverrideShanghai != nil { config.SetEIP3651TransitionTime(overrides.OverrideShanghai) config.SetEIP3855TransitionTime(overrides.OverrideShanghai) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 4803be74e3..5d957f46b2 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1262,7 +1262,7 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { // enable shanghai on the last block time := blocks[len(blocks)-1].Header().Time + 1 // enable shanghai on the last block - genesis.Config.SetEIP3651TransitionTime(&time) + genesis.Config.SetEIP3651TransitionTime(&time) // SetEIP3651Transition is not implemented in this test helper. genesis.Config.SetEIP3855TransitionTime(&time) genesis.Config.SetEIP3860TransitionTime(&time) genesis.Config.SetEIP4895TransitionTime(&time) From 09bb064e3c3751ea676f0796173c70a0aa853935 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 07:29:40 -0600 Subject: [PATCH 07/31] consensus/clique,core/vm: GetEIP3855Transition Date: 2023-08-19 07:29:40-06:00 Signed-off-by: meows --- consensus/clique/clique.go | 2 +- core/vm/jump_table.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 0a67538839..d9bef488e2 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -299,7 +299,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H if header.GasLimit > vars.MaxGasLimit { return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, vars.MaxGasLimit) } - if chain.Config().IsEnabledByTime(chain.Config().GetEIP3855TransitionTime, &header.Time) { + if chain.Config().IsEnabledByTime(chain.Config().GetEIP3855TransitionTime, &header.Time) || chain.Config().IsEnabled(chain.Config().GetEIP3855Transition, header.Number) { return fmt.Errorf("clique does not support shanghai fork") } if chain.Config().IsEnabledByTime(chain.Config().GetEIP4844TransitionTime, &header.Time) { diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 31f203636b..a8db6a19c9 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -201,7 +201,7 @@ func instructionSetForConfig(config ctypes.ChainConfigurator, isPostMerge bool, maxStack: maxStack(0, 1), } } - if config.IsEnabledByTime(config.GetEIP3855TransitionTime, bt) { + if config.IsEnabledByTime(config.GetEIP3855TransitionTime, bt) || config.IsEnabled(config.GetEIP3855Transition, bn) { enable3855(instructionSet) // PUSH0 instruction } if config.IsEnabledByTime(config.GetEIP3860TransitionTime, bt) { From 725ceed8e92e8821a687e1f18fb4d7e082d92007 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 07:43:32 -0600 Subject: [PATCH 08/31] eth/catalyst: SetEIP3855Transition Date: 2023-08-19 07:43:32-06:00 Signed-off-by: meows --- eth/catalyst/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 5d957f46b2..58e33c809f 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1263,7 +1263,7 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { time := blocks[len(blocks)-1].Header().Time + 1 // enable shanghai on the last block genesis.Config.SetEIP3651TransitionTime(&time) // SetEIP3651Transition is not implemented in this test helper. - genesis.Config.SetEIP3855TransitionTime(&time) + genesis.Config.SetEIP3855TransitionTime(&time) // SetEIP3855TransitionTime is not implemented in this test helper. genesis.Config.SetEIP3860TransitionTime(&time) genesis.Config.SetEIP4895TransitionTime(&time) genesis.Config.SetEIP6049TransitionTime(&time) From 4de463705360c7d24e08fd2de3e4c510417cf10d Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 07:53:58 -0600 Subject: [PATCH 09/31] cmd/evm/internal/t8ntool,consensus/ethash,core,core/txpool,core/vm,light: GetEIP3860Transition Date: 2023-08-19 07:53:58-06:00 Signed-off-by: meows --- cmd/evm/internal/t8ntool/transaction.go | 4 ++-- consensus/ethash/consensus.go | 2 +- core/state_transition.go | 3 ++- core/txpool/txpool.go | 2 +- core/vm/jump_table.go | 2 +- light/txpool.go | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transaction.go b/cmd/evm/internal/t8ntool/transaction.go index 001bec55f2..39e86304f0 100644 --- a/cmd/evm/internal/t8ntool/transaction.go +++ b/cmd/evm/internal/t8ntool/transaction.go @@ -145,7 +145,7 @@ func Transaction(ctx *cli.Context) error { eip2f := chainConfig.IsEnabled(chainConfig.GetEIP2Transition, new(big.Int)) eip2028f := chainConfig.IsEnabled(chainConfig.GetEIP2028Transition, new(big.Int)) zero := uint64(0) - eip3860f := chainConfig.IsEnabledByTime(chainConfig.GetEIP3860TransitionTime, &zero) + eip3860f := chainConfig.IsEnabledByTime(chainConfig.GetEIP3860TransitionTime, &zero) || chainConfig.IsEnabled(chainConfig.GetEIP3860Transition, new(big.Int)) // Check intrinsic gas if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, @@ -182,7 +182,7 @@ func Transaction(ctx *cli.Context) error { } // Check whether the init code size has been exceeded. // EIP-3860: Limit and meter initcode - if chainConfig.IsEnabledByTime(chainConfig.GetEIP3860TransitionTime, &zero) && tx.To() == nil && uint64(len(tx.Data())) > vars.MaxInitCodeSize { + if (chainConfig.IsEnabledByTime(chainConfig.GetEIP3860TransitionTime, &zero) || chainConfig.IsEnabled(chainConfig.GetEIP3860Transition, new(big.Int))) && tx.To() == nil && uint64(len(tx.Data())) > vars.MaxInitCodeSize { r.Error = errors.New("max initcode size exceeded") } results = append(results, r) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 64f13c80b1..651c68999a 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -277,7 +277,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 { return consensus.ErrInvalidNumber } - if chain.Config().IsEnabledByTime(chain.Config().GetEIP3860TransitionTime, &header.Time) { + if chain.Config().IsEnabledByTime(chain.Config().GetEIP3860TransitionTime, &header.Time) || chain.Config().IsEnabled(chain.Config().GetEIP3860Transition, header.Number) { return fmt.Errorf("ethash does not support shanghai fork") } if chain.Config().IsEnabledByTime(chain.Config().GetEIP4844TransitionTime, &header.Time) { diff --git a/core/state_transition.go b/core/state_transition.go index 385f42e071..03cac4838d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -358,7 +358,8 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { eip3529f = st.evm.ChainConfig().IsEnabled(st.evm.ChainConfig().GetEIP3529Transition, st.evm.Context.BlockNumber) // EIP-3860: Limit and meter initcode - eip3860f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3860TransitionTime, &st.evm.Context.Time) + eip3860f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3860TransitionTime, &st.evm.Context.Time) || + st.evm.ChainConfig().IsEnabled(st.evm.ChainConfig().GetEIP3860Transition, st.evm.Context.BlockNumber) // EIP-3651: Warm coinbase eip3651f = st.evm.ChainConfig().IsEnabledByTime(st.evm.ChainConfig().GetEIP3651TransitionTime, &st.evm.Context.Time) || diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 10aacafe5a..4cc9282a48 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -1417,7 +1417,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { pool.eip2718.Store(pool.chainconfig.IsEnabled(pool.chainconfig.GetEIP2718Transition, next)) pool.eip1559.Store(pool.chainconfig.IsEnabled(pool.chainconfig.GetEIP1559Transition, next)) now := uint64(time.Now().Unix()) - pool.eip3860.Store(pool.chainconfig.IsEnabledByTime(pool.chainconfig.GetEIP3860TransitionTime, &now)) + pool.eip3860.Store(pool.chainconfig.IsEnabledByTime(pool.chainconfig.GetEIP3860TransitionTime, &now) || pool.chainconfig.IsEnabled(pool.chainconfig.GetEIP3860Transition, next)) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index a8db6a19c9..6aa6961f40 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -204,7 +204,7 @@ func instructionSetForConfig(config ctypes.ChainConfigurator, isPostMerge bool, if config.IsEnabledByTime(config.GetEIP3855TransitionTime, bt) || config.IsEnabled(config.GetEIP3855Transition, bn) { enable3855(instructionSet) // PUSH0 instruction } - if config.IsEnabledByTime(config.GetEIP3860TransitionTime, bt) { + if config.IsEnabledByTime(config.GetEIP3860TransitionTime, bt) || config.IsEnabled(config.GetEIP3860Transition, bn) { enable3860(instructionSet) // Limit and meter initcode } return validate(instructionSet) diff --git a/light/txpool.go b/light/txpool.go index f076f522df..6b33e75eb1 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -339,7 +339,7 @@ func (pool *TxPool) setNewHead(head *types.Header) { pool.eip2028f = pool.config.IsEnabled(pool.config.GetEIP2028Transition, next) pool.eip2718 = pool.config.IsEnabled(pool.config.GetEIP2718Transition, next) now := uint64(time.Now().Unix()) - pool.eip3860 = pool.config.IsEnabledByTime(pool.config.GetEIP3860TransitionTime, &now) + pool.eip3860 = pool.config.IsEnabledByTime(pool.config.GetEIP3860TransitionTime, &now) || pool.config.IsEnabled(pool.config.GetEIP3860Transition, next) } // Stop stops the light transaction pool From 890361c8e07960bc22cd509f69bdc6aa7bd0ab50 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 07:55:11 -0600 Subject: [PATCH 10/31] eth/catalyst: SetEIP3860Transition Date: 2023-08-19 07:55:11-06:00 Signed-off-by: meows --- eth/catalyst/api_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 58e33c809f..96972fc6d3 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1263,8 +1263,8 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { time := blocks[len(blocks)-1].Header().Time + 1 // enable shanghai on the last block genesis.Config.SetEIP3651TransitionTime(&time) // SetEIP3651Transition is not implemented in this test helper. - genesis.Config.SetEIP3855TransitionTime(&time) // SetEIP3855TransitionTime is not implemented in this test helper. - genesis.Config.SetEIP3860TransitionTime(&time) + genesis.Config.SetEIP3855TransitionTime(&time) // SetEIP3855Transition is not implemented in this test helper. + genesis.Config.SetEIP3860TransitionTime(&time) // SetEIP3860Transition is not implemented in this test helper. genesis.Config.SetEIP4895TransitionTime(&time) genesis.Config.SetEIP6049TransitionTime(&time) n, ethservice := startEthService(t, genesis, blocks) From 25a1c1db3feb8f5765927c4b04481497e3fff606 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 08:22:35 -0600 Subject: [PATCH 11/31] cmd/evm/internal/t8ntool,consensus/beacon,core,eth/catalyst: GetEIP4895Transition Date: 2023-08-19 08:22:35-06:00 Signed-off-by: meows --- cmd/evm/internal/t8ntool/transition.go | 2 +- consensus/beacon/consensus.go | 4 ++-- core/genesis.go | 2 +- core/state_processor.go | 2 +- core/state_processor_test.go | 4 ++-- eth/catalyst/api.go | 8 +++++--- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index d999cbe852..de1b5aca20 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -276,7 +276,7 @@ func Transition(ctx *cli.Context) error { } } // Withdrawals are only valid in Shanghai; EIP-4895. - if chainConfig.IsEnabledByTime(chainConfig.GetEIP4895TransitionTime, &prestate.Env.Number) && prestate.Env.Withdrawals == nil { + if (chainConfig.IsEnabledByTime(chainConfig.GetEIP4895TransitionTime, &prestate.Env.Timestamp) || chainConfig.IsEnabled(chainConfig.GetEIP4895Transition, new(big.Int).SetUint64(prestate.Env.Number))) && prestate.Env.Withdrawals == nil { return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section")) } isMerged := chainConfig.GetEthashTerminalTotalDifficulty() != nil && chainConfig.GetEthashTerminalTotalDifficulty().BitLen() == 0 diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 50c65f7fac..3e212bcc4c 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -261,7 +261,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa return err } // Verify existence / non-existence of withdrawalsHash. - shanghai := chain.Config().IsEnabledByTime(chain.Config().GetEIP4895TransitionTime, &header.Time) + shanghai := chain.Config().IsEnabledByTime(chain.Config().GetEIP4895TransitionTime, &header.Time) || chain.Config().IsEnabled(chain.Config().GetEIP4895Transition, header.Number) if shanghai && header.WithdrawalsHash == nil { return errors.New("missing withdrawalsHash") } @@ -356,7 +356,7 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea if !beacon.IsPoSHeader(header) { return beacon.ethone.FinalizeAndAssemble(chain, header, state, txs, uncles, receipts, nil) } - shanghai := chain.Config().IsEnabledByTime(chain.Config().GetEIP4895TransitionTime, &header.Time) + shanghai := chain.Config().IsEnabledByTime(chain.Config().GetEIP4895TransitionTime, &header.Time) || chain.Config().IsEnabled(chain.Config().GetEIP4895Transition, header.Number) if shanghai { // All blocks after Shanghai must include a withdrawals root. if withdrawals == nil { diff --git a/core/genesis.go b/core/genesis.go index edb57e2dac..10c9312e21 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -430,7 +430,7 @@ func GenesisToBlock(g *genesisT.Genesis, db ethdb.Database) *types.Block { } } var withdrawals []*types.Withdrawal - if g.Config != nil && g.Config.IsEnabledByTime(g.Config.GetEIP4895TransitionTime, &g.Timestamp) { + if g.Config != nil && (g.Config.IsEnabledByTime(g.Config.GetEIP4895TransitionTime, &g.Timestamp) || g.Config.IsEnabled(g.Config.GetEIP4895Transition, new(big.Int).SetUint64(g.Number))) { head.WithdrawalsHash = &types.EmptyWithdrawalsHash withdrawals = make([]*types.Withdrawal, 0) } diff --git a/core/state_processor.go b/core/state_processor.go index 87d9a1a3f8..4a75884f73 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -96,7 +96,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg // Fail if Shanghai not enabled and len(withdrawals) is non-zero. withdrawals := block.Withdrawals() blockTime := block.Time() - if len(withdrawals) > 0 && !p.config.IsEnabledByTime(p.config.GetEIP4895TransitionTime, &blockTime) { + if len(withdrawals) > 0 && !(p.config.IsEnabledByTime(p.config.GetEIP4895TransitionTime, &blockTime) || p.config.IsEnabled(p.config.GetEIP4895Transition, blockNumber)) { return nil, nil, 0, fmt.Errorf("withdrawals before shanghai") } // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index d2b6377ec0..e6095913c8 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -409,7 +409,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr if config.IsEnabled(config.GetEIP1559Transition, header.Number) { header.BaseFee = misc.CalcBaseFee(config, parent.Header()) } - if config.IsEnabledByTime(config.GetEIP4895TransitionTime, &header.Time) { + if config.IsEnabledByTime(config.GetEIP4895TransitionTime, &header.Time) || config.IsEnabled(config.GetEIP4895Transition, header.Number) { header.WithdrawalsHash = &types.EmptyWithdrawalsHash } var receipts []*types.Receipt @@ -429,7 +429,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr } header.Root = common.BytesToHash(hasher.Sum(nil)) // Assemble and return the final block for sealing - if config.IsEnabledByTime(config.GetEIP4895TransitionTime, &header.Time) { + if config.IsEnabledByTime(config.GetEIP4895TransitionTime, &header.Time) || config.IsEnabled(config.GetEIP4895Transition, header.Number) { return types.NewBlockWithWithdrawals(header, txs, nil, receipts, []*types.Withdrawal{}, trie.NewStackTrie(nil)) } return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 6dd420199a..19074ec987 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -20,6 +20,7 @@ package catalyst import ( "errors" "fmt" + "math/big" "sync" "time" @@ -167,7 +168,8 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, pa if payloadAttributes.Withdrawals != nil { return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("withdrawals not supported in V1")) } - if api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &payloadAttributes.Timestamp) { + if api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &payloadAttributes.Timestamp) || // PTAL(meowsbits) Is it really safe/sensible to call the backing Blockchain here? + api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number) { return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai")) } } @@ -185,7 +187,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa } func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error { - if !api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) { + if !api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number) { // PTAL(meowsbits) re: Number for 4985 block transition. // Reject payload attributes with withdrawals before shanghai if attr.Withdrawals != nil { return errors.New("withdrawals before shanghai") @@ -424,7 +426,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl // NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) { - if api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, ¶ms.Timestamp) { + if api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, ¶ms.Timestamp) || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, new(big.Int).SetUint64(params.Number)) { if params.Withdrawals == nil { return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai")) } From 6caf07c3af3e2fb23a5f4c61e29513e1fe6e4d7b Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 08:23:35 -0600 Subject: [PATCH 12/31] params: (typo) remove spurious character '$' Date: 2023-08-19 08:23:35-06:00 Signed-off-by: meows --- params/config_classic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/config_classic.go b/params/config_classic.go index c2f6a7169f..b9682dc4ba 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -95,7 +95,7 @@ var ( EIP3541FBlock: big.NewInt(14_525_000), EIP4399FBlock: big.NewInt(18_000_000), -$ + RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), 2500000: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"), From 19a2f4674412f4d723bcb9e97791547db27e36dc Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 08:27:25 -0600 Subject: [PATCH 13/31] eth/catalyst: SetEIP4895Transition Date: 2023-08-19 08:27:25-06:00 Signed-off-by: meows --- eth/catalyst/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 96972fc6d3..da90341a38 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1265,7 +1265,7 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { genesis.Config.SetEIP3651TransitionTime(&time) // SetEIP3651Transition is not implemented in this test helper. genesis.Config.SetEIP3855TransitionTime(&time) // SetEIP3855Transition is not implemented in this test helper. genesis.Config.SetEIP3860TransitionTime(&time) // SetEIP3860Transition is not implemented in this test helper. - genesis.Config.SetEIP4895TransitionTime(&time) + genesis.Config.SetEIP4895TransitionTime(&time) // SetEIP4895Transition is not implemented in this test helper. genesis.Config.SetEIP6049TransitionTime(&time) n, ethservice := startEthService(t, genesis, blocks) From f5c79002c7b3b44b76e9e34e4b47c81aa6788610 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 08:30:24 -0600 Subject: [PATCH 14/31] eth/catalyst: SetEIP6049Transition Date: 2023-08-19 08:30:24-06:00 Signed-off-by: meows --- eth/catalyst/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index da90341a38..49fce2a86b 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -1266,7 +1266,7 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) { genesis.Config.SetEIP3855TransitionTime(&time) // SetEIP3855Transition is not implemented in this test helper. genesis.Config.SetEIP3860TransitionTime(&time) // SetEIP3860Transition is not implemented in this test helper. genesis.Config.SetEIP4895TransitionTime(&time) // SetEIP4895Transition is not implemented in this test helper. - genesis.Config.SetEIP6049TransitionTime(&time) + genesis.Config.SetEIP6049TransitionTime(&time) // SetEIP6049Transition is not implemented in this test helper. n, ethservice := startEthService(t, genesis, blocks) var ( From ff0d8a20ae2e33dbcbcc7ab0cfcc34bb77f11a9b Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 08:54:33 -0600 Subject: [PATCH 15/31] core/vm,params: GetEIP4399Transition (noop for ETC) Date: 2023-08-19 08:54:33-06:00 Signed-off-by: meows --- core/vm/jump_table.go | 2 +- params/config_classic.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 6aa6961f40..49f633f7d2 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -193,7 +193,7 @@ func instructionSetForConfig(config ctypes.ChainConfigurator, isPostMerge bool, if config.IsEnabled(config.GetEIP3198Transition, bn) { enable3198(instructionSet) // BASEFEE opcode https://eips.ethereum.org/EIPS/eip-3198 } - if isPostMerge { + if isPostMerge || config.IsEnabled(config.GetEIP4399Transition, bn) { // EIP4399: Supplant DIFFICULTY opcode with PREVRANDAO (ETH @ PoS) instructionSet[PREVRANDAO] = &operation{ execute: opRandom, constantGas: GasQuickStep, diff --git a/params/config_classic.go b/params/config_classic.go index b9682dc4ba..5aee3445e6 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -94,7 +94,7 @@ var ( EIP3529FBlock: big.NewInt(14_525_000), EIP3541FBlock: big.NewInt(14_525_000), - EIP4399FBlock: big.NewInt(18_000_000), + // EIP4399FBlock: big.NewInt(18_000_000), // Commented for transparency. ETC does not spec 4399 because still PoW, and 4399 is only applicable for the PoS system. RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), From c10a368cf35e9265acc6d02eb466d955006b72ff Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 09:13:58 -0600 Subject: [PATCH 16/31] params: install Spiral placeholder activation vals Date: 2023-08-19 09:13:58-06:00 Signed-off-by: meows --- core/forkid/forkid_test.go | 26 ++++++++++++++------------ params/config_classic.go | 7 ++++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/core/forkid/forkid_test.go b/core/forkid/forkid_test.go index d21e843c63..828b002971 100644 --- a/core/forkid/forkid_test.go +++ b/core/forkid/forkid_test.go @@ -182,8 +182,10 @@ func TestCreation(t *testing.T) { {13_189_133, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, {13_189_134, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, {14_524_999, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, - {14_525_000, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 0}}, - {14_525_001, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 0}}, + {14_525_000, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 18_400_000}}, + {14_525_001, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 18_400_000}}, + {18_400_000, 0, ID{Hash: checksumToBytes(0x1e7801b5), Next: 0}}, + {18_400_001, 0, ID{Hash: checksumToBytes(0x1e7801b5), Next: 0}}, }, }, { @@ -397,21 +399,21 @@ func TestValidation(t *testing.T) { // In this case we don't know if Cancun passed yet or not. // // TODO(karalabe): Enable this when Cancun is specced - //{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, nil}, + // {params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, nil}, // Local is mainnet currently in Shanghai only (so it's aware of Cancun), remote announces // also Shanghai, and it's also aware of Cancun (e.g. updated node before the fork). We // don't know if Cancun passed yet (will pass) or not. // // TODO(karalabe): Enable this when Cancun is specced and update next timestamp - //{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil}, + // {params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil}, // Local is mainnet currently in Shanghai only (so it's aware of Cancun), remote announces // also Shanghai, and it's also aware of some random fork (e.g. misconfigured Cancun). As // neither forks passed at neither nodes, they may mismatch, but we still connect for now. // // TODO(karalabe): Enable this when Cancun is specced - //{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: math.MaxUint64}, nil}, + // {params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(0x71147644), Next: math.MaxUint64}, nil}, // Local is mainnet exactly on Cancun, remote announces Shanghai + knowledge about Cancun. Remote // is simply out of sync, accept. @@ -422,30 +424,30 @@ func TestValidation(t *testing.T) { // Local is mainnet Cancun, remote announces Shanghai + knowledge about Cancun. Remote // is simply out of sync, accept. // TODO(karalabe): Enable this when Cancun is specced, update local head and time, next timestamp - //{params.MainnetChainConfig, 21123456, 1678123456, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil}, + // {params.MainnetChainConfig, 21123456, 1678123456, ID{Hash: checksumToBytes(0x71147644), Next: 1678000000}, nil}, // Local is mainnet Prague, remote announces Shanghai + knowledge about Cancun. Remote // is definitely out of sync. It may or may not need the Prague update, we don't know yet. // // TODO(karalabe): Enable this when Cancun **and** Prague is specced, update all the numbers - //{params.MainnetChainConfig, 0, 0, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}, nil}, + // {params.MainnetChainConfig, 0, 0, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}, nil}, // Local is mainnet Shanghai, remote announces Cancun. Local is out of sync, accept. // // TODO(karalabe): Enable this when Cancun is specced, update remote checksum - //{params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x00000000), Next: 0}, nil}, + // {params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x00000000), Next: 0}, nil}, // Local is mainnet Shanghai, remote announces Cancun, but is not aware of Prague. Local // out of sync. Local also knows about a future fork, but that is uncertain yet. // // TODO(karalabe): Enable this when Cancun **and** Prague is specced, update remote checksum - //{params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x00000000), Next: 0}, nil}, + // {params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x00000000), Next: 0}, nil}, // Local is mainnet Cancun. remote announces Shanghai but is not aware of further forks. // Remote needs software update. // // TODO(karalabe): Enable this when Cancun is specced, update local head and time - //{params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, ErrRemoteStale}, + // {params.MainnetChainConfig, 21000000, 1678000000, ID{Hash: checksumToBytes(0x71147644), Next: 0}, ErrRemoteStale}, // Local is mainnet Shanghai, and isn't aware of more forks. Remote announces Shanghai + // 0xffffffff. Local needs software update, reject. @@ -455,7 +457,7 @@ func TestValidation(t *testing.T) { // 0xffffffff. Local needs software update, reject. // // TODO(karalabe): Enable this when Cancun is specced, update remote checksum - //{params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(checksumUpdate(0x00000000, math.MaxUint64)), Next: 0}, ErrLocalIncompatibleOrStale}, + // {params.MainnetChainConfig, 20000000, 1668000000, ID{Hash: checksumToBytes(checksumUpdate(0x00000000, math.MaxUint64)), Next: 0}, ErrLocalIncompatibleOrStale}, // Local is mainnet Shanghai, remote is random Shanghai. {params.MainnetChainConfig, 20000000, 1681338455, ID{Hash: checksumToBytes(0x12345678), Next: 0}, ErrLocalIncompatibleOrStale}, @@ -512,7 +514,7 @@ func TestGatherForks(t *testing.T) { { "classic", params.ClassicChainConfig, - []uint64{1150000, 2500000, 3000000, 5000000, 5900000, 8772000, 9573000, 10500839, 11_700_000, 13_189_133, 14_525_000}, + []uint64{1150000, 2500000, 3000000, 5000000, 5900000, 8772000, 9573000, 10500839, 11_700_000, 13_189_133, 14_525_000, 18_400_000}, }, { "mainnet", diff --git a/params/config_classic.go b/params/config_classic.go index 5aee3445e6..e35441567d 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -94,7 +94,12 @@ var ( EIP3529FBlock: big.NewInt(14_525_000), EIP3541FBlock: big.NewInt(14_525_000), - // EIP4399FBlock: big.NewInt(18_000_000), // Commented for transparency. ETC does not spec 4399 because still PoW, and 4399 is only applicable for the PoS system. + // EIP4399FBlock: big.NewInt(18_400_000), // Supplant DIFFICULTY with PREVRANDAO. ETC does not spec 4399 because it's still PoW, and 4399 is only applicable for the PoS system. + EIP3651FBlock: big.NewInt(18_400_000), // Warm COINBASE (gas reprice) + EIP3855FBlock: big.NewInt(18_400_000), // PUSH0 instruction + EIP3860FBlock: big.NewInt(18_400_000), // Limit and meter initcode + // EIP4895FBlock: big.NewInt(18_400_000), // Beacon chain push withdrawals as operations + EIP6049FBlock: big.NewInt(18_400_000), // Deprecate SELFDESTRUCT (noop) RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), From 310236b14fedeed0f0d4d215e5083134ec9b0f99 Mon Sep 17 00:00:00 2001 From: meows Date: Sat, 19 Aug 2023 09:17:33 -0600 Subject: [PATCH 17/31] params/types/goethereum: fix incompatible check; permit passthrough block-based Shanghai config Failing was TestCheckCompatible, which converts Geth::CoreGeth configuration types; CoreGeth's EIP3651 block transition was fatally inapplicable to Geth's config. So this patch sidesteps the issue by permitting the conversion to quietly fail; expecting that users/developers will be sane enough to configure upgrades with one pattern or the other but not both. Date: 2023-08-19 09:17:33-06:00 Signed-off-by: meows --- params/types/goethereum/goethereum_configurator.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/params/types/goethereum/goethereum_configurator.go b/params/types/goethereum/goethereum_configurator.go index 0d7d21c8f1..c773e2ee0a 100644 --- a/params/types/goethereum/goethereum_configurator.go +++ b/params/types/goethereum/goethereum_configurator.go @@ -598,7 +598,7 @@ func (c *ChainConfig) GetEIP3651Transition() *uint64 { } func (c *ChainConfig) SetEIP3651Transition(n *uint64) error { - return ctypes.ErrUnsupportedConfigFatal + return ctypes.ErrUnsupportedConfigNoop } // GetEIP3855Transition EIP3855: PUSH0 instruction @@ -607,7 +607,7 @@ func (c *ChainConfig) GetEIP3855Transition() *uint64 { } func (c *ChainConfig) SetEIP3855Transition(n *uint64) error { - return ctypes.ErrUnsupportedConfigFatal + return ctypes.ErrUnsupportedConfigNoop } // GetEIP3860Transition EIP3860: Limit and meter initcode @@ -616,7 +616,7 @@ func (c *ChainConfig) GetEIP3860Transition() *uint64 { } func (c *ChainConfig) SetEIP3860Transition(n *uint64) error { - return ctypes.ErrUnsupportedConfigFatal + return ctypes.ErrUnsupportedConfigNoop } // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations @@ -625,7 +625,7 @@ func (c *ChainConfig) GetEIP4895Transition() *uint64 { } func (c *ChainConfig) SetEIP4895Transition(n *uint64) error { - return ctypes.ErrUnsupportedConfigFatal + return ctypes.ErrUnsupportedConfigNoop } // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT @@ -634,7 +634,7 @@ func (c *ChainConfig) GetEIP6049Transition() *uint64 { } func (c *ChainConfig) SetEIP6049Transition(n *uint64) error { - return ctypes.ErrUnsupportedConfigFatal + return ctypes.ErrUnsupportedConfigNoop } // GetEIP4844TransitionTime EIP4844: Shard Block Transactions From 30711dd7cb4ca3a1fc45b6317dc2500cf2f3ada1 Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 25 Aug 2023 08:55:58 -0600 Subject: [PATCH 18/31] tests: add ETC_Spiral test fork config Date: 2023-08-25 08:55:58-06:00 Signed-off-by: meows --- tests/init.go | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/init.go b/tests/init.go index eaf6595d50..0b3f6d8eb7 100644 --- a/tests/init.go +++ b/tests/init.go @@ -521,6 +521,76 @@ var Forks = map[string]ctypes.ChainConfigurator{ TerminalTotalDifficulty: big.NewInt(0), ShanghaiTime: u64(15_000), }, + "ETC_Spiral": &coregeth.CoreGethChainConfig{ + NetworkID: 1, + Ethash: new(ctypes.EthashConfig), + ChainID: big.NewInt(61), + EIP2FBlock: big.NewInt(0), + EIP7FBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP160FBlock: big.NewInt(0), + EIP161FBlock: big.NewInt(0), + EIP170FBlock: big.NewInt(0), + EIP100FBlock: big.NewInt(0), + EIP140FBlock: big.NewInt(0), + EIP198FBlock: big.NewInt(0), + EIP211FBlock: big.NewInt(0), + EIP212FBlock: big.NewInt(0), + EIP213FBlock: big.NewInt(0), + EIP214FBlock: big.NewInt(0), + EIP658FBlock: big.NewInt(0), + EIP145FBlock: big.NewInt(0), + EIP1014FBlock: big.NewInt(0), + EIP1052FBlock: big.NewInt(0), + EIP1283FBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + // Istanbul eq, aka Phoenix + // ECIP-1088 + EIP152FBlock: big.NewInt(0), + EIP1108FBlock: big.NewInt(0), + EIP1344FBlock: big.NewInt(0), + EIP1884FBlock: big.NewInt(0), + EIP2028FBlock: big.NewInt(0), + EIP2200FBlock: big.NewInt(0), // RePetersburg (=~ re-1283) + + // Berlin + EIP2565FBlock: big.NewInt(0), + EIP2929FBlock: big.NewInt(0), + EIP2718FBlock: big.NewInt(0), + EIP2930FBlock: big.NewInt(0), + + // London + /* + https://github.com/ethereumclassic/ECIPs/blob/master/_specs/ecip-1104.md + + 3529 (Alternative refund reduction) #22733 Include + 3541 (Reject new contracts starting with the 0xEF byte) #22809 Include + 1559 (Fee market change) #22837 #22896 Omit + 3198 (BASEFEE opcode) #22837 Omit + 3228 (bomb delay) #22840 and #22870 Omit + */ + EIP3529FBlock: big.NewInt(0), + EIP3541FBlock: big.NewInt(0), + EIP1559FBlock: nil, + EIP3198FBlock: nil, + EIP3554FBlock: nil, + + // Shanghai == Spiral + EIP4399FBlock: nil, // Supplant DIFFICULTY with PREVRANDAO. ETC does not spec 4399 because it's still PoW, and 4399 is only applicable for the PoS system. + EIP3651FBlock: big.NewInt(0), // Warm COINBASE (gas reprice) + EIP3855FBlock: big.NewInt(0), // PUSH0 instruction + EIP3860FBlock: big.NewInt(0), // Limit and meter initcode + EIP4895FBlock: nil, // Beacon chain push withdrawals as operations + EIP6049FBlock: big.NewInt(0), // Deprecate SELFDESTRUCT (noop) + + // ETC specifics + DisposalBlock: big.NewInt(0), + ECIP1017FBlock: big.NewInt(5000000), // FIXME(meows) maybe + ECIP1017EraRounds: big.NewInt(5000000), + ECIP1010PauseBlock: nil, + ECIP1010Length: nil, + }, } // AvailableForks returns the set of defined fork names From a5e0c62fe940d93578105b8c8cd81688cd13f174 Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 25 Aug 2023 14:51:50 -0600 Subject: [PATCH 19/31] params/types/coregeth,params/types/goethereum: problem: TestEquivalent_Features fails Mismatched EIP3651 activations caused an incompatibility between core-geth and go-ethereum config types. This is mostly just a problem of/with the tests because of the disparate configuration TYPES now (block vs. time). This patches fixes the issue by implementing a logical short-circut equivocating zero values for time and block fields in core-geth and go-ethereum configuration configurator interfaces. Probably these logical steps will only be followed by tests or testnets or networks using time OR block values. Date: 2023-08-25 14:51:50-06:00 Signed-off-by: meows --- .../coregeth/chain_config_configurator.go | 45 +++++++++++++++ .../goethereum/goethereum_configurator.go | 55 +++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/params/types/coregeth/chain_config_configurator.go b/params/types/coregeth/chain_config_configurator.go index daae683dde..0466487646 100644 --- a/params/types/coregeth/chain_config_configurator.go +++ b/params/types/coregeth/chain_config_configurator.go @@ -516,57 +516,90 @@ func (c *CoreGethChainConfig) SetEIP4399Transition(n *uint64) error { // EIP3651: Warm COINBASE func (c *CoreGethChainConfig) GetEIP3651TransitionTime() *uint64 { + if c.EIP3651FBlock != nil && c.EIP3651FBlock.Cmp(big.NewInt(0)) == 0 { + return newU64(0) + } return c.EIP3651FTime } func (c *CoreGethChainConfig) SetEIP3651TransitionTime(n *uint64) error { c.EIP3651FTime = n + if n != nil && *n == 0 { + c.EIP3651FBlock = big.NewInt(0) + } return nil } // GetEIP3855TransitionTime EIP3855: PUSH0 instruction func (c *CoreGethChainConfig) GetEIP3855TransitionTime() *uint64 { + if c.EIP3855FBlock != nil && c.EIP3855FBlock.Cmp(big.NewInt(0)) == 0 { + return newU64(0) + } return c.EIP3855FTime } func (c *CoreGethChainConfig) SetEIP3855TransitionTime(n *uint64) error { c.EIP3855FTime = n + if n != nil && *n == 0 { + c.EIP3855FBlock = big.NewInt(0) + } return nil } // GetEIP3860TransitionTime EIP3860: Limit and meter initcode func (c *CoreGethChainConfig) GetEIP3860TransitionTime() *uint64 { + if c.EIP3860FBlock != nil && c.EIP3860FBlock.Cmp(big.NewInt(0)) == 0 { + return newU64(0) + } return c.EIP3860FTime } func (c *CoreGethChainConfig) SetEIP3860TransitionTime(n *uint64) error { c.EIP3860FTime = n + if n != nil && *n == 0 { + c.EIP3860FBlock = big.NewInt(0) + } return nil } // GetEIP4895TransitionTime EIP4895: Beacon chain push withdrawals as operations func (c *CoreGethChainConfig) GetEIP4895TransitionTime() *uint64 { + if c.EIP4895FBlock != nil && c.EIP4895FBlock.Cmp(big.NewInt(0)) == 0 { + return newU64(0) + } return c.EIP4895FTime } func (c *CoreGethChainConfig) SetEIP4895TransitionTime(n *uint64) error { c.EIP4895FTime = n + if n != nil && *n == 0 { + c.EIP4895FBlock = big.NewInt(0) + } return nil } // GetEIP6049TransitionTime EIP6049: Deprecate SELFDESTRUCT func (c *CoreGethChainConfig) GetEIP6049TransitionTime() *uint64 { + if c.EIP6049FBlock != nil && c.EIP6049FBlock.Cmp(big.NewInt(0)) == 0 { + return newU64(0) + } return c.EIP6049FTime } func (c *CoreGethChainConfig) SetEIP6049TransitionTime(n *uint64) error { c.EIP6049FTime = n + if n != nil && *n == 0 { + c.EIP6049FBlock = big.NewInt(0) + } return nil } // Shanghai by block // EIP3651: Warm COINBASE func (c *CoreGethChainConfig) GetEIP3651Transition() *uint64 { + if c.EIP3651FTime != nil && *c.EIP3651FTime == 0 { + return newU64(0) + } return bigNewU64(c.EIP3651FBlock) } @@ -577,6 +610,9 @@ func (c *CoreGethChainConfig) SetEIP3651Transition(n *uint64) error { // GetEIP3855Transition EIP3855: PUSH0 instruction func (c *CoreGethChainConfig) GetEIP3855Transition() *uint64 { + if c.EIP3855FTime != nil && *c.EIP3855FTime == 0 { + return newU64(0) + } return bigNewU64(c.EIP3855FBlock) } @@ -587,6 +623,9 @@ func (c *CoreGethChainConfig) SetEIP3855Transition(n *uint64) error { // GetEIP3860Transition EIP3860: Limit and meter initcode func (c *CoreGethChainConfig) GetEIP3860Transition() *uint64 { + if c.EIP3860FTime != nil && *c.EIP3860FTime == 0 { + return newU64(0) + } return bigNewU64(c.EIP3860FBlock) } @@ -597,6 +636,9 @@ func (c *CoreGethChainConfig) SetEIP3860Transition(n *uint64) error { // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations func (c *CoreGethChainConfig) GetEIP4895Transition() *uint64 { + if c.EIP4895FTime != nil && *c.EIP4895FTime == 0 { + return newU64(0) + } return bigNewU64(c.EIP4895FBlock) } @@ -607,6 +649,9 @@ func (c *CoreGethChainConfig) SetEIP4895Transition(n *uint64) error { // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT func (c *CoreGethChainConfig) GetEIP6049Transition() *uint64 { + if c.EIP6049FTime != nil && *c.EIP6049FTime == 0 { + return newU64(0) + } return bigNewU64(c.EIP6049FBlock) } diff --git a/params/types/goethereum/goethereum_configurator.go b/params/types/goethereum/goethereum_configurator.go index c773e2ee0a..5758719ed0 100644 --- a/params/types/goethereum/goethereum_configurator.go +++ b/params/types/goethereum/goethereum_configurator.go @@ -594,46 +594,101 @@ func (c *ChainConfig) SetEIP6049TransitionTime(n *uint64) error { // EIP3651: Warm COINBASE func (c *ChainConfig) GetEIP3651Transition() *uint64 { + if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { + return newU64(0) + } return nil } func (c *ChainConfig) SetEIP3651Transition(n *uint64) error { + if n == nil { + c.ShanghaiTime = nil + return nil + } + if *n == 0 { + c.ShanghaiTime = newU64(0) + return nil + } return ctypes.ErrUnsupportedConfigNoop } // GetEIP3855Transition EIP3855: PUSH0 instruction func (c *ChainConfig) GetEIP3855Transition() *uint64 { + if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { + return newU64(0) + } return nil } func (c *ChainConfig) SetEIP3855Transition(n *uint64) error { + if n == nil { + c.ShanghaiTime = nil + return nil + } + if *n == 0 { + c.ShanghaiTime = newU64(0) + return nil + } return ctypes.ErrUnsupportedConfigNoop } // GetEIP3860Transition EIP3860: Limit and meter initcode func (c *ChainConfig) GetEIP3860Transition() *uint64 { + if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { + return newU64(0) + } return nil } func (c *ChainConfig) SetEIP3860Transition(n *uint64) error { + if n == nil { + c.ShanghaiTime = nil + return nil + } + if *n == 0 { + c.ShanghaiTime = newU64(0) + return nil + } return ctypes.ErrUnsupportedConfigNoop } // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations func (c *ChainConfig) GetEIP4895Transition() *uint64 { + if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { + return newU64(0) + } return nil } func (c *ChainConfig) SetEIP4895Transition(n *uint64) error { + if n == nil { + c.ShanghaiTime = nil + return nil + } + if *n == 0 { + c.ShanghaiTime = newU64(0) + return nil + } return ctypes.ErrUnsupportedConfigNoop } // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT func (c *ChainConfig) GetEIP6049Transition() *uint64 { + if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { + return newU64(0) + } return nil } func (c *ChainConfig) SetEIP6049Transition(n *uint64) error { + if n == nil { + c.ShanghaiTime = nil + return nil + } + if *n == 0 { + c.ShanghaiTime = newU64(0) + return nil + } return ctypes.ErrUnsupportedConfigNoop } From 8f3f7dee8a41dc08c27edfc0c79cf85c12f80231 Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Tue, 29 Aug 2023 14:25:40 +0300 Subject: [PATCH 20/31] params/types/genesisT: fix indentation --- params/types/genesisT/gen_genesis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go index 8473a90f85..0136309ee6 100644 --- a/params/types/genesisT/gen_genesis.go +++ b/params/types/genesisT/gen_genesis.go @@ -81,7 +81,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` } var dec Genesis - // We have to look at the raw input, decide what kind of configurator schema it's using, + // We have to look at the raw input, decide what kind of configurator schema it's using, // then assign the decoder struct to use that schema type. conf, err := generic.UnmarshalChainConfigurator(input) if err != nil { From b62c4e5bb51b174321c2255029586313ea8ba107 Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Tue, 29 Aug 2023 15:01:27 +0300 Subject: [PATCH 21/31] tests: set new head for tests/testdata --- tests/testdata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testdata b/tests/testdata index a380655e5f..ee3fa4c86d 160000 --- a/tests/testdata +++ b/tests/testdata @@ -1 +1 @@ -Subproject commit a380655e5ffab1a5ea0f4d860224bdb19013f06a +Subproject commit ee3fa4c86d05f99f2717f83a6ad08008490ddf07 From f6a7b2d3fbb025fb57e9c122fc2068e41e5137c8 Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Tue, 29 Aug 2023 15:01:40 +0300 Subject: [PATCH 22/31] tests: Set new submodule head for tests/testdata-etc --- tests/testdata-etc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testdata-etc b/tests/testdata-etc index c138c1391d..06ec708ea7 160000 --- a/tests/testdata-etc +++ b/tests/testdata-etc @@ -1 +1 @@ -Subproject commit c138c1391deb604aa8efa97561b3f8edc49f0eb5 +Subproject commit 06ec708ea7f3707826142a97a94b61d40c920696 From ae0efa109d37e8374999a304bb03dd3ece6bde2a Mon Sep 17 00:00:00 2001 From: meows Date: Tue, 29 Aug 2023 09:01:11 -0600 Subject: [PATCH 23/31] beacon/engine: include error in wrapped error Error method By Go conventions the Error method should return a descriptive string. When I was debugging the simulated beacon test, the reported error was hardly usedful, describing only that an error existed, but lacking any contextual detail. Now the engine api will return a more detailed error and that will hopefully help debuggers in the future. Date: 2023-08-29 09:01:11-06:00 Signed-off-by: meows --- beacon/engine/errors.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beacon/engine/errors.go b/beacon/engine/errors.go index 769001b9e3..318ddf3276 100644 --- a/beacon/engine/errors.go +++ b/beacon/engine/errors.go @@ -30,7 +30,13 @@ type EngineAPIError struct { } func (e *EngineAPIError) ErrorCode() int { return e.code } -func (e *EngineAPIError) Error() string { return e.msg } +func (e *EngineAPIError) Error() string { + str := e.msg + if e.err != nil { + str += ": " + e.err.Error() + } + return str +} func (e *EngineAPIError) ErrorData() interface{} { if e.err == nil { return nil From f935bfa5cbc7c5448c03d49715b4cf438c0edfd9 Mon Sep 17 00:00:00 2001 From: meows Date: Tue, 29 Aug 2023 09:10:51 -0600 Subject: [PATCH 24/31] eth/catalyst: fix EIP4895 conditional logic This logic was just wrong because of misplaced negation. Date: 2023-08-29 09:10:51-06:00 Signed-off-by: meows --- eth/catalyst/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index b9ccb3be85..043dd668ec 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -189,7 +189,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa } func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error { - if !api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number) { // PTAL(meowsbits) re: Number for 4985 block transition. + if !(api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number)) { // Reject payload attributes with withdrawals before shanghai if attr.Withdrawals != nil { return errors.New("withdrawals before shanghai") From 9e174f93e2aea7b5533caab690cb9c6231aeb9c4 Mon Sep 17 00:00:00 2001 From: meows Date: Tue, 29 Aug 2023 09:28:43 -0600 Subject: [PATCH 25/31] Revert "beacon/engine: include error in wrapped error Error method" This reverts commit ae0efa109d37e8374999a304bb03dd3ece6bde2a. Reason: it caused a test failure TestGetBlockBodiesByRangeInvalidParams where that test compares the have/want errors as strings and I can't be bothered to adjust the test. It would be better, probably, to use errors.Is with wrapped errors. --- beacon/engine/errors.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/beacon/engine/errors.go b/beacon/engine/errors.go index 318ddf3276..769001b9e3 100644 --- a/beacon/engine/errors.go +++ b/beacon/engine/errors.go @@ -30,13 +30,7 @@ type EngineAPIError struct { } func (e *EngineAPIError) ErrorCode() int { return e.code } -func (e *EngineAPIError) Error() string { - str := e.msg - if e.err != nil { - str += ": " + e.err.Error() - } - return str -} +func (e *EngineAPIError) Error() string { return e.msg } func (e *EngineAPIError) ErrorData() interface{} { if e.err == nil { return nil From 87843da919d1a04d517518025c8b5a9bae90b5b9 Mon Sep 17 00:00:00 2001 From: meows Date: Fri, 1 Sep 2023 10:18:47 -0600 Subject: [PATCH 26/31] beacon/engine,eth/catalyst: catalyst api payload attributes get block number In order to check eip4895 features for ETC-style block number-based activations, the attributes get a block number field which is allowed to be nil. As usual for core-geth, activation numbers are OR'd with activation times. Date: 2023-09-01 10:18:47-06:00 Signed-off-by: meows --- beacon/engine/gen_blockparams.go | 6 ++++++ beacon/engine/types.go | 1 + eth/catalyst/api.go | 13 ++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/beacon/engine/gen_blockparams.go b/beacon/engine/gen_blockparams.go index 0dd2b52597..2193b2f976 100644 --- a/beacon/engine/gen_blockparams.go +++ b/beacon/engine/gen_blockparams.go @@ -17,12 +17,14 @@ var _ = (*payloadAttributesMarshaling)(nil) func (p PayloadAttributes) MarshalJSON() ([]byte, error) { type PayloadAttributes struct { Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` + Number *uint64 `json:"blockNumber,omitempty"` Random common.Hash `json:"prevRandao" gencodec:"required"` SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` } var enc PayloadAttributes enc.Timestamp = hexutil.Uint64(p.Timestamp) + enc.Number = p.Number enc.Random = p.Random enc.SuggestedFeeRecipient = p.SuggestedFeeRecipient enc.Withdrawals = p.Withdrawals @@ -33,6 +35,7 @@ func (p PayloadAttributes) MarshalJSON() ([]byte, error) { func (p *PayloadAttributes) UnmarshalJSON(input []byte) error { type PayloadAttributes struct { Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"` + Number *uint64 `json:"blockNumber,omitempty"` Random *common.Hash `json:"prevRandao" gencodec:"required"` SuggestedFeeRecipient *common.Address `json:"suggestedFeeRecipient" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` @@ -45,6 +48,9 @@ func (p *PayloadAttributes) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'timestamp' for PayloadAttributes") } p.Timestamp = uint64(*dec.Timestamp) + if dec.Number != nil { + p.Number = dec.Number + } if dec.Random == nil { return errors.New("missing required field 'prevRandao' for PayloadAttributes") } diff --git a/beacon/engine/types.go b/beacon/engine/types.go index f1801edd1a..9688506ae2 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -33,6 +33,7 @@ import ( // be built. type PayloadAttributes struct { Timestamp uint64 `json:"timestamp" gencodec:"required"` + Number *uint64 `json:"blockNumber,omitempty"` Random common.Hash `json:"prevRandao" gencodec:"required"` SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 043dd668ec..f8aecb17ad 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -170,8 +170,11 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, pa if payloadAttributes.Withdrawals != nil { return engine.STATUS_INVALID, engine.InvalidParams.With(errors.New("withdrawals not supported in V1")) } - if api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &payloadAttributes.Timestamp) || // PTAL(meowsbits) Is it really safe/sensible to call the backing Blockchain here? - api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number) { + eip4895 := api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &payloadAttributes.Timestamp) + if payloadAttributes.Number != nil { + eip4895 = eip4895 || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, new(big.Int).SetUint64(*payloadAttributes.Number)) + } + if eip4895 { return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai")) } } @@ -189,7 +192,11 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa } func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error { - if !(api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, api.eth.BlockChain().CurrentHeader().Number)) { + eip4895 := api.eth.BlockChain().Config().IsEnabledByTime(api.eth.BlockChain().Config().GetEIP4895TransitionTime, &attr.Timestamp) + if attr.Number != nil { + eip4895 = eip4895 || api.eth.BlockChain().Config().IsEnabled(api.eth.BlockChain().Config().GetEIP4895Transition, new(big.Int).SetUint64(*attr.Number)) + } + if !eip4895 { // Reject payload attributes with withdrawals before shanghai if attr.Withdrawals != nil { return errors.New("withdrawals before shanghai") From 1302f3d4ad6c601fe87bbc251fd0ccf5cd610bbd Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 4 Sep 2023 05:22:48 -0600 Subject: [PATCH 27/31] core: prefer EIP descriptors over fork names ... but reference forks by name to keep the important context. Date: 2023-09-04 05:22:48-06:00 Signed-off-by: meows --- core/genesis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index d6b7da4dbb..857dee8f09 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -438,8 +438,9 @@ func GenesisToBlock(g *genesisT.Genesis, db ethdb.Database) *types.Block { } var withdrawals []*types.Withdrawal if conf := g.Config; conf != nil { - isShangai := conf.IsEnabledByTime(g.Config.GetEIP4895TransitionTime, &g.Timestamp) || g.Config.IsEnabled(g.Config.GetEIP4895Transition, new(big.Int).SetUint64(g.Number)) - if isShangai { + // EIP4895 defines the withdwrawals tx type, implemented on ETH in the Shanghai fork. + isEIP4895 := conf.IsEnabledByTime(g.Config.GetEIP4895TransitionTime, &g.Timestamp) || g.Config.IsEnabled(g.Config.GetEIP4895Transition, new(big.Int).SetUint64(g.Number)) + if isEIP4895 { head.WithdrawalsHash = &types.EmptyWithdrawalsHash withdrawals = make([]*types.Withdrawal, 0) } From 84158926e74d1359dd7085829cecaed4f2c5e3b4 Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Mon, 4 Sep 2023 18:32:46 +0300 Subject: [PATCH 28/31] params/types/coregeth,params/types/goethereum: Revert "params/types/coregeth,params/types/goethereum: problem: TestEquivalent_Features fails" This reverts commit a5e0c62fe940d93578105b8c8cd81688cd13f174. --- .../coregeth/chain_config_configurator.go | 45 --------------- .../goethereum/goethereum_configurator.go | 55 ------------------- 2 files changed, 100 deletions(-) diff --git a/params/types/coregeth/chain_config_configurator.go b/params/types/coregeth/chain_config_configurator.go index 4c5b61d116..c7837e58f4 100644 --- a/params/types/coregeth/chain_config_configurator.go +++ b/params/types/coregeth/chain_config_configurator.go @@ -516,90 +516,57 @@ func (c *CoreGethChainConfig) SetEIP4399Transition(n *uint64) error { // EIP3651: Warm COINBASE func (c *CoreGethChainConfig) GetEIP3651TransitionTime() *uint64 { - if c.EIP3651FBlock != nil && c.EIP3651FBlock.Cmp(big.NewInt(0)) == 0 { - return newU64(0) - } return c.EIP3651FTime } func (c *CoreGethChainConfig) SetEIP3651TransitionTime(n *uint64) error { c.EIP3651FTime = n - if n != nil && *n == 0 { - c.EIP3651FBlock = big.NewInt(0) - } return nil } // GetEIP3855TransitionTime EIP3855: PUSH0 instruction func (c *CoreGethChainConfig) GetEIP3855TransitionTime() *uint64 { - if c.EIP3855FBlock != nil && c.EIP3855FBlock.Cmp(big.NewInt(0)) == 0 { - return newU64(0) - } return c.EIP3855FTime } func (c *CoreGethChainConfig) SetEIP3855TransitionTime(n *uint64) error { c.EIP3855FTime = n - if n != nil && *n == 0 { - c.EIP3855FBlock = big.NewInt(0) - } return nil } // GetEIP3860TransitionTime EIP3860: Limit and meter initcode func (c *CoreGethChainConfig) GetEIP3860TransitionTime() *uint64 { - if c.EIP3860FBlock != nil && c.EIP3860FBlock.Cmp(big.NewInt(0)) == 0 { - return newU64(0) - } return c.EIP3860FTime } func (c *CoreGethChainConfig) SetEIP3860TransitionTime(n *uint64) error { c.EIP3860FTime = n - if n != nil && *n == 0 { - c.EIP3860FBlock = big.NewInt(0) - } return nil } // GetEIP4895TransitionTime EIP4895: Beacon chain push withdrawals as operations func (c *CoreGethChainConfig) GetEIP4895TransitionTime() *uint64 { - if c.EIP4895FBlock != nil && c.EIP4895FBlock.Cmp(big.NewInt(0)) == 0 { - return newU64(0) - } return c.EIP4895FTime } func (c *CoreGethChainConfig) SetEIP4895TransitionTime(n *uint64) error { c.EIP4895FTime = n - if n != nil && *n == 0 { - c.EIP4895FBlock = big.NewInt(0) - } return nil } // GetEIP6049TransitionTime EIP6049: Deprecate SELFDESTRUCT func (c *CoreGethChainConfig) GetEIP6049TransitionTime() *uint64 { - if c.EIP6049FBlock != nil && c.EIP6049FBlock.Cmp(big.NewInt(0)) == 0 { - return newU64(0) - } return c.EIP6049FTime } func (c *CoreGethChainConfig) SetEIP6049TransitionTime(n *uint64) error { c.EIP6049FTime = n - if n != nil && *n == 0 { - c.EIP6049FBlock = big.NewInt(0) - } return nil } // Shanghai by block // EIP3651: Warm COINBASE func (c *CoreGethChainConfig) GetEIP3651Transition() *uint64 { - if c.EIP3651FTime != nil && *c.EIP3651FTime == 0 { - return newU64(0) - } return bigNewU64(c.EIP3651FBlock) } @@ -610,9 +577,6 @@ func (c *CoreGethChainConfig) SetEIP3651Transition(n *uint64) error { // GetEIP3855Transition EIP3855: PUSH0 instruction func (c *CoreGethChainConfig) GetEIP3855Transition() *uint64 { - if c.EIP3855FTime != nil && *c.EIP3855FTime == 0 { - return newU64(0) - } return bigNewU64(c.EIP3855FBlock) } @@ -623,9 +587,6 @@ func (c *CoreGethChainConfig) SetEIP3855Transition(n *uint64) error { // GetEIP3860Transition EIP3860: Limit and meter initcode func (c *CoreGethChainConfig) GetEIP3860Transition() *uint64 { - if c.EIP3860FTime != nil && *c.EIP3860FTime == 0 { - return newU64(0) - } return bigNewU64(c.EIP3860FBlock) } @@ -636,9 +597,6 @@ func (c *CoreGethChainConfig) SetEIP3860Transition(n *uint64) error { // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations func (c *CoreGethChainConfig) GetEIP4895Transition() *uint64 { - if c.EIP4895FTime != nil && *c.EIP4895FTime == 0 { - return newU64(0) - } return bigNewU64(c.EIP4895FBlock) } @@ -649,9 +607,6 @@ func (c *CoreGethChainConfig) SetEIP4895Transition(n *uint64) error { // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT func (c *CoreGethChainConfig) GetEIP6049Transition() *uint64 { - if c.EIP6049FTime != nil && *c.EIP6049FTime == 0 { - return newU64(0) - } return bigNewU64(c.EIP6049FBlock) } diff --git a/params/types/goethereum/goethereum_configurator.go b/params/types/goethereum/goethereum_configurator.go index e065216adb..65b9db3550 100644 --- a/params/types/goethereum/goethereum_configurator.go +++ b/params/types/goethereum/goethereum_configurator.go @@ -594,101 +594,46 @@ func (c *ChainConfig) SetEIP6049TransitionTime(n *uint64) error { // EIP3651: Warm COINBASE func (c *ChainConfig) GetEIP3651Transition() *uint64 { - if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { - return newU64(0) - } return nil } func (c *ChainConfig) SetEIP3651Transition(n *uint64) error { - if n == nil { - c.ShanghaiTime = nil - return nil - } - if *n == 0 { - c.ShanghaiTime = newU64(0) - return nil - } return ctypes.ErrUnsupportedConfigNoop } // GetEIP3855Transition EIP3855: PUSH0 instruction func (c *ChainConfig) GetEIP3855Transition() *uint64 { - if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { - return newU64(0) - } return nil } func (c *ChainConfig) SetEIP3855Transition(n *uint64) error { - if n == nil { - c.ShanghaiTime = nil - return nil - } - if *n == 0 { - c.ShanghaiTime = newU64(0) - return nil - } return ctypes.ErrUnsupportedConfigNoop } // GetEIP3860Transition EIP3860: Limit and meter initcode func (c *ChainConfig) GetEIP3860Transition() *uint64 { - if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { - return newU64(0) - } return nil } func (c *ChainConfig) SetEIP3860Transition(n *uint64) error { - if n == nil { - c.ShanghaiTime = nil - return nil - } - if *n == 0 { - c.ShanghaiTime = newU64(0) - return nil - } return ctypes.ErrUnsupportedConfigNoop } // GetEIP4895Transition EIP4895: Beacon chain push withdrawals as operations func (c *ChainConfig) GetEIP4895Transition() *uint64 { - if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { - return newU64(0) - } return nil } func (c *ChainConfig) SetEIP4895Transition(n *uint64) error { - if n == nil { - c.ShanghaiTime = nil - return nil - } - if *n == 0 { - c.ShanghaiTime = newU64(0) - return nil - } return ctypes.ErrUnsupportedConfigNoop } // GetEIP6049Transition EIP6049: Deprecate SELFDESTRUCT func (c *ChainConfig) GetEIP6049Transition() *uint64 { - if c.ShanghaiTime != nil && *c.ShanghaiTime == 0 { - return newU64(0) - } return nil } func (c *ChainConfig) SetEIP6049Transition(n *uint64) error { - if n == nil { - c.ShanghaiTime = nil - return nil - } - if *n == 0 { - c.ShanghaiTime = newU64(0) - return nil - } return ctypes.ErrUnsupportedConfigNoop } From 26265c73c011f2e678f6aff4fc99db114cc5d4bf Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Mon, 4 Sep 2023 18:35:13 +0300 Subject: [PATCH 29/31] params/types/coregeth: fix typo on core-geth chain configurator EIPs for Shanghai --- params/types/coregeth/chain_config_configurator.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/params/types/coregeth/chain_config_configurator.go b/params/types/coregeth/chain_config_configurator.go index c7837e58f4..2f34271355 100644 --- a/params/types/coregeth/chain_config_configurator.go +++ b/params/types/coregeth/chain_config_configurator.go @@ -571,7 +571,7 @@ func (c *CoreGethChainConfig) GetEIP3651Transition() *uint64 { } func (c *CoreGethChainConfig) SetEIP3651Transition(n *uint64) error { - c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) + c.EIP3651FBlock = setBig(c.EIP3651FBlock, n) return nil } @@ -581,7 +581,7 @@ func (c *CoreGethChainConfig) GetEIP3855Transition() *uint64 { } func (c *CoreGethChainConfig) SetEIP3855Transition(n *uint64) error { - c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) + c.EIP3855FBlock = setBig(c.EIP3855FBlock, n) return nil } @@ -591,7 +591,7 @@ func (c *CoreGethChainConfig) GetEIP3860Transition() *uint64 { } func (c *CoreGethChainConfig) SetEIP3860Transition(n *uint64) error { - c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) + c.EIP3860FBlock = setBig(c.EIP3860FBlock, n) return nil } @@ -601,7 +601,7 @@ func (c *CoreGethChainConfig) GetEIP4895Transition() *uint64 { } func (c *CoreGethChainConfig) SetEIP4895Transition(n *uint64) error { - c.EIP6049FBlock = setBig(c.EIP6049FBlock, n) + c.EIP4895FBlock = setBig(c.EIP4895FBlock, n) return nil } From 1c9478df7387cc8991ea0bce7fb8f108c21954cb Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 4 Sep 2023 10:34:38 -0600 Subject: [PATCH 30/31] params: unset Spiral/Shanghai activation blocks for Classic, Mordor The ECIP does not specify valid activation blocks yet, so we should not code them. https://github.com/ethereumclassic/ECIPs/blob/64423c73b7416c2f8e40d4c66bf40b715c458b8c/_specs/ecip-1109.md Date: 2023-09-04 10:34:38-06:00 Signed-off-by: meows --- params/config_classic.go | 13 +++++++------ params/config_mordor.go | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/params/config_classic.go b/params/config_classic.go index e35441567d..ceba7d4ffe 100644 --- a/params/config_classic.go +++ b/params/config_classic.go @@ -94,12 +94,13 @@ var ( EIP3529FBlock: big.NewInt(14_525_000), EIP3541FBlock: big.NewInt(14_525_000), - // EIP4399FBlock: big.NewInt(18_400_000), // Supplant DIFFICULTY with PREVRANDAO. ETC does not spec 4399 because it's still PoW, and 4399 is only applicable for the PoS system. - EIP3651FBlock: big.NewInt(18_400_000), // Warm COINBASE (gas reprice) - EIP3855FBlock: big.NewInt(18_400_000), // PUSH0 instruction - EIP3860FBlock: big.NewInt(18_400_000), // Limit and meter initcode - // EIP4895FBlock: big.NewInt(18_400_000), // Beacon chain push withdrawals as operations - EIP6049FBlock: big.NewInt(18_400_000), // Deprecate SELFDESTRUCT (noop) + // Spiral, aka Shanghai (partially) + // EIP4399FBlock: nil, // Supplant DIFFICULTY with PREVRANDAO. ETC does not spec 4399 because it's still PoW, and 4399 is only applicable for the PoS system. + EIP3651FBlock: nil, // Warm COINBASE (gas reprice) + EIP3855FBlock: nil, // PUSH0 instruction + EIP3860FBlock: nil, // Limit and meter initcode + // EIP4895FBlock: nil, // Beacon chain push withdrawals as operations + EIP6049FBlock: nil, // Deprecate SELFDESTRUCT (noop) RequireBlockHashes: map[uint64]common.Hash{ 1920000: common.HexToHash("0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f"), diff --git a/params/config_mordor.go b/params/config_mordor.go index 1540a1c689..a1dd40dc02 100644 --- a/params/config_mordor.go +++ b/params/config_mordor.go @@ -80,6 +80,14 @@ var ( EIP3529FBlock: big.NewInt(5_520_000), EIP3541FBlock: big.NewInt(5_520_000), + // Spiral, aka Shanghai (partially) + // EIP4399FBlock: nil, // Supplant DIFFICULTY with PREVRANDAO. ETC does not spec 4399 because it's still PoW, and 4399 is only applicable for the PoS system. + EIP3651FBlock: nil, // Warm COINBASE (gas reprice) + EIP3855FBlock: nil, // PUSH0 instruction + EIP3860FBlock: nil, // Limit and meter initcode + // EIP4895FBlock: nil, // Beacon chain push withdrawals as operations + EIP6049FBlock: nil, // Deprecate SELFDESTRUCT (noop) + DisposalBlock: big.NewInt(0), ECIP1017FBlock: big.NewInt(0), ECIP1017EraRounds: big.NewInt(2000000), From 40a56aa92fcf98562843552599348310134028c1 Mon Sep 17 00:00:00 2001 From: Chris Ziogas Date: Tue, 5 Sep 2023 15:42:26 +0300 Subject: [PATCH 31/31] core/forkid: unset Spiral activation blocks tests for Classic --- core/forkid/forkid_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/forkid/forkid_test.go b/core/forkid/forkid_test.go index ba53a72c84..04582e0541 100644 --- a/core/forkid/forkid_test.go +++ b/core/forkid/forkid_test.go @@ -157,10 +157,8 @@ func TestCreation(t *testing.T) { {13_189_133, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, {13_189_134, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, {14_524_999, 0, ID{Hash: checksumToBytes(0x0f6bf187), Next: 14_525_000}}, - {14_525_000, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 18_400_000}}, - {14_525_001, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 18_400_000}}, - {18_400_000, 0, ID{Hash: checksumToBytes(0x1e7801b5), Next: 0}}, - {18_400_001, 0, ID{Hash: checksumToBytes(0x1e7801b5), Next: 0}}, + {14_525_000, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 0}}, + {14_525_001, 0, ID{Hash: checksumToBytes(0x7fd1bb25), Next: 0}}, }, }, { @@ -489,7 +487,7 @@ func TestGatherForks(t *testing.T) { { "classic", params.ClassicChainConfig, - []uint64{1150000, 2500000, 3000000, 5000000, 5900000, 8772000, 9573000, 10500839, 11_700_000, 13_189_133, 14_525_000, 18_400_000}, + []uint64{1150000, 2500000, 3000000, 5000000, 5900000, 8772000, 9573000, 10500839, 11_700_000, 13_189_133, 14_525_000}, }, { "mainnet",