From 303e7ae0a383b54d4a0faf3aa09def744753b625 Mon Sep 17 00:00:00 2001 From: Kartik Chopra Date: Tue, 26 Nov 2024 11:32:25 -0500 Subject: [PATCH] chore: wip changes to correctly add zero fee address --- cmd/geth/config.go | 9 ++++ cmd/utils/flags.go | 5 +- core/blockchain.go | 1 + eth/backend.go | 1 + eth/ethconfig/config.go | 3 ++ geth-poa/genesis.json | 102 ++++++++++++---------------------------- go.mod | 2 - 7 files changed, 48 insertions(+), 75 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 5f52f1df5442..cb0786516507 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -177,6 +177,15 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { v := ctx.Uint64(utils.OverrideVerkle.Name) cfg.Eth.OverrideVerkle = &v } + if ctx.IsSet(utils.ZeroFeeAddressesFlag.Name) { + for _, addr := range ctx.StringSlice(utils.ZeroFeeAddressesFlag.Name) { + cfg.Eth.ZeroFeeAddresses = append( + cfg.Eth.ZeroFeeAddresses, + common.HexToAddress(strings.TrimSpace(addr)), + ) + } + } + log.Info("Final Eth Config: ", cfg.Eth) backend, eth := utils.RegisterEthService(stack, &cfg.Eth) // Create gauge with geth system and build information diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2a74c1fd4de8..7cbf8e759e7a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1865,6 +1865,7 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) { // RegisterEthService adds an Ethereum client to the stack. // The second return value is the full node instance. func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend, *eth.Ethereum) { + log.Info("RegisterEthService called with cfg: ", cfg) backend, err := eth.New(stack, cfg) if err != nil { Fatalf("Failed to register the Ethereum service: %v", err) @@ -2124,8 +2125,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheGCFlag.Name) { cache.TrieDirtyLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheGCFlag.Name) / 100 } - vmcfg := vm.Config{EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name)} + log.Info("VM Config: EnablePreimageRecording=", vmcfg.EnablePreimageRecording) if ctx.IsSet(ZeroFeeAddressesFlag.Name) { for _, addr := range ctx.StringSlice(ZeroFeeAddressesFlag.Name) { vmcfg.ZeroFeeAddresses = append( @@ -2133,7 +2134,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh common.HexToAddress(strings.TrimSpace(addr)), ) } + log.Info("VM Config: ZeroFeeAddresses=", vmcfg.ZeroFeeAddresses) } + log.Info("Final VM Config: ", vmcfg) // Disable transaction indexing/unindexing by default. chain, err := core.NewBlockChain(chainDb, cache, gspec, nil, engine, vmcfg, nil, nil) if err != nil { diff --git a/core/blockchain.go b/core/blockchain.go index 15a3bf5d0579..051b1ceaa9c1 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -303,6 +303,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis engine: engine, vmConfig: vmConfig, } + log.Info("VM Config: ", bc.vmConfig) bc.flushInterval.Store(int64(cacheConfig.TrieTimeLimit)) bc.forker = NewForkChoice(bc, shouldPreserve) bc.stateCache = state.NewDatabaseWithNodeDB(bc.db, bc.triedb) diff --git a/eth/backend.go b/eth/backend.go index aff23a910bcb..241516622ba2 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -192,6 +192,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { var ( vmConfig = vm.Config{ EnablePreimageRecording: config.EnablePreimageRecording, + ZeroFeeAddresses: config.ZeroFeeAddresses, } cacheConfig = &core.CacheConfig{ TrieCleanLimit: config.TrieCleanCache, diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index ad664afb5bd1..9a063ff2b958 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -159,6 +159,9 @@ type Config struct { // OverrideVerkle (TODO: remove after the fork) OverrideVerkle *uint64 `toml:",omitempty"` + + // ZeroFeeAddresses is a list of addresses that are exempt from the zero fee policy. + ZeroFeeAddresses []common.Address `toml:",omitempty"` } // CreateConsensusEngine creates a consensus engine for the given chain config. diff --git a/geth-poa/genesis.json b/geth-poa/genesis.json index ffe42de68b05..b3593df16512 100644 --- a/geth-poa/genesis.json +++ b/geth-poa/genesis.json @@ -1,74 +1,32 @@ { - "config": { - "chainId": 17864, - "homesteadBlock": 0, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "berlinBlock": 0, - "londonBlock": 0, - "cancunTime": 0, - "arrowGlacierBlock": 0, - "grayGlacierBlock": 0, - "clique": { - "period": 200, - "epoch": 30000 - } - }, - "nonce": "0x0", - "timestamp": "0x18E0A4E0D22", - "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000d9cd8E5DE6d55f796D980B818D350C0746C25b970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x1c9c380", - "difficulty": "0x1", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "alloc": { - "0xBe3dEF3973584FdcC1326634aF188f0d9772D57D": { - "balance": "10000000000000000000000000000" - }, - "0xd9cd8E5DE6d55f796D980B818D350C0746C25b97": { - "balance": "10000000000000000000000000000" - }, - "0x788EBABe5c3dD422Ef92Ca6714A69e2eabcE1Ee4": { - "balance": "10000000000000000000000000000" - }, - "0xf6ba5bca9b489de3a4ac3a57823d5d97d608feb9": { - "balance": "10000000000000000000000000000" - }, - "0x0DCaa27B9E4Db92F820189345792f8eC5Ef148F6": { - "balance": "10000000000000000000000000000" - }, - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266": { - "balance": "10000000000000000000000000000" - }, - "0x3fab184622dc19b6109349b94811493bf2a45362": { - "balance": "10000000000000000000000000000" - }, - "0xBcA333b67fb805aB18B4Eb7aa5a0B09aB25E5ce2": { - "balance": "10000000000000000000000000000" - }, - "0xB9286CB4782E43A202BfD426AbB72c8cb34f886c": { - "balance": "10000000000000000000000000000" - }, - "0x04F713A0b687c84D4F66aCd1423712Af6F852B78": { - "balance": "10000000000000000000000000000" - }, - "0x82b941824b43F33e417be1E92273A3020a0D760c": { - "balance": "10000000000000000000000000000" - }, - "0x57508f0B0f3426758F1f3D63ad4935a7c9383620": { - "balance": "10000000000000000000000000000" - }, - "0xa51f13769d1466e0b5483cb719e89add8d615052": { - "balance": "10000000000000000000000000000" - }, - "0x9a5a8ebd13951c8500c728c1982317a503b3e8ce": { - "balance": "10000000000000000000000000000" - } + "config": { + "chainId": 13923, + "terminalTotalDifficulty": 500, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "shanghaiTime": 0, + "cancunTime": 0, + "pragueTime": 0 + }, + "alloc": { + "0xc3bc246D6B0094C8B7D054f911F2bE3b07cE8A63": { + "balance": "999999999999911111" } - } + }, + "coinbase": "0x0000000000000000000000000000000000000000", + "difficulty": "0x0", + "extraData": "", + "gasLimit": "0x2fefd8", + "nonce": "0x0000000000000042", + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "timestamp": "0x00" +} diff --git a/go.mod b/go.mod index bb27902cce8c..d16691cc22f5 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/ethereum/go-ethereum go 1.22.0 -toolchain go1.23.1 - require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 github.com/Microsoft/go-winio v0.6.1