Refactoring Checkpoint: (WIP)
This commit is contained in:
@@ -59,20 +59,20 @@ tokio = { workspace = true, features = ["full"] }
|
||||
env_logger = { workspace = true }
|
||||
pezpallet-revive-fixtures = { workspace = true, default-features = true }
|
||||
pretty_assertions = { workspace = true }
|
||||
revive-dev-node = { workspace = true }
|
||||
pez-revive-dev-node = { workspace = true }
|
||||
pezsp-io = { workspace = true, default-features = true }
|
||||
|
||||
[build-dependencies]
|
||||
git2 = { workspace = true }
|
||||
revive-dev-runtime = { workspace = true, default-features = true }
|
||||
pez-revive-dev-runtime = { workspace = true, default-features = true }
|
||||
pezsp-io = { workspace = true, default-features = true }
|
||||
pezsp-runtime = { workspace = true, default-features = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"pezpallet-revive/runtime-benchmarks",
|
||||
"revive-dev-node/runtime-benchmarks",
|
||||
"revive-dev-runtime/runtime-benchmarks",
|
||||
"pez-revive-dev-node/runtime-benchmarks",
|
||||
"pez-revive-dev-runtime/runtime-benchmarks",
|
||||
"pezsc-cli/runtime-benchmarks",
|
||||
"pezsc-rpc-api/runtime-benchmarks",
|
||||
"pezsc-rpc/runtime-benchmarks",
|
||||
|
||||
@@ -55,7 +55,7 @@ fn generate_git_revision() {
|
||||
fn generate_metadata_file() {
|
||||
let mut ext = pezsp_io::TestExternalities::new(Default::default());
|
||||
ext.execute_with(|| {
|
||||
let metadata = revive_dev_runtime::Runtime::metadata_at_version(16).unwrap();
|
||||
let metadata = pez_revive_dev_runtime::Runtime::metadata_at_version(16).unwrap();
|
||||
let bytes: &[u8] = &metadata;
|
||||
fs::write("revive_chain.scale", bytes).unwrap();
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ fn start_docker(docker_bin: &str, docker_image: &str) -> anyhow::Result<Child> {
|
||||
"-p",
|
||||
"8545:8545",
|
||||
&format!("docker.io/paritypr/{docker_image}"),
|
||||
"--node-rpc-url",
|
||||
"--pez-node-rpc-url",
|
||||
"wss://zagros-asset-hub-rpc.pezkuwichain.io",
|
||||
"--rpc-cors",
|
||||
"all",
|
||||
|
||||
@@ -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() })?,
|
||||
)?;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user