iota_types/gas_model/
gas_predicates.rs

1// Copyright (c) 2021, Facebook, Inc. and its affiliates
2// Copyright (c) Mysten Labs, Inc.
3// Modifications Copyright (c) 2024 IOTA Stiftung
4// SPDX-License-Identifier: Apache-2.0
5
6// Predicates and utility functions based on gas versions.
7//
8
9use crate::gas_model::{tables::initial_cost_schedule_v1, units_types::CostTable};
10
11// Threshold after which native functions contribute to virtual instruction
12// count.
13const V2_NATIVE_FUNCTION_CALL_THRESHOLD: u64 = 700;
14
15// Return if the native function call threshold is exceeded
16pub fn native_function_threshold_exceeded(gas_model_version: u64, num_native_calls: u64) -> bool {
17    if gas_model_version > 1 {
18        num_native_calls > V2_NATIVE_FUNCTION_CALL_THRESHOLD
19    } else {
20        false
21    }
22}
23
24// Return the version supported cost table
25pub fn cost_table_for_version(_gas_model: u64) -> CostTable {
26    initial_cost_schedule_v1()
27}