Skip to content

Commit 51b99e4

Browse files
authored
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.
1 parent 84ac794 commit 51b99e4

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"
@@ -1020,7 +1019,7 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr
10201019
log.Trace("Data special transaction invalid length", "hash", hash, "data", len(data))
10211020
continue
10221021
}
1023-
blkNumber := binary.BigEndian.Uint64(data[8:40])
1022+
blkNumber := new(big.Int).SetBytes(data[4:36]).Uint64()
10241023
if blkNumber >= w.header.Number.Uint64() || blkNumber+w.config.XDPoS.Epoch*2 <= w.header.Number.Uint64() {
10251024
log.Trace("Data special transaction invalid number", "hash", hash, "blkNumber", blkNumber, "miner", w.header.Number)
10261025
continue

0 commit comments

Comments
 (0)