Skip to content

Commit

Permalink
Add gas vesion list, and fix gas version for derived object id native…
Browse files Browse the repository at this point in the history
… function (#13047)

Co-authored-by: Igor <[email protected]>
  • Loading branch information
igor-aptos and igor-aptos authored Apr 26, 2024
1 parent 77e1d22 commit 55a32ed
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
36 changes: 18 additions & 18 deletions aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! This module defines the gas parameters for Aptos Framework & Stdlib.
use crate::gas_schedule::NativeGasParameters;
use crate::{gas_schedule::NativeGasParameters, ver::gas_feature_versions::RELEASE_V1_12};
use aptos_gas_algebra::{
InternalGas, InternalGasPerAbstractValueUnit, InternalGasPerArg, InternalGasPerByte,
};
Expand Down Expand Up @@ -242,11 +242,11 @@ crate::gas_schedule::macros::define_gas_parameters!(
[type_info_chain_id_base: InternalGas, { 4.. => "type_info.chain_id.base" }, 551],

// TODO(Gas): Fix my cost
[function_info_check_is_identifier_base: InternalGas, { 17.. => "function_info.is_identifier.base" }, 551],
[function_info_check_is_identifier_per_byte: InternalGasPerByte, { 17.. => "function_info.is_identifier.per_byte" }, 3],
[function_info_check_dispatch_type_compatibility_impl_base: InternalGas, { 17.. => "function_info.check_dispatch_type_compatibility_impl.base" }, 1002],
[function_info_load_function_base: InternalGas, { 17.. => "function_info.load_function.base" }, 551],
[dispatchable_fungible_asset_dispatch_base: InternalGas, { 17.. => "dispatchable_fungible_asset.dispatch.base" }, 551],
[function_info_check_is_identifier_base: InternalGas, { RELEASE_V1_12.. => "function_info.is_identifier.base" }, 551],
[function_info_check_is_identifier_per_byte: InternalGasPerByte, { RELEASE_V1_12.. => "function_info.is_identifier.per_byte" }, 3],
[function_info_check_dispatch_type_compatibility_impl_base: InternalGas, { RELEASE_V1_12.. => "function_info.check_dispatch_type_compatibility_impl.base" }, 1002],
[function_info_load_function_base: InternalGas, { RELEASE_V1_12.. => "function_info.load_function.base" }, 551],
[dispatchable_fungible_asset_dispatch_base: InternalGas, { RELEASE_V1_12.. => "dispatchable_fungible_asset.dispatch.base" }, 551],

// Reusing SHA2-512's cost from Ristretto
[hash_sha2_512_base: InternalGas, { 4.. => "hash.sha2_512.base" }, 11910], // 3_240 * 20
Expand All @@ -267,17 +267,17 @@ crate::gas_schedule::macros::define_gas_parameters!(
[transaction_context_get_script_hash_base: InternalGas, "transaction_context.get_script_hash.base", 735],
// Based on SHA3-256's cost
[transaction_context_generate_unique_address_base: InternalGas, { 10.. => "transaction_context.generate_unique_address.base" }, 14704],
[transaction_context_sender_base: InternalGas, {17.. => "transaction_context.sender.base"}, 735],
[transaction_context_secondary_signers_base: InternalGas, {17.. => "transaction_context.secondary_signers.base"}, 735],
[transaction_context_secondary_signers_per_signer: InternalGasPerArg, {17.. => "transaction_context.secondary_signers.per_signer"}, 576], // 18 * 32
[transaction_context_fee_payer_base: InternalGas, {17.. => "transaction_context.fee_payer.base"}, 735],
[transaction_context_max_gas_amount_base: InternalGas, {17.. => "transaction_context.max_gas_amount.base"}, 735],
[transaction_context_gas_unit_price_base: InternalGas, {17.. => "transaction_context.gas_unit_price.base"}, 735],
[transaction_context_chain_id_base: InternalGas, {17.. => "transaction_context.chain_id.base"}, 735],
[transaction_context_entry_function_payload_base: InternalGas, {17.. => "transaction_context.entry_function_payload.base"}, 735],
[transaction_context_entry_function_payload_per_byte_in_str: InternalGasPerByte, {17.. => "transaction_context.entry_function_payload.per_abstract_memory_unit"}, 18],
[transaction_context_multisig_payload_base: InternalGas, {17.. => "transaction_context.multisig_payload.base"}, 735],
[transaction_context_multisig_payload_per_byte_in_str: InternalGasPerByte, {17.. => "transaction_context.multisig_payload.per_abstract_memory_unit"}, 18],
[transaction_context_sender_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.sender.base"}, 735],
[transaction_context_secondary_signers_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.secondary_signers.base"}, 735],
[transaction_context_secondary_signers_per_signer: InternalGasPerArg, {RELEASE_V1_12.. => "transaction_context.secondary_signers.per_signer"}, 576], // 18 * 32
[transaction_context_fee_payer_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.fee_payer.base"}, 735],
[transaction_context_max_gas_amount_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.max_gas_amount.base"}, 735],
[transaction_context_gas_unit_price_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.gas_unit_price.base"}, 735],
[transaction_context_chain_id_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.chain_id.base"}, 735],
[transaction_context_entry_function_payload_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.entry_function_payload.base"}, 735],
[transaction_context_entry_function_payload_per_byte_in_str: InternalGasPerByte, {RELEASE_V1_12.. => "transaction_context.entry_function_payload.per_abstract_memory_unit"}, 18],
[transaction_context_multisig_payload_base: InternalGas, {RELEASE_V1_12.. => "transaction_context.multisig_payload.base"}, 735],
[transaction_context_multisig_payload_per_byte_in_str: InternalGasPerByte, {RELEASE_V1_12.. => "transaction_context.multisig_payload.per_abstract_memory_unit"}, 18],

[code_request_publish_base: InternalGas, "code.request_publish.base", 1838],
[code_request_publish_per_byte: InternalGasPerByte, "code.request_publish.per_byte", 7],
Expand Down Expand Up @@ -309,7 +309,7 @@ crate::gas_schedule::macros::define_gas_parameters!(

[object_exists_at_base: InternalGas, { 7.. => "object.exists_at.base" }, 919],
// Based on SHA3-256's cost
[object_user_derived_address_base: InternalGas, { 16.. => "object.user_derived_address.base" }, 14704],
[object_user_derived_address_base: InternalGas, { RELEASE_V1_12.. => "object.user_derived_address.base" }, 14704],

// These are dummy value, they copied from storage gas in aptos-core/aptos-vm/src/aptos_vm_impl.rs
[object_exists_at_per_byte_loaded: InternalGasPerByte, { 7.. => "object.exists_at.per_byte_loaded" }, 183],
Expand Down
11 changes: 7 additions & 4 deletions aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
//! This module defines all the gas parameters for transactions, along with their initial values
//! in the genesis and a mapping between the Rust representation and the on-chain gas schedule.
use crate::gas_schedule::VMGasParameters;
use crate::{
gas_schedule::VMGasParameters,
ver::gas_feature_versions::{RELEASE_V1_11, RELEASE_V1_12},
};
use aptos_gas_algebra::{
AbstractValueSize, Fee, FeePerByte, FeePerGasUnit, FeePerSlot, Gas, GasExpression,
GasScalingFactor, GasUnit, NumModules, NumSlots,
Expand Down Expand Up @@ -120,12 +123,12 @@ crate::gas_schedule::macros::define_gas_parameters!(
],
[
storage_io_per_event_byte_write: InternalGasPerByte,
{ 16.. => "storage_io_per_event_byte_write" },
{ RELEASE_V1_11.. => "storage_io_per_event_byte_write" },
89,
],
[
storage_io_per_transaction_byte_write: InternalGasPerByte,
{ 16.. => "storage_io_per_transaction_byte_write" },
{ RELEASE_V1_11.. => "storage_io_per_transaction_byte_write" },
89,
],
[memory_quota: AbstractValueSize, { 1.. => "memory_quota" }, 10_000_000],
Expand Down Expand Up @@ -233,7 +236,7 @@ crate::gas_schedule::macros::define_gas_parameters!(
],
[
keyless_base_cost: InternalGas,
{ 17.. => "keyless.base" },
{ RELEASE_V1_12.. => "keyless.base" },
414_000_000,
]
]
Expand Down
7 changes: 7 additions & 0 deletions aptos-move/aptos-gas-schedule/src/ver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@
/// - V1
/// - TBA
pub const LATEST_GAS_FEATURE_VERSION: u64 = 17;

#[allow(dead_code)]
pub(crate) mod gas_feature_versions {
pub(crate) const RELEASE_V1_11: u64 = 16;
pub(crate) const RELEASE_V1_12: u64 = 17;
pub(crate) const RELEASE_V1_13: u64 = 18;
}

0 comments on commit 55a32ed

Please sign in to comment.