miner: fix block number extraction for BlockSigner tx (#1894)

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.
This commit is contained in:
Daniel Liu 2026-01-05 18:11:43 +08:00 committed by GitHub
parent 84ac794e22
commit 51b99e40a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,7 +18,6 @@ package miner
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"math/big"
@ -1020,7 +1019,7 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr
log.Trace("Data special transaction invalid length", "hash", hash, "data", len(data))
continue
}
blkNumber := binary.BigEndian.Uint64(data[8:40])
blkNumber := new(big.Int).SetBytes(data[4:36]).Uint64()
if blkNumber >= w.header.Number.Uint64() || blkNumber+w.config.XDPoS.Epoch*2 <= w.header.Number.Uint64() {
log.Trace("Data special transaction invalid number", "hash", hash, "blkNumber", blkNumber, "miner", w.header.Number)
continue