From 7db0dea6996110b69eb5f880ace3e72f2b05c138 Mon Sep 17 00:00:00 2001 From: johnzhu0908 Date: Fri, 17 Oct 2025 18:33:47 +0800 Subject: [PATCH 1/2] fix: use maximum uint64 value for receipt chain insertion ## Summary: Replace incorrect expression 2^64-1 (bitwise XOR, evaluates to 65) with the intended uint64 maximum. This was a logic bug that passes the wrong limit into InsertReceiptChain during Era import. ## Why: In Go ^ is bitwise XOR, not exponentiation. 2^64-1 does not produce max uint64 and causes incorrect behavior during import. Not an immediate remote-exec security vulnerability, but a correctness bug that can cause data/consensus problems when importing history. ## Fix: Use idiomatic ^uint64(0) to represent max uint64 without adding imports. ## Files changed: - cmd/utils/cmd.go --- cmd/utils/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index db7bd691d8e1..16c15753a57c 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -311,7 +311,7 @@ func ImportHistory(chain *core.BlockChain, dir string, network string) error { return fmt.Errorf("error reading receipts %d: %w", it.Number(), err) } encReceipts := types.EncodeBlockReceiptLists([]types.Receipts{receipts}) - if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, 2^64-1); err != nil { + if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, ^uint64(0)); err != nil { return fmt.Errorf("error inserting body %d: %w", it.Number(), err) } imported += 1 From af06e6d516836898abe51e1c355530ce7604c0d4 Mon Sep 17 00:00:00 2001 From: johnzhu0908 Date: Sat, 18 Oct 2025 08:32:35 +0800 Subject: [PATCH 2/2] fix: use math.MaxUint64 instead of ^uint64(0) --- cmd/utils/cmd.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 16c15753a57c..3e337a3d00a3 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -25,6 +25,7 @@ import ( "errors" "fmt" "io" + "math" "math/big" "os" "os/signal" @@ -311,7 +312,7 @@ func ImportHistory(chain *core.BlockChain, dir string, network string) error { return fmt.Errorf("error reading receipts %d: %w", it.Number(), err) } encReceipts := types.EncodeBlockReceiptLists([]types.Receipts{receipts}) - if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, ^uint64(0)); err != nil { + if _, err := chain.InsertReceiptChain([]*types.Block{block}, encReceipts, math.MaxUint64); err != nil { return fmt.Errorf("error inserting body %d: %w", it.Number(), err) } imported += 1