Skip to content

Commit

Permalink
Test: Reproduce 8ru7VEAEbyfZdbC1W2PYQv2cY3W92rbTToDEN4yTp8aZ gas fail…
Browse files Browse the repository at this point in the history
…ure (#485)
  • Loading branch information
birchmd committed Apr 27, 2022
1 parent 24eccb6 commit dbe5d76
Show file tree
Hide file tree
Showing 3 changed files with 1,380 additions and 0 deletions.
53 changes: 53 additions & 0 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,56 @@ fn repro_GdASJ3KESs() {
);
standalone.close()
}

/// This test reproduces a transaction from mainnet:
/// https://explorer.mainnet.near.org/transactions/8ru7VEAEbyfZdbC1W2PYQv2cY3W92rbTToDEN4yTp8aZ
/// It hit the NEAR gas limit even after the 2.5.2 engine release and limit increase to 300 Tgas.
/// The purpose of having it here is to be able to track its performance as we continue to
/// optimize the Engine.
/// The test is somewhat inscrutable because the data was directly pulled from the Engine contract
/// on mainnet, but according to the partner that submitted the transaction, the transaction should
/// be doing something similar to this one on Ethereum itself:
/// https://etherscan.io/tx/0x6c1ccadf6553f4f8bdb475667a91f050b1dfb63ded09053354f1e6fd78ff63a6
#[allow(non_snake_case)]
#[test]
fn repro_8ru7VEA() {
// Note: this snapshot is pruned from the full Engine state on mainnet at that block height.
// The full snapshot is very large, and all that is necessary for this test are the keys used
// in the transaction. This pruned snapshot contains precisely those keys, and no others.
let snapshot = json_snapshot::types::JsonSnapshot::load_from_file(
"src/tests/res/aurora_state_8ru7VEA.json",
)
.unwrap();

let mut runner = AuroraRunner::default();
runner.wasm_config.limit_config.max_gas_burnt = 3_000_000_000_000_000;
runner.context.storage_usage = 1_000_000_000;
runner.consume_json_snapshot(snapshot.clone());
runner.context.block_index = 62625815;
runner.context.block_timestamp = 1648829935343349589;

let tx_hex = std::fs::read_to_string("src/tests/res/input_8ru7VEA.hex").unwrap();
let tx_bytes = hex::decode(tx_hex.trim()).unwrap();

let (outcome, error) = runner.call("submit", "relay.aurora", tx_bytes);
let outcome = outcome.unwrap();
let profile = ExecutionProfile::new(&outcome);
if let Some(error) = error {
panic!("{:?}", error);
}
let submit_result =
SubmitResult::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap();

assert_eq!(submit_result.gas_used, 1732181);
assert_eq!(411, profile.all_gas() / 1_000_000_000_000);

// Also validate the SubmitResult in the standalone engine
let mut standalone = standalone::StandaloneRunner::default();
json_snapshot::initialize_engine_state(&mut standalone.storage, snapshot).unwrap();
let standalone_result = standalone.submit_raw("submit", &runner.context).unwrap();
assert_eq!(
submit_result.try_to_vec().unwrap(),
standalone_result.try_to_vec().unwrap()
);
standalone.close()
}
Loading

0 comments on commit dbe5d76

Please sign in to comment.