core/state: access trie through Database interface, track errors (#14589)
With this commit, core/state's access to the underlying key/value database is mediated through an interface. Database errors are tracked in StateDB and returned by CommitTo or the new Error method. Motivation for this change: We can remove the light client's duplicated copy of core/state. The light client now supports node iteration, so tracing and storage enumeration can work with the light client (not implemented in this commit).
This commit is contained in:
@ -131,7 +131,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.chainDb)
|
||||
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.stateCache)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -148,7 +148,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
|
||||
blockchain.mu.Lock()
|
||||
WriteTd(blockchain.chainDb, block.Hash(), block.NumberU64(), new(big.Int).Add(block.Difficulty(), blockchain.GetTdByHash(block.ParentHash())))
|
||||
WriteBlock(blockchain.chainDb, block)
|
||||
statedb.Commit(false)
|
||||
statedb.CommitTo(blockchain.chainDb, false)
|
||||
blockchain.mu.Unlock()
|
||||
}
|
||||
return nil
|
||||
@ -1131,7 +1131,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
|
||||
if _, err := blockchain.InsertChain(types.Blocks{blocks[0]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !blockchain.stateCache.Exist(theAddr) {
|
||||
if st, _ := blockchain.State(); !st.Exist(theAddr) {
|
||||
t.Error("expected account to exist")
|
||||
}
|
||||
|
||||
@ -1139,7 +1139,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
|
||||
if _, err := blockchain.InsertChain(types.Blocks{blocks[1]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if blockchain.stateCache.Exist(theAddr) {
|
||||
if st, _ := blockchain.State(); st.Exist(theAddr) {
|
||||
t.Error("account should not exist")
|
||||
}
|
||||
|
||||
@ -1147,7 +1147,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
|
||||
if _, err := blockchain.InsertChain(types.Blocks{blocks[2]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if blockchain.stateCache.Exist(theAddr) {
|
||||
if st, _ := blockchain.State(); st.Exist(theAddr) {
|
||||
t.Error("account should not exist")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user