From 2a59d24b7368085d357aff00369203dd2af0c9c0 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 12 Jul 2023 17:38:19 +0200 Subject: [PATCH] add genesis alloc to hook --- core/blockchain.go | 2 +- core/genesis.go | 2 +- eth/tracers/printer.go | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 4abf32ed80..b72917f7b3 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -162,7 +162,7 @@ type BlockchainLogger interface { // `td` is the total difficulty prior to `block`. OnBlockStart(block *types.Block, td *big.Int, finalized *types.Header, safe *types.Header) OnBlockEnd(err error) - OnGenesisBlock(genesis *types.Block) + OnGenesisBlock(genesis *types.Block, alloc GenesisAlloc) } // BlockChain represents the canonical chain given a database with a genesis diff --git a/core/genesis.go b/core/genesis.go index 2d84efcfde..c5f615210b 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -485,7 +485,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database, bcLogger Bloc return nil, errors.New("can't start clique chain without signers") } if bcLogger != nil { - bcLogger.OnGenesisBlock(block) + bcLogger.OnGenesisBlock(block, g.Alloc) } // All the checks has passed, flush the states derived from the genesis // specification as well as the specification itself into the provided diff --git a/eth/tracers/printer.go b/eth/tracers/printer.go index ce38f3b1a3..3dcf2c1098 100644 --- a/eth/tracers/printer.go +++ b/eth/tracers/printer.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" ) @@ -82,8 +83,8 @@ func (p *Printer) OnBlockEnd(err error) { fmt.Printf("OnBlockEnd: err=%v\n", err) } -func (p *Printer) OnGenesisBlock(b *types.Block) { - fmt.Printf("OnGenesisBlock: b=%v\n", b.NumberU64()) +func (p *Printer) OnGenesisBlock(b *types.Block, alloc core.GenesisAlloc) { + fmt.Printf("OnGenesisBlock: b=%v, allocLength=%d\n", b.NumberU64(), len(alloc)) } func (p *Printer) OnBalanceChange(a common.Address, prev, new *big.Int) {