mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
fix failing tests
This commit is contained in:
parent
d3a07a2592
commit
7fd5179029
4 changed files with 9 additions and 19 deletions
|
|
@ -353,9 +353,9 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
|
|||
|
||||
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
|
||||
// assembling the block.
|
||||
func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
|
||||
func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
|
||||
if !beacon.IsPoSHeader(header) {
|
||||
return beacon.ethone.FinalizeAndAssemble(chain, header, state, body, receipts)
|
||||
return beacon.ethone.FinalizeAndAssemble(chain, header, statedb, body, receipts)
|
||||
}
|
||||
shanghai := chain.Config().IsShanghai(header.Number, header.Time)
|
||||
if shanghai {
|
||||
|
|
@ -369,10 +369,10 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
|
|||
}
|
||||
}
|
||||
// Finalize and assemble the block.
|
||||
beacon.Finalize(chain, header, state, body)
|
||||
beacon.Finalize(chain, header, statedb, body)
|
||||
|
||||
// Assign the final state root to header.
|
||||
header.Root = state.IntermediateRoot(true)
|
||||
header.Root = statedb.IntermediateRoot(true)
|
||||
|
||||
// Assemble the final block.
|
||||
block := types.NewBlock(header, body, receipts, trie.NewStackTrie(nil))
|
||||
|
|
@ -380,23 +380,20 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
|
|||
// Create the block witness and attach to block.
|
||||
// This step needs to happen as late as possible to catch all access events.
|
||||
if chain.Config().IsVerkle(header.Number, header.Time) {
|
||||
keys := state.AccessEvents().Keys()
|
||||
//statedb.Database().SaveTransitionState(header.Root, &state.TransitionState{Ended: true})
|
||||
keys := statedb.AccessEvents().Keys()
|
||||
|
||||
// Open the pre-tree to prove the pre-state against
|
||||
parent := chain.GetHeaderByNumber(header.Number.Uint64() - 1)
|
||||
if parent == nil {
|
||||
return nil, fmt.Errorf("nil parent header for block %d", header.Number)
|
||||
}
|
||||
preTrie, err := state.Database().OpenTrie(parent.Root)
|
||||
preTrie, err := statedb.Database().OpenTrie(parent.Root)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error opening pre-state tree root: %w", err)
|
||||
}
|
||||
postTrie := state.GetTrie()
|
||||
if postTrie == nil {
|
||||
return nil, errors.New("post-state tree is not available")
|
||||
}
|
||||
vktPreTrie, okpre := preTrie.(*trie.VerkleTrie)
|
||||
vktPostTrie, okpost := state.GetTrie().(*trie.VerkleTrie)
|
||||
vktPostTrie, okpost := statedb.GetTrie().(*trie.VerkleTrie)
|
||||
|
||||
// The witness is only attached iff both parent and current block are
|
||||
// using verkle tree.
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ func (g *Genesis) chainConfigOrDefault(ghash common.Hash, stored *params.ChainCo
|
|||
// IsVerkle indicates whether the state is already stored in a verkle
|
||||
// tree at genesis time.
|
||||
func (g *Genesis) IsVerkle() bool {
|
||||
return g.Config.VerkleTime != nil && *g.Config.VerkleTime == g.Timestamp
|
||||
return g != nil && g.Config != nil && g.Config.VerkleTime != nil && *g.Config.VerkleTime == g.Timestamp
|
||||
}
|
||||
|
||||
// ToBlock returns the genesis block according to genesis specification.
|
||||
|
|
|
|||
|
|
@ -66,12 +66,6 @@ type Database interface {
|
|||
|
||||
// Snapshot returns the underlying state snapshot.
|
||||
Snapshot() *snapshot.Tree
|
||||
|
||||
// SaveTransitionState saves the tree transition progress markers to the database.
|
||||
SaveTransitionState(common.Hash, *TransitionState)
|
||||
|
||||
// LoadTransitionState loads the tree transition progress markers from the database.
|
||||
LoadTransitionState(common.Hash) *TransitionState
|
||||
}
|
||||
|
||||
// Trie is a Ethereum Merkle Patricia trie.
|
||||
|
|
|
|||
|
|
@ -1305,7 +1305,6 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool, noStorag
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
s.db.SaveTransitionState(ret.root, &TransitionState{Ended: true})
|
||||
if !ret.empty() {
|
||||
// If snapshotting is enabled, update the snapshot tree with this new version
|
||||
if snap := s.db.Snapshot(); snap != nil && snap.Snapshot(ret.originRoot) != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue