Skip to content

Commit

Permalink
Lower gas bounds due to new optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
birchmd committed Feb 28, 2022
1 parent 223f1b3 commit 9203997
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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 @@ -39,7 +39,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(), 34); // less than 34 NEAR Tgas used
assert_gas_bound(profile.all_gas(), 33); // less than 33 NEAR Tgas used

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

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

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

#[test]
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 @@ -28,7 +28,7 @@ fn test_uniswap_input_multihop() {
let mut context = UniswapTestContext::new("uniswap");

// evm_gas = 970k
// near total gas = 214 Tgas
// near total gas = 204 Tgas
// Wish: optimize so that this transaction costs less than 200 Tgas.
// For now we just have to increase the burnt gas limit to make it run to completion.
context.runner.wasm_config.limit_config.max_gas_burnt = 500_000_000_000_000;
Expand All @@ -54,7 +54,7 @@ fn test_uniswap_exact_output() {

let (_result, profile) =
context.add_equal_liquidity(LIQUIDITY_AMOUNT.into(), &token_a, &token_b);
test_utils::assert_gas_bound(profile.all_gas(), 58);
test_utils::assert_gas_bound(profile.all_gas(), 57);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
20 <= wasm_fraction && wasm_fraction <= 30,
Expand All @@ -64,7 +64,7 @@ fn test_uniswap_exact_output() {

let (_amount_in, profile) =
context.exact_output_single(&token_a, &token_b, OUTPUT_AMOUNT.into());
test_utils::assert_gas_bound(profile.all_gas(), 32);
test_utils::assert_gas_bound(profile.all_gas(), 31);
let wasm_fraction = 100 * profile.wasm_gas() / profile.all_gas();
assert!(
25 <= wasm_fraction && wasm_fraction <= 35,
Expand Down

0 comments on commit 9203997

Please sign in to comment.