Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/actions/run-differential-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ inputs:
required: false
default: "main"
type: string
resolc-version:
description: "The version of resolc to install and use in tests."
required: false
default: "0.5.0"
resolc-download-url:
description: "The URL to use to download the resolc compiler."
required: true
type: string
use-compilation-caches:
description: "Controls if the compilation caches will be used for the test run or not."
Expand Down Expand Up @@ -62,11 +61,8 @@ runs:
submodules: recursive
- name: Installing the Latest Resolc
shell: bash
if: ${{ runner.os == 'Linux' && runner.arch == 'X64' }}
run: |
VERSION="${{ inputs['resolc-version'] }}"
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-x86_64-unknown-linux-musl"
echo "Downloading resolc v$VERSION from $ASSET_URL"
ASSET_URL="${{ inputs['resolc-download-url'] }}"
curl -Lsf --show-error -o resolc "$ASSET_URL"
chmod +x resolc
./resolc --version
Expand Down
18 changes: 9 additions & 9 deletions crates/core/src/differential_tests/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,16 @@ where
.context("Failed to find deployment receipt for constructor call"),
Method::Fallback | Method::FunctionName(_) => {
let resolver = self.platform_information.node.resolver().await?;
let tx = match step
let mut tx = step
.as_transaction(resolver.as_ref(), self.default_resolution_context())
.await
{
Ok(tx) => tx,
Err(err) => {
return Err(err);
}
};
.await?;

let gas_overrides = step
.gas_overrides
.get(&self.platform_information.platform.platform_identifier())
.copied()
.unwrap_or_default();
gas_overrides.apply_to::<Ethereum>(&mut tx);

self.platform_information.node.execute_transaction(tx).await
}
Expand Down Expand Up @@ -911,7 +912,6 @@ where
.get(contract_instance)
{
info!(

%address,
"Contract instance already deployed."
);
Expand Down
63 changes: 63 additions & 0 deletions crates/format/src/steps.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashMap, fmt::Display, str::FromStr};

use alloy::hex::ToHexExt;
use alloy::network::Network;
use alloy::primitives::{FixedBytes, utils::parse_units};
use alloy::{
eips::BlockNumberOrTag,
Expand All @@ -11,6 +12,7 @@ use alloy::{
};
use anyhow::Context as _;
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, stream};
use revive_dt_common::types::PlatformIdentifier;
use schemars::JsonSchema;
use semver::VersionReq;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -152,6 +154,11 @@ pub struct FunctionCallStep {
/// during the execution.
#[serde(skip_serializing_if = "Option::is_none")]
pub variable_assignments: Option<VariableAssignments>,

/// Allows for the test to set a specific value for the various gas parameter for each one of
/// the platforms we support. This is ignored for steps that perform contract deployments.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub gas_overrides: HashMap<PlatformIdentifier, GasOverrides>,
}

/// This represents a balance assertion step where the framework needs to query the balance of some
Expand Down Expand Up @@ -965,6 +972,62 @@ impl<'de> Deserialize<'de> for EtherValue {
}
}

#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
pub struct GasOverrides {
#[serde(skip_serializing_if = "Option::is_none")]
pub gas_limit: Option<u64>,

#[serde(skip_serializing_if = "Option::is_none")]
pub gas_price: Option<u128>,

#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee_per_gas: Option<u128>,

#[serde(skip_serializing_if = "Option::is_none")]
pub max_priority_fee_per_gas: Option<u128>,
}

impl GasOverrides {
pub fn new() -> Self {
Default::default()
}

pub fn with_gas_limit(mut self, value: impl Into<Option<u64>>) -> Self {
self.gas_limit = value.into();
self
}

pub fn with_gas_price(mut self, value: impl Into<Option<u128>>) -> Self {
self.gas_price = value.into();
self
}

pub fn with_max_fee_per_gas(mut self, value: impl Into<Option<u128>>) -> Self {
self.max_fee_per_gas = value.into();
self
}

pub fn with_max_priority_fee_per_gas(mut self, value: impl Into<Option<u128>>) -> Self {
self.max_priority_fee_per_gas = value.into();
self
}

pub fn apply_to<N: Network>(&self, transaction_request: &mut N::TransactionRequest) {
if let Some(gas_limit) = self.gas_limit {
transaction_request.set_gas_limit(gas_limit);
}
if let Some(gas_price) = self.gas_price {
transaction_request.set_gas_price(gas_price);
}
if let Some(max_fee_per_gas) = self.max_fee_per_gas {
transaction_request.set_max_fee_per_gas(max_fee_per_gas);
}
if let Some(max_priority_fee_per_gas) = self.max_priority_fee_per_gas {
transaction_request.set_max_priority_fee_per_gas(max_priority_fee_per_gas)
}
}
}

#[cfg(test)]
mod tests {

Expand Down
Loading