try to fix hanging iterator

This commit is contained in:
Roy Crihfield 2022-05-31 23:34:02 +08:00
parent f235a1751a
commit 913852e22b
3 changed files with 8 additions and 2 deletions

2
go.mod
View File

@ -46,3 +46,5 @@ require (
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/vulcanize/go-ethereum v1.10.17-statediff-3.2.1
replace github.com/vulcanize/go-eth-state-node-iterator => ../state-node-iterator

View File

@ -44,7 +44,7 @@ func TestCreateSnapshot(t *testing.T) {
pub.EXPECT().PrepareTxForBatch(gomock.Any(), gomock.Any()).Return(tx, nil).
AnyTimes()
pub.EXPECT().PublishStateNode(gomock.Any(), gomock.Any(), gomock.Any()).
Times(len(fixt.Block1_StateNodePaths))
MinTimes(len(fixt.Block1_StateNodePaths))
// TODO: fixtures for storage node
// pub.EXPECT().PublishStorageNode(gomock.Eq(fixt.StorageNode), gomock.Eq(int64(0)), gomock.Any())

View File

@ -137,7 +137,11 @@ func (tr *iteratorTracker) restore(tree state.Trie) ([]trie.NodeIterator, error)
}
}
it := iter.NewPrefixBoundIterator(tree, paths[0], paths[1])
// Force the lower bound path to an even length
if len(paths[0])&0b1 == 1 {
paths[0] = append(paths[0], 0)
}
it := iter.NewPrefixBoundIterator(tree.NodeIterator(iter.HexToKeyBytes(paths[0])), paths[1])
ret = append(ret, tr.tracked(it))
}
return ret, nil