From 913852e22b0a73220a7256927dd2860f1fd595dd Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Tue, 31 May 2022 23:34:02 +0800 Subject: [PATCH] try to fix hanging iterator --- go.mod | 2 ++ pkg/snapshot/service_test.go | 2 +- pkg/snapshot/tracker.go | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 149553b..4698e29 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/pkg/snapshot/service_test.go b/pkg/snapshot/service_test.go index f1263fe..8058623 100644 --- a/pkg/snapshot/service_test.go +++ b/pkg/snapshot/service_test.go @@ -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()) diff --git a/pkg/snapshot/tracker.go b/pkg/snapshot/tracker.go index 1e5fbdf..8ca9b34 100644 --- a/pkg/snapshot/tracker.go +++ b/pkg/snapshot/tracker.go @@ -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