Skip to content

Commit 2c64396

Browse files
committed
miner: fix block number extraction for BlockSigner tx
Previously, the code used binary.BigEndian.Uint64(data[8:40]), which incorrectly read the index and only extracted the highest 8 bytes of the 32-byte left-padded block number, resulting in wrong values (often zero). Now, the code uses new(big.Int).SetBytes(data[4:36]).Uint64() to correctly extract the block number from the proper 32-byte field. This change fixes both the incorrect index and the parsing logic, ensuring accurate block number extraction and correct validation for special transactions.
1 parent 292c050 commit 2c64396

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

miner/worker.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package miner
1818

1919
import (
2020
"bytes"
21-
"encoding/binary"
2221
"errors"
2322
"fmt"
2423
"math/big"
@@ -990,7 +989,7 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr
990989
log.Trace("Data special transaction invalid length", "hash", hash, "data", len(data))
991990
continue
992991
}
993-
blkNumber := binary.BigEndian.Uint64(data[8:40])
992+
blkNumber := new(big.Int).SetBytes(data[4:36]).Uint64()
994993
if blkNumber >= w.header.Number.Uint64() || blkNumber <= w.header.Number.Uint64()-w.config.XDPoS.Epoch*2 {
995994
log.Trace("Data special transaction invalid number", "hash", hash, "blkNumber", blkNumber, "miner", w.header.Number)
996995
continue

0 commit comments

Comments
 (0)