From beb2b95ff82c8f510709f27bc037940e59a31001 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:23:02 +0100 Subject: [PATCH 1/3] set verkle mode from genesis with override --- cmd/geth/chaincmd.go | 2 +- core/genesis.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 55c22f7322f3..2179b61032b6 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -214,7 +214,7 @@ func initGenesis(ctx *cli.Context) error { } triedb := trie.NewDatabaseWithConfig(chaindb, &trie.Config{ Preimages: ctx.Bool(utils.CachePreimagesFlag.Name), - Verkle: true, + Verkle: genesis.IsVerkle(), }) _, hash, err := core.SetupGenesisBlockWithOverride(chaindb, triedb, genesis, &overrides) if err != nil { diff --git a/core/genesis.go b/core/genesis.go index 74294afb7272..e6874039f2e2 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -456,6 +456,12 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { } } +// IsVerkle indicates whether the state is already stored in a verkle +// tree at genesis time. +func (g *Genesis) IsVerkle() bool { + return g.Config.IsPrague(new(big.Int).SetUint64(g.Number), g.Timestamp) +} + // ToBlock returns the genesis block according to genesis specification. func (g *Genesis) ToBlock() *types.Block { root, err := g.Alloc.deriveHash(g.Config, g.Timestamp) From 1acbed0214915235f949d8cfdaa8ddf9ffb6b960 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:17:58 +0100 Subject: [PATCH 2/3] make linter happy --- core/state_processor.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/state_processor.go b/core/state_processor.go index ed55c478843c..392b5f3a20aa 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -20,7 +20,6 @@ import ( "encoding/binary" "errors" "fmt" - "math/big" "runtime" "sync" "time" From 484bf90cd336d69a1c29656836ed8dc4a21989e1 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:33:33 +0100 Subject: [PATCH 3/3] fix more linter snafu --- cmd/geth/chaincmd.go | 1 - core/state_processor.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 641830991476..2179b61032b6 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -20,7 +20,6 @@ import ( "encoding/json" "errors" "fmt" - "math/big" "os" "runtime" "strconv" diff --git a/core/state_processor.go b/core/state_processor.go index 392b5f3a20aa..ed55c478843c 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -20,6 +20,7 @@ import ( "encoding/binary" "errors" "fmt" + "math/big" "runtime" "sync" "time"