Skip to content

Commit

Permalink
add some logs;
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbundler committed Nov 15, 2023
1 parent 433a4c9 commit 7da279e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions core/state/state_expiry.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func defaultStateExpiryMeta() *stateExpiryMeta {
}

// tryReviveState request expired state from remote full state node;
func tryReviveState(meta *stateExpiryMeta, addr common.Address, root common.Hash, tr Trie, prefixKey []byte, key common.Hash, force bool) (map[string][]byte, error) {
func tryReviveState(meta *stateExpiryMeta, addr common.Address, root common.Hash, tr Trie, prefixKey []byte, key common.Hash) (map[string][]byte, error) {
if !meta.enableStateExpiry {
return nil, nil
}
//log.Debug("fetching expired storage from remoteDB", "addr", addr, "prefix", prefixKey, "key", key)
reviveTrieMeter.Mark(1)
if meta.enableLocalRevive && !force {
if meta.enableLocalRevive {
// if there need revive expired state, try to revive locally, when the node is not being pruned, just renew the epoch
val, err := tr.TryLocalRevive(addr, key.Bytes())
switch err.(type) {
Expand Down Expand Up @@ -174,13 +174,13 @@ func ReviveStorageTrie(addr common.Address, tr Trie, proof types.ReviveStoragePr

nubs, err := tr.TryRevive(key, proofCache.CacheNubs())
if err != nil {
log.Info("ReviveStorageTrie tr.TryRevive", "addr", addr, "key", key, "err", err)
log.Info("ReviveStorageTrie tr.TryRevive", "addr", addr, "key", common.BytesToHash(key), "err", err)
return nil, err
}

// check if it could get from trie
if _, err = tr.GetStorage(addr, key); err != nil {
log.Info("ReviveStorageTrie tr.GetStorage", "addr", addr, "key", key, "err", err)
log.Info("ReviveStorageTrie tr.GetStorage", "addr", addr, "key", common.BytesToHash(key), "err", err)
return nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func (s *stateObject) updateTrie() (Trie, error) {
//log.Debug("updateTrie pendingFutureReviveState", "contract", s.address, "key", key, "epoch", s.db.Epoch(), "tr.epoch", tr.Epoch(), "tr", fmt.Sprintf("%p", tr), "ins", fmt.Sprintf("%p", s), "err", err)
continue
}
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key, false); err != nil {
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key); err != nil {
s.db.setError(fmt.Errorf("updateTrie pendingFutureReviveState tryReviveState err, contract: %v, key: %v, path: %v, err: %v", s.address, key, path, err))
}
//log.Debug("updateTrie pendingFutureReviveState", "contract", s.address, "key", key, "epoch", s.db.Epoch(), "tr.epoch", tr.Epoch(), "tr", fmt.Sprintf("%p", tr), "ins", fmt.Sprintf("%p", s))
Expand Down Expand Up @@ -524,7 +524,7 @@ func (s *stateObject) updateTrie() (Trie, error) {
err := tr.DeleteStorage(s.address, key[:])
if path, ok := trie.ParseExpiredNodeErr(err); ok {
touchExpiredStorage[key] = value
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key, true); err != nil {
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key); err != nil {
s.db.setError(fmt.Errorf("updateTrie DeleteStorage tryReviveState err, contract: %v, key: %v, path: %v, err: %v", s.address, key, path, err))
}
} else if err != nil {
Expand All @@ -536,7 +536,7 @@ func (s *stateObject) updateTrie() (Trie, error) {
err := tr.UpdateStorage(s.address, key[:], value)
if path, ok := trie.ParseExpiredNodeErr(err); ok {
touchExpiredStorage[key] = value
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key, true); err != nil {
if _, err = tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, path, key); err != nil {
s.db.setError(fmt.Errorf("updateTrie DeleteStorage tryReviveState err, contract: %v, key: %v, path: %v, err: %v", s.address, key, path, err))
}
} else if err != nil {
Expand Down Expand Up @@ -908,7 +908,7 @@ func (s *stateObject) tryReviveState(prefixKey []byte, key common.Hash) ([]byte,
}

// if there need resolvePath from snap, it must not locally revive successful.
kvs, err := tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, prefixKey, key, true)
kvs, err := tryReviveState(s.db.expiryMeta, s.address, s.data.Root, tr, prefixKey, key)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/state/trie_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func (sf *subfetcher) loop() {
// TODO(0xbundler): revert to single fetch, because tasks is a channel
if path, match := trie2.ParseExpiredNodeErr(err); match {
key := common.BytesToHash(task)
_, err = tryReviveState(sf.expiryMeta, sf.addr, sf.root, sf.trie, path, key, false)
_, err = tryReviveState(sf.expiryMeta, sf.addr, sf.root, sf.trie, path, key)
if err != nil {
log.Error("subfetcher tryReviveState err", "addr", sf.addr, "path", path, "err", err)
}
Expand Down

0 comments on commit 7da279e

Please sign in to comment.