feat(db): record client version history (#7119)

This commit is contained in:
Roman Krasiuk
2024-03-13 13:07:13 +01:00
committed by GitHub
parent 884fd71a01
commit 610731ced8
32 changed files with 366 additions and 119 deletions

View File

@ -1,4 +1,4 @@
use reth_db::open_db_read_only;
use reth_db::{mdbx::DatabaseArguments, models::client_version::ClientVersion, open_db_read_only};
use reth_primitives::{Address, ChainSpecBuilder, B256};
use reth_provider::{
AccountReader, BlockReader, BlockSource, HeaderProvider, ProviderFactory, ReceiptProvider,
@ -19,7 +19,10 @@ fn main() -> eyre::Result<()> {
// doing in 2 steps.
let db_path = std::env::var("RETH_DB_PATH")?;
let db_path = Path::new(&db_path);
let db = open_db_read_only(db_path.join("db").as_path(), Default::default())?;
let db = open_db_read_only(
db_path.join("db").as_path(),
DatabaseArguments::new(ClientVersion::default()),
)?;
// Instantiate a provider factory for Ethereum mainnet using the provided DB.
// TODO: Should the DB version include the spec so that you do not need to specify it here?

View File

@ -9,6 +9,7 @@ license.workspace = true
futures.workspace = true
jsonrpsee.workspace = true
reth.workspace = true
reth-db.workspace = true
reth-node-ethereum.workspace = true
tokio = { workspace = true, features = ["full"] }
eyre.workspace = true

View File

@ -17,6 +17,7 @@ use reth::{
providers::{providers::BlockchainProvider, ProviderFactory},
utils::db::open_db_read_only,
};
use reth_db::{mdbx::DatabaseArguments, models::client_version::ClientVersion};
// Bringing up the RPC
use reth::rpc::builder::{
RethRpcModule, RpcModuleBuilder, RpcServerConfig, TransportRpcModuleConfig,
@ -38,7 +39,10 @@ async fn main() -> eyre::Result<()> {
// 1. Setup the DB
let db_path = std::env::var("RETH_DB_PATH")?;
let db_path = Path::new(&db_path);
let db = Arc::new(open_db_read_only(db_path.join("db").as_path(), Default::default())?);
let db = Arc::new(open_db_read_only(
db_path.join("db").as_path(),
DatabaseArguments::new(ClientVersion::default()),
)?);
let spec = Arc::new(ChainSpecBuilder::mainnet().build());
let factory = ProviderFactory::new(db.clone(), spec.clone(), db_path.join("static_files"))?;