Skip to content

Commit 95320ff

Browse files
authored
miner: set slot number for pending block post-Amsterdam (ethereum#34792)
1 parent 4017efe commit 95320ff

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

miner/miner.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,24 @@ func (miner *Miner) getPending() *newPayloadResult {
151151
return cached
152152
}
153153
var (
154-
timestamp = uint64(time.Now().Unix())
155-
withdrawal types.Withdrawals
154+
timestamp = uint64(time.Now().Unix())
155+
childNumber = new(big.Int).Add(header.Number, big.NewInt(1))
156+
withdrawal types.Withdrawals
157+
slotNum *uint64
156158
)
157-
if miner.chainConfig.IsShanghai(new(big.Int).Add(header.Number, big.NewInt(1)), timestamp) {
159+
if miner.chainConfig.IsShanghai(childNumber, timestamp) {
158160
withdrawal = []*types.Withdrawal{}
159161
}
162+
// Post-Amsterdam, prepareWork requires a slot number (EIP-7843). The pending
163+
// block is synthetic and has no canonical slot, so derive one from the parent
164+
// when available and fall back to zero otherwise.
165+
if miner.chainConfig.IsAmsterdam(childNumber, timestamp) {
166+
var n uint64
167+
if header.SlotNumber != nil {
168+
n = *header.SlotNumber + 1
169+
}
170+
slotNum = &n
171+
}
160172
ret := miner.generateWork(context.Background(),
161173
&generateParams{
162174
timestamp: timestamp,
@@ -166,6 +178,7 @@ func (miner *Miner) getPending() *newPayloadResult {
166178
random: common.Hash{},
167179
withdrawals: withdrawal,
168180
beaconRoot: nil,
181+
slotNum: slotNum,
169182
noTxs: false,
170183
}, false) // we will never make a witness for a pending block
171184
if ret.err != nil {

0 commit comments

Comments
 (0)