Skip to content

Commit 91031b3

Browse files
committed
feat: Implement Committee aggregation fork choice logic
1 parent 83a58ca commit 91031b3

File tree

10 files changed

+866
-102
lines changed

10 files changed

+866
-102
lines changed

bin/ream/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ pub async fn run_lean_node(config: LeanNodeConfig, executor: ReamExecutor, ream_
289289
anchor_state,
290290
lean_db,
291291
None,
292+
#[cfg(feature = "devnet3")]
293+
None,
292294
)
293295
.expect("Could not get forkchoice store"),
294296
);

crates/common/chain/lean/src/service.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ impl LeanChainService {
131131
self.sync_status = self.update_sync_status().await?;
132132
}
133133
if self.sync_status == SyncStatus::Synced {
134+
#[cfg(feature = "devnet2")]
134135
self.store.write().await.tick_interval(tick_count % 4 == 1).await.expect("Failed to tick interval");
136+
#[cfg(feature = "devnet3")]
137+
self.store.write().await.tick_interval(tick_count % 4 == 1, false).await.expect("Failed to tick interval");
135138
self.step_head_sync(tick_count).await?;
136139
}
137140

@@ -622,7 +625,10 @@ impl LeanChainService {
622625
.duration_since(UNIX_EPOCH)
623626
.map_err(|err| anyhow!("System time before epoch: {err:?}"))?
624627
.as_secs();
628+
#[cfg(feature = "devnet2")]
625629
self.store.write().await.on_tick(now, false).await?;
630+
#[cfg(feature = "devnet3")]
631+
self.store.write().await.on_tick(now, false, false).await?;
626632
}
627633

628634
Ok(sync_status)
@@ -931,12 +937,20 @@ impl LeanChainService {
931937
&mut self,
932938
signed_attestation: SignedAttestation,
933939
) -> anyhow::Result<()> {
940+
#[cfg(feature = "devnet2")]
934941
self.store
935942
.write()
936943
.await
937944
.on_gossip_attestation(signed_attestation)
938945
.await?;
939946

947+
#[cfg(feature = "devnet3")]
948+
self.store
949+
.write()
950+
.await
951+
.on_gossip_attestation(signed_attestation, false)
952+
.await?;
953+
940954
Ok(())
941955
}
942956

crates/common/chain/lean/src/sync/forward_background_syncer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ impl ForwardBackgroundSyncer {
8080
})?;
8181
let time = lean_network_spec().genesis_time
8282
+ (block.message.block.slot * lean_network_spec().seconds_per_slot);
83+
#[cfg(feature = "devnet2")]
8384
self.store.write().await.on_tick(time, false).await?;
85+
#[cfg(feature = "devnet3")]
86+
self.store.write().await.on_tick(time, false, false).await?;
8487
self.store.write().await.on_block(&block, true).await?;
8588
}
8689

crates/common/consensus/lean/src/attestation.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy_primitives::{B256, FixedBytes};
1+
use alloy_primitives::B256;
22
use ream_post_quantum_crypto::leansig::signature::Signature;
33
use serde::{Deserialize, Serialize};
44
use ssz_derive::{Decode, Encode};
@@ -37,7 +37,7 @@ impl SignatureKey {
3737
}
3838
}
3939

40-
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode)]
40+
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)]
4141
pub struct AggregatedSignatureProof {
4242
pub participants: BitList<U4096>,
4343
pub proof_data: VariableList<u8, U1048576>,
@@ -119,7 +119,6 @@ pub struct AggregatedAttestation {
119119
/// Aggregated attestation bundled with aggregated signatures.
120120
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash)]
121121
pub struct SignedAggregatedAttestation {
122-
pub message: AggregatedAttestation,
123-
/// U4096 = VALIDATOR_REGISTRY_LIMIT
124-
pub signature: VariableList<FixedBytes<4000>, U4096>,
122+
pub data: AttestationData,
123+
pub proof: AggregatedSignatureProof,
125124
}

crates/common/consensus/misc/src/constants/lean.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// 3SF-mini divides a slot into 4 intervals.
22
/// Reference: https://github.com/ethereum/research/blob/d225a6775a9b184b5c1fd6c830cc58a375d9535f/3sf-mini/p2p.py#L77-L98
3+
pub const ATTESTATION_COMMITTEE_COUNT: u64 = 1;
34
pub const INTERVALS_PER_SLOT: u64 = 4;
45
pub const MAX_HISTORICAL_BLOCK_HASHES: u64 = 262144;
56
pub const SLOT_DURATION: u64 = 12;

0 commit comments

Comments
 (0)