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
107 changes: 106 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ tree_hash_derive = "0.9.1"
vergen-git2 = { version = "9", features = ["rustc"] }

rand = "0.9"
rocksdb = "0.24"
6 changes: 4 additions & 2 deletions bin/ethlambda/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
collections::{BTreeMap, HashMap},
net::{IpAddr, SocketAddr},
path::{Path, PathBuf},
sync::Arc,
};

use clap::Parser;
Expand All @@ -19,7 +20,7 @@ use tracing::{error, info};
use tracing_subscriber::{EnvFilter, Layer, Registry, layer::SubscriberExt};

use ethlambda_blockchain::BlockChain;
use ethlambda_storage::Store;
use ethlambda_storage::{Store, backend::RocksDBBackend};

const ASCII_ART: &str = r#"
_ _ _ _ _
Expand Down Expand Up @@ -91,7 +92,8 @@ async fn main() {
read_validator_keys(&validators_path, &validator_keys_dir, &options.node_id);

let genesis_state = State::from_genesis(&genesis, validators);
let store = Store::from_genesis(genesis_state);
let backend = Arc::new(RocksDBBackend::open("./data").expect("Failed to open RocksDB"));
let store = Store::from_genesis(backend, genesis_state);

let (p2p_tx, p2p_rx) = tokio::sync::mpsc::unbounded_channel();
let blockchain = BlockChain::spawn(store.clone(), p2p_tx, validator_keys);
Expand Down
6 changes: 4 additions & 2 deletions crates/blockchain/tests/forkchoice_spectests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::{
collections::{HashMap, HashSet},
path::Path,
sync::Arc,
};

use ethlambda_blockchain::{SECONDS_PER_SLOT, store};
use ethlambda_storage::Store;
use ethlambda_storage::{Store, backend::InMemoryBackend};
use ethlambda_types::{
attestation::Attestation,
block::{Block, BlockSignatures, BlockWithAttestation, SignedBlockWithAttestation},
Expand Down Expand Up @@ -35,7 +36,8 @@ fn run(path: &Path) -> datatest_stable::Result<()> {
let anchor_state: State = test.anchor_state.into();
let anchor_block: Block = test.anchor_block.into();
let genesis_time = anchor_state.config.genesis_time;
let mut store = Store::get_forkchoice_store(anchor_state, anchor_block);
let backend = Arc::new(InMemoryBackend::new());
let mut store = Store::get_forkchoice_store(backend, anchor_state, anchor_block);

// Block registry: maps block labels to their roots
let mut block_registry: HashMap<String, H256> = HashMap::new();
Expand Down
6 changes: 4 additions & 2 deletions crates/blockchain/tests/signature_spectests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::path::Path;
use std::sync::Arc;

use ethlambda_blockchain::{SECONDS_PER_SLOT, store};
use ethlambda_storage::Store;
use ethlambda_storage::{Store, backend::InMemoryBackend};
use ethlambda_types::{
block::{Block, SignedBlockWithAttestation},
primitives::TreeHash,
Expand Down Expand Up @@ -41,7 +42,8 @@ fn run(path: &Path) -> datatest_stable::Result<()> {

// Initialize the store with the anchor state and block
let genesis_time = anchor_state.config.genesis_time;
let mut st = Store::get_forkchoice_store(anchor_state, anchor_block);
let backend = Arc::new(InMemoryBackend::new());
let mut st = Store::get_forkchoice_store(backend, anchor_state, anchor_block);

// Step 2: Run the state transition function with the block fixture
let signed_block: SignedBlockWithAttestation = test.signed_block_with_attestation.into();
Expand Down
9 changes: 6 additions & 3 deletions crates/net/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ mod tests {
body::Body,
http::{Request, StatusCode},
};
use ethlambda_storage::Store;
use ethlambda_storage::{Store, backend::InMemoryBackend};
use ethlambda_types::{
block::{BlockBody, BlockHeader},
primitives::TreeHash,
state::{ChainConfig, Checkpoint, JustificationValidators, JustifiedSlots, State},
};
use http_body_util::BodyExt;
use serde_json::json;
use std::sync::Arc;
use tower::ServiceExt;

/// Create a minimal test state for testing.
Expand Down Expand Up @@ -116,7 +117,8 @@ mod tests {
#[tokio::test]
async fn test_get_latest_justified_checkpoint() {
let state = create_test_state();
let store = Store::from_genesis(state);
let backend = Arc::new(InMemoryBackend::new());
let store = Store::from_genesis(backend, state);

let app = build_api_router(store.clone());

Expand Down Expand Up @@ -151,7 +153,8 @@ mod tests {
use ethlambda_types::primitives::Encode;

let state = create_test_state();
let store = Store::from_genesis(state);
let backend = Arc::new(InMemoryBackend::new());
let store = Store::from_genesis(backend, state);

// Get the expected state from the store
let finalized = store.latest_finalized();
Expand Down
4 changes: 4 additions & 0 deletions crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ version.workspace = true
ethlambda-types.workspace = true

tracing.workspace = true
rocksdb.workspace = true

[dev-dependencies]
tempfile = "3"
Loading