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

core/state/pruner: fix compaction range error #22294

Merged
merged 1 commit into from
Feb 9, 2021
Merged
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
11 changes: 5 additions & 6 deletions core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,15 @@ func prune(maindb ethdb.Database, stateBloom *stateBloom, middleStateRoots map[c
// Note for small pruning, the compaction is skipped.
if count >= rangeCompactionThreshold {
cstart := time.Now()

for b := byte(0); b < byte(16); b++ {
for b := 0x00; b <= 0xf0; b += 0x10 {
var (
start = []byte{b << 4}
end = []byte{(b+1)<<4 - 1}
start = []byte{byte(b)}
end = []byte{byte(b + 0x10)}
)
log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
if b == 15 {
if b == 0xf0 {
end = nil
}
log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move it below the if, you'll end up printing nil into hex. Not sure how that behaves.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The very last range's end.

Copy link
Contributor Author

@holiman holiman Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, neither did I, that's why I linked to https://play.golang.org/p/66KgDfD-96d above

0x00-0x10
0x10-0x20
0x20-0x30
0x30-0x40
0x40-0x50
0x50-0x60
0x60-0x70
0x70-0x80
0x80-0x90
0x90-0xa0
0xa0-0xb0
0xb0-0xc0
0xc0-0xd0
0xd0-0xe0
0xe0-0xf0
0xf0-

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funky

if err := maindb.Compact(start, end); err != nil {
log.Error("Database compaction failed", "error", err)
return err
Expand Down