mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-11 01:31:03 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ba28671c9 | |||
| 5d4c3b06c4 | |||
| c32124395d | |||
| 029aeccba3 | |||
| 71a05c3f47 | |||
| 22e46e0762 | |||
| eacff46624 |
@@ -12,14 +12,6 @@
|
|||||||
"address": "0xdeadbeef00000000000000000000000000000042",
|
"address": "0xdeadbeef00000000000000000000000000000042",
|
||||||
"expected_balance": "1233"
|
"expected_balance": "1233"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"address": "0xdeadbeef00000000000000000000000000000042",
|
|
||||||
"is_storage_empty": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"address": "0xdeadbeef00000000000000000000000000000042",
|
|
||||||
"is_storage_empty": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"instance": "WBTC_1",
|
"instance": "WBTC_1",
|
||||||
"method": "#deployer",
|
"method": "#deployer",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use std::collections::HashMap;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use alloy::consensus::EMPTY_ROOT_HASH;
|
|
||||||
use alloy::hex;
|
use alloy::hex;
|
||||||
use alloy::json_abi::JsonAbi;
|
use alloy::json_abi::JsonAbi;
|
||||||
use alloy::network::{Ethereum, TransactionBuilder};
|
use alloy::network::{Ethereum, TransactionBuilder};
|
||||||
@@ -29,7 +28,6 @@ use semver::Version;
|
|||||||
use revive_dt_format::case::{Case, CaseIdx};
|
use revive_dt_format::case::{Case, CaseIdx};
|
||||||
use revive_dt_format::input::{
|
use revive_dt_format::input::{
|
||||||
BalanceAssertion, Calldata, EtherValue, Expected, ExpectedOutput, Input, Method,
|
BalanceAssertion, Calldata, EtherValue, Expected, ExpectedOutput, Input, Method,
|
||||||
StorageEmptyAssertion,
|
|
||||||
};
|
};
|
||||||
use revive_dt_format::metadata::{ContractInstance, ContractPathAndIdent};
|
use revive_dt_format::metadata::{ContractInstance, ContractPathAndIdent};
|
||||||
use revive_dt_format::{input::Step, metadata::Metadata};
|
use revive_dt_format::{input::Step, metadata::Metadata};
|
||||||
@@ -92,11 +90,6 @@ where
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(StepOutput::BalanceAssertion)
|
Ok(StepOutput::BalanceAssertion)
|
||||||
}
|
}
|
||||||
Step::StorageEmptyAssertion(storage_empty) => {
|
|
||||||
self.handle_storage_empty(metadata, case_idx, storage_empty, node)
|
|
||||||
.await?;
|
|
||||||
Ok(StepOutput::StorageEmptyAssertion)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,22 +125,7 @@ where
|
|||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
self.handle_balance_assertion_contract_deployment(metadata, balance_assertion, node)
|
self.handle_balance_assertion_contract_deployment(metadata, balance_assertion, node)
|
||||||
.await?;
|
.await?;
|
||||||
self.handle_balance_assertion_execution(balance_assertion, node)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn handle_storage_empty(
|
|
||||||
&mut self,
|
|
||||||
metadata: &Metadata,
|
|
||||||
_: CaseIdx,
|
|
||||||
storage_empty: &StorageEmptyAssertion,
|
|
||||||
node: &T::Blockchain,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
self.handle_storage_empty_assertion_contract_deployment(metadata, storage_empty, node)
|
|
||||||
.await?;
|
|
||||||
self.handle_storage_empty_assertion_execution(storage_empty, node)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,67 +557,6 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_storage_empty_assertion_contract_deployment(
|
|
||||||
&mut self,
|
|
||||||
metadata: &Metadata,
|
|
||||||
storage_empty_assertion: &StorageEmptyAssertion,
|
|
||||||
node: &T::Blockchain,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let Some(instance) = storage_empty_assertion
|
|
||||||
.address
|
|
||||||
.strip_prefix(".address")
|
|
||||||
.map(ContractInstance::new)
|
|
||||||
else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
self.get_or_deploy_contract_instance(
|
|
||||||
&instance,
|
|
||||||
metadata,
|
|
||||||
Input::default_caller(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
node,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn handle_storage_empty_assertion_execution(
|
|
||||||
&mut self,
|
|
||||||
StorageEmptyAssertion {
|
|
||||||
address: address_string,
|
|
||||||
is_storage_empty,
|
|
||||||
}: &StorageEmptyAssertion,
|
|
||||||
node: &T::Blockchain,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let address = Address::from_slice(
|
|
||||||
Calldata::new_compound([address_string])
|
|
||||||
.calldata(node, self.default_resolution_context())
|
|
||||||
.await?
|
|
||||||
.get(12..32)
|
|
||||||
.expect("Can't fail"),
|
|
||||||
);
|
|
||||||
|
|
||||||
let storage = node.latest_state_proof(address, Default::default()).await?;
|
|
||||||
let is_empty = storage.storage_hash == EMPTY_ROOT_HASH;
|
|
||||||
|
|
||||||
let expected = is_storage_empty;
|
|
||||||
let actual = is_empty;
|
|
||||||
|
|
||||||
if *expected != actual {
|
|
||||||
tracing::error!(%expected, %actual, %address, "Storage Empty Assertion failed");
|
|
||||||
anyhow::bail!(
|
|
||||||
"Storage Empty Assertion failed - Expected {} but got {} for {} resolved to {}",
|
|
||||||
expected,
|
|
||||||
actual,
|
|
||||||
address_string,
|
|
||||||
address,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the information of a deployed contract or library from the state. If it's found to not
|
/// Gets the information of a deployed contract or library from the state. If it's found to not
|
||||||
/// be deployed then it will be deployed.
|
/// be deployed then it will be deployed.
|
||||||
///
|
///
|
||||||
@@ -863,7 +780,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(StepOutput::BalanceAssertion, StepOutput::BalanceAssertion) => {}
|
(StepOutput::BalanceAssertion, StepOutput::BalanceAssertion) => {}
|
||||||
(StepOutput::StorageEmptyAssertion, StepOutput::StorageEmptyAssertion) => {}
|
|
||||||
_ => unreachable!("The two step outputs can not be of a different kind"),
|
_ => unreachable!("The two step outputs can not be of a different kind"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,5 +795,4 @@ where
|
|||||||
pub enum StepOutput {
|
pub enum StepOutput {
|
||||||
FunctionCall(TransactionReceipt, GethTrace, DiffMode),
|
FunctionCall(TransactionReceipt, GethTrace, DiffMode),
|
||||||
BalanceAssertion,
|
BalanceAssertion,
|
||||||
StorageEmptyAssertion,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,7 +451,6 @@ where
|
|||||||
.filter_map(|step| match step {
|
.filter_map(|step| match step {
|
||||||
Step::FunctionCall(input) => Some(input.caller),
|
Step::FunctionCall(input) => Some(input.caller),
|
||||||
Step::BalanceAssertion(..) => None,
|
Step::BalanceAssertion(..) => None,
|
||||||
Step::StorageEmptyAssertion(..) => None,
|
|
||||||
})
|
})
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or(Input::default_caller());
|
.unwrap_or(Input::default_caller());
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ pub enum Step {
|
|||||||
FunctionCall(Box<Input>),
|
FunctionCall(Box<Input>),
|
||||||
/// A step for performing a balance assertion on some account or contract.
|
/// A step for performing a balance assertion on some account or contract.
|
||||||
BalanceAssertion(Box<BalanceAssertion>),
|
BalanceAssertion(Box<BalanceAssertion>),
|
||||||
/// A step for asserting that the storage of some contract or account is empty.
|
|
||||||
StorageEmptyAssertion(Box<StorageEmptyAssertion>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
|
||||||
@@ -62,20 +60,6 @@ pub struct BalanceAssertion {
|
|||||||
pub expected_balance: U256,
|
pub expected_balance: U256,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
|
|
||||||
pub struct StorageEmptyAssertion {
|
|
||||||
/// The address that the balance assertion should be done on.
|
|
||||||
///
|
|
||||||
/// This is a string which will be resolved into an address when being processed. Therefore,
|
|
||||||
/// this could be a normal hex address, a variable such as `Test.address`, or perhaps even a
|
|
||||||
/// full on variable like `$VARIABLE:Uniswap`. It follows the same resolution rules that are
|
|
||||||
/// followed in the calldata.
|
|
||||||
pub address: String,
|
|
||||||
|
|
||||||
/// A boolean of whether the storage of the address is empty or not.
|
|
||||||
pub is_storage_empty: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Expected {
|
pub enum Expected {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! This crate implements all node interactions.
|
//! This crate implements all node interactions.
|
||||||
|
|
||||||
use alloy::primitives::{Address, StorageKey, U256};
|
use alloy::primitives::{Address, U256};
|
||||||
use alloy::rpc::types::trace::geth::{DiffMode, GethDebugTracingOptions, GethTrace};
|
use alloy::rpc::types::trace::geth::{DiffMode, GethDebugTracingOptions, GethTrace};
|
||||||
use alloy::rpc::types::{EIP1186AccountProofResponse, TransactionReceipt, TransactionRequest};
|
use alloy::rpc::types::{TransactionReceipt, TransactionRequest};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
/// An interface for all interactions with Ethereum compatible nodes.
|
/// An interface for all interactions with Ethereum compatible nodes.
|
||||||
@@ -25,11 +25,4 @@ pub trait EthereumNode {
|
|||||||
|
|
||||||
/// Returns the balance of the provided [`Address`] back.
|
/// Returns the balance of the provided [`Address`] back.
|
||||||
fn balance_of(&self, address: Address) -> impl Future<Output = Result<U256>>;
|
fn balance_of(&self, address: Address) -> impl Future<Output = Result<U256>>;
|
||||||
|
|
||||||
/// Returns the latest storage proof of the provided [`Address`]
|
|
||||||
fn latest_state_proof(
|
|
||||||
&self,
|
|
||||||
address: Address,
|
|
||||||
keys: Vec<StorageKey>,
|
|
||||||
) -> impl Future<Output = Result<EIP1186AccountProofResponse>>;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-18
@@ -17,16 +17,14 @@ use alloy::{
|
|||||||
eips::BlockNumberOrTag,
|
eips::BlockNumberOrTag,
|
||||||
genesis::{Genesis, GenesisAccount},
|
genesis::{Genesis, GenesisAccount},
|
||||||
network::{Ethereum, EthereumWallet, NetworkWallet},
|
network::{Ethereum, EthereumWallet, NetworkWallet},
|
||||||
primitives::{
|
primitives::{Address, BlockHash, BlockNumber, BlockTimestamp, FixedBytes, TxHash, U256},
|
||||||
Address, BlockHash, BlockNumber, BlockTimestamp, FixedBytes, StorageKey, TxHash, U256,
|
|
||||||
},
|
|
||||||
providers::{
|
providers::{
|
||||||
Provider, ProviderBuilder,
|
Provider, ProviderBuilder,
|
||||||
ext::DebugApi,
|
ext::DebugApi,
|
||||||
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
|
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
|
||||||
},
|
},
|
||||||
rpc::types::{
|
rpc::types::{
|
||||||
EIP1186AccountProofResponse, TransactionReceipt, TransactionRequest,
|
TransactionReceipt, TransactionRequest,
|
||||||
trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame},
|
trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame},
|
||||||
},
|
},
|
||||||
signers::local::PrivateKeySigner,
|
signers::local::PrivateKeySigner,
|
||||||
@@ -382,20 +380,6 @@ impl EthereumNode for GethNode {
|
|||||||
.await
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, fields(geth_node_id = self.id))]
|
|
||||||
async fn latest_state_proof(
|
|
||||||
&self,
|
|
||||||
address: Address,
|
|
||||||
keys: Vec<StorageKey>,
|
|
||||||
) -> anyhow::Result<EIP1186AccountProofResponse> {
|
|
||||||
self.provider()
|
|
||||||
.await?
|
|
||||||
.get_proof(address, keys)
|
|
||||||
.latest()
|
|
||||||
.await
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResolverApi for GethNode {
|
impl ResolverApi for GethNode {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use alloy::{
|
|||||||
},
|
},
|
||||||
primitives::{
|
primitives::{
|
||||||
Address, B64, B256, BlockHash, BlockNumber, BlockTimestamp, Bloom, Bytes, FixedBytes,
|
Address, B64, B256, BlockHash, BlockNumber, BlockTimestamp, Bloom, Bytes, FixedBytes,
|
||||||
StorageKey, TxHash, U256,
|
TxHash, U256,
|
||||||
},
|
},
|
||||||
providers::{
|
providers::{
|
||||||
Provider, ProviderBuilder,
|
Provider, ProviderBuilder,
|
||||||
@@ -25,7 +25,7 @@ use alloy::{
|
|||||||
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
|
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
|
||||||
},
|
},
|
||||||
rpc::types::{
|
rpc::types::{
|
||||||
EIP1186AccountProofResponse, TransactionReceipt,
|
TransactionReceipt,
|
||||||
eth::{Block, Header, Transaction},
|
eth::{Block, Header, Transaction},
|
||||||
trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame},
|
trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame},
|
||||||
},
|
},
|
||||||
@@ -437,20 +437,6 @@ impl EthereumNode for KitchensinkNode {
|
|||||||
.await
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, fields(kitchensink_node_id = self.id))]
|
|
||||||
async fn latest_state_proof(
|
|
||||||
&self,
|
|
||||||
address: Address,
|
|
||||||
keys: Vec<StorageKey>,
|
|
||||||
) -> anyhow::Result<EIP1186AccountProofResponse> {
|
|
||||||
self.provider()
|
|
||||||
.await?
|
|
||||||
.get_proof(address, keys)
|
|
||||||
.latest()
|
|
||||||
.await
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResolverApi for KitchensinkNode {
|
impl ResolverApi for KitchensinkNode {
|
||||||
|
|||||||
Reference in New Issue
Block a user