From 8ff94100b137d6a25928720180a047d4046e8d93 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 1 Aug 2024 11:23:05 -0300 Subject: [PATCH] imprv Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 1e3f42388429..40db78ad28a6 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -428,12 +428,26 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest // Start with generating the MPT DB, which should be empty if it's post-verkle transition sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: true, Verkle: false}) - // TODO: this only works for verkle-genesis tests. We can fix this line whenever the testing infra sends the correct - // started/ended transition flags in env for verkle-genesis tests. - sdb.InitTransitionStatus(true, true, common.Hash{}) + if pre.Env.Ended != nil && *pre.Env.Ended { + sdb.InitTransitionStatus(true, true, common.Hash{}) + } statedb, _ := state.New(types.EmptyRootHash, sdb, nil) + if pre.Env.Ended != nil && *pre.Env.Ended { + vtr := statedb.GetTrie().(*trie.VerkleTrie) + + // create the vkt, should be empty on first insert + for k, v := range pre.VKT { + values := make([][]byte, 256) + values[k[31]] = make([]byte, 32) + copy(values[k[31]], v) + vtr.UpdateStem(k.Bytes(), values) + } + + return statedb + } + // MPT pre is the same as the pre state for first conversion block for addr, a := range pre.Pre { statedb.SetCode(addr, a.Code)