Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add PRAGUE hard fork support #988

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ bstr = "1"
byte-slice-cast = { version = "1", default-features = false }
criterion = "0.5"
ethabi = { version = "18", default-features = false }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.47.0-beta.1", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.47.0-beta.1", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.47.0-beta.1", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.47.0-beta.1", default-features = false, features = ["std", "tracing"] }
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "0.47.0-rc.1", default-features = false }
evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "0.47.0-rc.1", default-features = false, features = ["std"] }
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "0.47.0-rc.1", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "0.47.0-rc.1", default-features = false, features = ["std", "tracing"] }
fixed-hash = { version = "0.8", default-features = false }
function_name = "0.3"
git2 = "0.20"
Expand Down
8 changes: 4 additions & 4 deletions engine-tests/src/tests/one_inch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn test_1inch_liquidity_protocol() {
let (result, profile, pool) =
helper.create_pool(&pool_factory, token_a.0.address, token_b.0.address);
assert!(result.gas_used >= 4_500_000); // more than 4.5M EVM gas used
assert_gas_bound(profile.all_gas(), 21);
assert_gas_bound(profile.all_gas(), 22);

// Approve giving ERC-20 tokens to the pool
helper.approve_erc20_tokens(&token_a, pool.address());
Expand All @@ -54,7 +54,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 302_000); // more than 302k EVM gas used
assert_gas_bound(profile.all_gas(), 23);
assert_gas_bound(profile.all_gas(), 25);

// Same here
helper.runner.context.block_timestamp += 10_000_000 * 1_000_000_000;
Expand All @@ -69,7 +69,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 210_000); // more than 210k EVM gas used
assert_gas_bound(profile.all_gas(), 25);
assert_gas_bound(profile.all_gas(), 26);

let (result, profile) = helper.pool_withdraw(
&pool,
Expand All @@ -80,7 +80,7 @@ fn test_1inch_liquidity_protocol() {
},
);
assert!(result.gas_used >= 150_000); // more than 150k EVM gas used
assert_gas_bound(profile.all_gas(), 21);
assert_gas_bound(profile.all_gas(), 22);
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn repro_GdASJ3KESs() {
block_timestamp: 1_645_717_564_644_206_730,
input_path: "src/tests/res/input_GdASJ3KESs.hex",
evm_gas_used: 706_713,
near_gas_used: 113,
near_gas_used: 130,
});
}

Expand All @@ -51,7 +51,7 @@ fn repro_8ru7VEA() {
block_timestamp: 1_648_829_935_343_349_589,
input_path: "src/tests/res/input_8ru7VEA.hex",
evm_gas_used: 1_732_181,
near_gas_used: 202,
near_gas_used: 231,
});
}

Expand All @@ -71,7 +71,7 @@ fn repro_FRcorNv() {
block_timestamp: 1_650_960_438_774_745_116,
input_path: "src/tests/res/input_FRcorNv.hex",
evm_gas_used: 1_239_721,
near_gas_used: 163,
near_gas_used: 185,
});
}

Expand All @@ -88,7 +88,7 @@ fn repro_5bEgfRQ() {
block_timestamp: 1_651_073_772_931_594_646,
input_path: "src/tests/res/input_5bEgfRQ.hex",
evm_gas_used: 6_414_105,
near_gas_used: 508,
near_gas_used: 509,
});
}

Expand All @@ -106,7 +106,7 @@ fn repro_D98vwmi() {
block_timestamp: 1_651_753_443_421_003_245,
input_path: "src/tests/res/input_D98vwmi.hex",
evm_gas_used: 1_035_348,
near_gas_used: 164,
near_gas_used: 190,
});
}

Expand All @@ -125,7 +125,7 @@ fn repro_Emufid2() {
block_timestamp: 1_662_118_048_636_713_538,
input_path: "src/tests/res/input_Emufid2.hex",
evm_gas_used: 1_156_364,
near_gas_used: 294,
near_gas_used: 300,
});
}

Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/standard_precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn profile_ecpair() {
#[test]
fn profile_blake2f() {
let profile = precompile_execution_profile("test_blake2f");
utils::assert_gas_bound(profile.all_gas(), 6);
utils::assert_gas_bound(profile.all_gas(), 7);
}

fn initialize() -> (AuroraRunner, Signer, PrecompilesContract) {
Expand Down
6 changes: 3 additions & 3 deletions engine-tests/src/tests/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn test_uniswap_input_multihop() {

let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into());

assert_eq!(107, profile.all_gas() / 1_000_000_000_000);
assert_eq!(117, profile.all_gas() / 1_000_000_000_000);
}

#[test]
Expand All @@ -50,7 +50,7 @@ fn test_uniswap_exact_output() {

let (_result, profile) =
context.add_equal_liquidity(LIQUIDITY_AMOUNT.into(), &token_a, &token_b);
utils::assert_gas_bound(profile.all_gas(), 32);
utils::assert_gas_bound(profile.all_gas(), 34);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
(38..=48).contains(&wasm_fraction),
Expand All @@ -59,7 +59,7 @@ fn test_uniswap_exact_output() {

let (_amount_in, profile) =
context.exact_output_single(&token_a, &token_b, OUTPUT_AMOUNT.into());
utils::assert_gas_bound(profile.all_gas(), 17);
utils::assert_gas_bound(profile.all_gas(), 18);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
(38..=48).contains(&wasm_fraction),
Expand Down
4 changes: 2 additions & 2 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub struct Engine<'env, I: IO, E: Env, M = AuroraModExp> {
modexp_algorithm: PhantomData<M>,
}

pub(crate) const CONFIG: &Config = &Config::cancun();
pub(crate) const CONFIG: &Config = &Config::prague();

impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Engine<'env, I, E, M> {
pub fn new(
Expand Down Expand Up @@ -2749,7 +2749,7 @@ mod tests {
let mut handler = Noop;
let actual_result = refund_on_error(io, &env, expected_state, &args, &mut handler).unwrap();
let expected_result =
SubmitResult::new(TransactionStatus::Succeed(Vec::new()), 21344, Vec::new());
SubmitResult::new(TransactionStatus::Succeed(Vec::new()), 21860, Vec::new());

assert_eq!(expected_result, actual_result);
}
Expand Down
Loading