Skip to content

Commit

Permalink
Approximate other gas costs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajbouw committed Jul 14, 2022
1 parent 345490e commit 687885d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 23 deletions.
Binary file removed bin/aurora-mainnet-test.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions engine-tests/src/test_utils/standard_precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ impl PrecompilesContract {
"test_modexp",
"test_ecadd",
"test_ecmul",
// TODO(#46): ecpair uses up all the gas (by itself) for some reason, need to look into this.
// "test_ecpair",
"test_ecpair",
"test_blake2f",
"test_all",
]
Expand Down
69 changes: 59 additions & 10 deletions engine-tests/src/tests/standard_precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ use crate::prelude::Wei;
use crate::test_utils::{
self,
standard_precompiles::{PrecompilesConstructor, PrecompilesContract},
AuroraRunner, Signer,
AuroraRunner, ExecutionProfile, Signer,
};

const INITIAL_BALANCE: Wei = Wei::new_u64(1000);
const INITIAL_NONCE: u64 = 0;

fn precompile_execution_profile(method: &str) -> ExecutionProfile {
let (mut runner, mut signer, contract) = initialize();
let (_result, profile) = runner
.submit_with_signer_profiled(&mut signer, |nonce| contract.call_method(method, nonce))
.unwrap();
profile
}

#[test]
fn standard_precompiles() {
fn test_standard_precompiles() {
let (mut runner, mut signer, contract) = initialize();

let outcome = runner
Expand All @@ -20,16 +28,57 @@ fn standard_precompiles() {
}

#[test]
fn ecpair() {
let (mut runner, mut signer, contract) = initialize();
fn profile_ecrecover() {
let profile = precompile_execution_profile("test_ecrecover");
test_utils::assert_gas_bound(profile.all_gas(), 6);
}

let (_result, profile) = runner
.submit_with_signer_profiled(&mut signer, |nonce| {
contract.call_method("test_ecpair", nonce)
})
.unwrap();
#[test]
fn profile_sha256() {
let profile = precompile_execution_profile("test_sha256");
test_utils::assert_gas_bound(profile.all_gas(), 5);
}

#[test]
fn profile_ripemd160() {
let profile = precompile_execution_profile("test_ripemd160");
test_utils::assert_gas_bound(profile.all_gas(), 5);
}

#[test]
fn profile_identity() {
let profile = precompile_execution_profile("test_identity");
test_utils::assert_gas_bound(profile.all_gas(), 5);
}

#[test]
fn profile_modexp() {
let profile = precompile_execution_profile("test_modexp");
test_utils::assert_gas_bound(profile.all_gas(), 7);
}

#[test]
fn profile_ecadd() {
let profile = precompile_execution_profile("test_ecadd");
test_utils::assert_gas_bound(profile.all_gas(), 5);
}

assert!(profile.all_gas() < 200_000_000_000_000);
#[test]
fn profile_ecmul() {
let profile = precompile_execution_profile("test_ecmul");
test_utils::assert_gas_bound(profile.all_gas(), 6);
}

#[test]
fn profile_ecpair() {
let profile = precompile_execution_profile("test_ecpair");
test_utils::assert_gas_bound(profile.all_gas(), 102);
}

#[test]
fn profile_blake2f() {
let profile = precompile_execution_profile("test_blake2f");
test_utils::assert_gas_bound(profile.all_gas(), 6);
}

fn initialize() -> (AuroraRunner, Signer, PrecompilesContract) {
Expand Down
35 changes: 24 additions & 11 deletions etc/state-migration-test/Cargo.lock

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

0 comments on commit 687885d

Please sign in to comment.