Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f555656
strategy
Dec 7, 2025
20e923d
allow to specify tree on construction of sled_db
Dec 8, 2025
ed7914b
apply traits to sled_db
Dec 8, 2025
de7e914
header
Dec 8, 2025
812fa67
refactor sled_db
Dec 8, 2025
376fbcf
add header
Dec 8, 2025
10a9a53
setup in memory data structures
Dec 8, 2025
950714f
setup inmem hlcstore
Dec 8, 2025
8608b91
update to simplify event store
Dec 8, 2025
b461f3b
move event_bus_factory to ciphernode_builder
Dec 9, 2025
8404304
refactor to event system factory
Dec 10, 2025
115e38a
header
Dec 11, 2025
33fe9ac
header
Dec 11, 2025
82fbc10
compiling
Dec 11, 2025
0775ebb
update in mem log
Dec 11, 2025
29dc152
get tests passing
Dec 11, 2025
7ec690f
add comments to event system for clarity
Dec 11, 2025
f03006a
remove redunant imports
Dec 11, 2025
f02003c
add todos
Dec 11, 2025
eeb1b39
fix issues
Dec 11, 2025
b5d1956
implement InMemSequenceIndex
Dec 11, 2025
28ab74d
connect up enclave factory method
Dec 11, 2025
a55ff36
fix up testing
Dec 11, 2025
3ad90e3
add comment
Dec 11, 2025
b448c0b
add buffer implementation
Dec 11, 2025
e99e4b1
add batch to sled
Dec 11, 2025
fe4f0da
hook up batch insert
Dec 11, 2025
edc8544
dont build evm
Dec 11, 2025
a4028a6
add solc and jq
Dec 12, 2025
2997af0
use image tag based on commit
Dec 12, 2025
d3729df
--wip-- [skip ci]
Dec 12, 2025
d81bd36
Unit test eventsystem
Dec 13, 2025
323366e
--wip-- [skip ci]
Dec 13, 2025
756bb06
add piping
Dec 16, 2025
2529464
refactor ciphernodeselector
Dec 16, 2025
4d2f556
remove test stop
Dec 16, 2025
0ee7914
tidy up
Dec 16, 2025
12551e4
Merge branch 'main' into ry/1050-storage
ryardley Dec 16, 2025
9fd60d4
fix missing await and add color utils for debugging
Dec 17, 2025
57dd201
implement commit log and tidy up
Dec 17, 2025
d396f07
remove unused dep
Dec 17, 2025
866679a
remove unused dep
Dec 17, 2025
5cebe4b
remove comments
Dec 17, 2025
6dacec4
use persistence
Dec 17, 2025
83698b0
update eventstore limit
Dec 17, 2025
467939d
update eventstore limit
Dec 17, 2025
895276e
add event context
Dec 17, 2025
1ef1a88
tidy up pr
Dec 17, 2025
30537f9
tidy up unused imports
Dec 17, 2025
c43a73d
add comments
Dec 17, 2025
794bc89
add comments
Dec 17, 2025
6ac6835
remove e3 meta once request is complete
Dec 17, 2025
73a2cf0
Update crates/ciphernode-builder/src/event_system.rs
ryardley Dec 17, 2025
fc31deb
Update crates/data/src/in_mem_sequence_index.rs
ryardley Dec 17, 2025
5d8b314
Update crates/events/src/traits.rs
ryardley Dec 17, 2025
f2f67f8
Update crates/net/src/document_publisher.rs
ryardley Dec 17, 2025
8d3c84b
Update crates/config/src/paths_engine.rs
ryardley Dec 17, 2025
f3893d1
add logging when requested
Dec 17, 2025
ca01581
remove redundant struct
Dec 17, 2025
0b11081
remove inaccurate comments
Dec 17, 2025
f917621
Merge branch 'main' into ry/1050-storage
ryardley Dec 17, 2025
18beae9
update to use addr as the node id
Dec 17, 2025
1b37e3f
Remove comment
Dec 17, 2025
42dc92e
Merge branch 'main' into ry/1050-storage
ryardley Dec 18, 2025
b9dad49
Merge branch 'main' into ry/1050-storage
hmzakhalid Dec 22, 2025
7328f4d
Merge branch 'main' into ry/1050-storage
ryardley Dec 23, 2025
3dc7a0b
fix bug with offset not updating
Dec 23, 2025
5400f03
ensure index cannot have a value already stored at timestamp
Dec 23, 2025
ffee673
add panic instead of just logging
Dec 23, 2025
8cbd0ef
remove extra bus
Dec 23, 2025
c910511
update to avoid bug in seek return
Dec 23, 2025
f80f522
Merge branch 'main' into ry/1050-storage
ryardley Dec 24, 2025
8006ff1
Merge branch 'main' into ry/1050-storage
hmzakhalid Dec 24, 2025
99f398c
Merge branch 'main' into ry/1050-storage
hmzakhalid Dec 24, 2025
956916a
Merge branch 'main' into ry/1050-storage
ryardley Dec 27, 2025
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
53 changes: 53 additions & 0 deletions 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 @@ -115,6 +115,7 @@ bs58 = "=0.5.1"
base64 = "=0.22.1"
clap = { version = "=4.5.41", features = ["derive"] }
chrono = { version = "=0.4.41", features = ["serde"] }
commitlog = "=0.2.0"
compile-time = "=0.2.0"
derivative = "=2.2.0"
dirs = "=5.0.1"
Expand Down
4 changes: 4 additions & 0 deletions crates/ciphernode-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ actix.workspace = true
alloy.workspace = true
anyhow.workspace = true
derivative.workspace = true
once_cell.workspace = true
e3-aggregator.workspace = true
e3-crypto.workspace = true
e3-config.workspace = true
Expand All @@ -24,4 +25,7 @@ e3-request.workspace = true
e3-sortition.workspace = true
e3-trbfv.workspace = true
e3-utils.workspace = true
tempfile.workspace = true
tokio.workspace = true
tracing.workspace = true
bincode.workspace = true
75 changes: 54 additions & 21 deletions crates/ciphernode-builder/src/ciphernode_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.

use crate::CiphernodeHandle;
use crate::{CiphernodeHandle, EventSystem};
use actix::{Actor, Addr};
use alloy::signers::{k256::ecdsa::SigningKey, local::LocalSigner};
use anyhow::Result;
Expand All @@ -15,8 +15,8 @@ use e3_aggregator::ext::{
};
use e3_config::chain_config::ChainConfig;
use e3_crypto::Cipher;
use e3_data::{DataStore, InMemStore, Repositories, RepositoriesFactory};
use e3_events::{BusHandle, EnclaveEvent, EventBus, EventBusConfig};
use e3_data::{InMemStore, Repositories, RepositoriesFactory};
use e3_events::{EnclaveEvent, EventBus, EventBusConfig};
use e3_evm::{
helpers::{
load_signer_from_repository, ConcreteReadProvider, ConcreteWriteProvider, EthProvider,
Expand All @@ -32,28 +32,36 @@ use e3_keyshare::ext::{KeyshareExtension, ThresholdKeyshareExtension};
use e3_multithread::Multithread;
use e3_request::E3Router;
use e3_sortition::{
CiphernodeSelector, FinalizedCommitteesRepositoryFactory, NodeStateRepositoryFactory,
Sortition, SortitionBackend, SortitionRepositoryFactory,
CiphernodeSelector, CiphernodeSelectorFactory, FinalizedCommitteesRepositoryFactory,
NodeStateRepositoryFactory, Sortition, SortitionBackend, SortitionRepositoryFactory,
};
use e3_utils::{rand_eth_addr, SharedRng};
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use tracing::{error, info};

#[derive(Clone, Debug)]
enum EventSystemType {
Persisted { log_path: PathBuf, kv_path: PathBuf },
InMem,
}

/// Build a ciphernode configuration.
// NOTE: We could use a typestate pattern here to separate production and testing methods. I hummed
// and hawed about it for quite a while and in the end felt it was too complex while we dont know
// the exact configurations we will use yet
#[derive(Derivative)]
#[derivative(Debug)]
pub struct CiphernodeBuilder {
name: String,
address: Option<String>,
chains: Vec<ChainConfig>,
#[derivative(Debug = "ignore")]
cipher: Arc<Cipher>,
contract_components: ContractComponents,
datastore: Option<DataStore>,
in_mem_store: Option<Addr<InMemStore>>,
keyshare: Option<KeyshareKind>,
logging: bool,
event_system: EventSystemType,
multithread_cache: Option<Addr<Multithread>>,
multithread_concurrent_jobs: Option<usize>,
multithread_capture_events: bool,
Expand Down Expand Up @@ -89,19 +97,26 @@ pub enum KeyshareKind {
}

impl CiphernodeBuilder {
pub fn new(rng: SharedRng, cipher: Arc<Cipher>) -> Self {
/// Create a new ciphernode builder.
///
/// - name - Unique name for the ciphernode
/// - rng - Arc Mutex wrapped random number generator
/// - cipher - Cipher for encryption and decryption of sensitive data
pub fn new(name: &str, rng: SharedRng, cipher: Arc<Cipher>) -> Self {
Self {
name: name.to_owned(),
address: None,
chains: vec![],
cipher,
contract_components: ContractComponents::default(),
datastore: None,
in_mem_store: None,
keyshare: None,
logging: false,
multithread_cache: None,
plaintext_agg: false,
pubkey_agg: false,
multithread_concurrent_jobs: None,
event_system: EventSystemType::InMem,
rng,
source_bus: None,
sortition_backend: SortitionBackend::score(),
Expand Down Expand Up @@ -139,9 +154,19 @@ impl CiphernodeBuilder {
self
}

/// Attach an existing in mem store to the node
pub fn with_datastore(mut self, store: DataStore) -> Self {
self.datastore = Some(store);
/// Use the given in-mem datastore. This is useful for injecting a store dump.
pub fn with_in_mem_datastore(mut self, store: &Addr<InMemStore>) -> Self {
self.in_mem_store = Some(store.to_owned());
self
}

/// Add persistence information for storing events and data. Without persistence information
/// the node will run in memory by default.
pub fn with_persistence(mut self, log_path: &PathBuf, kv_path: &PathBuf) -> Self {
self.event_system = EventSystemType::Persisted {
log_path: log_path.to_owned(),
kv_path: kv_path.to_owned(),
};
self
}
Comment thread
ryardley marked this conversation as resolved.

Expand All @@ -166,7 +191,7 @@ impl CiphernodeBuilder {
self
}

/// Use the given Address to represent the node
/// Use the given Address to represent the node. This should be unique.
pub fn with_address(mut self, addr: &str) -> Self {
self.address = Some(addr.to_owned());
self
Expand Down Expand Up @@ -298,9 +323,6 @@ impl CiphernodeBuilder {
None
};

// Get a handle from the event bus
let bus = BusHandle::new_from_consumer(local_bus);

let addr = if let Some(addr) = self.address.clone() {
info!("Using eth address = {}", addr);
addr
Expand All @@ -310,10 +332,20 @@ impl CiphernodeBuilder {
rand_eth_addr(&self.rng)
};

let store = self
.datastore
.clone()
.unwrap_or_else(|| (&InMemStore::new(self.logging).start()).into());
// Get an event system instance.
let event_system =
if let EventSystemType::Persisted { kv_path, log_path } = self.event_system.clone() {
EventSystem::persisted(&addr, log_path, kv_path).with_event_bus(local_bus)
} else {
if let Some(ref store) = self.in_mem_store {
EventSystem::in_mem_from_store(&addr, store).with_event_bus(local_bus)
} else {
EventSystem::in_mem(&addr).with_event_bus(local_bus)
}
};

let bus = event_system.handle()?;
let store = event_system.store()?;

let repositories = store.repositories();

Expand All @@ -329,7 +361,8 @@ impl CiphernodeBuilder {
)
.await?;

CiphernodeSelector::attach(&bus, &sortition, &addr, &store);
CiphernodeSelector::attach(&bus, &sortition, repositories.ciphernode_selector(), &addr)
.await?;

let mut provider_cache = ProviderCaches::new();
let cipher = &self.cipher;
Expand Down
Loading
Loading