|
|
|
|
@ -79,6 +79,8 @@ pub struct ExecutionPayload {
|
|
|
|
|
pub timestamp: U64,
|
|
|
|
|
pub extra_data: Bytes,
|
|
|
|
|
pub base_fee_per_gas: U256,
|
|
|
|
|
pub blob_gas_used: Option<U64>,
|
|
|
|
|
pub excess_blob_gas: Option<U64>,
|
|
|
|
|
pub block_hash: H256,
|
|
|
|
|
pub transactions: Vec<Bytes>,
|
|
|
|
|
/// Array of [`Withdrawal`] enabled with V2
|
|
|
|
|
@ -111,6 +113,8 @@ impl From<SealedBlock> for ExecutionPayload {
|
|
|
|
|
timestamp: value.timestamp.into(),
|
|
|
|
|
extra_data: value.extra_data.clone(),
|
|
|
|
|
base_fee_per_gas: U256::from(value.base_fee_per_gas.unwrap_or_default()),
|
|
|
|
|
blob_gas_used: value.blob_gas_used.map(U64::from),
|
|
|
|
|
excess_blob_gas: value.excess_blob_gas.map(U64::from),
|
|
|
|
|
block_hash: value.hash(),
|
|
|
|
|
transactions,
|
|
|
|
|
withdrawals: value.withdrawals,
|
|
|
|
|
@ -167,14 +171,15 @@ impl TryFrom<ExecutionPayload> for SealedBlock {
|
|
|
|
|
.uint_try_to()
|
|
|
|
|
.map_err(|_| PayloadError::BaseFee(payload.base_fee_per_gas))?,
|
|
|
|
|
),
|
|
|
|
|
blob_gas_used: payload.blob_gas_used.map(|blob_gas_used| blob_gas_used.as_u64()),
|
|
|
|
|
excess_blob_gas: payload
|
|
|
|
|
.excess_blob_gas
|
|
|
|
|
.map(|excess_blob_gas| excess_blob_gas.as_u64()),
|
|
|
|
|
extra_data: payload.extra_data,
|
|
|
|
|
// Defaults
|
|
|
|
|
ommers_hash: EMPTY_LIST_HASH,
|
|
|
|
|
difficulty: Default::default(),
|
|
|
|
|
nonce: Default::default(),
|
|
|
|
|
// TODO: add conversion once ExecutionPayload has 4844 fields
|
|
|
|
|
blob_gas_used: None,
|
|
|
|
|
excess_blob_gas: None,
|
|
|
|
|
}
|
|
|
|
|
.seal_slow();
|
|
|
|
|
|
|
|
|
|
@ -211,6 +216,12 @@ pub enum PayloadError {
|
|
|
|
|
/// Invalid payload base fee.
|
|
|
|
|
#[error("Invalid payload base fee: {0}")]
|
|
|
|
|
BaseFee(U256),
|
|
|
|
|
/// Invalid payload base fee.
|
|
|
|
|
#[error("Invalid payload blob gas used: {0}")]
|
|
|
|
|
BlobGasUsed(U256),
|
|
|
|
|
/// Invalid payload base fee.
|
|
|
|
|
#[error("Invalid payload excess blob gas: {0}")]
|
|
|
|
|
ExcessBlobGas(U256),
|
|
|
|
|
/// Invalid payload block hash.
|
|
|
|
|
#[error("blockhash mismatch, want {consensus}, got {execution}")]
|
|
|
|
|
BlockHash {
|
|
|
|
|
@ -519,7 +530,7 @@ mod tests {
|
|
|
|
|
#[test]
|
|
|
|
|
fn serde_roundtrip_legacy_txs_payload() {
|
|
|
|
|
// pulled from hive tests
|
|
|
|
|
let s = r#"{"parentHash":"0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x4e3c608a9f2e129fccb91a1dae7472e78013b8e654bccc8d224ce3d63ae17006","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0x44bb4b98c59dbb726f96ffceb5ee028dcbe35b9bba4f9ffd56aeebf8d1e4db62","blockNumber":"0x1","gasLimit":"0x2fefd8","gasUsed":"0xa860","timestamp":"0x1235","extraData":"0x8b726574682f76302e312e30","baseFeePerGas":"0x342770c0","blockHash":"0x5655011482546f16b2312ef18e9fad03d6a52b1be95401aea884b222477f9e64","transactions":["0xf865808506fc23ac00830124f8940000000000000000000000000000000000000316018032a044b25a8b9b247d01586b3d59c71728ff49c9b84928d9e7fa3377ead3b5570b5da03ceac696601ff7ee6f5fe8864e2998db9babdf5eeba1a0cd5b4d44b3fcbd181b"]}"#;
|
|
|
|
|
let s = r#"{"parentHash":"0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x4e3c608a9f2e129fccb91a1dae7472e78013b8e654bccc8d224ce3d63ae17006","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0x44bb4b98c59dbb726f96ffceb5ee028dcbe35b9bba4f9ffd56aeebf8d1e4db62","blockNumber":"0x1","gasLimit":"0x2fefd8","gasUsed":"0xa860","timestamp":"0x1235","extraData":"0x8b726574682f76302e312e30","baseFeePerGas":"0x342770c0","blobGasUsed":null,"excessBlobGas":null,"blockHash":"0x5655011482546f16b2312ef18e9fad03d6a52b1be95401aea884b222477f9e64","transactions":["0xf865808506fc23ac00830124f8940000000000000000000000000000000000000316018032a044b25a8b9b247d01586b3d59c71728ff49c9b84928d9e7fa3377ead3b5570b5da03ceac696601ff7ee6f5fe8864e2998db9babdf5eeba1a0cd5b4d44b3fcbd181b"]}"#;
|
|
|
|
|
let payload: ExecutionPayload = serde_json::from_str(s).unwrap();
|
|
|
|
|
assert_eq!(serde_json::to_string(&payload).unwrap(), s);
|
|
|
|
|
}
|
|
|
|
|
@ -527,7 +538,7 @@ mod tests {
|
|
|
|
|
#[test]
|
|
|
|
|
fn serde_roundtrip_enveloped_txs_payload() {
|
|
|
|
|
// pulled from hive tests
|
|
|
|
|
let s = r#"{"parentHash":"0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x76a03cbcb7adce07fd284c61e4fa31e5e786175cefac54a29e46ec8efa28ea41","receiptsRoot":"0x4e3c608a9f2e129fccb91a1dae7472e78013b8e654bccc8d224ce3d63ae17006","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0x028111cb7d25918386a69656b3d17b2febe95fd0f11572c1a55c14f99fdfe3df","blockNumber":"0x1","gasLimit":"0x2fefd8","gasUsed":"0xa860","timestamp":"0x1235","extraData":"0x8b726574682f76302e312e30","baseFeePerGas":"0x342770c0","blockHash":"0xa6f40ed042e61e88e76125dede8fff8026751ea14454b68fb534cea99f2b2a77","transactions":["0xf865808506fc23ac00830124f8940000000000000000000000000000000000000316018032a044b25a8b9b247d01586b3d59c71728ff49c9b84928d9e7fa3377ead3b5570b5da03ceac696601ff7ee6f5fe8864e2998db9babdf5eeba1a0cd5b4d44b3fcbd181b"]}"#;
|
|
|
|
|
let s = r#"{"parentHash":"0x67ead97eb79b47a1638659942384143f36ed44275d4182799875ab5a87324055","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x76a03cbcb7adce07fd284c61e4fa31e5e786175cefac54a29e46ec8efa28ea41","receiptsRoot":"0x4e3c608a9f2e129fccb91a1dae7472e78013b8e654bccc8d224ce3d63ae17006","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0x028111cb7d25918386a69656b3d17b2febe95fd0f11572c1a55c14f99fdfe3df","blockNumber":"0x1","gasLimit":"0x2fefd8","gasUsed":"0xa860","timestamp":"0x1235","extraData":"0x8b726574682f76302e312e30","baseFeePerGas":"0x342770c0","blobGasUsed":null,"excessBlobGas":null,"blockHash":"0xa6f40ed042e61e88e76125dede8fff8026751ea14454b68fb534cea99f2b2a77","transactions":["0xf865808506fc23ac00830124f8940000000000000000000000000000000000000316018032a044b25a8b9b247d01586b3d59c71728ff49c9b84928d9e7fa3377ead3b5570b5da03ceac696601ff7ee6f5fe8864e2998db9babdf5eeba1a0cd5b4d44b3fcbd181b"]}"#;
|
|
|
|
|
let payload: ExecutionPayload = serde_json::from_str(s).unwrap();
|
|
|
|
|
assert_eq!(serde_json::to_string(&payload).unwrap(), s);
|
|
|
|
|
}
|
|
|
|
|
|