fix: Initialize DB with HL-specific tables on init-state

This commit is contained in:
sprites0
2025-08-22 10:40:14 -04:00
parent 20610ccc82
commit 7daf203bc2

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
chainspec::{parser::HlChainSpecParser, HlChainSpec}, chainspec::{parser::HlChainSpecParser, HlChainSpec},
node::{consensus::HlConsensus, evm::config::HlEvmConfig, HlNode}, node::{consensus::HlConsensus, evm::config::HlEvmConfig, storage::tables::Tables, HlNode},
pseudo_peer::BlockSourceArgs, pseudo_peer::BlockSourceArgs,
}; };
use clap::{Args, Parser}; use clap::{Args, Parser};
@ -14,8 +14,8 @@ use reth::{
}; };
use reth_chainspec::EthChainSpec; use reth_chainspec::EthChainSpec;
use reth_cli::chainspec::ChainSpecParser; use reth_cli::chainspec::ChainSpecParser;
use reth_cli_commands::launcher::FnLauncher; use reth_cli_commands::{common::EnvironmentArgs, launcher::FnLauncher};
use reth_db::DatabaseEnv; use reth_db::{init_db, mdbx::init_db_for, DatabaseEnv};
use reth_tracing::FileWorkerGuard; use reth_tracing::FileWorkerGuard;
use std::{ use std::{
fmt::{self}, fmt::{self},
@ -123,6 +123,8 @@ where
runner.run_blocking_until_ctrl_c(command.execute::<HlNode>()) runner.run_blocking_until_ctrl_c(command.execute::<HlNode>())
} }
Commands::InitState(command) => { Commands::InitState(command) => {
// Need to invoke `init_db_for` to create `BlockReadPrecompileCalls` table
Self::init_db(&command.env)?;
runner.run_blocking_until_ctrl_c(command.execute::<HlNode>()) runner.run_blocking_until_ctrl_c(command.execute::<HlNode>())
} }
Commands::DumpGenesis(command) => runner.run_blocking_until_ctrl_c(command.execute()), Commands::DumpGenesis(command) => runner.run_blocking_until_ctrl_c(command.execute()),
@ -156,4 +158,12 @@ where
let guard = self.logs.init_tracing()?; let guard = self.logs.init_tracing()?;
Ok(guard) Ok(guard)
} }
fn init_db(env: &EnvironmentArgs<C>) -> eyre::Result<()> {
let data_dir = env.datadir.clone().resolve_datadir(env.chain.chain());
let db_path = data_dir.db();
init_db(db_path.clone(), env.db.database_args())?;
init_db_for::<_, Tables>(db_path, env.db.database_args())?;
Ok(())
}
} }