From 55a32ed0853475114f050f0e399fa8e518e3c582 Mon Sep 17 00:00:00 2001 From: igor-aptos <110557261+igor-aptos@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:50:52 -0700 Subject: [PATCH] Add gas vesion list, and fix gas version for derived object id native function (#13047) Co-authored-by: Igor --- .../src/gas_schedule/aptos_framework.rs | 36 +++++++++---------- .../src/gas_schedule/transaction.rs | 11 +++--- aptos-move/aptos-gas-schedule/src/ver.rs | 7 ++++ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs index 3bd2bfe75de45..f5fe106bf2b75 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs @@ -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, }; @@ -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 @@ -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], @@ -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], diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs index 59febb82fce85..b26871ec4e1eb 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs @@ -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, @@ -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], @@ -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, ] ] diff --git a/aptos-move/aptos-gas-schedule/src/ver.rs b/aptos-move/aptos-gas-schedule/src/ver.rs index 81d1fbbfcab7a..d83434cb0cca5 100644 --- a/aptos-move/aptos-gas-schedule/src/ver.rs +++ b/aptos-move/aptos-gas-schedule/src/ver.rs @@ -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; +}