Skip to content

Commit

Permalink
refactor: refactor storage code (#1090)
Browse files Browse the repository at this point in the history
* refactor: rename `PortalStorage` to `HistoryStorage`

* refactor: create `trin-storage` workspace crate

* refactor: trin-history storage

* refactor: trin-beacon storage

* refactor: trin-state storage

* refactor: move storage tests

* fix: remove unused crates from portalnet

* fix: address PR comments
  • Loading branch information
ogenev committed Jan 12, 2024
1 parent e19b6b6 commit 4a21a56
Show file tree
Hide file tree
Showing 31 changed files with 2,056 additions and 1,832 deletions.
37 changes: 34 additions & 3 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 @@ -37,6 +37,7 @@ tracing-subscriber = "0.3.15"
trin-beacon = { path = "trin-beacon" }
trin-history = { path = "trin-history" }
trin-state = { path = "trin-state" }
trin-storage = { path = "trin-storage" }
trin-utils = { path = "trin-utils" }
trin-validation = { path = "trin-validation" }
utp-rs = "0.1.0-alpha.8"
Expand All @@ -60,6 +61,7 @@ members = [
"trin-beacon",
"trin-history",
"trin-state",
"trin-storage",
"trin-utils",
"trin-validation",
"utp-testing",
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ COPY ./portal-bridge ./portal-bridge
COPY ./trin-history ./trin-history
COPY ./trin-metrics ./trin-metrics
COPY ./trin-state ./trin-state
COPY ./trin-utils ./trin-utils
COPY ./trin-storage ./trin-storage
COPY ./trin-utils ./trin-utils
COPY ./trin-validation ./trin-validation
COPY ./utp-testing ./utp-testing

Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.bridge
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./portal-bridge ./portal-bridge
COPY ./trin-history ./trin-history
COPY ./trin-metrics ./trin-metrics
COPY ./trin-state ./trin-state
COPY ./trin-storage ./trin-storage
COPY ./trin-utils ./trin-utils
COPY ./trin-validation ./trin-validation
COPY ./ethportal-peertest ./ethportal-peertest
Expand Down
4 changes: 1 addition & 3 deletions portalnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ lru = "0.7.8"
parking_lot = "0.11.2"
rand = "0.8.4"
rlp = "0.5.0"
rusqlite = { version = "0.26.3", features = ["bundled"] }
r2d2 = "0.8.9"
r2d2_sqlite = "0.19.0"
serde = { version = "1.0.150", features = ["derive"] }
serde_json = "1.0.89"
smallvec = "1.8.0"
Expand All @@ -45,6 +42,7 @@ thiserror = "1.0.29"
tokio = { version = "1.14.0", features = ["full"] }
tracing = "0.1.36"
trin-metrics = { path = "../trin-metrics" }
trin-storage = { path = "../trin-storage" }
trin-utils = { path = "../trin-utils" }
trin-validation = { path = "../trin-validation" }
validator = { version = "0.13.0", features = ["derive"] }
Expand Down
1 change: 0 additions & 1 deletion portalnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ pub mod gossip;
pub mod overlay;
pub mod overlay_service;
pub mod socket;
pub mod storage;
pub mod types;
pub mod utils;
2 changes: 1 addition & 1 deletion portalnet/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use crate::{
OverlayCommand, OverlayRequest, OverlayRequestError, OverlayService, RequestDirection,
UTP_CONN_CFG,
},
storage::ContentStore,
types::node::Node,
};
use ethportal_api::{
Expand All @@ -48,6 +47,7 @@ use ethportal_api::{
OverlayContentKey, RawContentKey,
};
use trin_metrics::{overlay::OverlayMetricsReporter, portalnet::PORTALNET_METRICS};
use trin_storage::ContentStore;
use trin_validation::validator::Validator;

use crate::events::EventEnvelope;
Expand Down
4 changes: 2 additions & 2 deletions portalnet/src/overlay_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ use crate::{
query_pool::{QueryId, QueryPool, QueryPoolState, TargetKey},
},
gossip::propagate_gossip_cross_thread,
storage::{ContentStore, ShouldWeStoreContent},
types::node::Node,
utils::portal_wire,
};
Expand All @@ -72,6 +71,7 @@ use trin_metrics::{
labels::{UtpDirectionLabel, UtpOutcomeLabel},
overlay::OverlayMetricsReporter,
};
use trin_storage::{ContentStore, ShouldWeStoreContent};
use trin_validation::validator::Validator;

pub const FIND_NODES_MAX_NODES: usize = 32;
Expand Down Expand Up @@ -2665,14 +2665,14 @@ mod tests {
config::PortalnetConfig,
discovery::{Discovery, NodeAddress},
overlay::OverlayConfig,
storage::{DistanceFunction, MemoryContentStore},
utils::db::setup_temp_dir,
};
use ethportal_api::types::{
cli::DEFAULT_DISCOVERY_PORT, content_key::overlay::IdentityContentKey, distance::XorMetric,
enr::generate_random_remote_enr,
};
use trin_metrics::portalnet::PORTALNET_METRICS;
use trin_storage::{DistanceFunction, MemoryContentStore};
use trin_validation::validator::MockValidator;

macro_rules! poll_command_rx {
Expand Down
Loading

0 comments on commit 4a21a56

Please sign in to comment.