1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![forbid(unsafe_code)]
pub const APTOS_ROOT_KEY: &str = "aptos_root";
pub const CONSENSUS_KEY: &str = "consensus";
pub const FULLNODE_NETWORK_KEY: &str = "fullnode_network";
pub const OPERATOR_ACCOUNT: &str = "operator_account";
pub const OPERATOR_KEY: &str = "operator";
pub const OWNER_ACCOUNT: &str = "owner_account";
pub const OWNER_KEY: &str = "owner";
pub const VALIDATOR_NETWORK_KEY: &str = "validator_network";
pub const SAFETY_DATA: &str = "safety_data";
pub const WAYPOINT: &str = "waypoint";
pub const GENESIS_WAYPOINT: &str = "genesis-waypoint";
pub const MOVE_MODULES: &str = "move_modules";
pub const MIN_PRICE_PER_GAS_UNIT: &str = "min_price_per_gas_unit";
#[cfg(any(test, feature = "testing"))]
pub const GAS_UNIT_PRICE: u64 = 0;
#[cfg(not(any(test, feature = "testing")))]
pub const GAS_UNIT_PRICE: u64 = 100;
pub const MAX_GAS_AMOUNT: u64 = 1_000_000;
pub const GAS_HEADROOM_NUMERATOR: u64 = 3;
pub const GAS_HEADROOM_DENOMINATOR: u64 = 2;
pub fn adjust_gas_headroom(gas_used: u64, max_possible_gas: u64) -> u64 {
std::cmp::min(
max_possible_gas,
(gas_used.saturating_mul(GAS_HEADROOM_NUMERATOR)).saturating_div(GAS_HEADROOM_DENOMINATOR),
)
}