Skip to content

Commit

Permalink
Ndev 3050 rocks db (#525)
Browse files Browse the repository at this point in the history
* Add working with TracerDB based on RocksDB
* Add TRACER_DB_TYPE to select ClickHouse or RocksDB implementation
---------

Co-authored-by: Semen Medvedev <[email protected]>
  • Loading branch information
iguberman and Semen Medvedev authored Sep 4, 2024
1 parent ae50b87 commit d7ae8d2
Show file tree
Hide file tree
Showing 15 changed files with 732 additions and 256 deletions.
3 changes: 3 additions & 0 deletions ci/docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
SOLANA_KEY_FOR_CONFIG: BMp6gEnveANdvSvspESJUrNczuHz1GF5UQKjVLCkAZih
COMMITMENT: confirmed
NEON_DB_CLICKHOUSE_URLS: "http://45.250.253.36:8123;http://45.250.253.38:8123"
TRACER_DB_TYPE: clickhouse
image: ${EVM_LOADER_IMAGE}
ports:
- "8085"
Expand All @@ -57,6 +58,7 @@ services:
NEON_CHAIN_ID: 111
COMMITMENT: confirmed
NEON_DB_CLICKHOUSE_URLS: "http://45.250.253.36:8123;http://45.250.253.38:8123"
TRACER_DB_TYPE: clickhouse
NEON_DB_INDEXER_HOST: 45.250.253.32
NEON_DB_INDEXER_PORT: 5432
NEON_DB_INDEXER_DATABASE: indexer
Expand All @@ -65,6 +67,7 @@ services:
KEYPAIR: /opt/operator-keypairs/id.json
FEEPAIR: /opt/operator-keypairs/id.json
SOLANA_KEY_FOR_CONFIG: BMp6gEnveANdvSvspESJUrNczuHz1GF5UQKjVLCkAZih

image: ${EVM_LOADER_IMAGE}
ports:
- "3100"
Expand Down
2 changes: 2 additions & 0 deletions ci/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
SOLANA_KEY_FOR_CONFIG: BMp6gEnveANdvSvspESJUrNczuHz1GF5UQKjVLCkAZih
COMMITMENT: confirmed
NEON_DB_CLICKHOUSE_URLS: "http://45.250.253.36:8123;http://45.250.253.38:8123"
TRACER_DB_TYPE: clickhouse
image: ${EVM_LOADER_IMAGE}
ports:
- "8085:8085"
Expand All @@ -61,6 +62,7 @@ services:
NEON_CHAIN_ID: 111
COMMITMENT: confirmed
NEON_DB_CLICKHOUSE_URLS: "http://45.250.253.36:8123;http://45.250.253.38:8123"
TRACER_DB_TYPE: clickhouse
NEON_DB_INDEXER_HOST: 45.250.253.32
NEON_DB_INDEXER_PORT: 5432
NEON_DB_INDEXER_DATABASE: indexer
Expand Down
150 changes: 145 additions & 5 deletions evm_loader/Cargo.lock

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

2 changes: 1 addition & 1 deletion evm_loader/api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn main() -> NeonApiResult<()> {
info!("{}", get_build_info());

let api_config = config::load_api_config_from_environment();
let state: NeonApiState = Data::new(State::new(api_config));
let state: NeonApiState = Data::new(State::new(api_config).await);

let listener_addr = options
.value_of("host")
Expand Down
14 changes: 6 additions & 8 deletions evm_loader/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,12 @@ async fn build_rpc(options: &ArgMatches<'_>, config: &Config) -> Result<RpcEnum,
.map(|slot_str| slot_str.parse().expect("slot parse error"));

Ok(if let Some(slot) = slot {
RpcEnum::CallDbClient(
CallDbClient::new(
TracerDb::new(config.db_config.as_ref().expect("db-config not found")),
slot,
None,
)
.await?,
)
let db_config = config
.db_config
.clone()
.ok_or(NeonError::LoadingDBConfigError)?;
let tracer_db = TracerDb::from_config(&db_config).await;
RpcEnum::CallDbClient(CallDbClient::new(tracer_db, slot, None).await?)
} else {
RpcEnum::CloneRpcClient(CloneRpcClient::new_from_config(config))
})
Expand Down
1 change: 1 addition & 0 deletions evm_loader/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anyhow = "1.0"
bincode = "1.3.3"
hyper = "0.14"
evm-loader = { path = "../program", default-features = false, features = ["log", "async-trait"] }
jsonrpsee = { version = "0.20", features = ["server", "ws-client", "macros"] }
solana-sdk.workspace = true
solana-client.workspace = true
solana-account-decoder.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion evm_loader/lib/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ use serde_json::json;

lazy_static! {
static ref RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap();
static ref STATE: State = State::new(load_config());
static ref STATE: State = init_state_sync();
}

#[must_use]
pub fn init_state_sync() -> State {
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async { State::new(load_config()).await })
}

pub const _MODULE_WM_: &WithMetadata<NeonEVMLib> = &WithMetadata::new(NeonEVMLib {
Expand Down
15 changes: 11 additions & 4 deletions evm_loader/lib/src/abi/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use crate::types::TracerDb;
use crate::NeonError;

pub struct State {
pub tracer_db: TracerDb,
pub tracer_db: Option<TracerDb>,
pub rpc_client: CloneRpcClient,
pub config: APIOptions,
}

impl State {
#[must_use]
pub fn new(config: APIOptions) -> Self {
pub async fn new(config: APIOptions) -> Self {
Self {
tracer_db: TracerDb::new(&config.db_config),
tracer_db: TracerDb::maybe_from_config(&config.db_config).await,
rpc_client: CloneRpcClient::new_from_api_config(&config),
config,
}
Expand All @@ -26,7 +26,14 @@ impl State {
) -> Result<RpcEnum, NeonError> {
Ok(if let Some(slot) = slot {
RpcEnum::CallDbClient(
CallDbClient::new(self.tracer_db.clone(), slot, tx_index_in_block).await?,
CallDbClient::new(
self.tracer_db
.clone()
.expect("TracerDB must be configured for CallDbClient"),
slot,
tx_index_in_block,
)
.await?,
)
} else {
RpcEnum::CloneRpcClient(self.rpc_client.clone())
Expand Down
5 changes: 3 additions & 2 deletions evm_loader/lib/src/commands/init_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@ pub async fn execute(
let program_parameters = Parameters::new(read_elf_parameters(config, &data));

let neon_revision = program_parameters.get::<String>("NEON_REVISION")?;
if neon_revision != env!("NEON_REVISION") {
let env_neon_revision = env!("NEON_REVISION");
if neon_revision != env_neon_revision {
if force {
warn!("NeonEVM revision doesn't match CLI revision. This check has been disabled with `--force` flag");
} else {
error!("NeonEVM revision doesn't match CLI revision. Use appropriate neon-cli version or add `--force` flag");
return Err(EnvironmentError::RevisionMismatch(
neon_revision,
env!("NEON_REVISION").to_string(),
env_neon_revision.to_string(),
)
.into());
}
Expand Down
Loading

0 comments on commit d7ae8d2

Please sign in to comment.