Skip to content

Commit 7fd5179

Browse files
committed
fix failing tests
1 parent d3a07a2 commit 7fd5179

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

consensus/beacon/consensus.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
353353

354354
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
355355
// 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) {
357357
if !beacon.IsPoSHeader(header) {
358-
return beacon.ethone.FinalizeAndAssemble(chain, header, state, body, receipts)
358+
return beacon.ethone.FinalizeAndAssemble(chain, header, statedb, body, receipts)
359359
}
360360
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
361361
if shanghai {
@@ -369,34 +369,31 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
369369
}
370370
}
371371
// Finalize and assemble the block.
372-
beacon.Finalize(chain, header, state, body)
372+
beacon.Finalize(chain, header, statedb, body)
373373

374374
// Assign the final state root to header.
375-
header.Root = state.IntermediateRoot(true)
375+
header.Root = statedb.IntermediateRoot(true)
376376

377377
// Assemble the final block.
378378
block := types.NewBlock(header, body, receipts, trie.NewStackTrie(nil))
379379

380380
// Create the block witness and attach to block.
381381
// This step needs to happen as late as possible to catch all access events.
382382
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()
384385

385386
// Open the pre-tree to prove the pre-state against
386387
parent := chain.GetHeaderByNumber(header.Number.Uint64() - 1)
387388
if parent == nil {
388389
return nil, fmt.Errorf("nil parent header for block %d", header.Number)
389390
}
390-
preTrie, err := state.Database().OpenTrie(parent.Root)
391+
preTrie, err := statedb.Database().OpenTrie(parent.Root)
391392
if err != nil {
392393
return nil, fmt.Errorf("error opening pre-state tree root: %w", err)
393394
}
394-
postTrie := state.GetTrie()
395-
if postTrie == nil {
396-
return nil, errors.New("post-state tree is not available")
397-
}
398395
vktPreTrie, okpre := preTrie.(*trie.VerkleTrie)
399-
vktPostTrie, okpost := state.GetTrie().(*trie.VerkleTrie)
396+
vktPostTrie, okpost := statedb.GetTrie().(*trie.VerkleTrie)
400397

401398
// The witness is only attached iff both parent and current block are
402399
// using verkle tree.

core/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainCo
473473
// IsVerkle indicates whether the state is already stored in a verkle
474474
// tree at genesis time.
475475
func (g *Genesis) IsVerkle() bool {
476-
return g.Config.VerkleTime != nil && *g.Config.VerkleTime == g.Timestamp
476+
return g != nil && g.Config != nil && g.Config.VerkleTime != nil && *g.Config.VerkleTime == g.Timestamp
477477
}
478478

479479
// ToBlock returns the genesis block according to genesis specification.

core/state/database.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ type Database interface {
6666

6767
// Snapshot returns the underlying state snapshot.
6868
Snapshot() *snapshot.Tree
69-
70-
// SaveTransitionState saves the tree transition progress markers to the database.
71-
SaveTransitionState(common.Hash, *TransitionState)
72-
73-
// LoadTransitionState loads the tree transition progress markers from the database.
74-
LoadTransitionState(common.Hash) *TransitionState
7569
}
7670

7771
// Trie is a Ethereum Merkle Patricia trie.

core/state/statedb.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool, noStorag
13051305
return nil, err
13061306
}
13071307
}
1308-
s.db.SaveTransitionState(ret.root, &TransitionState{Ended: true})
13091308
if !ret.empty() {
13101309
// If snapshotting is enabled, update the snapshot tree with this new version
13111310
if snap := s.db.Snapshot(); snap != nil && snap.Snapshot(ret.originRoot) != nil {

0 commit comments

Comments
 (0)