mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-11 21:11:13 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d5f9d9b4f | |||
| 4a615dc3f9 | |||
| 1824c499f7 | |||
| 70aec40631 | |||
| e9f82a9d98 | |||
| dc63d1454b | |||
| 028bdba0d0 | |||
| 12b98f4e7d | |||
| 7998ec5a0c | |||
| 2860d35754 | |||
| 413839a236 | |||
| 8e0de8f390 | |||
| 890a93132d | |||
| 20c51f3c6c | |||
| 33533fe9ce | |||
| 6fe0c01aca | |||
| 68aa11fd29 | |||
| e7cd7f019a | |||
| 086362be2b | |||
| 063336da4b | |||
| b444279a4c | |||
| e66da8080f | |||
| a81492a946 | |||
| 6d2bd85cf6 | |||
| 019260b413 | |||
| ee6d7f9c27 |
Generated
-1
@@ -5657,7 +5657,6 @@ dependencies = [
|
|||||||
"semver 1.0.26",
|
"semver 1.0.26",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"subxt 0.44.0",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-appender",
|
"tracing-appender",
|
||||||
|
|||||||
Binary file not shown.
@@ -37,7 +37,6 @@ schemars = { workspace = true }
|
|||||||
semver = { workspace = true }
|
semver = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
subxt = { workspace = true }
|
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@@ -127,8 +127,6 @@ where
|
|||||||
.inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
|
.inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
|
||||||
.context("Failed to produce the pre-linking compiled contracts")?;
|
.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 deployed_libraries = None::<HashMap<_, _>>;
|
||||||
let mut contract_sources = self
|
let mut contract_sources = self
|
||||||
.test_definition
|
.test_definition
|
||||||
@@ -161,6 +159,23 @@ where
|
|||||||
|
|
||||||
let code = alloy::hex::decode(code)?;
|
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(
|
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
|
||||||
TransactionRequest::default().from(deployer_address),
|
TransactionRequest::default().from(deployer_address),
|
||||||
code,
|
code,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use alloy::{
|
|||||||
hex,
|
hex,
|
||||||
json_abi::JsonAbi,
|
json_abi::JsonAbi,
|
||||||
network::{Ethereum, TransactionBuilder},
|
network::{Ethereum, TransactionBuilder},
|
||||||
primitives::{Address, TxHash, U256, address},
|
primitives::{Address, TxHash, U256},
|
||||||
rpc::types::{
|
rpc::types::{
|
||||||
TransactionReceipt, TransactionRequest,
|
TransactionReceipt, TransactionRequest,
|
||||||
trace::geth::{
|
trace::geth::{
|
||||||
@@ -18,9 +18,9 @@ use alloy::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::{Context as _, Result, bail};
|
use anyhow::{Context as _, Result, bail};
|
||||||
use futures::{TryStreamExt, future::try_join_all};
|
use futures::TryStreamExt;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator, VmIdentifier};
|
use revive_dt_common::types::{PlatformIdentifier, PrivateKeyAllocator};
|
||||||
use revive_dt_format::{
|
use revive_dt_format::{
|
||||||
metadata::{ContractInstance, ContractPathAndIdent},
|
metadata::{ContractInstance, ContractPathAndIdent},
|
||||||
steps::{
|
steps::{
|
||||||
@@ -30,7 +30,6 @@ use revive_dt_format::{
|
|||||||
},
|
},
|
||||||
traits::ResolutionContext,
|
traits::ResolutionContext,
|
||||||
};
|
};
|
||||||
use subxt::{ext::codec::Decode, metadata::Metadata, tx::Payload};
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tracing::{error, info, instrument};
|
use tracing::{error, info, instrument};
|
||||||
|
|
||||||
@@ -199,8 +198,6 @@ where
|
|||||||
})
|
})
|
||||||
.context("Failed to produce the pre-linking compiled contracts")?;
|
.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 deployed_libraries = None::<HashMap<_, _>>;
|
||||||
let mut contract_sources = test_definition
|
let mut contract_sources = test_definition
|
||||||
.metadata
|
.metadata
|
||||||
@@ -235,6 +232,22 @@ where
|
|||||||
|
|
||||||
let code = alloy::hex::decode(code)?;
|
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(
|
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
|
||||||
TransactionRequest::default().from(deployer_address),
|
TransactionRequest::default().from(deployer_address),
|
||||||
code,
|
code,
|
||||||
@@ -282,51 +295,6 @@ where
|
|||||||
})
|
})
|
||||||
.context("Failed to compile the post-link contracts")?;
|
.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(
|
Ok(ExecutionState::new(
|
||||||
compiler_output.contracts,
|
compiler_output.contracts,
|
||||||
deployed_libraries.unwrap_or_default(),
|
deployed_libraries.unwrap_or_default(),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use alloy::primitives::Address;
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@@ -108,20 +107,6 @@ impl Case {
|
|||||||
None => Mode::all().cloned().collect(),
|
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!(
|
define_wrapper_type!(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::{
|
|||||||
pin::Pin,
|
pin::Pin,
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
sync::{
|
sync::{
|
||||||
Arc, Mutex,
|
Arc,
|
||||||
atomic::{AtomicU32, Ordering},
|
atomic::{AtomicU32, Ordering},
|
||||||
},
|
},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
@@ -32,7 +32,7 @@ use futures::{FutureExt, Stream, StreamExt};
|
|||||||
use revive_common::EVMVersion;
|
use revive_common::EVMVersion;
|
||||||
use revive_dt_common::fs::clear_directory;
|
use revive_dt_common::fs::clear_directory;
|
||||||
use revive_dt_format::traits::ResolverApi;
|
use revive_dt_format::traits::ResolverApi;
|
||||||
use serde_json::{Value, json};
|
use serde_json::json;
|
||||||
use sp_core::crypto::Ss58Codec;
|
use sp_core::crypto::Ss58Codec;
|
||||||
use sp_runtime::AccountId32;
|
use sp_runtime::AccountId32;
|
||||||
|
|
||||||
@@ -57,9 +57,6 @@ use crate::{
|
|||||||
|
|
||||||
static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
|
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
|
/// 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
|
/// or the revive-dev-node which is done by changing the path and some of the other arguments passed
|
||||||
/// to the command.
|
/// to the command.
|
||||||
@@ -141,8 +138,6 @@ impl SubstrateNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
|
fn init(&mut self, _: Genesis) -> anyhow::Result<&mut Self> {
|
||||||
static CHAINSPEC_MUTEX: Mutex<Option<Value>> = Mutex::new(None);
|
|
||||||
|
|
||||||
if !self.rpc_url.is_empty() {
|
if !self.rpc_url.is_empty() {
|
||||||
return Ok(self);
|
return Ok(self);
|
||||||
}
|
}
|
||||||
@@ -161,22 +156,12 @@ impl SubstrateNode {
|
|||||||
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
|
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
|
||||||
|
|
||||||
trace!("Creating the node genesis");
|
trace!("Creating the node genesis");
|
||||||
let chainspec_json = {
|
let chainspec_json = Self::node_genesis(
|
||||||
let mut chainspec_mutex = CHAINSPEC_MUTEX.lock().expect("Poisoned");
|
&self.node_binary,
|
||||||
match chainspec_mutex.as_ref() {
|
&self.export_chainspec_command,
|
||||||
Some(chainspec_json) => chainspec_json.clone(),
|
&self.wallet,
|
||||||
None => {
|
)
|
||||||
let chainspec_json = Self::node_genesis(
|
.context("Failed to prepare the chainspec command")?;
|
||||||
&self.node_binary,
|
|
||||||
&self.export_chainspec_command,
|
|
||||||
&self.wallet,
|
|
||||||
)
|
|
||||||
.context("Failed to prepare the chainspec command")?;
|
|
||||||
*chainspec_mutex = Some(chainspec_json.clone());
|
|
||||||
chainspec_json
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
trace!("Writing the node genesis");
|
trace!("Writing the node genesis");
|
||||||
serde_json::to_writer_pretty(
|
serde_json::to_writer_pretty(
|
||||||
@@ -227,8 +212,6 @@ impl SubstrateNode {
|
|||||||
.arg(u32::MAX.to_string())
|
.arg(u32::MAX.to_string())
|
||||||
.arg("--pool-kbytes")
|
.arg("--pool-kbytes")
|
||||||
.arg(u32::MAX.to_string())
|
.arg(u32::MAX.to_string())
|
||||||
.arg("--state-pruning")
|
|
||||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
|
||||||
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
|
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
|
||||||
.stdout(stdout_file)
|
.stdout(stdout_file)
|
||||||
.stderr(stderr_file);
|
.stderr(stderr_file);
|
||||||
@@ -269,9 +252,9 @@ impl SubstrateNode {
|
|||||||
.arg("--rpc-max-connections")
|
.arg("--rpc-max-connections")
|
||||||
.arg(u32::MAX.to_string())
|
.arg(u32::MAX.to_string())
|
||||||
.arg("--index-last-n-blocks")
|
.arg("--index-last-n-blocks")
|
||||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
.arg(1_000u32.to_string())
|
||||||
.arg("--cache-size")
|
.arg("--cache-size")
|
||||||
.arg(NUMBER_OF_CACHED_BLOCKS.to_string())
|
.arg(1_000u32.to_string())
|
||||||
.env("RUST_LOG", Self::PROXY_LOG_ENV)
|
.env("RUST_LOG", Self::PROXY_LOG_ENV)
|
||||||
.stdout(stdout_file)
|
.stdout(stdout_file)
|
||||||
.stderr(stderr_file);
|
.stderr(stderr_file);
|
||||||
@@ -324,7 +307,7 @@ impl SubstrateNode {
|
|||||||
.get_or_try_init(|| async move {
|
.get_or_try_init(|| async move {
|
||||||
construct_concurrency_limited_provider::<Ethereum, _>(
|
construct_concurrency_limited_provider::<Ethereum, _>(
|
||||||
self.rpc_url.as_str(),
|
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)),
|
ChainIdFiller::new(Some(CHAIN_ID)),
|
||||||
NonceFiller::new(self.nonce_manager.clone()),
|
NonceFiller::new(self.nonce_manager.clone()),
|
||||||
self.wallet.clone(),
|
self.wallet.clone(),
|
||||||
|
|||||||
+1
-1
Submodule resolc-compiler-tests updated: 7bc445491e...40ffa2b839
Reference in New Issue
Block a user