Refactoring Checkpoint: (WIP)

This commit is contained in:
2025-12-14 10:29:31 +03:00
parent 09735eb97a
commit c89d7cac55
1424 changed files with 6415 additions and 6064 deletions
+5 -5
View File
@@ -45,7 +45,7 @@ const IN_MEMORY_DB: &str = "sqlite::memory:";
pub struct CliCommand {
/// The node url to connect to
#[clap(long, default_value = "ws://127.0.0.1:9944")]
pub node_rpc_url: String,
pub pez_node_rpc_url: String,
/// The maximum number of blocks to cache in memory.
#[clap(long, default_value = "256")]
@@ -103,12 +103,12 @@ fn build_client(
tokio_handle: &tokio::runtime::Handle,
cache_size: usize,
earliest_receipt_block: Option<BizinikiwiBlockNumber>,
node_rpc_url: &str,
pez_node_rpc_url: &str,
database_url: &str,
abort_signal: Signals,
) -> anyhow::Result<Client> {
let fut = async {
let (api, rpc_client, rpc) = connect(node_rpc_url).await?;
let (api, rpc_client, rpc) = connect(pez_node_rpc_url).await?;
let block_provider = SubxtBlockInfoProvider::new( api.clone(), rpc.clone()).await?;
let (pool, keep_latest_n_blocks) = if database_url == IN_MEMORY_DB {
@@ -158,7 +158,7 @@ pub fn run(cmd: CliCommand) -> anyhow::Result<()> {
let CliCommand {
rpc_params,
prometheus_params,
node_rpc_url,
pez_node_rpc_url,
cache_size,
database_url,
earliest_receipt_block,
@@ -204,7 +204,7 @@ pub fn run(cmd: CliCommand) -> anyhow::Result<()> {
tokio_handle,
cache_size,
earliest_receipt_block,
&node_rpc_url,
&pez_node_rpc_url,
&database_url,
tokio_runtime.block_on(async { Signals::capture() })?,
)?;
+4 -4
View File
@@ -208,16 +208,16 @@ async fn get_automine(rpc_client: &RpcClient) -> bool {
/// Connect to a node at the given URL, and return the underlying API, RPC client, and legacy RPC
/// clients.
pub async fn connect(
node_rpc_url: &str,
pez_node_rpc_url: &str,
) -> Result<(OnlineClient<SrcChainConfig>, RpcClient, LegacyRpcMethods<SrcChainConfig>), ClientError>
{
log::info!(target: LOG_TARGET, "🌐 Connecting to node at: {node_rpc_url} ...");
log::info!(target: LOG_TARGET, "🌐 Connecting to node at: {pez_node_rpc_url} ...");
let rpc_client = ReconnectingRpcClient::builder()
.retry_policy(ExponentialBackoff::from_millis(100).max_delay(Duration::from_secs(10)))
.build(node_rpc_url.to_string())
.build(pez_node_rpc_url.to_string())
.await?;
let rpc_client = RpcClient::new(rpc_client);
log::info!(target: LOG_TARGET, "🌟 Connected to node at: {node_rpc_url}");
log::info!(target: LOG_TARGET, "🌟 Connected to node at: {pez_node_rpc_url}");
let api = OnlineClient::<SrcChainConfig>::from_rpc_client(rpc_client.clone()).await?;
let rpc = LegacyRpcMethods::<SrcChainConfig>::new(rpc_client.clone());
+13 -13
View File
@@ -70,9 +70,9 @@ struct SharedResources {
impl SharedResources {
fn start() -> Self {
// Start revive-dev-node
// Start pez-revive-dev-node
let _node_handle = thread::spawn(move || {
if let Err(e) = revive_dev_node::command::run_with_args(vec![
if let Err(e) = pez_revive_dev_node::command::run_with_args(vec![
"--dev".to_string(),
"--rpc-port=45789".to_string(),
"-lerror,pezsc_rpc_server=info,runtime::revive=debug".to_string(),
@@ -85,7 +85,7 @@ impl SharedResources {
let args = CliCommand::parse_from([
"--dev",
"--rpc-port=45788",
"--node-rpc-url=ws://localhost:45789",
"--pez-node-rpc-url=ws://localhost:45789",
"--no-prometheus",
"-linfo,eth-rpc=debug",
]);
@@ -103,7 +103,7 @@ impl SharedResources {
ws_client_with_retry("ws://localhost:45788").await
}
fn node_rpc_url() -> &'static str {
fn pez_node_rpc_url() -> &'static str {
"ws://localhost:45789"
}
}
@@ -464,10 +464,10 @@ async fn test_invalid_transaction(client: Arc<WsClient>) -> anyhow::Result<()> {
async fn get_evm_block_from_storage(
node_client: &OnlineClient<SrcChainConfig>,
node_rpc_client: &RpcClient,
pez_node_rpc_client: &RpcClient,
block_number: U256,
) -> anyhow::Result<Block> {
let block_hash: H256 = node_rpc_client
let block_hash: H256 = pez_node_rpc_client
.request("chain_getBlockHash", rpc_params![block_number])
.await
.unwrap();
@@ -480,8 +480,8 @@ async fn get_evm_block_from_storage(
}
async fn test_evm_blocks_should_match(client: Arc<WsClient>) -> anyhow::Result<()> {
let (node_client, node_rpc_client, _) =
client::connect(SharedResources::node_rpc_url()).await.unwrap();
let (node_client, pez_node_rpc_client, _) =
client::connect(SharedResources::pez_node_rpc_url()).await.unwrap();
// Deploy a contract to have some interesting blocks
let (bytes, _) = pezpallet_revive_fixtures::compile_module("dummy")?;
@@ -499,7 +499,7 @@ async fn test_evm_blocks_should_match(client: Arc<WsClient>) -> anyhow::Result<(
log::trace!(target: LOG_TARGET, "tx hash = {:?}", tx.hash());
let evm_block_from_storage =
get_evm_block_from_storage(&node_client, &node_rpc_client, block_number).await?;
get_evm_block_from_storage(&node_client, &pez_node_rpc_client, block_number).await?;
// Fetch the block immediately (should come from storage EthereumBlock)
let evm_block_from_rpc_by_number = client
@@ -700,7 +700,7 @@ async fn test_mixed_evm_bizinikiwi_transactions(client: Arc<WsClient>) -> anyhow
// Prepare bizinikiwi transactions (simple remarks)
log::trace!(target: LOG_TARGET, "Creating {num_bizinikiwi_txs} bizinikiwi remark transactions");
let alice_signer = subxt_signer::sr25519::dev::alice();
let (node_client, _, _) = client::connect(SharedResources::node_rpc_url()).await.unwrap();
let (node_client, _, _) = client::connect(SharedResources::pez_node_rpc_url()).await.unwrap();
let bizinikiwi_txs =
prepare_bizinikiwi_transactions(&node_client, &alice_signer, num_bizinikiwi_txs).await?;
@@ -730,15 +730,15 @@ async fn test_mixed_evm_bizinikiwi_transactions(client: Arc<WsClient>) -> anyhow
}
async fn test_runtime_pallets_address_upload_code(client: Arc<WsClient>) -> anyhow::Result<()> {
let (node_client, node_rpc_client, _) =
client::connect(SharedResources::node_rpc_url()).await?;
let (node_client, pez_node_rpc_client, _) =
client::connect(SharedResources::pez_node_rpc_url()).await?;
let (bytecode, _) = pezpallet_revive_fixtures::compile_module("dummy")?;
let signer = Account::default();
// Helper function to get bizinikiwi block hash from EVM block number
let get_bizinikiwi_block_hash = |block_number: U256| {
let rpc_client = node_rpc_client.clone();
let rpc_client = pez_node_rpc_client.clone();
async move {
rpc_client
.request::<pezsp_core::H256>("chain_getBlockHash", rpc_params![block_number])