Compare commits

..

20 Commits

Author SHA1 Message Date
Omar Abdulla 372cd5c52b Update tests 2025-09-19 18:55:50 +03:00
Omar Abdulla e122bbd996 Update the default values of the cli 2025-09-19 18:15:50 +03:00
Omar Abdulla 6313ccb9b5 Resolve merge conflicts 2025-09-18 22:59:11 +03:00
Omar Abdulla 6b2516f639 Final set of renames 2025-09-18 22:44:39 +03:00
Omar Abdulla d4869deb68 Update the default values for the platforms 2025-09-18 20:16:57 +03:00
Omar Abdulla 52b21f8982 Remove an un-needed dependency 2025-09-18 20:11:33 +03:00
Omar Abdulla 13a5b5a7ee Remove the old traits 2025-09-18 20:10:32 +03:00
Omar Abdulla b962d032b9 Remoe all references to leader and follower 2025-09-18 20:03:33 +03:00
Omar Abdulla 496bc9a0ec Replace infra with the dyn infra 2025-09-18 19:59:52 +03:00
Omar Abdulla 92fc7894c0 Add a way to convert platform identifier into a platform 2025-09-17 21:27:33 +03:00
Omar Abdulla d7f69449af Add all of the platforms that we support 2025-09-17 21:06:29 +03:00
Omar Abdulla f0f59ad024 Provide a common node implementation for substrate chains 2025-09-17 20:23:31 +03:00
Omar Abdulla ac0f4e0cf2 Introduce a geth platform 2025-09-17 19:54:50 +03:00
Omar Abdulla 9e4f2e95f1 Support the dyn compiler in the builder pattern 2025-09-17 19:31:12 +03:00
Omar Abdulla 7aadd0a7f7 Implement the dyn compiler trait for compilers 2025-09-17 19:29:23 +03:00
Omar Abdulla 1a25c8e0ab Add more identifiers to the platform 2025-09-17 06:25:35 +03:00
Omar Abdulla 01d8042841 Allow for compilers to be created in the dyn trait 2025-09-17 06:10:44 +03:00
Omar Abdulla 8a05f8e6e8 Make the ethereum node trait object compatible 2025-09-17 06:01:13 +03:00
Omar Abdulla 9fc74aeea0 Groundwork for dyn traits 2025-09-17 05:47:13 +03:00
Omar Abdulla 49cbc51546 Generate schema for the metadata file 2025-09-08 17:09:35 +03:00
5 changed files with 43 additions and 140 deletions
+21 -55
View File
@@ -27,8 +27,8 @@ use semver::Version;
use revive_dt_format::case::Case;
use revive_dt_format::input::{
BalanceAssertionStep, Calldata, EtherValue, Expected, ExpectedOutput, FunctionCallStep, Method,
StepIdx, StorageEmptyAssertionStep,
BalanceAssertion, Calldata, EtherValue, Expected, ExpectedOutput, Input, Method, StepIdx,
StorageEmptyAssertion,
};
use revive_dt_format::metadata::{ContractIdent, ContractInstance, ContractPathAndIdent};
use revive_dt_format::{input::Step, metadata::Metadata};
@@ -36,7 +36,6 @@ use revive_dt_node_interaction::EthereumNode;
use tokio::try_join;
use tracing::{Instrument, info, info_span, instrument};
#[derive(Clone)]
pub struct CaseState {
/// A map of all of the compiled contracts for the given metadata file.
compiled_contracts: HashMap<PathBuf, HashMap<String, (String, JsonAbi)>>,
@@ -97,17 +96,6 @@ impl CaseState {
.context("Failed to handle storage empty assertion step")?;
Ok(StepOutput::StorageEmptyAssertion)
}
Step::Repeat(repetition_step) => {
self.handle_repeat(
metadata,
repetition_step.repeat,
&repetition_step.steps,
node,
)
.await
.context("Failed to handle the repetition step")?;
Ok(StepOutput::Repetition)
}
}
.inspect(|_| info!("Step Succeeded"))
}
@@ -116,7 +104,7 @@ impl CaseState {
pub async fn handle_input(
&mut self,
metadata: &Metadata,
input: &FunctionCallStep,
input: &Input,
node: &dyn EthereumNode,
) -> anyhow::Result<(TransactionReceipt, GethTrace, DiffMode)> {
let resolver = node.resolver().await?;
@@ -152,7 +140,7 @@ impl CaseState {
pub async fn handle_balance_assertion(
&mut self,
metadata: &Metadata,
balance_assertion: &BalanceAssertionStep,
balance_assertion: &BalanceAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
self.handle_balance_assertion_contract_deployment(metadata, balance_assertion, node)
@@ -168,7 +156,7 @@ impl CaseState {
pub async fn handle_storage_empty(
&mut self,
metadata: &Metadata,
storage_empty: &StorageEmptyAssertionStep,
storage_empty: &StorageEmptyAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
self.handle_storage_empty_assertion_contract_deployment(metadata, storage_empty, node)
@@ -180,33 +168,12 @@ impl CaseState {
Ok(())
}
#[instrument(level = "info", name = "Handling Repetition", skip_all)]
pub async fn handle_repeat(
&mut self,
metadata: &Metadata,
repetitions: usize,
steps: &[Step],
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
let tasks = (0..repetitions).map(|_| {
let mut state = self.clone();
async move {
for step in steps {
state.handle_step(metadata, step, node).await?;
}
Ok::<(), anyhow::Error>(())
}
});
try_join_all(tasks).await?;
Ok(())
}
/// Handles the contract deployment for a given input performing it if it needs to be performed.
#[instrument(level = "info", skip_all)]
async fn handle_input_contract_deployment(
&mut self,
metadata: &Metadata,
input: &FunctionCallStep,
input: &Input,
node: &dyn EthereumNode,
) -> anyhow::Result<HashMap<ContractInstance, TransactionReceipt>> {
let mut instances_we_must_deploy = IndexMap::<ContractInstance, bool>::new();
@@ -250,7 +217,7 @@ impl CaseState {
#[instrument(level = "info", skip_all)]
async fn handle_input_execution(
&mut self,
input: &FunctionCallStep,
input: &Input,
mut deployment_receipts: HashMap<ContractInstance, TransactionReceipt>,
node: &dyn EthereumNode,
) -> anyhow::Result<TransactionReceipt> {
@@ -314,7 +281,7 @@ impl CaseState {
#[instrument(level = "info", skip_all)]
fn handle_input_variable_assignment(
&mut self,
input: &FunctionCallStep,
input: &Input,
tracing_result: &CallFrame,
) -> anyhow::Result<()> {
let Some(ref assignments) = input.variable_assignments else {
@@ -345,26 +312,26 @@ impl CaseState {
#[instrument(level = "info", skip_all)]
async fn handle_input_expectations(
&self,
input: &FunctionCallStep,
input: &Input,
execution_receipt: &TransactionReceipt,
resolver: &(impl ResolverApi + ?Sized),
tracing_result: &CallFrame,
) -> anyhow::Result<()> {
// Resolving the `input.expected` into a series of expectations that we can then assert on.
let mut expectations = match input {
FunctionCallStep {
Input {
expected: Some(Expected::Calldata(calldata)),
..
} => vec![ExpectedOutput::new().with_calldata(calldata.clone())],
FunctionCallStep {
Input {
expected: Some(Expected::Expected(expected)),
..
} => vec![expected.clone()],
FunctionCallStep {
Input {
expected: Some(Expected::ExpectedMany(expected)),
..
} => expected.clone(),
FunctionCallStep { expected: None, .. } => vec![ExpectedOutput::new().with_success()],
Input { expected: None, .. } => vec![ExpectedOutput::new().with_success()],
};
// This is a bit of a special case and we have to support it separately on it's own. If it's
@@ -565,7 +532,7 @@ impl CaseState {
pub async fn handle_balance_assertion_contract_deployment(
&mut self,
metadata: &Metadata,
balance_assertion: &BalanceAssertionStep,
balance_assertion: &BalanceAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
let Some(instance) = balance_assertion
@@ -578,7 +545,7 @@ impl CaseState {
self.get_or_deploy_contract_instance(
&instance,
metadata,
FunctionCallStep::default_caller(),
Input::default_caller(),
None,
None,
node,
@@ -590,11 +557,11 @@ impl CaseState {
#[instrument(level = "info", skip_all)]
pub async fn handle_balance_assertion_execution(
&mut self,
BalanceAssertionStep {
BalanceAssertion {
address: address_string,
expected_balance: amount,
..
}: &BalanceAssertionStep,
}: &BalanceAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
let resolver = node.resolver().await?;
@@ -628,7 +595,7 @@ impl CaseState {
pub async fn handle_storage_empty_assertion_contract_deployment(
&mut self,
metadata: &Metadata,
storage_empty_assertion: &StorageEmptyAssertionStep,
storage_empty_assertion: &StorageEmptyAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
let Some(instance) = storage_empty_assertion
@@ -641,7 +608,7 @@ impl CaseState {
self.get_or_deploy_contract_instance(
&instance,
metadata,
FunctionCallStep::default_caller(),
Input::default_caller(),
None,
None,
node,
@@ -653,11 +620,11 @@ impl CaseState {
#[instrument(level = "info", skip_all)]
pub async fn handle_storage_empty_assertion_execution(
&mut self,
StorageEmptyAssertionStep {
StorageEmptyAssertion {
address: address_string,
is_storage_empty,
..
}: &StorageEmptyAssertionStep,
}: &StorageEmptyAssertion,
node: &dyn EthereumNode,
) -> anyhow::Result<()> {
let resolver = node.resolver().await?;
@@ -874,5 +841,4 @@ pub enum StepOutput {
FunctionCall(TransactionReceipt, GethTrace, DiffMode),
BalanceAssertion,
StorageEmptyAssertion,
Repetition,
}
+2 -3
View File
@@ -39,7 +39,7 @@ use revive_dt_core::{
use revive_dt_format::{
case::{Case, CaseIdx},
corpus::Corpus,
input::{FunctionCallStep, Step},
input::{Input, Step},
metadata::{ContractPathAndIdent, Metadata, MetadataFile},
mode::ParsedMode,
};
@@ -514,10 +514,9 @@ async fn handle_case_driver<'a>(
Step::FunctionCall(input) => Some(input.caller),
Step::BalanceAssertion(..) => None,
Step::StorageEmptyAssertion(..) => None,
Step::Repeat(..) => None,
})
.next()
.unwrap_or(FunctionCallStep::default_caller());
.unwrap_or(Input::default_caller());
let tx = TransactionBuilder::<Ethereum>::with_deploy_code(
TransactionRequest::default().from(deployer_address),
code,
+12 -27
View File
@@ -28,13 +28,11 @@ use crate::{metadata::ContractInstance, traits::ResolutionContext};
#[serde(untagged)]
pub enum Step {
/// A function call or an invocation to some function on some smart contract.
FunctionCall(Box<FunctionCallStep>),
FunctionCall(Box<Input>),
/// A step for performing a balance assertion on some account or contract.
BalanceAssertion(Box<BalanceAssertionStep>),
BalanceAssertion(Box<BalanceAssertion>),
/// A step for asserting that the storage of some contract or account is empty.
StorageEmptyAssertion(Box<StorageEmptyAssertionStep>),
/// A special step for repeating a bunch of steps a certain number of times.
Repeat(Box<RepeatStep>),
StorageEmptyAssertion(Box<StorageEmptyAssertion>),
}
define_wrapper_type!(
@@ -45,9 +43,9 @@ define_wrapper_type!(
/// This is an input step which is a transaction description that the framework translates into a
/// transaction and executes on the nodes.
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub struct FunctionCallStep {
pub struct Input {
/// The address of the account performing the call and paying the fees for it.
#[serde(default = "FunctionCallStep::default_caller")]
#[serde(default = "Input::default_caller")]
#[schemars(with = "String")]
pub caller: Address,
@@ -56,7 +54,7 @@ pub struct FunctionCallStep {
pub comment: Option<String>,
/// The contract instance that's being called in this transaction step.
#[serde(default = "FunctionCallStep::default_instance")]
#[serde(default = "Input::default_instance")]
pub instance: ContractInstance,
/// The method that's being called in this step.
@@ -87,7 +85,7 @@ pub struct FunctionCallStep {
/// This represents a balance assertion step where the framework needs to query the balance of some
/// account or contract and assert that it's some amount.
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub struct BalanceAssertionStep {
pub struct BalanceAssertion {
/// An optional comment on the balance assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
@@ -106,10 +104,8 @@ pub struct BalanceAssertionStep {
pub expected_balance: U256,
}
/// This represents an assertion for the storage of some contract or account and whether it's empty
/// or not.
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub struct StorageEmptyAssertionStep {
pub struct StorageEmptyAssertion {
/// An optional comment on the storage empty assertion.
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
@@ -126,17 +122,6 @@ pub struct StorageEmptyAssertionStep {
pub is_storage_empty: bool,
}
/// This represents a repetition step which is a special step type that allows for a sequence of
/// steps to be repeated (on different drivers) a certain number of times.
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub struct RepeatStep {
/// The number of repetitions that the steps should be repeated for.
pub repeat: usize,
/// The sequence of steps to repeat for the above defined number of repetitions.
pub steps: Vec<Step>,
}
/// A set of expectations and assertions to make about the transaction after it ran.
///
/// If this is not specified then the only assertion that will be ran is that the transaction
@@ -310,7 +295,7 @@ pub struct VariableAssignments {
pub return_data: Vec<String>,
}
impl FunctionCallStep {
impl Input {
pub const fn default_caller() -> Address {
Address(FixedBytes(alloy::hex!(
"0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"
@@ -905,7 +890,7 @@ mod tests {
.selector()
.0;
let input = FunctionCallStep {
let input = Input {
instance: ContractInstance::new("Contract"),
method: Method::FunctionName("store".to_owned()),
calldata: Calldata::new_compound(["42"]),
@@ -949,7 +934,7 @@ mod tests {
.selector()
.0;
let input: FunctionCallStep = FunctionCallStep {
let input: Input = Input {
instance: "Contract".to_owned().into(),
method: Method::FunctionName("send(address)".to_owned()),
calldata: Calldata::new_compound(["0x1000000000000000000000000000000000000001"]),
@@ -996,7 +981,7 @@ mod tests {
.selector()
.0;
let input: FunctionCallStep = FunctionCallStep {
let input: Input = Input {
instance: ContractInstance::new("Contract"),
method: Method::FunctionName("send".to_owned()),
calldata: Calldata::new_compound(["0x1000000000000000000000000000000000000001"]),
+1
View File
@@ -95,6 +95,7 @@ RUST_LOG="info" cargo run --release -- execute-tests \
--corpus "$CORPUS_FILE" \
--working-directory "$WORKDIR" \
--concurrency.number-of-nodes 5 \
--concurrency.ignore-concurrency-limit \
--kitchensink.path "$SUBSTRATE_NODE_BIN" \
--revive-dev-node.path "$REVIVE_DEV_NODE_BIN" \
--eth-rpc.path "$ETH_RPC_BIN" \
+7 -55
View File
@@ -25,7 +25,7 @@
"null"
],
"items": {
"$ref": "#/$defs/VmIdentifier"
"type": "string"
}
},
"cases": {
@@ -95,26 +95,6 @@
"cases"
],
"$defs": {
"VmIdentifier": {
"description": "An enum representing the identifiers of the supported VMs.",
"oneOf": [
{
"description": "The ethereum virtual machine.",
"type": "string",
"const": "evm"
},
{
"description": "The EraVM virtual machine.",
"type": "string",
"const": "eravm"
},
{
"description": "Polkadot's PolaVM Risc-v based virtual machine.",
"type": "string",
"const": "polkavm"
}
]
},
"Case": {
"type": "object",
"properties": {
@@ -188,23 +168,19 @@
"anyOf": [
{
"description": "A function call or an invocation to some function on some smart contract.",
"$ref": "#/$defs/FunctionCallStep"
"$ref": "#/$defs/Input"
},
{
"description": "A step for performing a balance assertion on some account or contract.",
"$ref": "#/$defs/BalanceAssertionStep"
"$ref": "#/$defs/BalanceAssertion"
},
{
"description": "A step for asserting that the storage of some contract or account is empty.",
"$ref": "#/$defs/StorageEmptyAssertionStep"
},
{
"description": "A special step for repeating a bunch of steps a certain number of times.",
"$ref": "#/$defs/RepeatStep"
"$ref": "#/$defs/StorageEmptyAssertion"
}
]
},
"FunctionCallStep": {
"Input": {
"description": "This is an input step which is a transaction description that the framework translates into a\ntransaction and executes on the nodes.",
"type": "object",
"properties": {
@@ -418,7 +394,7 @@
"return_data"
]
},
"BalanceAssertionStep": {
"BalanceAssertion": {
"description": "This represents a balance assertion step where the framework needs to query the balance of some\naccount or contract and assert that it's some amount.",
"type": "object",
"properties": {
@@ -443,8 +419,7 @@
"expected_balance"
]
},
"StorageEmptyAssertionStep": {
"description": "This represents an assertion for the storage of some contract or account and whether it's empty\nor not.",
"StorageEmptyAssertion": {
"type": "object",
"properties": {
"comment": {
@@ -468,29 +443,6 @@
"is_storage_empty"
]
},
"RepeatStep": {
"description": "This represents a repetition step which is a special step type that allows for a sequence of\nsteps to be repeated (on different drivers) a certain number of times.",
"type": "object",
"properties": {
"repeat": {
"description": "The number of repetitions that the steps should be repeated for.",
"type": "integer",
"format": "uint",
"minimum": 0
},
"steps": {
"description": "The sequence of steps to repeat for the above defined number of repetitions.",
"type": "array",
"items": {
"$ref": "#/$defs/Step"
}
}
},
"required": [
"repeat",
"steps"
]
},
"ContractPathAndIdent": {
"description": "Represents an identifier used for contracts.\n\nThe type supports serialization from and into the following string format:\n\n```text\n${path}:${contract_ident}\n```",
"type": "string"