etclabscore / core-geth

A highly configurable Go implementation of the Ethereum protocol.
https://etclabscore.github.io/core-geth
GNU Lesser General Public License v3.0
263 stars 144 forks source link

dumpconfig creates an invalid config.toml (ECBP1100 cannot umarshal <nil> into a *big.Int) #613

Closed meowsbits closed 5 months ago

meowsbits commented 5 months ago
geth version
Core
Version: 1.12.14-stable
Git Commit: f1c80f7e79631ee246d56de58822619c692ebab6
Architecture: amd64
Go Version: go1.20
Operating System: linux
GOPATH=/home/ia/go
GOROOT=/home/ia/go1.21.2.linux-amd64/go

./build/bin/geth --classic dumpconfig > config.toml
INFO [02-05|09:10:00.612] Maximum peer count                       ETH=50 LES=0 total=50
INFO [02-05|09:10:00.616] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [02-05|09:10:00.621] Set global gas cap                       cap=50,000,000
INFO [02-05|09:10:00.631] Configured Ethereum protocol versions    capabilities="[68 67 66]"
INFO [02-05|09:10:00.631] Initializing the KZG library             backend=gokzg

./build/bin/geth --config config.toml
INFO [02-05|09:10:15.803] Starting Geth on Ethereum mainnet... 
INFO [02-05|09:10:15.803] Bumping default cache on mainnet         provided=1024 updated=4096
Fatal: config.toml, line 29: (ethconfig.Config.ECBP1100) math/big: cannot unmarshal "<nil>" into a *big.Int
meowsbits commented 5 months ago

The config also includes a field ECBP1100Disable which should not be there, it should be OverrideECBP1100Deactivate. Makes me wonder about the go generate check too.

go generate -skip=trezor ./...

yields:

diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go
index fc71033021..8413f23c26 100644
--- a/eth/ethconfig/gen_config.go
+++ b/eth/ethconfig/gen_config.go
@@ -20,57 +20,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                   *big.Int
+       OverrideECBP1100Deactivate *big.Int
+       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 +119,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 +130,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                   *big.Int
+       OverrideECBP1100Deactivate *big.Int
+       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 +324,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
    }