Skip to content

Commit

Permalink
fix: sanity check that host functions don't increase action costs
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Apr 2, 2021
1 parent 46f5ce8 commit a3884c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/primitives-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ pub enum ExtCosts {
#[cfg(feature = "protocol_feature_alt_bn128")]
alt_bn128_g1_sum_byte,

// NB: this should be the last element of the enum.
// NOTE: this should be the last element of the enum.
__count,
}

Expand All @@ -556,7 +556,7 @@ pub enum ActionCosts {
value_return,
new_receipt,

// NB: this should be the last element of the enum.
// NOTE: this should be the last element of the enum.
__count,
}

Expand Down
6 changes: 5 additions & 1 deletion runtime/near-vm-runner/src/tests/rs_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fn run_test_ext(
let fees = RuntimeFeesConfig::default();
let context = create_context(input.to_vec());

let profile = ProfileData::new_enabled();
let (outcome, err) = run_vm(
&code,
&method,
Expand All @@ -145,9 +146,12 @@ fn run_test_ext(
vm_kind,
LATEST_PROTOCOL_VERSION,
None,
ProfileData::new_disabled(),
profile.clone(),
);

assert_eq!(profile.action_gas(), 0);
assert!(profile.host_gas() > 0);

if let Some(_) = err {
panic!("Failed execution: {:?}", err);
}
Expand Down

0 comments on commit a3884c4

Please sign in to comment.