all: expose block number information to statedb (#27753)
* core/state: clean up * all: add block number infomration to statedb * core, trie: rename blockNumber to block
This commit is contained in:
@@ -79,7 +79,7 @@ func TestAccountRange(t *testing.T) {
|
||||
m[addr] = true
|
||||
}
|
||||
}
|
||||
root, _ := sdb.Commit(true)
|
||||
root, _ := sdb.Commit(0, true)
|
||||
sdb, _ = state.New(root, statedb, nil)
|
||||
|
||||
trie, err := statedb.OpenTrie(root)
|
||||
@@ -137,7 +137,7 @@ func TestEmptyAccountRange(t *testing.T) {
|
||||
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
||||
)
|
||||
// Commit(although nothing to flush) and re-init the statedb
|
||||
st.Commit(true)
|
||||
st.Commit(0, true)
|
||||
st, _ = state.New(types.EmptyRootHash, statedb, nil)
|
||||
|
||||
results := st.IteratorDump(&state.DumpConfig{
|
||||
|
||||
@@ -1387,7 +1387,7 @@ func makeAccountTrieNoStorage(n int) (string, *trie.Trie, []*kv) {
|
||||
// Commit the state changes into db and re-create the trie
|
||||
// for accessing later.
|
||||
root, nodes, _ := accTrie.Commit(false)
|
||||
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes), nil)
|
||||
db.Update(root, types.EmptyRootHash, 0, trienode.NewWithNodeSet(nodes), nil)
|
||||
|
||||
accTrie, _ = trie.New(trie.StateTrieID(root), db)
|
||||
return db.Scheme(), accTrie, entries
|
||||
@@ -1449,7 +1449,7 @@ func makeBoundaryAccountTrie(n int) (string, *trie.Trie, []*kv) {
|
||||
// Commit the state changes into db and re-create the trie
|
||||
// for accessing later.
|
||||
root, nodes, _ := accTrie.Commit(false)
|
||||
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes), nil)
|
||||
db.Update(root, types.EmptyRootHash, 0, trienode.NewWithNodeSet(nodes), nil)
|
||||
|
||||
accTrie, _ = trie.New(trie.StateTrieID(root), db)
|
||||
return db.Scheme(), accTrie, entries
|
||||
@@ -1498,7 +1498,7 @@ func makeAccountTrieWithStorageWithUniqueStorage(accounts, slots int, code bool)
|
||||
nodes.Merge(set)
|
||||
|
||||
// Commit gathered dirty nodes into database
|
||||
db.Update(root, types.EmptyRootHash, nodes, nil)
|
||||
db.Update(root, types.EmptyRootHash, 0, nodes, nil)
|
||||
|
||||
// Re-create tries with new root
|
||||
accTrie, _ = trie.New(trie.StateTrieID(root), db)
|
||||
@@ -1563,7 +1563,7 @@ func makeAccountTrieWithStorage(accounts, slots int, code, boundary bool) (strin
|
||||
nodes.Merge(set)
|
||||
|
||||
// Commit gathered dirty nodes into database
|
||||
db.Update(root, types.EmptyRootHash, nodes, nil)
|
||||
db.Update(root, types.EmptyRootHash, 0, nodes, nil)
|
||||
|
||||
// Re-create tries with new root
|
||||
accTrie, err := trie.New(trie.StateTrieID(root), db)
|
||||
|
||||
@@ -164,7 +164,7 @@ func (eth *Ethereum) StateAtBlock(ctx context.Context, block *types.Block, reexe
|
||||
return nil, nil, fmt.Errorf("processing block %d failed: %v", current.NumberU64(), err)
|
||||
}
|
||||
// Finalize the state so any modifications are written to the trie
|
||||
root, err := statedb.Commit(eth.blockchain.Config().IsEIP158(current.Number()))
|
||||
root, err := statedb.Commit(current.NumberU64(), eth.blockchain.Config().IsEIP158(current.Number()))
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("stateAtBlock commit failed, number %d root %v: %w",
|
||||
current.NumberU64(), current.Root().Hex(), err)
|
||||
|
||||
Reference in New Issue
Block a user