Skip to content

Commit 934614d

Browse files
authored
D/add payload attributes (#118)
1 parent 23fab0f commit 934614d

8 files changed

Lines changed: 62 additions & 8 deletions

File tree

application/src/actor.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,22 @@ impl<
452452
aux_data.forkchoice,
453453
current,
454454
withdrawals,
455+
Default::default(),
456+
None,
455457
parent_block.height(),
456458
)
457459
.await
458460
}
459461
#[cfg(not(feature = "bench"))]
460462
{
461463
self.engine_client
462-
.start_building_block(aux_data.forkchoice, current, withdrawals)
464+
.start_building_block(
465+
aux_data.forkchoice,
466+
current,
467+
withdrawals,
468+
aux_data.withdrawal_credentials,
469+
Some(parent.1.0.into()),
470+
)
463471
.await
464472
}
465473
}

example_genesis.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
eth_genesis_hash = "0xda190bd7877d50c8d16bb9cacb68e54a280ce203fb8b3b838637b39265c1d3b5"
1+
eth_genesis_hash = "0x3bba1a6bb7df768e68169e3d62d8c1aea0461bfa967184593bec516fa507eca5"
22
leader_timeout_ms = 2000
33
notarization_timeout_ms = 4000
44
nullify_timeout_ms = 4000

finalizer/src/actor.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,16 @@ impl<
767767
return;
768768
};
769769

770+
let withdrawal_credentials = state
771+
.get_account(
772+
self.node_public_key
773+
.as_ref()
774+
.try_into()
775+
.expect("Safe: Ed pub key always 32 bytes"),
776+
)
777+
.map(|account| account.withdrawal_credentials)
778+
.unwrap_or_default();
779+
770780
// Create checkpoint if we're at an epoch boundary.
771781
// The consensus state is saved every `epoch_num_blocks` blocks.
772782
// The proposed block will contain the checkpoint that was saved at the previous height.
@@ -815,6 +825,7 @@ impl<
815825
.unwrap_or_default(),
816826
removed_validators: state.removed_validators.clone(),
817827
forkchoice: state.forkchoice,
828+
withdrawal_credentials,
818829
}
819830
} else {
820831
BlockAuxData {
@@ -825,6 +836,7 @@ impl<
825836
added_validators: vec![],
826837
removed_validators: vec![],
827838
forkchoice: state.forkchoice,
839+
withdrawal_credentials,
828840
}
829841
};
830842
trace!(

finalizer/src/tests/mocks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Mock implementations for finalizer tests.
22
3-
use alloy_primitives::U256;
3+
use alloy_primitives::{Address, FixedBytes, U256};
44
use alloy_rpc_types_engine::{
55
ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadV1, ExecutionPayloadV2,
66
ExecutionPayloadV3, ForkchoiceState, PayloadId, PayloadStatus, PayloadStatusEnum,
@@ -19,6 +19,8 @@ impl EngineClient for MockEngineClient {
1919
_fork_choice_state: ForkchoiceState,
2020
_timestamp: u64,
2121
_withdrawals: Vec<alloy_eips::eip4895::Withdrawal>,
22+
_suggested_fee_recipient: Address,
23+
_parent_beacon_block_root: Option<FixedBytes<32>>,
2224
#[cfg(feature = "bench")] height: u64,
2325
) -> Option<PayloadId> {
2426
Some(PayloadId::new([0u8; 8]))

node/src/bin/execute_blocks.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,19 @@ async fn main() -> Result<()> {
8484
println!("Block number: {}", block_number);
8585
#[cfg(feature = "bench")]
8686
let result = client
87-
.start_building_block(forkchoice, 0, vec![], block_number)
87+
.start_building_block(
88+
forkchoice,
89+
0,
90+
vec![],
91+
Default::default(),
92+
None,
93+
block_number,
94+
)
8895
.await;
8996
#[cfg(not(feature = "bench"))]
90-
let result = client.start_building_block(forkchoice, 0, vec![]).await;
97+
let result = client
98+
.start_building_block(forkchoice, 0, vec![], Default::default(), None)
99+
.await;
91100
match result {
92101
Some(payload_id) => {
93102
let payload = client.get_payload(payload_id).await;

node/src/test_harness/mock_engine_client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ impl EngineClient for MockEngineClient {
314314
fork_choice_state: ForkchoiceState,
315315
timestamp: u64,
316316
withdrawals: Vec<Withdrawal>,
317+
_suggested_fee_recipient: Address,
318+
_parent_beacon_block_root: Option<FixedBytes<32>>,
317319
#[cfg(feature = "bench")] height: u64,
318320
) -> Option<PayloadId> {
319321
let mut state = self.state.lock().unwrap();
@@ -674,6 +676,8 @@ mod tests {
674676
genesis_state,
675677
1000,
676678
vec![],
679+
Default::default(),
680+
None,
677681
#[cfg(feature = "bench")]
678682
0,
679683
)
@@ -742,6 +746,8 @@ mod tests {
742746
genesis_state,
743747
1000,
744748
vec![],
749+
Default::default(),
750+
None,
745751
#[cfg(feature = "bench")]
746752
0,
747753
)
@@ -824,6 +830,8 @@ mod tests {
824830
fork_choice,
825831
(round * 1000) as u64,
826832
vec![],
833+
Default::default(),
834+
None,
827835
#[cfg(feature = "bench")]
828836
round,
829837
)
@@ -912,6 +920,8 @@ mod tests {
912920
genesis_state,
913921
1000,
914922
vec![withdrawal.clone()],
923+
Default::default(),
924+
None,
915925
#[cfg(feature = "bench")]
916926
0,
917927
)
@@ -997,6 +1007,8 @@ mod tests {
9971007
genesis_state,
9981008
1000,
9991009
vec![],
1010+
Default::default(),
1011+
None,
10001012
#[cfg(feature = "bench")]
10011013
0,
10021014
)
@@ -1011,6 +1023,8 @@ mod tests {
10111023
genesis_state,
10121024
1000,
10131025
vec![],
1026+
Default::default(),
1027+
None,
10141028
#[cfg(feature = "bench")]
10151029
0,
10161030
)

types/src/engine_client.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ engine_newPayloadV3 : This is called to store(not commit) and validate blocks re
1818
1919
*/
2020
use alloy_eips::eip4895::Withdrawal;
21+
use alloy_primitives::{Address, FixedBytes};
2122
use alloy_provider::{ProviderBuilder, RootProvider, ext::EngineApi};
2223
use alloy_rpc_types_engine::{
2324
ExecutionPayloadEnvelopeV4, ForkchoiceState, PayloadAttributes, PayloadId, PayloadStatus,
@@ -34,6 +35,8 @@ pub trait EngineClient: Clone + Send + Sync + 'static {
3435
fork_choice_state: ForkchoiceState,
3536
timestamp: u64,
3637
withdrawals: Vec<Withdrawal>,
38+
suggested_fee_recipient: Address,
39+
parent_beacon_block_root: Option<FixedBytes<32>>,
3740
#[cfg(feature = "bench")] height: u64,
3841
) -> impl Future<Output = Option<PayloadId>> + Send;
3942

@@ -90,16 +93,18 @@ impl EngineClient for RethEngineClient {
9093
fork_choice_state: ForkchoiceState,
9194
timestamp: u64,
9295
withdrawals: Vec<Withdrawal>,
96+
suggested_fee_recipient: Address,
97+
parent_beacon_block_root: Option<FixedBytes<32>>,
9398
#[cfg(feature = "bench")] _height: u64,
9499
) -> Option<PayloadId> {
95100
let payload_attributes = PayloadAttributes {
96101
timestamp,
97102
prev_randao: [0; 32].into(),
98103
// todo(dalton): this should be the validators public key
99-
suggested_fee_recipient: [1; 20].into(),
104+
suggested_fee_recipient,
100105
withdrawals: Some(withdrawals),
101106
// todo(dalton): we should make this something that we can associate with the simplex height
102-
parent_beacon_block_root: Some([1; 32].into()),
107+
parent_beacon_block_root,
103108
};
104109

105110
let res = match self
@@ -195,7 +200,7 @@ pub mod benchmarking {
195200
use crate::{Block, Digest};
196201
use alloy_eips::eip4895::Withdrawal;
197202
use alloy_eips::eip7685::Requests;
198-
use alloy_primitives::{B256, FixedBytes, U256};
203+
use alloy_primitives::{Address, B256, FixedBytes, U256};
199204
use alloy_provider::{ProviderBuilder, RootProvider, ext::EngineApi};
200205
use alloy_rpc_types_engine::{
201206
ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadV3,
@@ -230,6 +235,8 @@ pub mod benchmarking {
230235
_fork_choice_state: ForkchoiceState,
231236
_timestamp: u64,
232237
_withdrawals: Vec<Withdrawal>,
238+
_suggested_fee_recipient: Address,
239+
_parent_beacon_block_hash: Option<FixedBytes<32>>,
233240
#[cfg(feature = "bench")] height: u64,
234241
) -> Option<PayloadId> {
235242
let next_block_num = height + 1;

types/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod scheme;
1919
pub mod utils;
2020
pub mod withdrawal;
2121

22+
use alloy_primitives::Address;
2223
use alloy_rpc_types_engine::ForkchoiceState;
2324
pub use block::*;
2425
pub use engine_client::*;
@@ -44,6 +45,7 @@ pub struct BlockAuxData {
4445
pub added_validators: Vec<AddedValidator>,
4546
pub removed_validators: Vec<PublicKey>,
4647
pub forkchoice: ForkchoiceState,
48+
pub withdrawal_credentials: Address,
4749
}
4850

4951
pub use commonware_cryptography::bls12381;

0 commit comments

Comments
 (0)