Skip to content

Commit b92786a

Browse files
author
Mac L
committed
Add ExecutionWitness to Payload
1 parent b786e6d commit b92786a

File tree

19 files changed

+472
-57
lines changed

19 files changed

+472
-57
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ validator_dir = { path = "common/validator_dir" }
234234
warp_utils = { path = "common/warp_utils" }
235235

236236
[patch.crates-io]
237+
ssz_types = { git = "https://github.com/macladson/ssz_types.git", branch = "optional" }
237238
yamux = { git = "https://github.com/sigp/rust-yamux.git" }
238239

239240
[profile.maxperf]

beacon_node/client/src/notifier.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -549,17 +549,15 @@ async fn electra_readiness_logging<T: BeaconChainTypes>(
549549
beacon_chain: &BeaconChain<T>,
550550
log: &Logger,
551551
) {
552-
// TODO(electra): Once Electra has features, this code can be swapped back.
553-
let electra_completed = false;
554-
//let electra_completed = beacon_chain
555-
// .canonical_head
556-
// .cached_head()
557-
// .snapshot
558-
// .beacon_block
559-
// .message()
560-
// .body()
561-
// .execution_payload()
562-
// .map_or(false, |payload| payload.electra_placeholder().is_ok());
552+
let electra_completed = beacon_chain
553+
.canonical_head
554+
.cached_head()
555+
.snapshot
556+
.beacon_block
557+
.message()
558+
.body()
559+
.execution_payload()
560+
.map_or(false, |payload| payload.execution_witness_root().is_ok());
563561

564562
let has_execution_layer = beacon_chain.execution_layer.is_some();
565563

beacon_node/execution_layer/src/block_hash.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub fn calculate_execution_block_hash<E: EthSpec>(
3636
None
3737
};
3838

39+
// TODO(mac): Fix rlp calc
40+
let rlp_execution_witness_root = None;
41+
3942
let rlp_blob_gas_used = payload.blob_gas_used().ok();
4043
let rlp_excess_blob_gas = payload.excess_blob_gas().ok();
4144

@@ -48,6 +51,7 @@ pub fn calculate_execution_block_hash<E: EthSpec>(
4851
rlp_blob_gas_used,
4952
rlp_excess_blob_gas,
5053
parent_beacon_block_root,
54+
rlp_execution_witness_root,
5155
);
5256

5357
// Hash the RLP encoding of the block header.
@@ -137,6 +141,7 @@ mod test {
137141
blob_gas_used: None,
138142
excess_blob_gas: None,
139143
parent_beacon_block_root: None,
144+
execution_witness_root: None,
140145
};
141146
let expected_rlp = "f90200a0e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2aa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ba5e000000000000000000000000000000000000a0ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7a050f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accfa029b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000188016345785d8a00008301553482079e42a0000000000000000000000000000000000000000000000000000000000000000088000000000000000082036b";
142147
let expected_hash =
@@ -168,6 +173,7 @@ mod test {
168173
blob_gas_used: None,
169174
excess_blob_gas: None,
170175
parent_beacon_block_root: None,
176+
execution_witness_root: None,
171177
};
172178
let expected_rlp = "f901fda0927ca537f06c783a3a2635b8805eef1c8c2124f7444ad4a3389898dd832f2dbea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ba5e000000000000000000000000000000000000a0e97859b065bd8dbbb4519c7cb935024de2484c2b7f881181b4360492f0b06b82a050f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accfa029b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800188016345785d8a00008301553482079e42a0000000000000000000000000000000000000000000000000000000000002000088000000000000000082036b";
173179
let expected_hash =
@@ -200,6 +206,7 @@ mod test {
200206
blob_gas_used: None,
201207
excess_blob_gas: None,
202208
parent_beacon_block_root: None,
209+
execution_witness_root: None,
203210
};
204211
let expected_hash =
205212
Hash256::from_str("6da69709cd5a34079b6604d29cd78fc01dacd7c6268980057ad92a2bede87351")
@@ -230,6 +237,7 @@ mod test {
230237
blob_gas_used: Some(0x0u64),
231238
excess_blob_gas: Some(0x0u64),
232239
parent_beacon_block_root: Some(Hash256::from_str("f7d327d2c04e4f12e9cdd492e53d39a1d390f8b1571e3b2a22ac6e1e170e5b1a").unwrap()),
240+
execution_witness_root: None,
233241
};
234242
let expected_hash =
235243
Hash256::from_str("a7448e600ead0a23d16f96aa46e8dea9eef8a7c5669a5f0a5ff32709afe9c408")
@@ -260,6 +268,7 @@ mod test {
260268
blob_gas_used: Some(0x0u64),
261269
excess_blob_gas: Some(0x0u64),
262270
parent_beacon_block_root: Some(Hash256::from_str("f7d327d2c04e4f12e9cdd492e53d39a1d390f8b1571e3b2a22ac6e1e170e5b1a").unwrap()),
271+
execution_witness_root: None,
263272
};
264273
let expected_hash =
265274
Hash256::from_str("a7448e600ead0a23d16f96aa46e8dea9eef8a7c5669a5f0a5ff32709afe9c408")

beacon_node/execution_layer/src/engine_api.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use strum::IntoStaticStr;
2121
use superstruct::superstruct;
2222
pub use types::{
2323
Address, BeaconBlockRef, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
24-
ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions, Uint256, VariableList,
25-
Withdrawal, Withdrawals,
24+
ExecutionPayloadRef, ExecutionWitness, FixedVector, ForkName, Hash256, Transactions, Uint256,
25+
VariableList, Withdrawal, Withdrawals,
2626
};
2727

2828
use types::{
@@ -197,6 +197,8 @@ pub struct ExecutionBlockWithTransactions<E: EthSpec> {
197197
#[superstruct(only(Deneb, Electra))]
198198
#[serde(with = "serde_utils::u64_hex_be")]
199199
pub excess_blob_gas: u64,
200+
#[superstruct(only(Electra))]
201+
pub execution_witness: ExecutionWitness<E>,
200202
}
201203

202204
impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions<E> {
@@ -302,6 +304,7 @@ impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions
302304
.collect(),
303305
blob_gas_used: block.blob_gas_used,
304306
excess_blob_gas: block.excess_blob_gas,
307+
execution_witness: block.execution_witness,
305308
})
306309
}
307310
};
@@ -521,6 +524,7 @@ impl<E: EthSpec> GetPayloadResponse<E> {
521524
pub struct ExecutionPayloadBodyV1<E: EthSpec> {
522525
pub transactions: Transactions<E>,
523526
pub withdrawals: Option<Withdrawals<E>>,
527+
pub execution_witness: Option<ExecutionWitness<E>>,
524528
}
525529

526530
impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
@@ -609,25 +613,31 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
609613
}
610614
ExecutionPayloadHeader::Electra(header) => {
611615
if let Some(withdrawals) = self.withdrawals {
612-
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
613-
parent_hash: header.parent_hash,
614-
fee_recipient: header.fee_recipient,
615-
state_root: header.state_root,
616-
receipts_root: header.receipts_root,
617-
logs_bloom: header.logs_bloom,
618-
prev_randao: header.prev_randao,
619-
block_number: header.block_number,
620-
gas_limit: header.gas_limit,
621-
gas_used: header.gas_used,
622-
timestamp: header.timestamp,
623-
extra_data: header.extra_data,
624-
base_fee_per_gas: header.base_fee_per_gas,
625-
block_hash: header.block_hash,
626-
transactions: self.transactions,
627-
withdrawals,
628-
blob_gas_used: header.blob_gas_used,
629-
excess_blob_gas: header.excess_blob_gas,
630-
}))
616+
if let Some(execution_witness) = self.execution_witness {
617+
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
618+
parent_hash: header.parent_hash,
619+
fee_recipient: header.fee_recipient,
620+
state_root: header.state_root,
621+
receipts_root: header.receipts_root,
622+
logs_bloom: header.logs_bloom,
623+
prev_randao: header.prev_randao,
624+
block_number: header.block_number,
625+
gas_limit: header.gas_limit,
626+
gas_used: header.gas_used,
627+
timestamp: header.timestamp,
628+
extra_data: header.extra_data,
629+
base_fee_per_gas: header.base_fee_per_gas,
630+
block_hash: header.block_hash,
631+
transactions: self.transactions,
632+
withdrawals,
633+
blob_gas_used: header.blob_gas_used,
634+
excess_blob_gas: header.excess_blob_gas,
635+
execution_witness,
636+
}))
637+
} else {
638+
Err(format!(
639+
"block {} is post-electra but payload body doesn't have an execution witness", header.block_hash))
640+
}
631641
} else {
632642
Err(format!(
633643
"block {} is post-capella but payload body doesn't have withdrawals",

0 commit comments

Comments
 (0)