mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
fix withdrawal inclusion
This commit is contained in:
parent
568b9ac62f
commit
b6e8755884
2 changed files with 27 additions and 4 deletions
|
|
@ -96,12 +96,12 @@ type generateParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateWork generates a sealing block based on the given parameters.
|
// generateWork generates a sealing block based on the given parameters.
|
||||||
func (miner *Miner) generateWork(params *generateParams, witness bool) *newPayloadResult {
|
func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPayloadResult {
|
||||||
work, err := miner.prepareWork(params, witness)
|
work, err := miner.prepareWork(genParam, witness)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &newPayloadResult{err: err}
|
return &newPayloadResult{err: err}
|
||||||
}
|
}
|
||||||
if !params.noTxs {
|
if !genParam.noTxs {
|
||||||
interrupt := new(atomic.Int32)
|
interrupt := new(atomic.Int32)
|
||||||
timer := time.AfterFunc(miner.config.Recommit, func() {
|
timer := time.AfterFunc(miner.config.Recommit, func() {
|
||||||
interrupt.Store(commitInterruptTimeout)
|
interrupt.Store(commitInterruptTimeout)
|
||||||
|
|
@ -114,7 +114,29 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body := types.Body{Transactions: work.txs, Withdrawals: params.withdrawals}
|
body := types.Body{Transactions: work.txs}
|
||||||
|
|
||||||
|
var includedWithdrawals types.Withdrawals
|
||||||
|
if miner.chainConfig.IsOsaka(work.header.Number, work.header.Time) {
|
||||||
|
// cap the size of blocks we will produce below the cap allowed by
|
||||||
|
// EIP-7934. This gives us buffer room if the estimated size of the
|
||||||
|
// block we are building is somewhat off.
|
||||||
|
maxBlockSize := params.BlockRLPSizeCap - 1_000_000
|
||||||
|
|
||||||
|
for _, withdrawal := range genParam.withdrawals {
|
||||||
|
if int(work.size)+params.WithdrawalSize > maxBlockSize {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
includedWithdrawals = append(includedWithdrawals, withdrawal)
|
||||||
|
work.size += params.WithdrawalSize
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
includedWithdrawals = genParam.withdrawals
|
||||||
|
}
|
||||||
|
body.Withdrawals = includedWithdrawals
|
||||||
|
|
||||||
allLogs := make([]*types.Log, 0)
|
allLogs := make([]*types.Log, 0)
|
||||||
for _, r := range work.receipts {
|
for _, r := range work.receipts {
|
||||||
allLogs = append(allLogs, r.Logs...)
|
allLogs = append(allLogs, r.Logs...)
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ const (
|
||||||
|
|
||||||
HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935.
|
HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935.
|
||||||
|
|
||||||
|
WithdrawalSize = 23 // size of a withdrawal
|
||||||
BlockRLPSizeCap = 9_961_472 // maximum size of an RLP-encoded block
|
BlockRLPSizeCap = 9_961_472 // maximum size of an RLP-encoded block
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue