Skip to content
Merged
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
14 changes: 9 additions & 5 deletions bin/ream/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use ream_post_quantum_crypto::leansig::{
};
use ream_rpc_common::config::RpcServerConfig;
use ream_storage::{
cache::{BeaconCacheDB, LeanCacheDB},
db::{ReamDB, reset_db},
dir::setup_data_dir,
tables::table::REDBTable,
Expand Down Expand Up @@ -190,9 +191,11 @@ pub async fn run_lean_node(config: LeanNodeConfig, executor: ReamExecutor, ream_
set_lean_network_spec(Arc::new(network));

// Initialize the lean database
let cache = Arc::new(LeanCacheDB::new());
let lean_db = ream_db
.init_lean_db()
.expect("unable to init Ream Lean Database");
.expect("unable to init Ream Lean Database")
.with_cache(cache);

info!("ream lean database has been initialized");

Expand Down Expand Up @@ -320,9 +323,11 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
set_beacon_network_spec(config.network.clone());

// Initialize the beacon database
let cache = Arc::new(BeaconCacheDB::new());
let beacon_db = ream_db
.init_beacon_db()
.expect("unable to init Ream Beacon Database");
.expect("unable to init Ream Beacon Database")
.with_cache(cache.clone());

info!("ream beacon database has been initialized");

Expand Down Expand Up @@ -396,7 +401,6 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
execution_engine.clone(),
Some(event_sender.clone()),
));
let cached_db = Arc::new(ream_storage::cache::CachedDB::new());

// Create network manager
let network_manager = NetworkManagerService::new(
Expand All @@ -405,7 +409,7 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
beacon_db.clone(),
beacon_db.data_dir.clone(),
beacon_chain.clone(),
cached_db.clone(),
cache.clone(),
)
.await
.expect("Failed to create manager service");
Expand All @@ -428,7 +432,7 @@ pub async fn run_beacon_node(config: BeaconNodeConfig, executor: ReamExecutor, r
event_sender,
beacon_chain,
p2p_sender,
cached_db,
cache,
)
.await
});
Expand Down
4 changes: 2 additions & 2 deletions crates/networking/manager/src/gossipsub/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ream_p2p::{
},
network::beacon::channel::GossipMessage,
};
use ream_storage::{cache::CachedDB, tables::table::CustomTable};
use ream_storage::{cache::BeaconCacheDB, tables::table::CustomTable};
use ream_validator_beacon::{
blob_sidecars::compute_subnet_for_blob_sidecar, constants::SYNC_COMMITTEE_SUBNET_COUNT,
};
Expand Down Expand Up @@ -122,7 +122,7 @@ pub fn init_gossipsub_config_with_topics() -> GossipsubConfig {
pub async fn handle_gossipsub_message(
message: Message,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
p2p_sender: &P2PSender,
) {
match GossipsubMessage::decode(&message.topic, &message.data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ream_consensus_misc::{
};
use ream_network_spec::networks::beacon_network_spec;
use ream_storage::{
cache::{AggregateAndProofKey, CachedDB},
cache::{AggregateAndProofKey, BeaconCacheDB},
tables::table::REDBTable,
};
use ream_validator_beacon::{
Expand All @@ -23,7 +23,7 @@ use super::result::ValidationResult;
pub async fn validate_aggregate_and_proof(
signed_aggregate_and_proof: &SignedAggregateAndProof,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use ream_chain_beacon::beacon_chain::BeaconChain;
use ream_consensus_beacon::{
attester_slashing::AttesterSlashing, electra::beacon_state::BeaconState,
};
use ream_storage::{cache::CachedDB, tables::table::REDBTable};
use ream_storage::{cache::BeaconCacheDB, tables::table::REDBTable};

use super::result::ValidationResult;

pub async fn validate_attester_slashing(
attester_slashing: &AttesterSlashing,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;
let head_root = store.get_head()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ream_consensus_misc::{
misc::{compute_epoch_at_slot, compute_signing_root},
};
use ream_storage::{
cache::{AtestationKey, CachedDB},
cache::{AtestationKey, BeaconCacheDB},
tables::{field::REDBField, table::REDBTable},
};
use ream_validator_beacon::attestation::compute_subnet_for_attestation;
Expand All @@ -20,7 +20,7 @@ pub async fn validate_beacon_attestation(
attestation: &SingleAttestation,
beacon_chain: &BeaconChain,
attestation_subnet_id: u64,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use ream_consensus_misc::{
use ream_execution_engine::new_payload_request::NewPayloadRequest;
use ream_execution_rpc_types::payload_status::PayloadStatus;
use ream_storage::{
cache::{AddressSlotIdentifier, CachedDB},
cache::{AddressSlotIdentifier, BeaconCacheDB},
tables::{field::REDBField, table::REDBTable},
};

use super::result::ValidationResult;

pub async fn validate_gossip_beacon_block(
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
block: &SignedBeaconBlock,
) -> anyhow::Result<ValidationResult> {
let latest_state = beacon_chain.store.lock().await.db.get_latest_state()?;
Expand Down Expand Up @@ -89,7 +89,7 @@ pub async fn validate_gossip_beacon_block(

pub async fn validate_beacon_block(
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
block: &SignedBeaconBlock,
state: &BeaconState,
is_parent: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ream_consensus_misc::{
};
use ream_polynomial_commitments::handlers::verify_blob_kzg_proof_batch;
use ream_storage::{
cache::CachedDB,
cache::BeaconCacheDB,
tables::{field::REDBField, table::REDBTable},
};
use ream_validator_beacon::blob_sidecars::compute_subnet_for_blob_sidecar;
Expand All @@ -17,7 +17,7 @@ pub async fn validate_blob_sidecar(
beacon_chain: &BeaconChain,
blob_sidecar: &BlobSidecar,
subnet_id: u64,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
// [REJECT] The sidecar's index is consistent with MAX_BLOBS_PER_BLOCK
if blob_sidecar.index >= MAX_BLOBS_PER_BLOCK_ELECTRA {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ream_consensus_beacon::{
};
use ream_network_spec::networks::beacon_network_spec;
use ream_storage::{
cache::{AddressValidaterIndexIdentifier, CachedDB},
cache::{AddressValidaterIndexIdentifier, BeaconCacheDB},
tables::table::REDBTable,
};

Expand All @@ -14,7 +14,7 @@ use super::result::ValidationResult;
pub async fn validate_bls_to_execution_change(
signed: &SignedBLSToExecutionChange,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ream_consensus_beacon::data_column_sidecar::DataColumnSidecar;
use ream_consensus_misc::misc::compute_start_slot_at_epoch;
use ream_polynomial_commitments::handlers::verify_cell_kzg_proof_batch;
use ream_storage::{
cache::CachedDB,
cache::BeaconCacheDB,
tables::{field::REDBField, table::REDBTable},
};

Expand All @@ -14,7 +14,7 @@ pub async fn validate_data_column_sidecar_full(
data_column_sidecar: &DataColumnSidecar,
beacon_chain: &BeaconChain,
subnet_id: u64,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
if !data_column_sidecar.verify() {
return Ok(ValidationResult::Reject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use anyhow::Ok;
use ream_consensus_misc::constants::beacon::SYNC_COMMITTEE_SIZE;
use ream_light_client::finality_update::LightClientFinalityUpdate;
use ream_network_spec::networks::{beacon_network_spec, lean_network_spec};
use ream_storage::cache::CachedDB;
use ream_storage::cache::BeaconCacheDB;

use crate::gossipsub::validate::result::ValidationResult;

pub async fn validate_light_client_finality_update(
update: &LightClientFinalityUpdate,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
// [IGNORE] The finalized header is greater than that of all previously forwarded finality
// updates or it matches the highest previously forwarded slot and also has a supermajority
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use anyhow::anyhow;
use ream_chain_beacon::beacon_chain::BeaconChain;
use ream_light_client::optimistic_update::LightClientOptimisticUpdate;
use ream_network_spec::networks::{beacon_network_spec, lean_network_spec};
use ream_storage::{cache::CachedDB, tables::table::REDBTable};
use ream_storage::{cache::BeaconCacheDB, tables::table::REDBTable};

use crate::gossipsub::validate::result::ValidationResult;

pub async fn validate_light_client_optimistic_update(
light_client_optimistic_update: &LightClientOptimisticUpdate,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;
let head_root = store.get_head()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use ream_chain_beacon::beacon_chain::BeaconChain;
use ream_consensus_beacon::{
electra::beacon_state::BeaconState, proposer_slashing::ProposerSlashing,
};
use ream_storage::{cache::CachedDB, tables::table::REDBTable};
use ream_storage::{cache::BeaconCacheDB, tables::table::REDBTable};

use super::result::ValidationResult;

pub async fn validate_proposer_slashing(
proposer_slashing: &ProposerSlashing,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let proposer_index = proposer_slashing.signed_header_1.message.proposer_index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ream_consensus_misc::{
misc::{compute_epoch_at_slot, compute_signing_root},
};
use ream_storage::{
cache::{CachedDB, SyncCommitteeKey},
cache::{BeaconCacheDB, SyncCommitteeKey},
tables::table::REDBTable,
};
use ream_validator_beacon::sync_committee::{
Expand All @@ -20,7 +20,7 @@ pub async fn validate_sync_committee(
message: &SyncCommitteeMessage,
beacon_chain: &BeaconChain,
subnet_id: u64,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ream_consensus_misc::{
};
use ream_events_beacon::contribution_and_proof::SignedContributionAndProof;
use ream_storage::{
cache::{CacheSyncCommitteeContribution, CachedDB, SyncCommitteeKey},
cache::{BeaconCacheDB, CacheSyncCommitteeContribution, SyncCommitteeKey},
tables::table::REDBTable,
};
use ream_validator_beacon::{
Expand All @@ -23,7 +23,7 @@ use super::result::ValidationResult;

pub async fn validate_sync_committee_contribution_and_proof(
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
signed_contribution_and_proof: &SignedContributionAndProof,
) -> anyhow::Result<ValidationResult> {
let contribution_and_proof = &signed_contribution_and_proof.message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use ream_chain_beacon::beacon_chain::BeaconChain;
use ream_consensus_beacon::{
electra::beacon_state::BeaconState, voluntary_exit::SignedVoluntaryExit,
};
use ream_storage::{cache::CachedDB, tables::table::REDBTable};
use ream_storage::{cache::BeaconCacheDB, tables::table::REDBTable};

use super::result::ValidationResult;

pub async fn validate_voluntary_exit(
voluntary_exit: &SignedVoluntaryExit,
beacon_chain: &BeaconChain,
cached_db: &CachedDB,
cached_db: &BeaconCacheDB,
) -> anyhow::Result<ValidationResult> {
let store = beacon_chain.store.lock().await;

Expand Down
6 changes: 3 additions & 3 deletions crates/networking/manager/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ream_p2p::{
config::NetworkConfig,
network::beacon::{Network, ReamNetworkEvent, network_state::NetworkState},
};
use ream_storage::{cache::CachedDB, db::beacon::BeaconDB};
use ream_storage::{cache::BeaconCacheDB, db::beacon::BeaconDB};
use ream_syncer::block_range::BlockRangeSyncer;
use tokio::{sync::mpsc, time::interval};
use tracing::{error, info};
Expand All @@ -34,7 +34,7 @@ pub struct NetworkManagerService {
pub network_state: Arc<NetworkState>,
pub block_range_syncer: BlockRangeSyncer,
pub ream_db: BeaconDB,
pub cached_db: Arc<CachedDB>,
pub cached_db: Arc<BeaconCacheDB>,
}

/// The `NetworkManagerService` acts as the manager for all networking activities in Ream.
Expand All @@ -57,7 +57,7 @@ impl NetworkManagerService {
ream_db: BeaconDB,
ream_dir: PathBuf,
beacon_chain: Arc<BeaconChain>,
cached_db: Arc<CachedDB>,
cached_db: Arc<BeaconCacheDB>,
) -> anyhow::Result<Self> {
let discv5_config = discv5::ConfigBuilder::new(discv5::ListenConfig::from_ip(
config.socket_address,
Expand Down
Loading