@@ -353,9 +353,9 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
353
353
354
354
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
355
355
// assembling the block.
356
- func (beacon * Beacon ) FinalizeAndAssemble (chain consensus.ChainHeaderReader , header * types.Header , state * state.StateDB , body * types.Body , receipts []* types.Receipt ) (* types.Block , error ) {
356
+ func (beacon * Beacon ) FinalizeAndAssemble (chain consensus.ChainHeaderReader , header * types.Header , statedb * state.StateDB , body * types.Body , receipts []* types.Receipt ) (* types.Block , error ) {
357
357
if ! beacon .IsPoSHeader (header ) {
358
- return beacon .ethone .FinalizeAndAssemble (chain , header , state , body , receipts )
358
+ return beacon .ethone .FinalizeAndAssemble (chain , header , statedb , body , receipts )
359
359
}
360
360
shanghai := chain .Config ().IsShanghai (header .Number , header .Time )
361
361
if shanghai {
@@ -369,34 +369,31 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
369
369
}
370
370
}
371
371
// Finalize and assemble the block.
372
- beacon .Finalize (chain , header , state , body )
372
+ beacon .Finalize (chain , header , statedb , body )
373
373
374
374
// Assign the final state root to header.
375
- header .Root = state .IntermediateRoot (true )
375
+ header .Root = statedb .IntermediateRoot (true )
376
376
377
377
// Assemble the final block.
378
378
block := types .NewBlock (header , body , receipts , trie .NewStackTrie (nil ))
379
379
380
380
// Create the block witness and attach to block.
381
381
// This step needs to happen as late as possible to catch all access events.
382
382
if chain .Config ().IsVerkle (header .Number , header .Time ) {
383
- keys := state .AccessEvents ().Keys ()
383
+ //statedb.Database().SaveTransitionState(header.Root, &state.TransitionState{Ended: true})
384
+ keys := statedb .AccessEvents ().Keys ()
384
385
385
386
// Open the pre-tree to prove the pre-state against
386
387
parent := chain .GetHeaderByNumber (header .Number .Uint64 () - 1 )
387
388
if parent == nil {
388
389
return nil , fmt .Errorf ("nil parent header for block %d" , header .Number )
389
390
}
390
- preTrie , err := state .Database ().OpenTrie (parent .Root )
391
+ preTrie , err := statedb .Database ().OpenTrie (parent .Root )
391
392
if err != nil {
392
393
return nil , fmt .Errorf ("error opening pre-state tree root: %w" , err )
393
394
}
394
- postTrie := state .GetTrie ()
395
- if postTrie == nil {
396
- return nil , errors .New ("post-state tree is not available" )
397
- }
398
395
vktPreTrie , okpre := preTrie .(* trie.VerkleTrie )
399
- vktPostTrie , okpost := state .GetTrie ().(* trie.VerkleTrie )
396
+ vktPostTrie , okpost := statedb .GetTrie ().(* trie.VerkleTrie )
400
397
401
398
// The witness is only attached iff both parent and current block are
402
399
// using verkle tree.
0 commit comments