|
|
|
@ -348,13 +348,13 @@ func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.H |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Finalize implements consensus.Engine and processes withdrawals on top.
|
|
|
|
|
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { |
|
|
|
|
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) { |
|
|
|
|
if !beacon.IsPoSHeader(header) { |
|
|
|
|
beacon.ethone.Finalize(chain, header, state, txs, uncles, nil) |
|
|
|
|
beacon.ethone.Finalize(chain, header, state, body) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// Withdrawals processing.
|
|
|
|
|
for _, w := range withdrawals { |
|
|
|
|
for _, w := range body.Withdrawals { |
|
|
|
|
// Convert amount from gwei to wei.
|
|
|
|
|
amount := new(uint256.Int).SetUint64(w.Amount) |
|
|
|
|
amount = amount.Mul(amount, uint256.NewInt(params.GWei)) |
|
|
|
@ -365,29 +365,29 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. |
|
|
|
|
|
|
|
|
|
// FinalizeAndAssemble implements consensus.Engine, setting the final state and
|
|
|
|
|
// assembling the block.
|
|
|
|
|
func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { |
|
|
|
|
func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) { |
|
|
|
|
if !beacon.IsPoSHeader(header) { |
|
|
|
|
return beacon.ethone.FinalizeAndAssemble(chain, header, state, txs, uncles, receipts, nil) |
|
|
|
|
return beacon.ethone.FinalizeAndAssemble(chain, header, state, body, receipts) |
|
|
|
|
} |
|
|
|
|
shanghai := chain.Config().IsShanghai(header.Number, header.Time) |
|
|
|
|
if shanghai { |
|
|
|
|
// All blocks after Shanghai must include a withdrawals root.
|
|
|
|
|
if withdrawals == nil { |
|
|
|
|
withdrawals = make([]*types.Withdrawal, 0) |
|
|
|
|
if body.Withdrawals == nil { |
|
|
|
|
body.Withdrawals = make([]*types.Withdrawal, 0) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if len(withdrawals) > 0 { |
|
|
|
|
if len(body.Withdrawals) > 0 { |
|
|
|
|
return nil, errors.New("withdrawals set before Shanghai activation") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Finalize and assemble the block.
|
|
|
|
|
beacon.Finalize(chain, header, state, txs, uncles, withdrawals) |
|
|
|
|
beacon.Finalize(chain, header, state, body) |
|
|
|
|
|
|
|
|
|
// Assign the final state root to header.
|
|
|
|
|
header.Root = state.IntermediateRoot(true) |
|
|
|
|
|
|
|
|
|
// Assemble and return the final block.
|
|
|
|
|
return types.NewBlockWithWithdrawals(header, txs, uncles, receipts, withdrawals, trie.NewStackTrie(nil)), nil |
|
|
|
|
return types.NewBlockWithWithdrawals(header, body.Transactions, body.Uncles, receipts, body.Withdrawals, trie.NewStackTrie(nil)), nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Seal generates a new sealing request for the given input block and pushes
|
|
|
|
|