beacon/engine: rename parameter from execParams to data

This commit is contained in:
lightclient 2024-08-02 11:00:30 -06:00
parent 1852c98593
commit cb3e46ee44
No known key found for this signature in database
GPG key ID: 75C916AFEE20183E

View file

@ -194,21 +194,21 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
// //
// and that the blockhash of the constructed block matches the parameters. Nil // and that the blockhash of the constructed block matches the parameters. Nil
// Withdrawals value will propagate through the returned block. Empty // Withdrawals value will propagate through the returned block. Empty
// Withdrawals value must be passed via non-nil, length 0 value in execParams. // Withdrawals value must be passed via non-nil, length 0 value in data.
func ExecutableDataToBlock(execParams ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash) (*types.Block, error) { func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash) (*types.Block, error) {
txs, err := decodeTransactions(execParams.Transactions) txs, err := decodeTransactions(data.Transactions)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(execParams.ExtraData) > int(params.MaximumExtraDataSize) { if len(data.ExtraData) > int(params.MaximumExtraDataSize) {
return nil, fmt.Errorf("invalid extradata length: %v", len(execParams.ExtraData)) return nil, fmt.Errorf("invalid extradata length: %v", len(data.ExtraData))
} }
if len(execParams.LogsBloom) != 256 { if len(data.LogsBloom) != 256 {
return nil, fmt.Errorf("invalid logsBloom length: %v", len(execParams.LogsBloom)) return nil, fmt.Errorf("invalid logsBloom length: %v", len(data.LogsBloom))
} }
// Check that baseFeePerGas is not negative or too big // Check that baseFeePerGas is not negative or too big
if execParams.BaseFeePerGas != nil && (execParams.BaseFeePerGas.Sign() == -1 || execParams.BaseFeePerGas.BitLen() > 256) { if data.BaseFeePerGas != nil && (data.BaseFeePerGas.Sign() == -1 || data.BaseFeePerGas.BitLen() > 256) {
return nil, fmt.Errorf("invalid baseFeePerGas: %v", execParams.BaseFeePerGas) return nil, fmt.Errorf("invalid baseFeePerGas: %v", data.BaseFeePerGas)
} }
var blobHashes []common.Hash var blobHashes []common.Hash
for _, tx := range txs { for _, tx := range txs {
@ -226,34 +226,34 @@ func ExecutableDataToBlock(execParams ExecutableData, versionedHashes []common.H
// ExecutableData before withdrawals are enabled by marshaling // ExecutableData before withdrawals are enabled by marshaling
// Withdrawals as the json null value. // Withdrawals as the json null value.
var withdrawalsRoot *common.Hash var withdrawalsRoot *common.Hash
if execParams.Withdrawals != nil { if data.Withdrawals != nil {
h := types.DeriveSha(types.Withdrawals(execParams.Withdrawals), trie.NewStackTrie(nil)) h := types.DeriveSha(types.Withdrawals(data.Withdrawals), trie.NewStackTrie(nil))
withdrawalsRoot = &h withdrawalsRoot = &h
} }
header := &types.Header{ header := &types.Header{
ParentHash: execParams.ParentHash, ParentHash: data.ParentHash,
UncleHash: types.EmptyUncleHash, UncleHash: types.EmptyUncleHash,
Coinbase: execParams.FeeRecipient, Coinbase: data.FeeRecipient,
Root: execParams.StateRoot, Root: data.StateRoot,
TxHash: types.DeriveSha(types.Transactions(txs), trie.NewStackTrie(nil)), TxHash: types.DeriveSha(types.Transactions(txs), trie.NewStackTrie(nil)),
ReceiptHash: execParams.ReceiptsRoot, ReceiptHash: data.ReceiptsRoot,
Bloom: types.BytesToBloom(execParams.LogsBloom), Bloom: types.BytesToBloom(data.LogsBloom),
Difficulty: common.Big0, Difficulty: common.Big0,
Number: new(big.Int).SetUint64(execParams.Number), Number: new(big.Int).SetUint64(data.Number),
GasLimit: execParams.GasLimit, GasLimit: data.GasLimit,
GasUsed: execParams.GasUsed, GasUsed: data.GasUsed,
Time: execParams.Timestamp, Time: data.Timestamp,
BaseFee: execParams.BaseFeePerGas, BaseFee: data.BaseFeePerGas,
Extra: execParams.ExtraData, Extra: data.ExtraData,
MixDigest: execParams.Random, MixDigest: data.Random,
WithdrawalsHash: withdrawalsRoot, WithdrawalsHash: withdrawalsRoot,
ExcessBlobGas: execParams.ExcessBlobGas, ExcessBlobGas: data.ExcessBlobGas,
BlobGasUsed: execParams.BlobGasUsed, BlobGasUsed: data.BlobGasUsed,
ParentBeaconRoot: beaconRoot, ParentBeaconRoot: beaconRoot,
} }
block := types.NewBlockWithHeader(header).WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: execParams.Withdrawals}) block := types.NewBlockWithHeader(header).WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: data.Withdrawals})
if block.Hash() != execParams.BlockHash { if block.Hash() != data.BlockHash {
return nil, fmt.Errorf("blockhash mismatch, want %x, got %x", execParams.BlockHash, block.Hash()) return nil, fmt.Errorf("blockhash mismatch, want %x, got %x", data.BlockHash, block.Hash())
} }
return block, nil return block, nil
} }