mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Deneb: implements engine API end points (#12384)
This commit is contained in:
committed by
Preston Van Loon
parent
e2750646fa
commit
5deb1f755b
930
proto/engine/v1/execution_engine.pb.go
generated
930
proto/engine/v1/execution_engine.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -65,11 +65,38 @@ message ExecutionPayloadCapella {
|
||||
repeated Withdrawal withdrawals = 15 [(ethereum.eth.ext.ssz_max) = "withdrawal.size"]; // New in Capella.
|
||||
}
|
||||
|
||||
message ExecutionPayloadDeneb {
|
||||
bytes parent_hash = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes fee_recipient = 2 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
bytes state_root = 3 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes receipts_root = 4 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes logs_bloom = 5 [(ethereum.eth.ext.ssz_size) = "logs_bloom.size"];
|
||||
bytes prev_randao = 6 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 block_number = 7;
|
||||
uint64 gas_limit = 8;
|
||||
uint64 gas_used = 9;
|
||||
uint64 timestamp = 10;
|
||||
bytes extra_data = 11 [(ethereum.eth.ext.ssz_max) = "extra_data.size"];
|
||||
bytes base_fee_per_gas = 12 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes block_hash = 13 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
repeated bytes transactions = 14 [(ethereum.eth.ext.ssz_size) = "?,?", (ethereum.eth.ext.ssz_max) = "1048576,1073741824"];
|
||||
// MAX_WITHDRAWALS_PER_PAYLOAD
|
||||
repeated Withdrawal withdrawals = 15 [(ethereum.eth.ext.ssz_max) = "withdrawal.size"];
|
||||
bytes excess_data_gas = 16 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
}
|
||||
|
||||
message ExecutionPayloadCapellaWithValue {
|
||||
ExecutionPayloadCapella payload = 1;
|
||||
bytes value = 2;
|
||||
}
|
||||
|
||||
message ExecutionPayloadDenebWithValueAndBlobsBundle {
|
||||
ExecutionPayloadDeneb payload = 1;
|
||||
bytes value = 2;
|
||||
BlobsBundle blobs_bundle = 3;
|
||||
}
|
||||
|
||||
|
||||
message ExecutionPayloadHeader {
|
||||
bytes parent_hash = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes fee_recipient = 2 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
@@ -105,26 +132,6 @@ message ExecutionPayloadHeaderCapella {
|
||||
bytes withdrawals_root = 15 [(ethereum.eth.ext.ssz_size) = "32"]; // New in Capella.
|
||||
}
|
||||
|
||||
message ExecutionPayloadDeneb {
|
||||
bytes parent_hash = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes fee_recipient = 2 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
bytes state_root = 3 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes receipts_root = 4 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes logs_bloom = 5 [(ethereum.eth.ext.ssz_size) = "logs_bloom.size"];
|
||||
bytes prev_randao = 6 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 block_number = 7;
|
||||
uint64 gas_limit = 8;
|
||||
uint64 gas_used = 9;
|
||||
uint64 timestamp = 10;
|
||||
bytes extra_data = 11 [(ethereum.eth.ext.ssz_max) = "extra_data.size"];
|
||||
bytes base_fee_per_gas = 12 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes block_hash = 13 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
repeated bytes transactions = 14 [(ethereum.eth.ext.ssz_size) = "?,?", (ethereum.eth.ext.ssz_max) = "1048576,1073741824"];
|
||||
// MAX_WITHDRAWALS_PER_PAYLOAD
|
||||
repeated Withdrawal withdrawals = 15 [(ethereum.eth.ext.ssz_max) = "withdrawal.size"];
|
||||
bytes excess_data_gas = 16 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
}
|
||||
|
||||
message ExecutionPayloadHeaderDeneb {
|
||||
bytes parent_hash = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes fee_recipient = 2 [(ethereum.eth.ext.ssz_size) = "20"];
|
||||
@@ -201,20 +208,18 @@ message Withdrawal {
|
||||
// Blobs bundle is retrieved through engine-api from the execution layer client.
|
||||
// It consists of the necessary components for constructing a blobs sidecar object to gossip through p2p.
|
||||
message BlobsBundle {
|
||||
// The block hash of the payload which corresponds to the blobs.
|
||||
bytes block_hash = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
// The KZG commitments of the blobs.
|
||||
repeated bytes kzg_commitments = 2 [(ethereum.eth.ext.ssz_size) = "?,48", (ethereum.eth.ext.ssz_max) = "16"];
|
||||
repeated bytes kzg_commitments = 1 [(ethereum.eth.ext.ssz_size) = "?,48", (ethereum.eth.ext.ssz_max) = "4"];
|
||||
// The proofs of the blobs.
|
||||
repeated bytes proofs = 2 [(ethereum.eth.ext.ssz_size) = "?,48", (ethereum.eth.ext.ssz_max) = "4"];
|
||||
// The blobs itself.
|
||||
repeated Blob blobs = 3 [(ethereum.eth.ext.ssz_max) = "16"];
|
||||
// The aggregated proof of the blobs to enable fast validation for commitments and blobs.
|
||||
bytes aggregated_proof = 4 [(ethereum.eth.ext.ssz_size) = "48"];
|
||||
repeated bytes blobs = 3 [(ethereum.eth.ext.ssz_size) = "?,131072", (ethereum.eth.ext.ssz_max) = "4"];
|
||||
}
|
||||
|
||||
// Blob contains the data that is to be committed on chain.
|
||||
message Blob {
|
||||
// Each blob consists of `BLS_FIELD_ELEMENT`(32) multiplies `FIELD_ELEMENTS_PER_BLOB`(4096)
|
||||
bytes data = 1 [(ethereum.eth.ext.ssz_size) = "131072"]; // 32 * 4096 = 131072
|
||||
bytes data = 1 [(ethereum.eth.ext.ssz_size) = "blob.size"];
|
||||
}
|
||||
|
||||
message ExchangeCapabilities {
|
||||
|
||||
@@ -34,6 +34,7 @@ type ExecutionBlock struct {
|
||||
Transactions []*gethtypes.Transaction `json:"transactions"`
|
||||
TotalDifficulty string `json:"totalDifficulty"`
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
ExcessDataGas []byte `json:"excessDataGas"`
|
||||
}
|
||||
|
||||
func (e *ExecutionBlock) MarshalJSON() ([]byte, error) {
|
||||
@@ -102,6 +103,15 @@ func (e *ExecutionBlock) UnmarshalJSON(enc []byte) error {
|
||||
}
|
||||
}
|
||||
e.Withdrawals = ws
|
||||
|
||||
exDG, hasExDG := decoded["excessDataGas"]
|
||||
if hasExDG && exDG != nil {
|
||||
e.Version = version.Deneb
|
||||
e.ExcessDataGas, err = hexutil.Decode(exDG.(string))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rawTxList, ok := decoded["transactions"]
|
||||
@@ -237,6 +247,31 @@ type ExecutionPayloadCapellaJSON struct {
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
}
|
||||
|
||||
type GetPayloadV3ResponseJson struct {
|
||||
ExecutionPayload *ExecutionPayloadDenebJSON `json:"executionPayload"`
|
||||
BlockValue string `json:"blockValue"`
|
||||
BlobsBundle *BlobBundleJSON `json:"blobsBundle"`
|
||||
}
|
||||
|
||||
type ExecutionPayloadDenebJSON struct {
|
||||
ParentHash *common.Hash `json:"parentHash"`
|
||||
FeeRecipient *common.Address `json:"feeRecipient"`
|
||||
StateRoot *common.Hash `json:"stateRoot"`
|
||||
ReceiptsRoot *common.Hash `json:"receiptsRoot"`
|
||||
LogsBloom *hexutil.Bytes `json:"logsBloom"`
|
||||
PrevRandao *common.Hash `json:"prevRandao"`
|
||||
BlockNumber *hexutil.Uint64 `json:"blockNumber"`
|
||||
GasLimit *hexutil.Uint64 `json:"gasLimit"`
|
||||
GasUsed *hexutil.Uint64 `json:"gasUsed"`
|
||||
Timestamp *hexutil.Uint64 `json:"timestamp"`
|
||||
ExtraData hexutil.Bytes `json:"extraData"`
|
||||
BaseFeePerGas string `json:"baseFeePerGas"`
|
||||
ExcessDataGas string `json:"excessDataGas"`
|
||||
BlockHash *common.Hash `json:"blockHash"`
|
||||
Transactions []hexutil.Bytes `json:"transactions"`
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (e *ExecutionPayload) MarshalJSON() ([]byte, error) {
|
||||
transactions := make([]hexutil.Bytes, len(e.Transactions))
|
||||
@@ -334,7 +369,6 @@ func (e *ExecutionPayload) UnmarshalJSON(enc []byte) error {
|
||||
if dec.ReceiptsRoot == nil {
|
||||
return errors.New("missing required field 'receiptsRoot' for ExecutableDataV1")
|
||||
}
|
||||
|
||||
if dec.LogsBloom == nil {
|
||||
return errors.New("missing required field 'logsBloom' for ExecutionPayload")
|
||||
}
|
||||
@@ -499,11 +533,16 @@ func (p *PayloadAttributes) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// MarshalJSON --
|
||||
func (p *PayloadAttributesV2) MarshalJSON() ([]byte, error) {
|
||||
withdrawals := p.Withdrawals
|
||||
if withdrawals == nil {
|
||||
withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
|
||||
return json.Marshal(payloadAttributesV2JSON{
|
||||
Timestamp: hexutil.Uint64(p.Timestamp),
|
||||
PrevRandao: p.PrevRandao,
|
||||
SuggestedFeeRecipient: p.SuggestedFeeRecipient,
|
||||
Withdrawals: p.Withdrawals,
|
||||
Withdrawals: withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -529,7 +568,11 @@ func (p *PayloadAttributesV2) UnmarshalJSON(enc []byte) error {
|
||||
p.Timestamp = uint64(dec.Timestamp)
|
||||
p.PrevRandao = dec.PrevRandao
|
||||
p.SuggestedFeeRecipient = dec.SuggestedFeeRecipient
|
||||
p.Withdrawals = dec.Withdrawals
|
||||
withdrawals := dec.Withdrawals
|
||||
if withdrawals == nil {
|
||||
withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
p.Withdrawals = withdrawals
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -642,6 +685,174 @@ func (f *ForkchoiceState) UnmarshalJSON(enc []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type BlobBundleJSON struct {
|
||||
Commitments [][48]byte `json:"commitments"`
|
||||
Proofs [][48]byte `json:"proofs"`
|
||||
Blobs [][]byte `json:"blobs"`
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (e *ExecutionPayloadDeneb) MarshalJSON() ([]byte, error) {
|
||||
transactions := make([]hexutil.Bytes, len(e.Transactions))
|
||||
for i, tx := range e.Transactions {
|
||||
transactions[i] = tx
|
||||
}
|
||||
baseFee := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(e.BaseFeePerGas))
|
||||
baseFeeHex := hexutil.EncodeBig(baseFee)
|
||||
dataGas := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(e.ExcessDataGas))
|
||||
dataGasHex := hexutil.EncodeBig(dataGas)
|
||||
pHash := common.BytesToHash(e.ParentHash)
|
||||
sRoot := common.BytesToHash(e.StateRoot)
|
||||
recRoot := common.BytesToHash(e.ReceiptsRoot)
|
||||
prevRan := common.BytesToHash(e.PrevRandao)
|
||||
bHash := common.BytesToHash(e.BlockHash)
|
||||
blockNum := hexutil.Uint64(e.BlockNumber)
|
||||
gasLimit := hexutil.Uint64(e.GasLimit)
|
||||
gasUsed := hexutil.Uint64(e.GasUsed)
|
||||
timeStamp := hexutil.Uint64(e.Timestamp)
|
||||
recipient := common.BytesToAddress(e.FeeRecipient)
|
||||
logsBloom := hexutil.Bytes(e.LogsBloom)
|
||||
if e.Withdrawals == nil {
|
||||
e.Withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
|
||||
return json.Marshal(ExecutionPayloadDenebJSON{
|
||||
ParentHash: &pHash,
|
||||
FeeRecipient: &recipient,
|
||||
StateRoot: &sRoot,
|
||||
ReceiptsRoot: &recRoot,
|
||||
LogsBloom: &logsBloom,
|
||||
PrevRandao: &prevRan,
|
||||
BlockNumber: &blockNum,
|
||||
GasLimit: &gasLimit,
|
||||
GasUsed: &gasUsed,
|
||||
Timestamp: &timeStamp,
|
||||
ExtraData: e.ExtraData,
|
||||
BaseFeePerGas: baseFeeHex,
|
||||
ExcessDataGas: dataGasHex,
|
||||
BlockHash: &bHash,
|
||||
Transactions: transactions,
|
||||
Withdrawals: e.Withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
func (e *ExecutionPayloadDenebWithValueAndBlobsBundle) UnmarshalJSON(enc []byte) error {
|
||||
dec := GetPayloadV3ResponseJson{}
|
||||
if err := json.Unmarshal(enc, &dec); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dec.ExecutionPayload.ParentHash == nil {
|
||||
return errors.New("missing required field 'parentHash' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.FeeRecipient == nil {
|
||||
return errors.New("missing required field 'feeRecipient' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.StateRoot == nil {
|
||||
return errors.New("missing required field 'stateRoot' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.ReceiptsRoot == nil {
|
||||
return errors.New("missing required field 'receiptsRoot' for ExecutableDataV1")
|
||||
}
|
||||
if dec.ExecutionPayload.LogsBloom == nil {
|
||||
return errors.New("missing required field 'logsBloom' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.PrevRandao == nil {
|
||||
return errors.New("missing required field 'prevRandao' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.ExtraData == nil {
|
||||
return errors.New("missing required field 'extraData' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.BlockHash == nil {
|
||||
return errors.New("missing required field 'blockHash' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.Transactions == nil {
|
||||
return errors.New("missing required field 'transactions' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.BlockNumber == nil {
|
||||
return errors.New("missing required field 'blockNumber' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.Timestamp == nil {
|
||||
return errors.New("missing required field 'timestamp' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.GasUsed == nil {
|
||||
return errors.New("missing required field 'gasUsed' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.GasLimit == nil {
|
||||
return errors.New("missing required field 'gasLimit' for ExecutionPayload")
|
||||
}
|
||||
|
||||
*e = ExecutionPayloadDenebWithValueAndBlobsBundle{Payload: &ExecutionPayloadDeneb{}}
|
||||
e.Payload.ParentHash = dec.ExecutionPayload.ParentHash.Bytes()
|
||||
e.Payload.FeeRecipient = dec.ExecutionPayload.FeeRecipient.Bytes()
|
||||
e.Payload.StateRoot = dec.ExecutionPayload.StateRoot.Bytes()
|
||||
e.Payload.ReceiptsRoot = dec.ExecutionPayload.ReceiptsRoot.Bytes()
|
||||
e.Payload.LogsBloom = *dec.ExecutionPayload.LogsBloom
|
||||
e.Payload.PrevRandao = dec.ExecutionPayload.PrevRandao.Bytes()
|
||||
e.Payload.BlockNumber = uint64(*dec.ExecutionPayload.BlockNumber)
|
||||
e.Payload.GasLimit = uint64(*dec.ExecutionPayload.GasLimit)
|
||||
e.Payload.GasUsed = uint64(*dec.ExecutionPayload.GasUsed)
|
||||
e.Payload.Timestamp = uint64(*dec.ExecutionPayload.Timestamp)
|
||||
e.Payload.ExtraData = dec.ExecutionPayload.ExtraData
|
||||
baseFee, err := hexutil.DecodeBig(dec.ExecutionPayload.BaseFeePerGas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Payload.BaseFeePerGas = bytesutil.PadTo(bytesutil.ReverseByteOrder(baseFee.Bytes()), fieldparams.RootLength)
|
||||
|
||||
dataGas, err := hexutil.DecodeBig(dec.ExecutionPayload.ExcessDataGas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Payload.ExcessDataGas = bytesutil.PadTo(bytesutil.ReverseByteOrder(dataGas.Bytes()), fieldparams.RootLength)
|
||||
|
||||
e.Payload.BlockHash = dec.ExecutionPayload.BlockHash.Bytes()
|
||||
transactions := make([][]byte, len(dec.ExecutionPayload.Transactions))
|
||||
for i, tx := range dec.ExecutionPayload.Transactions {
|
||||
transactions[i] = tx
|
||||
}
|
||||
e.Payload.Transactions = transactions
|
||||
if dec.ExecutionPayload.Withdrawals == nil {
|
||||
dec.ExecutionPayload.Withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
e.Payload.Withdrawals = dec.ExecutionPayload.Withdrawals
|
||||
|
||||
v, err := hexutil.DecodeBig(dec.BlockValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Value = bytesutil.PadTo(bytesutil.ReverseByteOrder(v.Bytes()), fieldparams.RootLength)
|
||||
|
||||
if dec.BlobsBundle == nil {
|
||||
return nil
|
||||
}
|
||||
e.BlobsBundle = &BlobsBundle{}
|
||||
|
||||
commitments := make([][]byte, len(dec.BlobsBundle.Commitments))
|
||||
for i, kzg := range dec.BlobsBundle.Commitments {
|
||||
k := kzg
|
||||
commitments[i] = bytesutil.PadTo(k[:], fieldparams.BLSPubkeyLength)
|
||||
}
|
||||
e.BlobsBundle.KzgCommitments = commitments
|
||||
|
||||
proofs := make([][]byte, len(dec.BlobsBundle.Proofs))
|
||||
for i, proof := range dec.BlobsBundle.Proofs {
|
||||
p := proof
|
||||
proofs[i] = bytesutil.PadTo(p[:], fieldparams.BLSPubkeyLength)
|
||||
}
|
||||
e.BlobsBundle.Proofs = proofs
|
||||
|
||||
blobs := make([][]byte, len(dec.BlobsBundle.Blobs))
|
||||
for i, blob := range dec.BlobsBundle.Blobs {
|
||||
b := make([]byte, fieldparams.BlobLength)
|
||||
copy(b, blob)
|
||||
blobs[i] = b
|
||||
}
|
||||
e.BlobsBundle.Blobs = blobs
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type executionPayloadBodyV1JSON struct {
|
||||
Transactions []hexutil.Bytes `json:"transactions"`
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
|
||||
@@ -205,6 +205,95 @@ func TestJsonMarshalUnmarshal(t *testing.T) {
|
||||
require.DeepEqual(t, bytesutil.PadTo([]byte("address"), 20), withdrawal.Address)
|
||||
require.Equal(t, uint64(1), withdrawal.Amount)
|
||||
})
|
||||
t.Run("execution payload deneb", func(t *testing.T) {
|
||||
parentHash := common.BytesToHash([]byte("parent"))
|
||||
feeRecipient := common.BytesToAddress([]byte("feeRecipient"))
|
||||
stateRoot := common.BytesToHash([]byte("stateRoot"))
|
||||
receiptsRoot := common.BytesToHash([]byte("receiptsRoot"))
|
||||
logsBloom := hexutil.Bytes(bytesutil.PadTo([]byte("logs"), fieldparams.LogsBloomLength))
|
||||
random := common.BytesToHash([]byte("random"))
|
||||
extra := common.BytesToHash([]byte("extra"))
|
||||
hash := common.BytesToHash([]byte("hash"))
|
||||
bn := hexutil.Uint64(1)
|
||||
gl := hexutil.Uint64(2)
|
||||
gu := hexutil.Uint64(3)
|
||||
ts := hexutil.Uint64(4)
|
||||
|
||||
resp := &enginev1.GetPayloadV3ResponseJson{
|
||||
BlobsBundle: &enginev1.BlobBundleJSON{
|
||||
Commitments: [][48]byte{{'a'}, {'b'}, {'c'}, {'d'}},
|
||||
Proofs: [][48]byte{{'e'}, {'f'}, {'g'}, {'h'}},
|
||||
Blobs: [][]byte{{'i'}, {'j'}, {'k'}, {'l'}},
|
||||
},
|
||||
BlockValue: fmt.Sprint("0x123"),
|
||||
ExecutionPayload: &enginev1.ExecutionPayloadDenebJSON{
|
||||
ParentHash: &parentHash,
|
||||
FeeRecipient: &feeRecipient,
|
||||
StateRoot: &stateRoot,
|
||||
ReceiptsRoot: &receiptsRoot,
|
||||
LogsBloom: &logsBloom,
|
||||
PrevRandao: &random,
|
||||
BlockNumber: &bn,
|
||||
GasLimit: &gl,
|
||||
GasUsed: &gu,
|
||||
Timestamp: &ts,
|
||||
ExtraData: hexutil.Bytes(extra[:]),
|
||||
BaseFeePerGas: "0x123",
|
||||
BlockHash: &hash,
|
||||
Transactions: []hexutil.Bytes{{}},
|
||||
ExcessDataGas: "0x456",
|
||||
Withdrawals: []*enginev1.Withdrawal{{
|
||||
Index: 1,
|
||||
ValidatorIndex: 1,
|
||||
Address: bytesutil.PadTo([]byte("address"), 20),
|
||||
Amount: 1,
|
||||
}},
|
||||
},
|
||||
}
|
||||
enc, err := json.Marshal(resp)
|
||||
require.NoError(t, err)
|
||||
pb := &enginev1.ExecutionPayloadDenebWithValueAndBlobsBundle{}
|
||||
require.NoError(t, json.Unmarshal(enc, pb))
|
||||
require.DeepEqual(t, parentHash.Bytes(), pb.Payload.ParentHash)
|
||||
require.DeepEqual(t, feeRecipient.Bytes(), pb.Payload.FeeRecipient)
|
||||
require.DeepEqual(t, stateRoot.Bytes(), pb.Payload.StateRoot)
|
||||
require.DeepEqual(t, receiptsRoot.Bytes(), pb.Payload.ReceiptsRoot)
|
||||
require.DeepEqual(t, logsBloom, hexutil.Bytes(pb.Payload.LogsBloom))
|
||||
require.DeepEqual(t, random.Bytes(), pb.Payload.PrevRandao)
|
||||
require.DeepEqual(t, uint64(1), pb.Payload.BlockNumber)
|
||||
require.DeepEqual(t, uint64(2), pb.Payload.GasLimit)
|
||||
require.DeepEqual(t, uint64(3), pb.Payload.GasUsed)
|
||||
require.DeepEqual(t, uint64(4), pb.Payload.Timestamp)
|
||||
require.DeepEqual(t, extra.Bytes(), pb.Payload.ExtraData)
|
||||
feePerGas := new(big.Int).SetBytes(pb.Payload.BaseFeePerGas)
|
||||
require.Equal(t, "15832716547479101977395928904157292820330083199902421483727713169783165812736", feePerGas.String())
|
||||
excessiveDataGas := new(big.Int).SetBytes(pb.Payload.ExcessDataGas)
|
||||
require.Equal(t, "38905972366420022937424210966359065718521195409201129457837768552463487467520", excessiveDataGas.String())
|
||||
require.DeepEqual(t, hash.Bytes(), pb.Payload.BlockHash)
|
||||
require.DeepEqual(t, [][]byte{{}}, pb.Payload.Transactions)
|
||||
require.Equal(t, 1, len(pb.Payload.Withdrawals))
|
||||
withdrawal := pb.Payload.Withdrawals[0]
|
||||
require.Equal(t, uint64(1), withdrawal.Index)
|
||||
require.Equal(t, primitives.ValidatorIndex(1), withdrawal.ValidatorIndex)
|
||||
require.DeepEqual(t, bytesutil.PadTo([]byte("address"), 20), withdrawal.Address)
|
||||
require.Equal(t, uint64(1), withdrawal.Amount)
|
||||
require.DeepEqual(t, [][]byte{
|
||||
bytesutil.PadTo([]byte{'e'}, 48),
|
||||
bytesutil.PadTo([]byte{'f'}, 48),
|
||||
bytesutil.PadTo([]byte{'g'}, 48),
|
||||
bytesutil.PadTo([]byte{'h'}, 48)}, pb.BlobsBundle.Proofs)
|
||||
require.DeepEqual(t, [][]byte{
|
||||
bytesutil.PadTo([]byte{'a'}, 48),
|
||||
bytesutil.PadTo([]byte{'b'}, 48),
|
||||
bytesutil.PadTo([]byte{'c'}, 48),
|
||||
bytesutil.PadTo([]byte{'d'}, 48)}, pb.BlobsBundle.KzgCommitments)
|
||||
require.DeepEqual(t, [][]byte{
|
||||
bytesutil.PadTo([]byte{'i'}, 131072),
|
||||
bytesutil.PadTo([]byte{'j'}, 131072),
|
||||
bytesutil.PadTo([]byte{'k'}, 131072),
|
||||
bytesutil.PadTo([]byte{'l'}, 131072)}, pb.BlobsBundle.Blobs)
|
||||
})
|
||||
|
||||
t.Run("execution block", func(t *testing.T) {
|
||||
baseFeePerGas := big.NewInt(1770307273)
|
||||
want := &gethtypes.Header{
|
||||
|
||||
Reference in New Issue
Block a user