From a11d68c38d4bef29198ef604f039c220e082845f Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 3 Aug 2023 02:23:24 +0800 Subject: [PATCH] builder cleanup --- builder.go | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/builder.go b/builder.go index 057f6be..b596c33 100644 --- a/builder.go +++ b/builder.go @@ -318,18 +318,6 @@ func (sdb *StateDiffBuilder) decodeStateLeaf(it trie.NodeIterator, parentBlob [] }, nil } -// processAccountUpdates emits state and storage node records for all updated existing accounts. -func (sdb *StateDiffBuilder) processAccountUpdates( - updates accountUpdateMap, - nodeSink sdtypes.StateNodeSink, - ipldSink sdtypes.IPLDSink, - logger log.Logger, -) error { - defer metrics.UpdateDuration(time.Now(), metrics.IndexerMetrics.BuildAccountUpdatesTimer) - - return nil -} - // processCreatedAccountStorage processes the storage node records for a newly created account // i.e. it returns all the storage nodes at this state, since there is no previous state. func (sdb *StateDiffBuilder) processCreatedAccountStorage( @@ -369,22 +357,6 @@ func (sdb *StateDiffBuilder) processCreatedAccountStorage( return it.Error() } -// decodes slot at leaf and encodes RLP data to CID -// reminder: it.Leaf() == true when the iterator is positioned at a "value node" (which is not something -// that actually exists in an MMPT), therefore we pass the parent node blob as the leaf RLP. -func (sdb *StateDiffBuilder) decodeStorageLeaf(it trie.NodeIterator, parentBlob []byte) sdtypes.StorageLeafNode { - leafKey := make([]byte, len(it.LeafKey())) - copy(leafKey, it.LeafKey()) - value := make([]byte, len(it.LeafBlob())) - copy(value, it.LeafBlob()) - - return sdtypes.StorageLeafNode{ - LeafKey: leafKey, - Value: value, - CID: ipld.Keccak256ToCid(ipld.MEthStorageTrie, crypto.Keccak256(parentBlob)).String(), - } -} - // processRemovedAccountStorage builds the "removed" diffs for all the storage nodes for a destroyed account func (sdb *StateDiffBuilder) processRemovedAccountStorage( sr common.Hash, storageSink sdtypes.StorageNodeSink, @@ -479,6 +451,22 @@ func (sdb *StateDiffBuilder) processUpdatedAccountStorage( return it.Error() } +// decodes slot at leaf and encodes RLP data to CID +// reminder: it.Leaf() == true when the iterator is positioned at a "value node" (which is not something +// that actually exists in an MMPT), therefore we pass the parent node blob as the leaf RLP. +func (sdb *StateDiffBuilder) decodeStorageLeaf(it trie.NodeIterator, parentBlob []byte) sdtypes.StorageLeafNode { + leafKey := make([]byte, len(it.LeafKey())) + copy(leafKey, it.LeafKey()) + value := make([]byte, len(it.LeafBlob())) + copy(value, it.LeafBlob()) + + return sdtypes.StorageLeafNode{ + LeafKey: leafKey, + Value: value, + CID: ipld.Keccak256ToCid(ipld.MEthStorageTrie, crypto.Keccak256(parentBlob)).String(), + } +} + // isWatchedPathPrefix checks if a node path is a prefix (ancestor) to one of the watched addresses. // An empty watch list means all paths are watched. func isWatchedPathPrefix(watchedLeafPaths [][]byte, path []byte) bool {