Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = [
"crates/common/operation_pool",
"crates/common/polynomial_commitments",
"crates/common/sync",
"crates/common/sync_committee_pool",
"crates/common/validator/beacon",
"crates/common/validator/lean",
"crates/crypto/bls",
Expand Down Expand Up @@ -161,6 +162,7 @@ ream-rpc-common = { path = "crates/rpc/common" }
ream-rpc-lean = { path = "crates/rpc/lean" }
ream-storage = { path = "crates/storage" }
ream-sync = { path = "crates/common/sync" }
ream-sync-committee-pool = { path = "crates/common/sync_committee_pool" }
ream-syncer = { path = "crates/networking/syncer" }
ream-validator-beacon = { path = "crates/common/validator/beacon" }
ream-validator-lean = { path = "crates/common/validator/lean" }
Expand Down
1 change: 1 addition & 0 deletions bin/ream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ream-rpc-beacon.workspace = true
ream-rpc-lean.workspace = true
ream-storage.workspace = true
ream-sync.workspace = true
ream-sync-committee-pool.workspace = true
ream-validator-beacon.workspace = true
ream-validator-lean.workspace = true

Expand Down
4 changes: 4 additions & 0 deletions bin/ream/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use ream_storage::{
tables::table::Table,
};
use ream_sync::rwlock::Writer;
use ream_sync_committee_pool::SyncCommitteePool;
use ream_validator_beacon::{
beacon_api_client::BeaconApiClient, validator::ValidatorService,
voluntary_exit::process_voluntary_exit,
Expand Down Expand Up @@ -305,6 +306,7 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
);

let operation_pool = Arc::new(OperationPool::default());
let sync_committee_pool = Arc::new(SyncCommitteePool::default());

let server_config = RpcServerConfig::new(
config.http_address,
Expand All @@ -318,6 +320,7 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
beacon_db.clone(),
beacon_db.data_dir.clone(),
operation_pool.clone(),
sync_committee_pool.clone(),
)
.await
.expect("Failed to create manager service");
Expand All @@ -336,6 +339,7 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
beacon_db,
network_state,
operation_pool,
sync_committee_pool,
execution_engine,
)
.await
Expand Down
7 changes: 7 additions & 0 deletions crates/common/api_types/beacon/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ pub struct AttestationQuery {
pub committee_index: u64,
}

#[derive(Debug, Deserialize)]
pub struct SyncCommitteeContributionQuery {
pub slot: u64,
pub subcommittee_index: u64,
pub beacon_block_root: B256,
}

impl StatusQuery {
pub fn has_status(&self) -> bool {
match &self.status {
Expand Down
1 change: 1 addition & 0 deletions crates/common/chain/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ream-network-spec.workspace = true
ream-operation-pool.workspace = true
ream-p2p.workspace = true
ream-storage.workspace = true
ream-sync-committee-pool.workspace = true

[lints]
workspace = true
4 changes: 3 additions & 1 deletion crates/common/chain/beacon/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ream_storage::{
db::beacon::BeaconDB,
tables::{field::Field, table::Table},
};
use ream_sync_committee_pool::SyncCommitteePool;
use tokio::sync::Mutex;
use tracing::warn;

Expand All @@ -32,10 +33,11 @@ impl BeaconChain {
pub fn new(
db: BeaconDB,
operation_pool: Arc<OperationPool>,
sync_committee_pool: Arc<SyncCommitteePool>,
execution_engine: Option<ExecutionEngine>,
) -> Self {
Self {
store: Mutex::new(Store::new(db, operation_pool)),
store: Mutex::new(Store::new(db, operation_pool, Some(sync_committee_pool))),
execution_engine,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/common/fork_choice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ream-network-spec.workspace = true
ream-operation-pool.workspace = true
ream-polynomial-commitments.workspace = true
ream-storage.workspace = true
ream-sync-committee-pool.workspace = true

[lints]
workspace = true
24 changes: 21 additions & 3 deletions crates/common/fork_choice/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use ream_storage::{
db::beacon::BeaconDB,
tables::{field::Field, multimap_table::MultimapTable, table::Table},
};
use ream_sync_committee_pool::SyncCommitteePool;
use tree_hash::TreeHash;

use crate::constants::{
Expand All @@ -46,11 +47,22 @@ pub struct BlockWithEpochInfo {
pub struct Store {
pub db: BeaconDB,
pub operation_pool: Arc<OperationPool>,
pub sync_committee_pool: Arc<SyncCommitteePool>,
}

impl Store {
pub fn new(db: BeaconDB, operation_pool: Arc<OperationPool>) -> Self {
Self { db, operation_pool }
pub fn new(
db: BeaconDB,
operation_pool: Arc<OperationPool>,
sync_committee_pool: Option<Arc<SyncCommitteePool>>,
) -> Self {
let sync_committee_pool =
sync_committee_pool.unwrap_or_else(|| Arc::new(SyncCommitteePool::default()));
Self {
db,
operation_pool,
sync_committee_pool,
}
}

pub fn is_previous_epoch_justified(&self) -> anyhow::Result<bool> {
Expand Down Expand Up @@ -594,6 +606,12 @@ impl Store {
// If this is a new slot, reset store.proposer_boost_root
if current_slot > previous_slot {
self.db.proposer_boost_root_provider().insert(B256::ZERO)?;

// Clean old sync committee messages and contributions per slot
self.sync_committee_pool
.clean_sync_committee_messages(current_slot);
self.sync_committee_pool
.clean_sync_committee_contributions(current_slot);
}

// If a new epoch, pull-up justification and finalization from previous epoch
Expand Down Expand Up @@ -880,7 +898,7 @@ pub fn get_forkchoice_store(

let operation_pool = Arc::new(OperationPool::default());

Ok(Store { db, operation_pool })
Ok(Store::new(db, operation_pool, None))
}

pub fn compute_slots_since_epoch_start(slot: u64) -> u64 {
Expand Down
27 changes: 27 additions & 0 deletions crates/common/sync_committee_pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "ream-sync-committee-pool"
authors.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[dependencies]
alloy-primitives.workspace = true
parking_lot.workspace = true
serde.workspace = true
ssz_types.workspace = true
thiserror.workspace = true
tracing.workspace = true
tree_hash.workspace = true
tree_hash_derive.workspace = true

# ream-dependencies
ream-bls.workspace = true
ream-validator-beacon.workspace = true

[lints]
workspace = true
Loading
Loading