Compare commits

..

3 Commits

Author SHA1 Message Date
Omar Abdulla 54d9f94134 Allow for the resolution of gas price 2025-08-06 17:34:30 +03:00
Omar Abdulla 5de7b161c5 Fix block difficulty resolution 2025-08-06 15:50:00 +03:00
Omar Abdulla f9060772c3 Allow resolution of base fee 2025-08-06 15:27:40 +03:00
7 changed files with 19 additions and 37 deletions
+1 -7
View File
@@ -2,7 +2,6 @@ use std::{
collections::HashMap,
path::Path,
sync::{Arc, LazyLock},
time::Instant,
};
use alloy::{
@@ -190,7 +189,6 @@ where
)));
let status_reporter_task = {
let metadata_case_status = metadata_case_status.clone();
let start = Instant::now();
async move {
const GREEN: &str = "\x1B[32m";
const RED: &str = "\x1B[31m";
@@ -283,12 +281,8 @@ where
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}
let elapsed = start.elapsed();
eprintln!(
"{GREEN}{}{RESET} cases succeeded, {RED}{}{RESET} cases failed in {} seconds",
number_of_successes,
number_of_failures,
elapsed.as_secs()
"{GREEN}{number_of_successes}{RESET} cases succeeded, {RED}{number_of_failures}{RESET} cases failed"
);
}
};
+2 -2
View File
@@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use revive_dt_common::macros::define_wrapper_type;
@@ -7,7 +7,7 @@ use crate::{
mode::Mode,
};
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Deserialize, Clone, Eq, PartialEq)]
pub struct Case {
pub name: Option<String>,
pub comment: Option<String>,
+9 -9
View File
@@ -17,7 +17,7 @@ use revive_dt_common::macros::define_wrapper_type;
use crate::traits::ResolverApi;
use crate::{metadata::ContractInstance, traits::ResolutionContext};
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct Input {
#[serde(default = "Input::default_caller")]
pub caller: Address,
@@ -33,7 +33,7 @@ pub struct Input {
pub variable_assignments: Option<VariableAssignments>,
}
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum Expected {
Calldata(Calldata),
@@ -41,7 +41,7 @@ pub enum Expected {
ExpectedMany(Vec<ExpectedOutput>),
}
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct ExpectedOutput {
pub compiler_version: Option<VersionReq>,
pub return_data: Option<Calldata>,
@@ -50,7 +50,7 @@ pub struct ExpectedOutput {
pub exception: bool,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct Event {
pub address: Option<String>,
pub topics: Vec<String>,
@@ -108,7 +108,7 @@ pub struct Event {
/// [`Single`]: Calldata::Single
/// [`Compound`]: Calldata::Compound
/// [reverse polish notation]: https://en.wikipedia.org/wiki/Reverse_Polish_notation
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
#[serde(untagged)]
pub enum Calldata {
Single(Bytes),
@@ -142,7 +142,7 @@ enum Operation {
}
/// Specify how the contract is called.
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Deserialize, Clone, Eq, PartialEq)]
pub enum Method {
/// Initiate a deploy transaction, calling contracts constructor.
///
@@ -167,7 +167,7 @@ define_wrapper_type!(
pub struct EtherValue(U256);
);
#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct VariableAssignments {
/// A vector of the variable names to assign to the return data.
///
@@ -599,7 +599,7 @@ impl<T: AsRef<str>> CalldataToken<T> {
Some(block_number) => *block_number,
None => resolver.last_block_number().await?,
};
let desired_block_number = current_block_number.saturating_sub(offset);
let desired_block_number = current_block_number - offset;
let block_hash = resolver.block_hash(desired_block_number.into()).await?;
@@ -612,7 +612,7 @@ impl<T: AsRef<str>> CalldataToken<T> {
Ok(U256::from(current_block_number))
} else if item == Self::BLOCK_TIMESTAMP_VARIABLE {
resolver
.block_timestamp(context.resolve_block_number(BlockNumberOrTag::Latest))
.block_timestamp(BlockNumberOrTag::Latest)
.await
.map(U256::from)
} else if let Some(variable_name) = item.strip_prefix(Self::VARIABLE_PREFIX) {
+2 -1
View File
@@ -43,11 +43,12 @@ impl Deref for MetadataFile {
}
}
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Default, Deserialize, Clone, Eq, PartialEq)]
pub struct Metadata {
pub targets: Option<Vec<String>>,
pub cases: Vec<Case>,
pub contracts: Option<BTreeMap<ContractInstance, ContractPathAndIdent>>,
// TODO: Convert into wrapper types for clarity.
pub libraries: Option<BTreeMap<PathBuf, BTreeMap<ContractIdent, ContractInstance>>>,
pub ignore: Option<bool>,
pub modes: Option<Vec<Mode>>,
+1 -18
View File
@@ -16,7 +16,6 @@ pub struct SolcMode {
pub solc_version: Option<semver::VersionReq>,
solc_optimize: Option<bool>,
pub llvm_optimizer_settings: Vec<String>,
mode_string: String,
}
impl SolcMode {
@@ -30,10 +29,7 @@ impl SolcMode {
/// - A solc `SemVer version requirement` string
/// - One or more `-OX` where X is a supposed to be an LLVM opt mode
pub fn parse_from_mode_string(mode_string: &str) -> Option<Self> {
let mut result = Self {
mode_string: mode_string.to_string(),
..Default::default()
};
let mut result = Self::default();
let mut parts = mode_string.trim().split(" ");
@@ -108,16 +104,3 @@ impl<'de> Deserialize<'de> for Mode {
Ok(Self::Unknown(mode_string))
}
}
impl Serialize for Mode {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let string = match self {
Mode::Solidity(solc_mode) => &solc_mode.mode_string,
Mode::Unknown(string) => string,
};
string.serialize(serializer)
}
}
+2
View File
@@ -22,6 +22,7 @@ use alloy::{
Provider, ProviderBuilder,
ext::DebugApi,
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
layers::CacheLayer,
},
rpc::types::{
TransactionReceipt, TransactionRequest,
@@ -257,6 +258,7 @@ impl GethNode {
.filler(FallbackGasFiller::new(500_000_000, 500_000_000, 1))
.filler(ChainIdFiller::default())
.filler(NonceFiller::new(nonce_manager))
.layer(CacheLayer::new(10_000))
.wallet(wallet)
.connect(&connection_string)
.await
+2
View File
@@ -23,6 +23,7 @@ use alloy::{
Provider, ProviderBuilder,
ext::DebugApi,
fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller},
layers::CacheLayer,
},
rpc::types::{
TransactionReceipt,
@@ -372,6 +373,7 @@ impl KitchensinkNode {
))
.filler(ChainIdFiller::default())
.filler(NonceFiller::new(nonce_manager))
.layer(CacheLayer::new(10_000))
.wallet(wallet)
.connect(&connection_string)
.await