Skip to content

Commit

Permalink
add runner crate (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: pgherveou <[email protected]>
  • Loading branch information
xermicus and pgherveou authored Aug 24, 2024
1 parent 0903718 commit 7844bbb
Show file tree
Hide file tree
Showing 10 changed files with 9,813 additions and 1,373 deletions.
10,443 changes: 9,246 additions & 1,197 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ env_logger = { version = "0.10.0", default-features = false }
serde_stacker = "0.1"
criterion = { version = "0.5", features = ["html_reports"] }
log = { version = "0.4" }
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
scale-info = { version = "2.11.1", default-features = false }

# Benchmarking against EVM
primitive-types = { version = "0.12", features = ["codec"] }
Expand All @@ -47,6 +49,10 @@ version = "0.5"
default-features = false
features = ["serde", "llvm18-0", "no-libffi-linking", "target-riscv"]

[workspace.dependencies.polkadot-sdk]
git = "https://github.com/paritytech/polkadot-sdk"
rev = "559fa1db0594a81d5dbf343613ba2f3fc16708da"

[profile.benchmark]
inherits = "release"
lto = true
Expand Down
1 change: 0 additions & 1 deletion crates/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ alloy-sol-types = { workspace = true }
hex = { workspace = true }
env_logger = { workspace = true }
log = { workspace = true }
once_cell = { workspace = true }

revive-solidity = { path = "../solidity" }
revive-differential = { path = "../differential" }
Expand Down
126 changes: 64 additions & 62 deletions crates/integration/src/cases.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use alloy_primitives::{Address, I256, U256};
use alloy_sol_types::{sol, SolCall, SolConstructor};

use revive_solidity::test_utils::*;

use crate::mock_runtime::{CallOutput, State};

#[derive(Clone)]
Expand Down Expand Up @@ -193,8 +195,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Baseline::baselineCall::new(()).abi_encode(),
}
}
Expand All @@ -205,8 +207,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Computation::odd_productCall::new((n,)).abi_encode(),
}
}
Expand All @@ -217,8 +219,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Computation::triangle_numberCall::new((n,)).abi_encode(),
}
}
Expand All @@ -229,8 +231,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: FibonacciRecursive::fib3Call::new((U256::from(n),)).abi_encode(),
}
}
Expand All @@ -241,8 +243,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: FibonacciIterative::fib3Call::new((U256::from(n),)).abi_encode(),
}
}
Expand All @@ -253,8 +255,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: FibonacciBinet::fib3Call::new((U256::from(n),)).abi_encode(),
}
}
Expand All @@ -265,8 +267,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: SHA1::sha1Call::new((pre,)).abi_encode(),
}
}
Expand All @@ -277,8 +279,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Flipper::flipCall::new(()).abi_encode(),
}
}
Expand All @@ -289,8 +291,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Flipper::constructorCall::new((coin,)).abi_encode(),
}
}
Expand All @@ -301,8 +303,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: IERC20::totalSupplyCall::new(()).abi_encode(),
}
}
Expand All @@ -313,8 +315,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Block::numberCall::new(()).abi_encode(),
}
}
Expand All @@ -325,8 +327,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Block::timestampCall::new(()).abi_encode(),
}
}
Expand All @@ -337,8 +339,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Context::address_thisCall::new(()).abi_encode(),
}
}
Expand All @@ -349,8 +351,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Context::callerCall::new(()).abi_encode(),
}
}
Expand All @@ -361,8 +363,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: DivisionArithmetics::divCall::new((n, d)).abi_encode(),
}
}
Expand All @@ -373,8 +375,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: DivisionArithmetics::sdivCall::new((n, d)).abi_encode(),
}
}
Expand All @@ -385,8 +387,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: DivisionArithmetics::modCall::new((n, d)).abi_encode(),
}
}
Expand All @@ -397,8 +399,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: DivisionArithmetics::smodCall::new((n, d)).abi_encode(),
}
}
Expand All @@ -409,8 +411,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: MStore8::mStore8Call::new((value,)).abi_encode(),
}
}
Expand All @@ -421,8 +423,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Events::emitEventCall::new((topics,)).abi_encode(),
}
}
Expand All @@ -433,8 +435,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: vec![0; 4],
}
}
Expand All @@ -445,8 +447,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: vec![0; 4],
}
}
Expand All @@ -457,8 +459,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: ExtCode::ExtCodeSizeCall::new((address,)).abi_encode(),
}
}
Expand All @@ -469,8 +471,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: ExtCode::CodeSizeCall::new(()).abi_encode(),
}
}
Expand All @@ -481,8 +483,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: MCopy::memcpyCall::new((payload,)).abi_encode(),
}
}
Expand All @@ -493,8 +495,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Call::value_transferCall::new((destination,)).abi_encode(),
}
}
Expand All @@ -505,8 +507,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Call::callCall::new((callee, payload)).abi_encode(),
}
}
Expand All @@ -517,8 +519,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Default::default(),
}
}
Expand All @@ -529,8 +531,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Value::balance_ofCall::new((address,)).abi_encode(),
}
}
Expand All @@ -541,8 +543,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Bitwise::opByteCall::new((index, value)).abi_encode(),
}
}
Expand All @@ -553,8 +555,8 @@ impl Contract {

Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
evm_runtime: compile_evm_bin_runtime(name, code),
pvm_runtime: compile_blob(name, code),
calldata: Storage::transientCall::new((value,)).abi_encode(),
}
}
Expand Down
Loading

0 comments on commit 7844bbb

Please sign in to comment.