Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prune-state when specify --triesInMemory 32 #2602

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ func (bc *BlockChain) Stop() {
if !bc.cacheConfig.TrieDirtyDisabled {
triedb := bc.triedb
var once sync.Once
for _, offset := range []uint64{0, 1, TriesInMemory - 1} {
for _, offset := range []uint64{0, 1, bc.TriesInMemory() - 1} {
if number := bc.CurrentBlock().Number.Uint64(); number > offset {
recent := bc.GetBlockByNumber(number - offset)
log.Info("Writing cached state to disk", "block", recent.Number(), "hash", recent.Hash(), "root", recent.Root())
Expand Down Expand Up @@ -1822,7 +1822,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.

// Flush limits are not considered for the first TriesInMemory blocks.
current := block.NumberU64()
if current <= TriesInMemory {
if current <= bc.TriesInMemory() {
return nil
}
// If we exceeded our memory allowance, flush matured singleton nodes to disk
Expand Down
4 changes: 2 additions & 2 deletions miner/bid_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func (b *bidSimulator) clearLoop() {
}
delete(b.bestBid, parentHash)
for k, v := range b.bestBid {
if v.bid.BlockNumber <= blockNumber-core.TriesInMemory {
if v.bid.BlockNumber <= blockNumber-b.chain.TriesInMemory() {
v.env.discard()
delete(b.bestBid, k)
}
Expand All @@ -418,7 +418,7 @@ func (b *bidSimulator) clearLoop() {

b.simBidMu.Lock()
for k, v := range b.simulatingBid {
if v.bid.BlockNumber <= blockNumber-core.TriesInMemory {
if v.bid.BlockNumber <= blockNumber-b.chain.TriesInMemory() {
v.env.discard()
delete(b.simulatingBid, k)
}
Expand Down
Loading