forked from cerc-io/plugeth
all: introduce trie owner notion (#24750)
* cmd, core/state, light, trie, eth: add trie owner notion * all: refactor * tests: fix goimports * core/state/snapshot: fix ineffasigns Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
co-authored by
Martin Holst Swende
parent
c375ee91e9
commit
22defa5af7
@@ -229,7 +229,7 @@ func (dl *downloadTester) CurrentFastBlock() *types.Block {
|
||||
func (dl *downloadTester) FastSyncCommitHead(hash common.Hash) error {
|
||||
// For now only check that the state trie is correct
|
||||
if block := dl.GetBlockByHash(hash); block != nil {
|
||||
_, err := trie.NewSecure(block.Root(), trie.NewDatabase(dl.stateDb))
|
||||
_, err := trie.NewSecure(common.Hash{}, block.Root(), trie.NewDatabase(dl.stateDb))
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("non existent block: %x", hash[:4])
|
||||
|
||||
+4
-4
@@ -405,7 +405,7 @@ func testGetProofs(t *testing.T, protocol int) {
|
||||
accounts := []common.Address{bankAddr, userAddr1, userAddr2, signerAddr, {}}
|
||||
for i := uint64(0); i <= bc.CurrentBlock().NumberU64(); i++ {
|
||||
header := bc.GetHeaderByNumber(i)
|
||||
trie, _ := trie.New(header.Root, trie.NewDatabase(server.db))
|
||||
trie, _ := trie.New(common.Hash{}, header.Root, trie.NewDatabase(server.db))
|
||||
|
||||
for _, acc := range accounts {
|
||||
req := ProofReq{
|
||||
@@ -456,7 +456,7 @@ func testGetStaleProof(t *testing.T, protocol int) {
|
||||
var expected []rlp.RawValue
|
||||
if wantOK {
|
||||
proofsV2 := light.NewNodeSet()
|
||||
t, _ := trie.New(header.Root, trie.NewDatabase(server.db))
|
||||
t, _ := trie.New(common.Hash{}, header.Root, trie.NewDatabase(server.db))
|
||||
t.Prove(account, 0, proofsV2)
|
||||
expected = proofsV2.NodeList()
|
||||
}
|
||||
@@ -512,7 +512,7 @@ func testGetCHTProofs(t *testing.T, protocol int) {
|
||||
AuxData: [][]byte{rlp},
|
||||
}
|
||||
root := light.GetChtRoot(server.db, 0, bc.GetHeaderByNumber(config.ChtSize-1).Hash())
|
||||
trie, _ := trie.New(root, trie.NewDatabase(rawdb.NewTable(server.db, light.ChtTablePrefix)))
|
||||
trie, _ := trie.New(common.Hash{}, root, trie.NewDatabase(rawdb.NewTable(server.db, light.ChtTablePrefix)))
|
||||
trie.Prove(key, 0, &proofsV2.Proofs)
|
||||
// Assemble the requests for the different protocols
|
||||
requestsV2 := []HelperTrieReq{{
|
||||
@@ -577,7 +577,7 @@ func testGetBloombitsProofs(t *testing.T, protocol int) {
|
||||
var proofs HelperTrieResps
|
||||
|
||||
root := light.GetBloomTrieRoot(server.db, 0, bc.GetHeaderByNumber(config.BloomTrieSize-1).Hash())
|
||||
trie, _ := trie.New(root, trie.NewDatabase(rawdb.NewTable(server.db, light.BloomTrieTablePrefix)))
|
||||
trie, _ := trie.New(common.Hash{}, root, trie.NewDatabase(rawdb.NewTable(server.db, light.BloomTrieTablePrefix)))
|
||||
trie.Prove(key, 0, &proofs.Proofs)
|
||||
|
||||
// Send the proof request and verify the response
|
||||
|
||||
@@ -359,7 +359,7 @@ func (h *serverHandler) AddTxsSync() bool {
|
||||
|
||||
// getAccount retrieves an account from the state based on root.
|
||||
func getAccount(triedb *trie.Database, root, hash common.Hash) (types.StateAccount, error) {
|
||||
trie, err := trie.New(root, triedb)
|
||||
trie, err := trie.New(common.Hash{}, root, triedb)
|
||||
if err != nil {
|
||||
return types.StateAccount{}, err
|
||||
}
|
||||
@@ -391,7 +391,7 @@ func (h *serverHandler) GetHelperTrie(typ uint, index uint64) *trie.Trie {
|
||||
if root == (common.Hash{}) {
|
||||
return nil
|
||||
}
|
||||
trie, _ := trie.New(root, trie.NewDatabase(rawdb.NewTable(h.chainDb, prefix)))
|
||||
trie, _ := trie.New(common.Hash{}, root, trie.NewDatabase(rawdb.NewTable(h.chainDb, prefix)))
|
||||
return trie
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user