From 7db0dea6996110b69eb5f880ace3e72f2b05c138 Mon Sep 17 00:00:00 2001 From: johnzhu0908 Date: Fri, 17 Oct 2025 18:33:47 +0800 Subject: [PATCH] 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 db7bd691d8..16c15753a5 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