From f6bea7f7493f75d2ff6b81c588c1b8e472d17a18 Mon Sep 17 00:00:00 2001 From: Francesco4203 Date: Thu, 26 Sep 2024 00:24:18 +0700 Subject: [PATCH] all: use rawdb.HasLegacyNode() to check for node existance instead of check for length --- cmd/ronin/snapshot.go | 6 ++---- core/state/pruner/pruner.go | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd/ronin/snapshot.go b/cmd/ronin/snapshot.go index 2a6a97f36..acb24361c 100644 --- a/cmd/ronin/snapshot.go +++ b/cmd/ronin/snapshot.go @@ -394,8 +394,7 @@ func traverseRawState(ctx *cli.Context) error { if node != (common.Hash{}) { // Check the present for non-empty hash node(embedded node doesn't // have their own hash). - blob := rawdb.ReadLegacyTrieNode(chaindb, node) - if len(blob) == 0 { + if !rawdb.HasLegacyTrieNode(chaindb, node) { log.Error("Missing trie node(account)", "hash", node) return errors.New("missing account") } @@ -423,8 +422,7 @@ func traverseRawState(ctx *cli.Context) error { // Check the present for non-empty hash node(embedded node doesn't // have their own hash). if node != (common.Hash{}) { - blob := rawdb.ReadLegacyTrieNode(chaindb, node) - if len(blob) == 0 { + if !rawdb.HasLegacyTrieNode(chaindb, node) { log.Error("Missing trie node(storage)", "hash", node) return errors.New("missing storage") } diff --git a/core/state/pruner/pruner.go b/core/state/pruner/pruner.go index 34497569d..a383990be 100644 --- a/core/state/pruner/pruner.go +++ b/core/state/pruner/pruner.go @@ -265,7 +265,7 @@ func (p *Pruner) Prune(root common.Hash) error { // Ensure the root is really present. The weak assumption // is the presence of root can indicate the presence of the // entire trie. - if blob := rawdb.ReadLegacyTrieNode(p.db, root); len(blob) == 0 { + if !rawdb.HasLegacyTrieNode(p.db, root) { // The special case is for clique based networks(rinkeby, goerli // and some other private networks), it's possible that two // consecutive blocks will have same root. In this case snapshot @@ -279,7 +279,7 @@ func (p *Pruner) Prune(root common.Hash) error { // as the pruning target. var found bool for i := len(layers) - 2; i >= 2; i-- { - if blob := rawdb.ReadLegacyTrieNode(p.db, layers[i].Root()); len(blob) != 0 { + if !rawdb.HasLegacyTrieNode(p.db, layers[i].Root()) { root = layers[i].Root() found = true log.Info("Selecting middle-layer as the pruning target", "root", root, "depth", i)