Skip to content

Commit

Permalink
don't use referencing when recovering states
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Jan 30, 2024
1 parent c53c26a commit 2cb1342
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions cmd/staterecovery/staterecovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -36,10 +35,9 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon
if err != nil {
return fmt.Errorf("genesis state is missing: %w", err)
}
_ = database.TrieDB().Reference(previousBlock.Root(), common.Hash{})
defer func() {
_ = database.TrieDB().Dereference(previousBlock.Root())
}()
// we don't need to reference states with `trie.Database.Reference` here, because:
// * either the state nodes will be read from disk and then cached in cleans cache
// * or they will be recreated, saved to disk and then also cached in cleans cache
logged := time.Now()
recreated := 0
for current <= last {
Expand Down Expand Up @@ -75,8 +73,6 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon
}
recreated++
}
_ = database.TrieDB().Reference(currentBlock.Root(), common.Hash{})
_ = database.TrieDB().Dereference(previousBlock.Root())
current++
previousBlock = currentBlock

Check failure on line 77 in cmd/staterecovery/staterecovery.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

SA4006: this value of `previousBlock` is never used (staticcheck)

Check failure on line 77 in cmd/staterecovery/staterecovery.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

SA4006: this value of `previousBlock` is never used (staticcheck)

Check failure on line 77 in cmd/staterecovery/staterecovery.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

SA4006: this value of `previousBlock` is never used (staticcheck)
previousState = currentState
Expand Down

0 comments on commit 2cb1342

Please sign in to comment.