Compare commits

..

26 Commits

Author SHA1 Message Date
Omar Abdulla 0d5f9d9b4f Make cache step faster 2025-11-11 02:00:20 +03:00
Omar Abdulla 4a615dc3f9 Fix zombienet tests 2025-11-11 01:53:40 +03:00
Omar Abdulla 1824c499f7 Update MacOS runner 2025-11-10 15:30:08 +03:00
Omar Abdulla 70aec40631 Simplify CI 2025-11-10 15:27:21 +03:00
Omar Abdulla e9f82a9d98 Update runners 2025-11-10 15:17:05 +03:00
Omar Abdulla dc63d1454b Update runners 2025-11-10 15:15:57 +03:00
Omar Abdulla 028bdba0d0 Allow warnings 2025-11-10 14:15:37 +03:00
Omar Abdulla 12b98f4e7d Fix CI 2025-11-10 13:10:26 +03:00
Omar Abdulla 7998ec5a0c Fix CI 2025-11-10 12:46:22 +03:00
Omar Abdulla 2860d35754 Fix CI 2025-11-10 12:29:51 +03:00
Omar Abdulla 413839a236 Fix CI 2025-11-10 12:27:02 +03:00
Omar Abdulla 8e0de8f390 Fix CI 2025-11-10 12:16:05 +03:00
Omar Abdulla 890a93132d Use 1.90.0 version of rust for the polkadot-sdk 2025-11-10 11:52:47 +03:00
Omar Abdulla 20c51f3c6c Fix ci 2025-11-10 11:48:28 +03:00
Omar Abdulla 33533fe9ce Fix ci 2025-11-10 11:45:26 +03:00
Omar Abdulla 6fe0c01aca Install llvm on macos 2025-11-10 11:36:20 +03:00
Omar Abdulla 68aa11fd29 Update the version of clang 2025-11-10 11:32:12 +03:00
Omar Abdulla e7cd7f019a Install clang and llvm dependencies 2025-11-10 11:29:14 +03:00
Omar Abdulla 086362be2b Fix the CI 2025-11-10 11:18:50 +03:00
Omar Abdulla 063336da4b Add a testing step 2025-11-10 11:17:25 +03:00
Omar Abdulla b444279a4c Overhaul the polkadot-sdk caching step 2025-11-10 11:06:38 +03:00
Omar Abdulla e66da8080f Add other jobs to CI 2025-11-10 10:39:21 +03:00
Omar Abdulla a81492a946 WIP: update the CI 2025-11-10 10:32:41 +03:00
Omar Abdulla 6d2bd85cf6 Remove the polkadot-sdk from the submodules 2025-11-10 10:25:17 +03:00
Omar Abdulla 019260b413 Switch to cargo-make 2025-11-10 10:24:34 +03:00
Omar Abdulla ee6d7f9c27 Move all scripts to a single directory 2025-11-10 10:15:41 +03:00
8 changed files with 48 additions and 99 deletions
Generated
-1
View File
@@ -5657,7 +5657,6 @@ dependencies = [
"semver 1.0.26",
"serde",
"serde_json",
"subxt 0.44.0",
"tokio",
"tracing",
"tracing-appender",
Binary file not shown.
-1
View File
@@ -37,7 +37,6 @@ schemars = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
subxt = { workspace = true }
[lints]
workspace = true
@@ -127,8 +127,6 @@ where
.inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
.context("Failed to produce the pre-linking compiled contracts")?;
let deployer_address = self.test_definition.case.deployer_address();
let mut deployed_libraries = None::<HashMap<_, _>>;
let mut contract_sources = self
.test_definition
@@ -161,6 +159,23 @@ where
let code = alloy::hex::decode(code)?;
// Getting the deployer address from the cases themselves. This is to ensure
// that we're doing the deployments from different accounts and therefore we're
// not slowed down by the nonce.
let deployer_address = self
.test_definition
.case
.steps
.iter()
.filter_map(|step| match step {
Step::FunctionCall(input) => input.caller.as_address().copied(),
Step::BalanceAssertion(..) => None,
Step::StorageEmptyAssertion(..) => None,
Step::Repeat(..) => None,
Step::AllocateAccount(..) => None,
})
.next()
.unwrap_or(FunctionCallStep::default_caller_address());
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
TransactionRequest::default().from(deployer_address),
code,
+19 -51
View File
@@ -8,7 +8,7 @@ use alloy::{
hex,
json_abi::JsonAbi,
network::{Ethereum, TransactionBuilder},
primitives::{Address, TxHash, U256, address},
primitives::{Address, TxHash, U256},
rpc::types::{
TransactionReceipt, TransactionRequest,
trace::geth::{
@@ -18,9 +18,9 @@ use alloy::{
},
};
use anyhow::{Context as _, Result, bail};
use futures::{TryStreamExt, future::try_join_all};
use futures::TryStreamExt;
use indexmap::IndexMap;
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator, VmIdentifier};
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator};
use revive_dt_format::{
metadata::{ContractInstance, ContractPathAndIdent},
steps::{
@@ -30,7 +30,6 @@ use revive_dt_format::{
},
traits::ResolutionContext,
};
use subxt::{ext::codec::Decode, metadata::Metadata, tx::Payload};
use tokio::sync::Mutex;
use tracing::{error, info, instrument};
@@ -199,8 +198,6 @@ where
})
.context("Failed to produce the pre-linking compiled contracts")?;
let deployer_address = test_definition.case.deployer_address();
let mut deployed_libraries = None::<HashMap<_, _>>;
let mut contract_sources = test_definition
.metadata
@@ -235,6 +232,22 @@ where
let code = alloy::hex::decode(code)?;
// Getting the deployer address from the cases themselves. This is to ensure
// that we're doing the deployments from different accounts and therefore we're
// not slowed down by the nonce.
let deployer_address = test_definition
.case
.steps
.iter()
.filter_map(|step| match step {
Step::FunctionCall(input) => input.caller.as_address().copied(),
Step::BalanceAssertion(..) => None,
Step::StorageEmptyAssertion(..) => None,
Step::Repeat(..) => None,
Step::AllocateAccount(..) => None,
})
.next()
.unwrap_or(FunctionCallStep::default_caller_address());
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
TransactionRequest::default().from(deployer_address),
code,
@@ -282,51 +295,6 @@ where
})
.context("Failed to compile the post-link contracts")?;
// Factory contracts on the PVM refer to the code that they're instantiating by hash rather
// than including the actual bytecode. This creates a problem where a factory contract could
// be deployed but the code it's supposed to create is not on chain. Therefore, we upload
// all the code to the chain prior to running any transactions on the driver.
if platform_information.platform.vm_identifier() == VmIdentifier::PolkaVM {
#[subxt::subxt(runtime_metadata_path = "../../assets/revive_metadata.scale")]
pub mod revive {}
let metadata_bytes = include_bytes!("../../../../assets/revive_metadata.scale");
let metadata = Metadata::decode(&mut &metadata_bytes[..])
.context("Failed to decode the revive metadata")?;
const RUNTIME_PALLET_ADDRESS: Address =
address!("0x6d6f646c70792f70616464720000000000000000");
let code_upload_tasks = compiler_output
.contracts
.values()
.flat_map(|item| item.values())
.map(|(code_string, _)| {
let metadata = metadata.clone();
async move {
let code = alloy::hex::decode(code_string)
.context("Failed to hex-decode the post-link code. This is a bug")?;
let payload = revive::tx().revive().upload_code(code, u128::MAX);
let encoded_payload = payload
.encode_call_data(&metadata)
.context("Failed to encode the upload code payload")?;
let tx_request = TransactionRequest::default()
.from(deployer_address)
.to(RUNTIME_PALLET_ADDRESS)
.input(encoded_payload.into());
platform_information
.node
.execute_transaction(tx_request)
.await
.context("Failed to execute transaction")
}
});
try_join_all(code_upload_tasks)
.await
.context("Code upload failed")?;
}
Ok(ExecutionState::new(
compiler_output.contracts,
deployed_libraries.unwrap_or_default(),
-15
View File
@@ -1,4 +1,3 @@
use alloy::primitives::Address;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@@ -108,20 +107,6 @@ impl Case {
None => Mode::all().cloned().collect(),
}
}
pub fn deployer_address(&self) -> Address {
self.steps
.iter()
.filter_map(|step| match step {
Step::FunctionCall(input) => input.caller.as_address().copied(),
Step::BalanceAssertion(..) => None,
Step::StorageEmptyAssertion(..) => None,
Step::Repeat(..) => None,
Step::AllocateAccount(..) => None,
})
.next()
.unwrap_or(FunctionCallStep::default_caller_address())
}
}
define_wrapper_type!(
@@ -4,7 +4,7 @@ use std::{
pin::Pin,
process::{Command, Stdio},
sync::{
Arc, Mutex,
Arc,
atomic::{AtomicU32, Ordering},
},
time::Duration,
@@ -32,7 +32,7 @@ use futures::{FutureExt, Stream, StreamExt};
use revive_common::EVMVersion;
use revive_dt_common::fs::clear_directory;
use revive_dt_format::traits::ResolverApi;
use serde_json::{Value, json};
use serde_json::json;
use sp_core::crypto::Ss58Codec;
use sp_runtime::AccountId32;
@@ -57,9 +57,6 @@ use crate::{
static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
/// The number of blocks that should be cached by the revive-dev-node and the eth-rpc.
const NUMBER_OF_CACHED_BLOCKS: u32 = 100_000;
/// A node implementation for Substrate based chains. Currently, this supports either substrate
/// or the revive-dev-node which is done by changing the path and some of the other arguments passed
/// to the command.
@@ -141,8 +138,6 @@ impl SubstrateNode {
}
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
static CHAINSPEC_MUTEX: Mutex<Option<Value>> = Mutex::new(None);
if !self.rpc_url.is_empty() {
return Ok(self);
}
@@ -161,22 +156,12 @@ impl SubstrateNode {
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
trace!("Creating the node genesis");
let chainspec_json = {
let mut chainspec_mutex = CHAINSPEC_MUTEX.lock().expect("Poisoned");
match chainspec_mutex.as_ref() {
Some(chainspec_json) => chainspec_json.clone(),
None => {
let chainspec_json = Self::node_genesis(
&self.node_binary,
&self.export_chainspec_command,
&self.wallet,
)
.context("Failed to prepare the chainspec command")?;
*chainspec_mutex = Some(chainspec_json.clone());
chainspec_json
}
}
};
let chainspec_json = Self::node_genesis(
&self.node_binary,
&self.export_chainspec_command,
&self.wallet,
)
.context("Failed to prepare the chainspec command")?;
trace!("Writing the node genesis");
serde_json::to_writer_pretty(
@@ -227,8 +212,6 @@ impl SubstrateNode {
.arg(u32::MAX.to_string())
.arg("--pool-kbytes")
.arg(u32::MAX.to_string())
.arg("--state-pruning")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
.stdout(stdout_file)
.stderr(stderr_file);
@@ -269,9 +252,9 @@ impl SubstrateNode {
.arg("--rpc-max-connections")
.arg(u32::MAX.to_string())
.arg("--index-last-n-blocks")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
.arg(1_000u32.to_string())
.arg("--cache-size")
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
.arg(1_000u32.to_string())
.env("RUST_LOG", Self::PROXY_LOG_ENV)
.stdout(stdout_file)
.stderr(stderr_file);
@@ -324,7 +307,7 @@ impl SubstrateNode {
.get_or_try_init(|| async move {
construct_concurrency_limited_provider::<Ethereum, _>(
self.rpc_url.as_str(),
FallbackGasFiller::new(u64::MAX, 50_000_000_000, 1_000_000_000),
FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
ChainIdFiller::new(Some(CHAIN_ID)),
NonceFiller::new(self.nonce_manager.clone()),
self.wallet.clone(),