From 6f08c7e89305cb30000eedb6b5dd9770d3e80250 Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 09:53:17 -0700 Subject: [PATCH 1/7] cmd/geth,eth,eth/ethconfig,params/types/genesisT: fix data type for ECBP config fields (*big.Int -> *uint64) Date: 2024-02-05 09:53:17-07:00 Signed-off-by: meows --- cmd/geth/config.go | 5 +- eth/backend.go | 6 +- eth/ethconfig/config.go | 5 +- eth/ethconfig/gen_config.go | 212 +++++++++++++-------------- params/types/genesisT/gen_genesis.go | 25 +--- 5 files changed, 114 insertions(+), 139 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 6174d53a0a..6dfbf179cc 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "math" - "math/big" "os" "reflect" "unicode" @@ -171,7 +170,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { stack, cfg := makeConfigNode(ctx) if ctx.IsSet(utils.ECBP1100Flag.Name) { if n := ctx.Uint64(utils.ECBP1100Flag.Name); n != math.MaxUint64 { - cfg.Eth.ECBP1100 = new(big.Int).SetUint64(n) + cfg.Eth.ECBP1100 = &n } } if ctx.IsSet(utils.ECBP1100NoDisableFlag.Name) { @@ -181,7 +180,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { } if ctx.IsSet(utils.OverrideECBP1100DeactivateFlag.Name) { if n := ctx.Uint64(utils.OverrideECBP1100DeactivateFlag.Name); n != math.MaxUint64 { - cfg.Eth.OverrideECBP1100Deactivate = new(big.Int).SetUint64(n) + cfg.Eth.OverrideECBP1100Deactivate = &n } } if ctx.IsSet(utils.OverrideShanghai.Name) { diff --git a/eth/backend.go b/eth/backend.go index f8232de2e6..9364237cb6 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -231,14 +231,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { eth.bloomIndexer.Start(eth.blockchain) // Handle artificial finality config override cases. if n := config.ECBP1100; n != nil { - v := n.Uint64() - if err := eth.blockchain.Config().SetECBP1100Transition(&v); err != nil { + if err := eth.blockchain.Config().SetECBP1100Transition(n); err != nil { return nil, err } } if n := config.OverrideECBP1100Deactivate; n != nil { - v := n.Uint64() - if err := eth.blockchain.Config().SetECBP1100DeactivateTransition(&v); err != nil { + if err := eth.blockchain.Config().SetECBP1100DeactivateTransition(n); err != nil { return nil, err } } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 417b70f8c8..50f4f8cd2e 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -18,7 +18,6 @@ package ethconfig import ( - "math/big" "os" "os/user" "path/filepath" @@ -217,9 +216,9 @@ type Config struct { CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` // Manual configuration field for ECBP1100 activation number. Used for modifying genesis config via CLI flag. - ECBP1100 *big.Int + ECBP1100 *uint64 // Manual configuration field for ECBP1100's disablement block number. Used for modifying genesis config via CLI flag. - OverrideECBP1100Deactivate *big.Int + OverrideECBP1100Deactivate *uint64 // ECBP1100NoDisable overrides // When this value is *true, ECBP100 will not (ever) be disabled; when *false, it will never be enabled. diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index fc71033021..8f4e75505e 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -3,7 +3,6 @@ package ethconfig import ( - "math/big" "time" "github.com/ethereum/go-ethereum/common" @@ -20,57 +19,57 @@ import ( // MarshalTOML marshals as TOML. func (c Config) MarshalTOML() (interface{}, error) { type Config struct { - Genesis *genesisT.Genesis `toml:",omitempty"` - NetworkId uint64 - ProtocolVersions []uint - SyncMode downloader.SyncMode - EthDiscoveryURLs []string - SnapDiscoveryURLs []string - NoPruning bool - NoPrefetch bool - TxLookupLimit uint64 `toml:",omitempty"` - RequiredBlocks map[uint64]common.Hash `toml:"-"` - LightServ int `toml:",omitempty"` - LightIngress int `toml:",omitempty"` - LightEgress int `toml:",omitempty"` - LightPeers int `toml:",omitempty"` - LightNoPrune bool `toml:",omitempty"` - LightNoSyncServe bool `toml:",omitempty"` - SyncFromCheckpoint bool `toml:",omitempty"` - UltraLightServers []string `toml:",omitempty"` - UltraLightFraction int `toml:",omitempty"` - UltraLightOnlyAnnounce bool `toml:",omitempty"` - SkipBcVersionCheck bool `toml:"-"` - DatabaseHandles int `toml:"-"` - DatabaseCache int - DatabaseFreezer string - DatabaseFreezerRemote string - TrieCleanCache int - TrieDirtyCache int - TrieTimeout time.Duration - SnapshotCache int - Preimages bool - FilterLogCacheSize int - Miner miner.Config - Ethash ethash.Config - TxPool legacypool.Config - BlobPool blobpool.Config - GPO gasprice.Config - EnablePreimageRecording bool - DocRoot string `toml:"-"` - EWASMInterpreter string - EVMInterpreter string - RPCGasCap uint64 - RPCEVMTimeout time.Duration - RPCTxFeeCap float64 - Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` - CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *big.Int - ECBP1100Disable *big.Int - ECBP1100NoDisable *bool `toml:",omitempty"` - OverrideShanghai *uint64 `toml:",omitempty"` - OverrideCancun *uint64 `toml:",omitempty"` - OverrideVerkle *uint64 `toml:",omitempty"` + Genesis *genesisT.Genesis `toml:",omitempty"` + NetworkId uint64 + ProtocolVersions []uint + SyncMode downloader.SyncMode + EthDiscoveryURLs []string + SnapDiscoveryURLs []string + NoPruning bool + NoPrefetch bool + TxLookupLimit uint64 `toml:",omitempty"` + RequiredBlocks map[uint64]common.Hash `toml:"-"` + LightServ int `toml:",omitempty"` + LightIngress int `toml:",omitempty"` + LightEgress int `toml:",omitempty"` + LightPeers int `toml:",omitempty"` + LightNoPrune bool `toml:",omitempty"` + LightNoSyncServe bool `toml:",omitempty"` + SyncFromCheckpoint bool `toml:",omitempty"` + UltraLightServers []string `toml:",omitempty"` + UltraLightFraction int `toml:",omitempty"` + UltraLightOnlyAnnounce bool `toml:",omitempty"` + SkipBcVersionCheck bool `toml:"-"` + DatabaseHandles int `toml:"-"` + DatabaseCache int + DatabaseFreezer string + DatabaseFreezerRemote string + TrieCleanCache int + TrieDirtyCache int + TrieTimeout time.Duration + SnapshotCache int + Preimages bool + FilterLogCacheSize int + Miner miner.Config + Ethash ethash.Config + TxPool legacypool.Config + BlobPool blobpool.Config + GPO gasprice.Config + EnablePreimageRecording bool + DocRoot string `toml:"-"` + EWASMInterpreter string + EVMInterpreter string + RPCGasCap uint64 + RPCEVMTimeout time.Duration + RPCTxFeeCap float64 + Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` + CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` + ECBP1100 *uint64 + OverrideECBP1100Deactivate *uint64 + ECBP1100NoDisable *bool `toml:",omitempty"` + OverrideShanghai *uint64 `toml:",omitempty"` + OverrideCancun *uint64 `toml:",omitempty"` + OverrideVerkle *uint64 `toml:",omitempty"` } var enc Config enc.Genesis = c.Genesis @@ -119,9 +118,8 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.Checkpoint = c.Checkpoint enc.CheckpointOracle = c.CheckpointOracle enc.ECBP1100 = c.ECBP1100 - enc.ECBP1100Disable = c.OverrideECBP1100Deactivate + enc.OverrideECBP1100Deactivate = c.OverrideECBP1100Deactivate enc.ECBP1100NoDisable = c.ECBP1100NoDisable - enc.OverrideShanghai = c.OverrideShanghai enc.OverrideCancun = c.OverrideCancun enc.OverrideVerkle = c.OverrideVerkle @@ -131,57 +129,57 @@ func (c Config) MarshalTOML() (interface{}, error) { // UnmarshalTOML unmarshals from TOML. func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { type Config struct { - Genesis *genesisT.Genesis `toml:",omitempty"` - NetworkId *uint64 - ProtocolVersions []uint - SyncMode *downloader.SyncMode - EthDiscoveryURLs []string - SnapDiscoveryURLs []string - NoPruning *bool - NoPrefetch *bool - TxLookupLimit *uint64 `toml:",omitempty"` - RequiredBlocks map[uint64]common.Hash `toml:"-"` - LightServ *int `toml:",omitempty"` - LightIngress *int `toml:",omitempty"` - LightEgress *int `toml:",omitempty"` - LightPeers *int `toml:",omitempty"` - LightNoPrune *bool `toml:",omitempty"` - LightNoSyncServe *bool `toml:",omitempty"` - SyncFromCheckpoint *bool `toml:",omitempty"` - UltraLightServers []string `toml:",omitempty"` - UltraLightFraction *int `toml:",omitempty"` - UltraLightOnlyAnnounce *bool `toml:",omitempty"` - SkipBcVersionCheck *bool `toml:"-"` - DatabaseHandles *int `toml:"-"` - DatabaseCache *int - DatabaseFreezer *string - DatabaseFreezerRemote *string - TrieCleanCache *int - TrieDirtyCache *int - TrieTimeout *time.Duration - SnapshotCache *int - Preimages *bool - FilterLogCacheSize *int - Miner *miner.Config - Ethash *ethash.Config - TxPool *legacypool.Config - BlobPool *blobpool.Config - GPO *gasprice.Config - EnablePreimageRecording *bool - DocRoot *string `toml:"-"` - EWASMInterpreter *string - EVMInterpreter *string - RPCGasCap *uint64 - RPCEVMTimeout *time.Duration - RPCTxFeeCap *float64 - Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` - CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *big.Int - ECBP1100Disable *big.Int - ECBP1100NoDisable *bool `toml:",omitempty"` - OverrideShanghai *uint64 `toml:",omitempty"` - OverrideCancun *uint64 `toml:",omitempty"` - OverrideVerkle *uint64 `toml:",omitempty"` + Genesis *genesisT.Genesis `toml:",omitempty"` + NetworkId *uint64 + ProtocolVersions []uint + SyncMode *downloader.SyncMode + EthDiscoveryURLs []string + SnapDiscoveryURLs []string + NoPruning *bool + NoPrefetch *bool + TxLookupLimit *uint64 `toml:",omitempty"` + RequiredBlocks map[uint64]common.Hash `toml:"-"` + LightServ *int `toml:",omitempty"` + LightIngress *int `toml:",omitempty"` + LightEgress *int `toml:",omitempty"` + LightPeers *int `toml:",omitempty"` + LightNoPrune *bool `toml:",omitempty"` + LightNoSyncServe *bool `toml:",omitempty"` + SyncFromCheckpoint *bool `toml:",omitempty"` + UltraLightServers []string `toml:",omitempty"` + UltraLightFraction *int `toml:",omitempty"` + UltraLightOnlyAnnounce *bool `toml:",omitempty"` + SkipBcVersionCheck *bool `toml:"-"` + DatabaseHandles *int `toml:"-"` + DatabaseCache *int + DatabaseFreezer *string + DatabaseFreezerRemote *string + TrieCleanCache *int + TrieDirtyCache *int + TrieTimeout *time.Duration + SnapshotCache *int + Preimages *bool + FilterLogCacheSize *int + Miner *miner.Config + Ethash *ethash.Config + TxPool *legacypool.Config + BlobPool *blobpool.Config + GPO *gasprice.Config + EnablePreimageRecording *bool + DocRoot *string `toml:"-"` + EWASMInterpreter *string + EVMInterpreter *string + RPCGasCap *uint64 + RPCEVMTimeout *time.Duration + RPCTxFeeCap *float64 + Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` + CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` + ECBP1100 *uint64 + OverrideECBP1100Deactivate *uint64 + ECBP1100NoDisable *bool `toml:",omitempty"` + OverrideShanghai *uint64 `toml:",omitempty"` + OverrideCancun *uint64 `toml:",omitempty"` + OverrideVerkle *uint64 `toml:",omitempty"` } var dec Config if err := unmarshal(&dec); err != nil { @@ -325,8 +323,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.ECBP1100 != nil { c.ECBP1100 = dec.ECBP1100 } - if dec.ECBP1100Disable != nil { - c.OverrideECBP1100Deactivate = dec.ECBP1100Disable + if dec.OverrideECBP1100Deactivate != nil { + c.OverrideECBP1100Deactivate = dec.OverrideECBP1100Deactivate } if dec.ECBP1100NoDisable != nil { c.ECBP1100NoDisable = dec.ECBP1100NoDisable diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go index 12f3d10b05..6438ab5125 100644 --- a/params/types/genesisT/gen_genesis.go +++ b/params/types/genesisT/gen_genesis.go @@ -10,10 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/params/confp/generic" - "github.com/ethereum/go-ethereum/params/types/coregeth" "github.com/ethereum/go-ethereum/params/types/ctypes" - "github.com/ethereum/go-ethereum/params/types/goethereum" ) var _ = (*genesisSpecMarshaling)(nil) @@ -76,27 +73,11 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { Number *math.HexOrDecimal64 `json:"number"` GasUsed *math.HexOrDecimal64 `json:"gasUsed"` ParentHash *common.Hash `json:"parentHash"` - BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` - ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` - BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` + BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas,omitempty"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas,omitempty"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` } var dec Genesis - // 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 { - return err - } - - switch conf.(type) { - case *coregeth.CoreGethChainConfig: - dec.Config = &coregeth.CoreGethChainConfig{} - case *goethereum.ChainConfig: - dec.Config = &goethereum.ChainConfig{} - default: - panic("unmarshal genesis chain config returned a type not supported by unmarshaling") - } - if err := json.Unmarshal(input, &dec); err != nil { return err } From 16278dc3bd5bc75c86cdc4d18fe2f5aab85859cc Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 09:54:38 -0700 Subject: [PATCH 2/7] params/types/genesisT: add genesis decoder switch for core-geth vs. go-ethereum config types Date: 2024-02-05 09:54:38-07:00 Signed-off-by: meows --- params/types/genesisT/gen_genesis.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go index 6438ab5125..299c979ba8 100644 --- a/params/types/genesisT/gen_genesis.go +++ b/params/types/genesisT/gen_genesis.go @@ -10,7 +10,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/params/confp/generic" + "github.com/ethereum/go-ethereum/params/types/coregeth" "github.com/ethereum/go-ethereum/params/types/ctypes" + "github.com/ethereum/go-ethereum/params/types/goethereum" ) var _ = (*genesisSpecMarshaling)(nil) @@ -78,6 +81,22 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` } var dec Genesis + // 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 { + return err + } + + switch conf.(type) { + case *coregeth.CoreGethChainConfig: + dec.Config = &coregeth.CoreGethChainConfig{} + case *goethereum.ChainConfig: + dec.Config = &goethereum.ChainConfig{} + default: + panic("unmarshal genesis chain config returned a type not supported by unmarshaling") + } + if err := json.Unmarshal(input, &dec); err != nil { return err } From 7db8348071ba6b5e3a5116b21325c4960b361447 Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 10:01:44 -0700 Subject: [PATCH 3/7] eth/ethconfig: problem: toml: cannot marshal nil *uint64; solution: add missing omitempty tags Date: 2024-02-05 10:01:44-07:00 Signed-off-by: meows --- eth/ethconfig/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 50f4f8cd2e..0177748cac 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -216,9 +216,9 @@ type Config struct { CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` // Manual configuration field for ECBP1100 activation number. Used for modifying genesis config via CLI flag. - ECBP1100 *uint64 + ECBP1100 *uint64 `toml:",omitempty"` // Manual configuration field for ECBP1100's disablement block number. Used for modifying genesis config via CLI flag. - OverrideECBP1100Deactivate *uint64 + OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` // ECBP1100NoDisable overrides // When this value is *true, ECBP100 will not (ever) be disabled; when *false, it will never be enabled. From d3a2850a6b457af0845d3892210caa5a92424472 Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 10:04:07 -0700 Subject: [PATCH 4/7] eth/ethconfig,params/types/genesisT: go generate -skip=trezor ./... Date: 2024-02-05 10:04:07-07:00 Signed-off-by: meows --- eth/ethconfig/gen_config.go | 24 ++++++++++++------------ params/types/genesisT/gen_genesis.go | 19 ------------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 8f4e75505e..84fed41fd8 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -64,12 +64,12 @@ func (c Config) MarshalTOML() (interface{}, error) { RPCTxFeeCap float64 Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *uint64 - OverrideECBP1100Deactivate *uint64 - ECBP1100NoDisable *bool `toml:",omitempty"` - OverrideShanghai *uint64 `toml:",omitempty"` - OverrideCancun *uint64 `toml:",omitempty"` - OverrideVerkle *uint64 `toml:",omitempty"` + ECBP1100 *uint64 `toml:",omitempty"` + OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` + ECBP1100NoDisable *bool `toml:",omitempty"` + OverrideShanghai *uint64 `toml:",omitempty"` + OverrideCancun *uint64 `toml:",omitempty"` + OverrideVerkle *uint64 `toml:",omitempty"` } var enc Config enc.Genesis = c.Genesis @@ -174,12 +174,12 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { RPCTxFeeCap *float64 Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *uint64 - OverrideECBP1100Deactivate *uint64 - ECBP1100NoDisable *bool `toml:",omitempty"` - OverrideShanghai *uint64 `toml:",omitempty"` - OverrideCancun *uint64 `toml:",omitempty"` - OverrideVerkle *uint64 `toml:",omitempty"` + ECBP1100 *uint64 `toml:",omitempty"` + OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` + ECBP1100NoDisable *bool `toml:",omitempty"` + OverrideShanghai *uint64 `toml:",omitempty"` + OverrideCancun *uint64 `toml:",omitempty"` + OverrideVerkle *uint64 `toml:",omitempty"` } var dec Config if err := unmarshal(&dec); err != nil { diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go index 299c979ba8..6438ab5125 100644 --- a/params/types/genesisT/gen_genesis.go +++ b/params/types/genesisT/gen_genesis.go @@ -10,10 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/params/confp/generic" - "github.com/ethereum/go-ethereum/params/types/coregeth" "github.com/ethereum/go-ethereum/params/types/ctypes" - "github.com/ethereum/go-ethereum/params/types/goethereum" ) var _ = (*genesisSpecMarshaling)(nil) @@ -81,22 +78,6 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` } var dec Genesis - // 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 { - return err - } - - switch conf.(type) { - case *coregeth.CoreGethChainConfig: - dec.Config = &coregeth.CoreGethChainConfig{} - case *goethereum.ChainConfig: - dec.Config = &goethereum.ChainConfig{} - default: - panic("unmarshal genesis chain config returned a type not supported by unmarshaling") - } - if err := json.Unmarshal(input, &dec); err != nil { return err } From 759c3e00779460eef29dd202e23195be2cfd881c Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 10:04:35 -0700 Subject: [PATCH 5/7] params/types/genesisT: params/types/genesisT: add genesis decoder switch for core-geth vs. go-ethereum config types Date: 2024-02-05 10:04:35-07:00 Signed-off-by: meows --- params/types/genesisT/gen_genesis.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/params/types/genesisT/gen_genesis.go b/params/types/genesisT/gen_genesis.go index 6438ab5125..299c979ba8 100644 --- a/params/types/genesisT/gen_genesis.go +++ b/params/types/genesisT/gen_genesis.go @@ -10,7 +10,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/params/confp/generic" + "github.com/ethereum/go-ethereum/params/types/coregeth" "github.com/ethereum/go-ethereum/params/types/ctypes" + "github.com/ethereum/go-ethereum/params/types/goethereum" ) var _ = (*genesisSpecMarshaling)(nil) @@ -78,6 +81,22 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` } var dec Genesis + // 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 { + return err + } + + switch conf.(type) { + case *coregeth.CoreGethChainConfig: + dec.Config = &coregeth.CoreGethChainConfig{} + case *goethereum.ChainConfig: + dec.Config = &goethereum.ChainConfig{} + default: + panic("unmarshal genesis chain config returned a type not supported by unmarshaling") + } + if err := json.Unmarshal(input, &dec); err != nil { return err } From 0ae1b0425f0d12b48c6aaace37773f543aef3e7a Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 10:06:16 -0700 Subject: [PATCH 6/7] .github/workflows: add workflow_dispatch Date: 2024-02-05 10:06:16-07:00 Signed-off-by: meows --- .github/workflows/go-generate-check.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-generate-check.yml b/.github/workflows/go-generate-check.yml index 38fd5bc458..a40179e98d 100644 --- a/.github/workflows/go-generate-check.yml +++ b/.github/workflows/go-generate-check.yml @@ -1,5 +1,7 @@ name: Developer helper -on: pull_request +on: + pull_request: + workflow_dispatch: env: # GENERATE_EXCEPTIONS are exceptions made to the 'go generate' command. # These patterns are matched (negatively) against 'go list' output. From 82ebc797cb524efcbea77034c05c60e8c0141bfc Mon Sep 17 00:00:00 2001 From: meows Date: Mon, 5 Feb 2024 11:00:37 -0700 Subject: [PATCH 7/7] cmd/geth,eth,eth/ethconfig: rename config field ECBP1100 -> OverrideECBP1100 Date: 2024-02-05 11:00:37-07:00 Signed-off-by: meows --- cmd/geth/config.go | 2 +- eth/backend.go | 2 +- eth/ethconfig/config.go | 2 +- eth/ethconfig/gen_config.go | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 6dfbf179cc..17a5b474e5 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -170,7 +170,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { stack, cfg := makeConfigNode(ctx) if ctx.IsSet(utils.ECBP1100Flag.Name) { if n := ctx.Uint64(utils.ECBP1100Flag.Name); n != math.MaxUint64 { - cfg.Eth.ECBP1100 = &n + cfg.Eth.OverrideECBP1100 = &n } } if ctx.IsSet(utils.ECBP1100NoDisableFlag.Name) { diff --git a/eth/backend.go b/eth/backend.go index 9364237cb6..b9af5f4762 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -230,7 +230,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } eth.bloomIndexer.Start(eth.blockchain) // Handle artificial finality config override cases. - if n := config.ECBP1100; n != nil { + if n := config.OverrideECBP1100; n != nil { if err := eth.blockchain.Config().SetECBP1100Transition(n); err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 0177748cac..5f8190ecac 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -216,7 +216,7 @@ type Config struct { CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` // Manual configuration field for ECBP1100 activation number. Used for modifying genesis config via CLI flag. - ECBP1100 *uint64 `toml:",omitempty"` + OverrideECBP1100 *uint64 `toml:",omitempty"` // Manual configuration field for ECBP1100's disablement block number. Used for modifying genesis config via CLI flag. OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 84fed41fd8..876e90bc26 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -64,7 +64,7 @@ func (c Config) MarshalTOML() (interface{}, error) { RPCTxFeeCap float64 Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *uint64 `toml:",omitempty"` + OverrideECBP1100 *uint64 `toml:",omitempty"` OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` ECBP1100NoDisable *bool `toml:",omitempty"` OverrideShanghai *uint64 `toml:",omitempty"` @@ -117,7 +117,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.RPCTxFeeCap = c.RPCTxFeeCap enc.Checkpoint = c.Checkpoint enc.CheckpointOracle = c.CheckpointOracle - enc.ECBP1100 = c.ECBP1100 + enc.OverrideECBP1100 = c.OverrideECBP1100 enc.OverrideECBP1100Deactivate = c.OverrideECBP1100Deactivate enc.ECBP1100NoDisable = c.ECBP1100NoDisable enc.OverrideShanghai = c.OverrideShanghai @@ -174,7 +174,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { RPCTxFeeCap *float64 Checkpoint *ctypes.TrustedCheckpoint `toml:",omitempty"` CheckpointOracle *ctypes.CheckpointOracleConfig `toml:",omitempty"` - ECBP1100 *uint64 `toml:",omitempty"` + OverrideECBP1100 *uint64 `toml:",omitempty"` OverrideECBP1100Deactivate *uint64 `toml:",omitempty"` ECBP1100NoDisable *bool `toml:",omitempty"` OverrideShanghai *uint64 `toml:",omitempty"` @@ -320,8 +320,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.CheckpointOracle != nil { c.CheckpointOracle = dec.CheckpointOracle } - if dec.ECBP1100 != nil { - c.ECBP1100 = dec.ECBP1100 + if dec.OverrideECBP1100 != nil { + c.OverrideECBP1100 = dec.OverrideECBP1100 } if dec.OverrideECBP1100Deactivate != nil { c.OverrideECBP1100Deactivate = dec.OverrideECBP1100Deactivate