diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 8d85cf38051..58136b1d244 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -536,6 +536,9 @@ pub enum ExtCosts { alt_bn128_g1_sum_base, #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_byte, + + // NOTE: this should be the last element of the enum. + __count, } // Type of an action, used in fees logic. @@ -552,6 +555,9 @@ pub enum ActionCosts { delete_key, value_return, new_receipt, + + // NOTE: this should be the last element of the enum. + __count, } impl fmt::Display for ActionCosts { @@ -562,7 +568,7 @@ impl fmt::Display for ActionCosts { impl ActionCosts { pub const fn count() -> usize { - ActionCosts::new_receipt as usize + 1 + ActionCosts::__count as usize } pub fn name_of(index: usize) -> &'static str { @@ -654,11 +660,13 @@ impl ExtCosts { alt_bn128_g1_sum_base => config.alt_bn128_g1_sum_base, #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_byte => config.alt_bn128_g1_sum_byte, + + __count => unreachable!(), } } pub const fn count() -> usize { - ExtCosts::validator_total_stake_base as usize + 1 + ExtCosts::__count as usize } pub fn name_of(index: usize) -> &'static str { diff --git a/runtime/near-vm-runner/src/tests/rs_contract.rs b/runtime/near-vm-runner/src/tests/rs_contract.rs index 31d43b5f5eb..edf9351b9c5 100644 --- a/runtime/near-vm-runner/src/tests/rs_contract.rs +++ b/runtime/near-vm-runner/src/tests/rs_contract.rs @@ -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, @@ -145,9 +146,11 @@ fn run_test_ext( vm_kind, LATEST_PROTOCOL_VERSION, None, - ProfileData::new_disabled(), + profile.clone(), ); + assert_eq!(profile.action_gas(), 0); + if let Some(_) = err { panic!("Failed execution: {:?}", err); }