diff --git a/.github/actions/check-branch-commits/expected_on_mainnet_not_main.txt b/.github/actions/check-branch-commits/expected_on_mainnet_not_main.txt index 42102ea82cd5c..ecf2165abd33f 100644 --- a/.github/actions/check-branch-commits/expected_on_mainnet_not_main.txt +++ b/.github/actions/check-branch-commits/expected_on_mainnet_not_main.txt @@ -3,6 +3,9 @@ # hash should be on a new line, with a comment explaining why it is # not on the main branch. +cb4ba0a57c998c60cbab65af31a64875d2588ca5 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/d2a0d17164d978c025c04cc54be55ce08f069091 +f144de376c4c5bc04bcd945ff802c4d8ff499059 # Combines two cherry-picks into one: https://github.com/aptos-labs/aptos-core/pull/6480 +84a67d185df4a9c12947f6091d0c0dc3427703f1 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/05eabd73b989fd733ca4b51e4f06c42088ea1e7c 895ae28e4a105430d8b9d2ce2f6e48c3b2c7fcf0 # Included in https://github.com/aptos-labs/aptos-core/commit/e401d8fcb0105bcccb8ff7f2129088bf671b4644 and https://github.com/aptos-labs/aptos-core/commit/b4d48c23ac5eedfad707e975402c5a96cabd77ec a78970aa2a6fd6fa7db94d6d5700a902807102c7 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/08ba4052c2e8b1de994706d1faf0f84e7c935ae1 6aae9a3595da0321a8bda0220fcf593060d44941 # Included in https://github.com/aptos-labs/aptos-core/commit/7bd412edb762cbdc935f28f62a91fc69c8daf639 diff --git a/.github/actions/check-branch-commits/expected_on_testnet_not_devnet.txt b/.github/actions/check-branch-commits/expected_on_testnet_not_devnet.txt index 8552434b3e496..4e1d435c09f1f 100644 --- a/.github/actions/check-branch-commits/expected_on_testnet_not_devnet.txt +++ b/.github/actions/check-branch-commits/expected_on_testnet_not_devnet.txt @@ -3,8 +3,10 @@ # hash should be on a new line, with a comment explaining why it is # not on the devnet branch. -895ae28e4a105430d8b9d2ce2f6e48c3b2c7fcf0 # Expected divergence. Will clear when devnet is wiped and recut. - +cb4ba0a57c998c60cbab65af31a64875d2588ca5 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/d2a0d17164d978c025c04cc54be55ce08f069091 +f144de376c4c5bc04bcd945ff802c4d8ff499059 # Contains a few commits merged into one: https://github.com/aptos-labs/aptos-core/pull/6480 +84a67d185df4a9c12947f6091d0c0dc3427703f1 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/05eabd73b989fd733ca4b51e4f06c42088ea1e7c +895ae28e4a105430d8b9d2ce2f6e48c3b2c7fcf0 # Contains a few commits merged into one: https://github.com/aptos-labs/aptos-core/pull/6436 a78970aa2a6fd6fa7db94d6d5700a902807102c7 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/08ba4052c2e8b1de994706d1faf0f84e7c935ae1 6aae9a3595da0321a8bda0220fcf593060d44941 # Included in https://github.com/aptos-labs/aptos-core/commit/7bd412edb762cbdc935f28f62a91fc69c8daf639 43ec117fb2fbf879d6e816fc77c7ed5ed5cd9d7c # Included in https://github.com/aptos-labs/aptos-core/commit/9df438a1eb6e6be9d97129781543196f03e7a812 and https://github.com/aptos-labs/aptos-core/commit/91797aacf83c7f668efa9ddee575139cb4ddbb42 diff --git a/.github/actions/check-branch-commits/expected_on_testnet_not_main.txt b/.github/actions/check-branch-commits/expected_on_testnet_not_main.txt index 7b86004df2db7..1f2aaa8dd4fb4 100644 --- a/.github/actions/check-branch-commits/expected_on_testnet_not_main.txt +++ b/.github/actions/check-branch-commits/expected_on_testnet_not_main.txt @@ -3,6 +3,9 @@ # hash should be on a new line, with a comment explaining why it is # not on the main branch. +cb4ba0a57c998c60cbab65af31a64875d2588ca5 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/d2a0d17164d978c025c04cc54be55ce08f069091 +f144de376c4c5bc04bcd945ff802c4d8ff499059 # Contains a few commits merged into one, see: https://github.com/aptos-labs/aptos-core/pull/6480 +84a67d185df4a9c12947f6091d0c0dc3427703f1 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/05eabd73b989fd733ca4b51e4f06c42088ea1e7c 895ae28e4a105430d8b9d2ce2f6e48c3b2c7fcf0 # Included in https://github.com/aptos-labs/aptos-core/commit/e401d8fcb0105bcccb8ff7f2129088bf671b4644 and https://github.com/aptos-labs/aptos-core/commit/b4d48c23ac5eedfad707e975402c5a96cabd77ec a78970aa2a6fd6fa7db94d6d5700a902807102c7 # Different commit hash and message: https://github.com/aptos-labs/aptos-core/commit/08ba4052c2e8b1de994706d1faf0f84e7c935ae1 6aae9a3595da0321a8bda0220fcf593060d44941 # Included in https://github.com/aptos-labs/aptos-core/commit/7bd412edb762cbdc935f28f62a91fc69c8daf639 diff --git a/.github/workflows/experimental-docker-build-test.yaml b/.github/workflows/experimental-docker-build-test.yaml index 9834f535d6f94..afb8ccd131ea7 100644 --- a/.github/workflows/experimental-docker-build-test.yaml +++ b/.github/workflows/experimental-docker-build-test.yaml @@ -37,6 +37,9 @@ on: # build on main branch OR when a PR is labeled with `CICD:build-images` - ".github/workflows/docker-rust-build.yaml" - ".github/workflows/sdk-release.yaml" - ".github/workflows/lint-test.yaml" + push: + branches: + - main # cancel redundant builds concurrency: @@ -120,6 +123,8 @@ jobs: secrets: inherit with: GIT_SHA: ${{ needs.determine-docker-build-metadata.outputs.gitSha }} + IMAGE_TAG: experimental_${{ needs.determine-docker-build-metadata.outputs.gitSha }} + FORGE_IMAGE_TAG: experimental_${{ needs.determine-docker-build-metadata.outputs.gitSha }} COMMENT_HEADER: forge-e2e # Use the cache ID as the Forge namespace so we can limit Forge test concurrency on k8s, since Forge # test lifecycle is separate from that of GHA. This protects us from the case where many Forge tests are triggered diff --git a/.github/workflows/experimental-docker-rust-build.yaml b/.github/workflows/experimental-docker-rust-build.yaml index 43c6eaea9e9df..e0fb42bdc1c2e 100644 --- a/.github/workflows/experimental-docker-rust-build.yaml +++ b/.github/workflows/experimental-docker-rust-build.yaml @@ -60,3 +60,4 @@ jobs: FEATURES: ${{ env.FEATURES }} BUILD_ADDL_TESTING_IMAGES: ${{ env.BUILD_ADDL_TESTING_IMAGES }} GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }} + CUSTOM_IMAGE_TAG_PREFIX: experimental diff --git a/.github/workflows/workflow-run-forge.yaml b/.github/workflows/workflow-run-forge.yaml index 93a2255b38345..745475963f46b 100644 --- a/.github/workflows/workflow-run-forge.yaml +++ b/.github/workflows/workflow-run-forge.yaml @@ -12,6 +12,10 @@ on: required: false type: string description: The docker image tag to test. If not specified, falls back on GIT_SHA, and then to the latest commits on the current branch + FORGE_IMAGE_TAG: + required: false + type: string + description: The docker image tag to use for forge runner. If not specified, falls back on GIT_SHA, and then to the latest commits on the current branch FORGE_NAMESPACE: required: false type: string @@ -70,6 +74,7 @@ env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: us-west-2 IMAGE_TAG: ${{ inputs.IMAGE_TAG }} + FORGE_IMAGE_TAG: ${{ inputs.FORGE_IMAGE_TAG }} FORGE_BLOCKING: ${{ secrets.FORGE_BLOCKING }} FORGE_CLUSTER_NAME: ${{ inputs.FORGE_CLUSTER_NAME }} FORGE_OUTPUT: forge_output.txt diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json index 73388a3c5be03..3c26e72fecd71 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json @@ -114,7 +114,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json index 2ec3971832c65..84a53b1bf5bcc 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json @@ -119,7 +119,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -397,7 +397,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -675,7 +675,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -953,7 +953,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1231,7 +1231,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1509,7 +1509,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1787,7 +1787,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -2065,7 +2065,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "1516", + "gas_used": "16", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json index d374a42e102fd..16a6e6b51e871 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json index d01e034e47152..61c4ab098a74b 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json index 489cd9bf2763b..38798af0bf4be 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json index 7f2d9bb4a1a96..f6fa75a1d24b9 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json index a76a38ff3e4bc..3617dc58407d8 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json index 03139305bb611..3e5214c4d3a39 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error CODE_DESERIALIZATION_ERROR", "accumulator_root_hash": "", diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json index 15e0b982d64be..831d908b279fc 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json @@ -4,7 +4,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "150", + "gas_used": "2", "success": false, "vm_status": "Transaction Executed and Committed with Error LINKER_ERROR", "accumulator_root_hash": "", diff --git a/api/src/accounts.rs b/api/src/accounts.rs index 8c9b105630452..fdbfc550cdd9e 100644 --- a/api/src/accounts.rs +++ b/api/src/accounts.rs @@ -20,13 +20,14 @@ use aptos_api_types::{ }; use aptos_types::{ access_path::AccessPath, - account_config::AccountResource, + account_config::{AccountResource, ObjectGroupResource}, event::{EventHandle, EventKey}, state_store::state_key::StateKey, }; +use aptos_vm::data_cache::AsMoveResolver; use move_core_types::{ identifier::Identifier, language_storage::StructTag, move_resource::MoveStructType, - value::MoveValue, + resolver::ResourceResolver, }; use poem_openapi::{ param::{Path, Query}, @@ -270,6 +271,35 @@ impl Account { }) } + /// Returns an error if an object or account resource does not exist at the address specified + /// within the context provided. + pub(crate) fn verify_account_or_object_resource(&self) -> Result<(), BasicErrorWith404> { + if self.get_account_resource().is_ok() { + return Ok(()); + } + + let state_key = StateKey::access_path(AccessPath::resource_group_access_path( + self.address.into(), + ObjectGroupResource::struct_tag(), + )); + + let state_value = self.context.get_state_value_poem( + &state_key, + self.ledger_version, + &self.latest_ledger_info, + )?; + + if state_value.is_some() { + Ok(()) + } else { + Err(account_not_found( + self.address, + self.ledger_version, + &self.latest_ledger_info, + )) + } + } + /// Retrieves the move resources associated with the account /// /// * JSON: Return a JSON encoded version of [`Vec`] @@ -279,7 +309,7 @@ impl Account { /// `start` and `limit` query parameters, the results will only be sorted within each page. pub fn resources(self, accept_type: &AcceptType) -> BasicResultWith404> { // check account exists - self.get_account_resource()?; + self.verify_account_or_object_resource()?; let max_account_resources_page_size = self.context.max_account_resources_page_size(); let (resources, next_state_key) = self .context @@ -348,7 +378,7 @@ impl Account { /// `start` and `limit` query parameters, the results will only be sorted within each page. pub fn modules(self, accept_type: &AcceptType) -> BasicResultWith404> { // check account exists - self.get_account_resource()?; + self.verify_account_or_object_resource()?; let max_account_modules_page_size = self.context.max_account_modules_page_size(); let (modules, next_state_key) = self .context @@ -479,52 +509,38 @@ impl Account { /// Find a resource associated with an account fn find_resource( &self, - struct_tag: &StructTag, - ) -> Result, BasicErrorWith404> { - let state_key = StateKey::access_path( - AccessPath::resource_access_path(self.address.into(), struct_tag.clone()).map_err( - |e| { - BasicErrorWith404::internal_with_code( - e, - AptosErrorCode::InternalError, - &self.latest_ledger_info, - ) - }, - )?, - ); - let state_value_bytes = self - .context - .db - .get_state_value_by_version(&state_key, self.ledger_version) - .context("Failed to read state value from db") + resource_type: &StructTag, + ) -> Result, BasicErrorWith404> { + let (ledger_info, ledger_version, state_view) = + self.context.state_view(Some(self.ledger_version))?; + + let resolver = state_view.as_move_resolver(); + let bytes = resolver + .get_resource(&self.address.into(), resource_type) + .context(format!( + "Failed to query DB to check for {} at {}", + resource_type, self.address + )) .map_err(|err| { BasicErrorWith404::internal_with_code( err, AptosErrorCode::InternalError, - &self.latest_ledger_info, + &ledger_info, ) })? .ok_or_else(|| { - resource_not_found( - self.address, - struct_tag, - self.ledger_version, - &self.latest_ledger_info, - ) - })? - .into_bytes(); + resource_not_found(self.address, resource_type, ledger_version, &ledger_info) + })?; - // Convert to fields in move struct - let move_resolver = self.context.move_resolver_poem(&self.latest_ledger_info)?; - move_resolver + resolver .as_converter(self.context.db.clone()) - .move_struct_fields(struct_tag, state_value_bytes.as_slice()) + .move_struct_fields(resource_type, bytes.as_slice()) .context("Failed to convert move structs from storage") .map_err(|err| { BasicErrorWith404::internal_with_code( err, AptosErrorCode::InternalError, - &self.latest_ledger_info, + &ledger_info, ) }) } diff --git a/api/src/context.rs b/api/src/context.rs index 9853fc7206d8f..34dc9716ddae9 100644 --- a/api/src/context.rs +++ b/api/src/context.rs @@ -128,6 +128,22 @@ impl Context { .map_err(|e| E::internal_with_code(e, AptosErrorCode::InternalError, ledger_info)) } + pub fn state_view( + &self, + requested_ledger_version: Option, + ) -> Result<(LedgerInfo, u64, DbStateView), E> { + let (latest_ledger_info, requested_ledger_version) = + self.get_latest_ledger_info_and_verify_lookup_version(requested_ledger_version)?; + + let state_view = self + .state_view_at_version(requested_ledger_version) + .map_err(|err| { + E::internal_with_code(err, AptosErrorCode::InternalError, &latest_ledger_info) + })?; + + Ok((latest_ledger_info, requested_ledger_version, state_view)) + } + pub fn state_view_at_version(&self, version: Version) -> Result { self.db.state_view_at_version(Some(version)) } diff --git a/api/src/events.rs b/api/src/events.rs index 18107f02b914c..ab52d18d75f8e 100644 --- a/api/src/events.rs +++ b/api/src/events.rs @@ -75,7 +75,7 @@ impl EventsApi { // Ensure that account exists let account = Account::new(self.context.clone(), address.0, None, None, None)?; - account.get_account_resource()?; + account.verify_account_or_object_resource()?; self.list( account.latest_ledger_info, accept_type, diff --git a/api/src/state.rs b/api/src/state.rs index 1b8d6cf964714..7ead4a8d5b3fa 100644 --- a/api/src/state.rs +++ b/api/src/state.rs @@ -7,18 +7,17 @@ use crate::{ response::{ api_disabled, build_not_found, module_not_found, resource_not_found, table_item_not_found, BadRequestError, BasicErrorWith404, BasicResponse, BasicResponseStatus, BasicResultWith404, - InternalError, StdApiError, + InternalError, }, ApiTags, Context, }; use anyhow::Context as AnyhowContext; use aptos_api_types::{ - verify_module_identifier, Address, AptosErrorCode, AsConverter, IdentifierWrapper, LedgerInfo, + verify_module_identifier, Address, AptosErrorCode, AsConverter, IdentifierWrapper, MoveModuleBytecode, MoveResource, MoveStructTag, MoveValue, RawTableItemRequest, TableItemRequest, VerifyInput, VerifyInputWithRecursion, U64, }; use aptos_state_view::TStateView; -use aptos_storage_interface::state_view::DbStateView; use aptos_types::{ access_path::AccessPath, state_store::{state_key::StateKey, table::TableHandle}, @@ -210,25 +209,6 @@ impl StateApi { } impl StateApi { - /// Retrieve state at the requested ledger version - fn preprocess_request( - &self, - requested_ledger_version: Option, - ) -> Result<(LedgerInfo, u64, DbStateView), E> { - let (latest_ledger_info, requested_ledger_version) = self - .context - .get_latest_ledger_info_and_verify_lookup_version(requested_ledger_version)?; - - let state_view = self - .context - .state_view_at_version(requested_ledger_version) - .map_err(|err| { - E::internal_with_code(err, AptosErrorCode::InternalError, &latest_ledger_info) - })?; - - Ok((latest_ledger_info, requested_ledger_version, state_view)) - } - /// Read a resource at the ledger version /// /// JSON: Convert to MoveResource @@ -246,7 +226,8 @@ impl StateApi { .map_err(|err| { BasicErrorWith404::bad_request_with_code_no_info(err, AptosErrorCode::InvalidInput) })?; - let (ledger_info, ledger_version, state_view) = self.preprocess_request(ledger_version)?; + + let (ledger_info, ledger_version, state_view) = self.context.state_view(ledger_version)?; let resolver = state_view.as_move_resolver(); let bytes = resolver .get_resource(&address.into(), &resource_type) @@ -302,8 +283,9 @@ impl StateApi { let module_id = ModuleId::new(address.into(), name.into()); let access_path = AccessPath::code_access_path(module_id.clone()); let state_key = StateKey::access_path(access_path); - let (ledger_info, ledger_version, state_view) = - self.preprocess_request(ledger_version.map(|inner| inner.0))?; + let (ledger_info, ledger_version, state_view) = self + .context + .state_view(ledger_version.map(|inner| inner.0))?; let bytes = state_view .get_state_value_bytes(&state_key) .context(format!("Failed to query DB to check for {:?}", state_key)) @@ -365,8 +347,9 @@ impl StateApi { })?; // Retrieve local state - let (ledger_info, ledger_version, state_view) = - self.preprocess_request(ledger_version.map(|inner| inner.0))?; + let (ledger_info, ledger_version, state_view) = self + .context + .state_view(ledger_version.map(|inner| inner.0))?; let resolver = state_view.as_move_resolver(); let converter = resolver.as_converter(self.context.db.clone()); @@ -438,8 +421,9 @@ impl StateApi { ledger_version: Option, ) -> BasicResultWith404 { // Retrieve local state - let (ledger_info, ledger_version, state_view) = - self.preprocess_request(ledger_version.map(|inner| inner.0))?; + let (ledger_info, ledger_version, state_view) = self + .context + .state_view(ledger_version.map(|inner| inner.0))?; let state_key = StateKey::table_item( TableHandle(table_handle.into()), diff --git a/api/src/tests/mod.rs b/api/src/tests/mod.rs index 692dbb942dead..bf8f801c3d8ad 100644 --- a/api/src/tests/mod.rs +++ b/api/src/tests/mod.rs @@ -10,6 +10,7 @@ mod index_test; mod invalid_post_request_test; mod modules; mod multisig_transactions_test; +mod objects; mod resource_groups; mod state_test; mod string_resource_test; diff --git a/api/src/tests/objects.rs b/api/src/tests/objects.rs new file mode 100644 index 0000000000000..8caae930b669d --- /dev/null +++ b/api/src/tests/objects.rs @@ -0,0 +1,132 @@ +// Copyright © Aptos Foundation +// SPDX-License-Identifier: Apache-2.0 + +use super::new_test_context; +use aptos_api_test_context::{current_function_name, TestContext}; +use aptos_types::{ + account_address::{self, AccountAddress}, + event::EventKey, +}; +use serde_json::{json, Value}; +use std::{collections::BTreeMap, path::PathBuf}; + +// This test verifies that READ APIs can parse objects and events from objects +// 1. Create account +// 2. Create an object +// 3. Read object +// 4. Transfer to cause transfer event +// 4. Read emitted event +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_gen_object() { + let mut context = new_test_context(current_function_name!()); + + // Prepare account + let mut user = context.create_account().await; + let user_addr = user.address(); + + // Publish packages + let named_addresses = vec![("token_objects".to_string(), user_addr)]; + let txn = futures::executor::block_on(async move { + let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR")) + .join("../aptos-move/move-examples/token_objects"); + TestContext::build_package(path, named_addresses) + }); + context.publish_package(&mut user, txn).await; + + // Read default data + let collection_addr = account_address::create_collection_address(user_addr, "Hero Quest!"); + let token_addr = account_address::create_token_address(user_addr, "Hero Quest!", "Wukong"); + let object_resource = "0x1::object::ObjectCore"; + let token_resource = format!("0x{}::token::Token", user_addr); + let hero_resource = format!("0x{}::hero::Hero", user_addr); + + let collection0 = context.gen_all_resources(&collection_addr).await; + + context + .api_execute_entry_function( + &mut user, + &format!("0x{}::hero::mint_hero", user_addr), + json!([]), + json!(["The best hero ever!", "Male", "Wukong", "Monkey God", ""]), + ) + .await; + let collection1 = context.gen_all_resources(&collection_addr).await; + assert_eq!(collection0, collection1); + + let hero = context.gen_all_resources(&token_addr).await; + let hero_map = to_object(hero); + assert!(hero_map.contains_key(object_resource)); + assert!(hero_map.contains_key(&token_resource)); + assert!(hero_map.contains_key(&hero_resource)); + let owner: AccountAddress = hero_map[object_resource]["owner"] + .as_str() + .unwrap() + .parse() + .unwrap(); + assert_eq!(owner, user_addr); + + let (before_event_key, before_event_seq) = transfer_events(&hero_map); + + context + .api_execute_entry_function( + &mut user, + "0x1::object::transfer_call", + json!([]), + json!([token_addr, token_addr]), + ) + .await; + + let hero = context.gen_all_resources(&token_addr).await; + let hero_map = to_object(hero); + + let owner: AccountAddress = hero_map[object_resource]["owner"] + .as_str() + .unwrap() + .parse() + .unwrap(); + assert_eq!(owner, token_addr); + + let (after_event_key, after_event_seq) = transfer_events(&hero_map); + assert_eq!(after_event_key, before_event_key); + assert_eq!(after_event_seq, before_event_seq + 1); + + let handle = context + .gen_events_by_handle(&token_addr, object_resource, "transfer_events") + .await; + let creation_num = context + .gen_events_by_creation_num(&token_addr, after_event_key.get_creation_number()) + .await; + assert_eq!(handle, creation_num); + assert_eq!(handle.as_array().unwrap().len(), 1); +} + +fn to_object(value: Value) -> BTreeMap { + value + .as_array() + .unwrap() + .iter() + .map(|entry| { + ( + entry["type"].as_str().unwrap().into(), + entry["data"].clone(), + ) + }) + .collect() +} + +fn transfer_events(object: &BTreeMap) -> (EventKey, u64) { + let transfer_events = object["0x1::object::ObjectCore"].as_object().unwrap()["transfer_events"] + .as_object() + .unwrap(); + let counter = transfer_events["counter"] + .as_str() + .unwrap() + .parse() + .unwrap(); + let guid = transfer_events["guid"].as_object().unwrap()["id"] + .as_object() + .unwrap(); + let creation_num = guid["creation_num"].as_str().unwrap().parse().unwrap(); + let addr = guid["addr"].as_str().unwrap().parse().unwrap(); + (EventKey::new(creation_num, addr), counter) +} diff --git a/api/test-context/src/test_context.rs b/api/test-context/src/test_context.rs index e545eab164411..adc46bccd7461 100644 --- a/api/test-context/src/test_context.rs +++ b/api/test-context/src/test_context.rs @@ -661,6 +661,28 @@ impl TestContext { .unwrap() } + pub async fn gen_events_by_handle( + &self, + account_address: &AccountAddress, + resource: &str, + field_name: &str, + ) -> Value { + let request = format!( + "/accounts/{}/events/{}/{}", + account_address, resource, field_name + ); + self.get(&request).await + } + + pub async fn gen_events_by_creation_num( + &self, + account_address: &AccountAddress, + creation_num: u64, + ) -> Value { + let request = format!("/accounts/{}/events/{}", account_address, creation_num); + self.get(&request).await + } + // return a specific resource for an account. None if not found. pub async fn gen_resource( &self, @@ -691,13 +713,8 @@ impl TestContext { module: &str, name: &str, ) -> serde_json::Value { - let resources = self - .get(&format!("/accounts/{}/resources", account.to_hex_literal())) - .await; - let vals: Vec = serde_json::from_value(resources).unwrap(); - vals.into_iter() - .find(|v| v["type"] == format!("{}::{}::{}", resource_account_address, module, name)) - .unwrap() + let resource = format!("{}::{}::{}", resource_account_address, module, name); + self.gen_resource(&account, &resource).await.unwrap() } // TODO: remove the helper function since we don't publish module directly anymore diff --git a/aptos-move/aptos-gas/src/gas_meter.rs b/aptos-move/aptos-gas/src/gas_meter.rs index b3b91314ca2de..c16643eaecd31 100644 --- a/aptos-move/aptos-gas/src/gas_meter.rs +++ b/aptos-move/aptos-gas/src/gas_meter.rs @@ -32,6 +32,7 @@ use std::collections::BTreeMap; // - V7 // - Native support for exists // - New formulae for storage fees based on fixed APT costs +// - Lower gas price (other than the newly introduced storage fees) by upping the scaling factor // - V6 // - Added a new native function - blake2b_256. // - V5 diff --git a/aptos-move/aptos-gas/src/transaction/mod.rs b/aptos-move/aptos-gas/src/transaction/mod.rs index 23e6c0e2792e4..6463381cac0e2 100644 --- a/aptos-move/aptos-gas/src/transaction/mod.rs +++ b/aptos-move/aptos-gas/src/transaction/mod.rs @@ -20,7 +20,7 @@ mod storage; pub use storage::{ChangeSetConfigs, StorageGasParameters}; -const GAS_SCALING_FACTOR: u64 = 10_000; +const GAS_SCALING_FACTOR: u64 = 1_000_000; crate::params::define_gas_parameters!( TransactionGasParameters, @@ -113,6 +113,11 @@ crate::params::define_gas_parameters!( { 5.. => "free_write_bytes_quota" }, 1024, // 1KB free per state write ], + [ + free_event_bytes_quota: NumBytes, + { 7.. => "free_event_bytes_quota" }, + 1024, // 1KB free event bytes per transaction + ], [ max_bytes_per_write_op: NumBytes, { 5.. => "max_bytes_per_write_op" }, @@ -222,14 +227,21 @@ impl TransactionGasParameters { &self, events: impl IntoIterator, ) -> Fee { - events.into_iter().fold(Fee::zero(), |acc, event| { - acc + self.storage_fee_per_event_byte * NumBytes::new(event.size() as u64) - }) + let total_bytes = events.into_iter().fold(NumBytes::zero(), |total, event| { + total + NumBytes::new(event.size() as u64) + }); + total_bytes + .checked_sub(self.free_event_bytes_quota) + .unwrap_or(NumBytes::zero()) + * self.storage_fee_per_event_byte } /// New formula to charge storage fee for transaction based on fixed APT costs. pub fn calculate_transaction_storage_fee(&self, txn_size: NumBytes) -> Fee { - self.storage_fee_per_transaction_byte * txn_size + txn_size + .checked_sub(self.large_transaction_cutoff) + .unwrap_or(NumBytes::zero()) + * self.storage_fee_per_transaction_byte } /// Calculate the intrinsic gas for the transaction based upon its size in bytes. diff --git a/aptos-move/aptos-release-builder/src/components/mod.rs b/aptos-move/aptos-release-builder/src/components/mod.rs index c120568513852..b18a32e0a5fe8 100644 --- a/aptos-move/aptos-release-builder/src/components/mod.rs +++ b/aptos-move/aptos-release-builder/src/components/mod.rs @@ -336,7 +336,7 @@ impl Default for ReleaseConfig { ReleaseConfig { testnet: true, framework_release: Some(FrameworkReleaseConfig { - bytecode_version: 6, + bytecode_version: 6, // TODO: remove explicit bytecode version from sources git_hash: None, }), gas_schedule: Some(aptos_gas::gen::current_gas_schedule()), diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp index a06f83af2ac9b..48a8463a5ab6e 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp @@ -1,7 +1,7 @@ processed 4 tasks task 1 'publish'. lines 4-30: -Error: Transaction discarded. VM status code: MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS +Error: Failed to execute transaction. ExecutionStatus: OutOfGas task 2 'run'. lines 33-33: Error: Transaction discarded. VM status code: MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp index b246fa070b510..6dbfbb8a4eaa0 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp @@ -1,16 +1,17 @@ processed 3 tasks task 1 'run'. lines 5-13: -Error: Transaction discarded. VM status code: MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS +mutable inputs after call: local#0: 0 +return values: 0 task 2 'view'. lines 15-15: key 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin> { coin: store 0x1::coin::Coin<0x1::aptos_coin::AptosCoin> { - value: 10000 + value: 10100 } frozen: false deposit_events: store 0x1::event::EventHandle<0x1::coin::DepositEvent> { - counter: 1 + counter: 2 guid: drop store 0x1::guid::GUID { id: copy drop store 0x1::guid::ID { creation_num: 2 diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/publish_module.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/publish_module.exp index 5a8a9d468c39d..d309b8933e42b 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/publish_module.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/publish_module.exp @@ -1,4 +1,4 @@ processed 2 tasks task 1 'publish'. lines 4-9: -Error: Transaction discarded. VM status code: MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS +Error: Failed to execute transaction. ExecutionStatus: OutOfGas diff --git a/aptos-move/e2e-move-tests/src/tests/per_category_gas_limits.rs b/aptos-move/e2e-move-tests/src/tests/per_category_gas_limits.rs index c2f5b4fddedda..b7e815ee907ce 100644 --- a/aptos-move/e2e-move-tests/src/tests/per_category_gas_limits.rs +++ b/aptos-move/e2e-move-tests/src/tests/per_category_gas_limits.rs @@ -4,6 +4,7 @@ use crate::{assert_success, assert_vm_status, tests::common, MoveHarness}; use aptos_gas::{Fee, Gas}; use aptos_types::{account_address::AccountAddress, vm_status::StatusCode}; +use move_core_types::gas_algebra::InternalGas; use serde::{Deserialize, Serialize}; /// Mimics `0xcafe::test::ModuleData` @@ -46,10 +47,8 @@ fn io_limit_reached() { let acc = h.new_account_at(AccountAddress::from_hex_literal("0xbeef").unwrap()); assert_success!(h.publish_package(&acc, &common::test_dir_path("execution_limit.data/test"),)); - // Lower the max io gas to 10 units. - h.modify_gas_schedule(|gas_params| { - gas_params.txn.max_io_gas = Gas::new(10) * gas_params.txn.gas_unit_scaling_factor - }); + // Lower the max io gas to lower than a single load_resource + h.modify_gas_schedule(|gas_params| gas_params.txn.max_io_gas = InternalGas::new(300_000 - 1)); // Execute the test function. The function will attempt to check if a resource exists and shall immediately hit the IO gas limit. let res = h.run_entry_function( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp index 195fb6d9c394c..a6fe8adac783f 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp @@ -30,7 +30,7 @@ Ok( events: [ ContractEvent { key: EventKey { creation_number: 0, account_address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1 }, index: 0, type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000001, module: Identifier("account"), name: Identifier("CoinRegisterEvent"), type_params: [] }), event_data: "00000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e" }, ], - gas_used: 1516, + gas_used: 16, status: Keep( Success, ), diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__borrow_after_move.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__borrow_after_move.exp index 8e74aeb00060a..b58a2b9941924 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__borrow_after_move.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__borrow_after_move.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 190, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -82,7 +82,7 @@ Ok( ), ), events: [], - gas_used: 685, + gas_used: 7, status: Keep( Success, ), @@ -107,7 +107,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -138,7 +138,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -159,7 +159,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__change_after_move.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__change_after_move.exp index d0f931f60c129..bb1cd8e9cf972 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__change_after_move.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__change_after_move.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 190, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -82,7 +82,7 @@ Ok( ), ), events: [], - gas_used: 685, + gas_used: 7, status: Keep( Success, ), @@ -107,7 +107,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -138,7 +138,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -159,7 +159,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -188,7 +188,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__move_from_across_blocks.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__move_from_across_blocks.exp index 0846cebfc8aed..24de95c87e07d 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__move_from_across_blocks.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__data_store__move_from_across_blocks.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 190, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -82,7 +82,7 @@ Ok( ), ), events: [], - gas_used: 685, + gas_used: 7, status: Keep( Success, ), @@ -107,7 +107,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -138,7 +138,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -163,7 +163,7 @@ Ok( ), ), events: [], - gas_used: 190, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -192,7 +192,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, @@ -227,7 +227,7 @@ Ok( ), ), events: [], - gas_used: 685, + gas_used: 7, status: Keep( Success, ), @@ -258,7 +258,7 @@ Ok( ), ), events: [], - gas_used: 191, + gas_used: 2, status: Keep( Success, ), @@ -279,7 +279,7 @@ Ok( ), ), events: [], - gas_used: 190, + gas_used: 2, status: Keep( ExecutionFailure { location: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1::M, diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__bad_module_address.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__bad_module_address.exp index fc14915027337..6a43cbac705b0 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__bad_module_address.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__bad_module_address.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb9178680138, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb917868013800000000000000000000000000000000d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb9178680138), + }: Modification(3e420f00000000000000000000000000000000000000000000d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb917868013800000000000000000000000000000000d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb9178680138), StateKey { inner: AccessPath( AccessPath { address: d88e78203e6688f0587d58ad01b0232da2a4b23f5916b324c365bb9178680138, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__duplicate_module.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__duplicate_module.exp index 932ee21437ad9..465454fc4bf5f 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__duplicate_module.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__duplicate_module.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_compatible_module.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_compatible_module.exp index 33b5e9cd8f97f..519e1aa203d31 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_compatible_module.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_compatible_module.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_changed_field.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_changed_field.exp index 78e3e8202999c..d8fe4642060b1 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_changed_field.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_changed_field.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_new_field.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_new_field.exp index 78e3e8202999c..d8fe4642060b1 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_new_field.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_new_field.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_field.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_field.exp index 78e3e8202999c..d8fe4642060b1 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_field.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_field.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_struct.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_struct.exp index 78e3e8202999c..d8fe4642060b1 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_struct.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__layout_incompatible_module_with_removed_struct.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_compatible_module.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_compatible_module.exp index 33b5e9cd8f97f..519e1aa203d31 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_compatible_module.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_compatible_module.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_added_param.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_added_param.exp index 7d5fc9542d746..d593cd3549af5 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_added_param.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_added_param.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_changed_param.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_changed_param.exp index b12e10764321a..d2dc2596f660e 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_changed_param.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_changed_param.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_removed_pub_fn.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_removed_pub_fn.exp index 7d5fc9542d746..d593cd3549af5 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_removed_pub_fn.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__linking_incompatible_module_with_removed_pub_fn.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), @@ -47,7 +47,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_allow_modules.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_allow_modules.exp index cb7e307792f46..2ffd877e21f45 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_allow_modules.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_allow_modules.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_invalid_sender.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_invalid_sender.exp index b220b76033332..a5403a8d7e27d 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_invalid_sender.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_invalid_sender.exp @@ -16,7 +16,7 @@ Ok( ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_proper_sender.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_proper_sender.exp index 16bb98d50bf4b..057b254ad77be 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_proper_sender.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__module_publishing__test_publishing_modules_proper_sender.exp @@ -22,7 +22,7 @@ Ok( ), ), events: [], - gas_used: 650, + gas_used: 7, status: Keep( Success, ), diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp index 6fed7b9fea1a4..cdfdbd372fb9a 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_bad_sig_function_dep.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp index 208bb8f3b6b3a..b85eb3a2fa26d 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_code_unverifiable.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp index b42238aa8d55b..51ff070de5c48 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_nested_type_argument_module_does_not_exist.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp index 883b8ab34691f..91f988848b3b7 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_non_existing_function_dep.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp index b42238aa8d55b..51ff070de5c48 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_none_existing_module_dep.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp index b42238aa8d55b..51ff070de5c48 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__scripts__script_type_argument_module_does_not_exist.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp index 047aa7414c654..b6a74ce562add 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_arbitrary_script_execution.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing.exp index f9068bdf3394f..d752df5017e93 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing.exp @@ -16,7 +16,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(8cf9983b000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(f4039a3b000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -64,13 +64,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(8b10f405000000000100000000000000), + }: Modification(f31af505000000000100000000000000), }, }, ), ), events: [], - gas_used: 1189, + gas_used: 507, status: Keep( Success, ), diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing_invalid_address.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing_invalid_address.exp index e2105a034736b..cad6e7043e071 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing_invalid_address.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__verify_txn__test_open_publishing_invalid_address.exp @@ -10,7 +10,7 @@ Ok( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 01000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00 }, ), hash: OnceCell(Uninit), - }: Modification(aa410f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), + }: Modification(3e420f00000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1), StateKey { inner: AccessPath( AccessPath { address: f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: 010000000000000000000000000000000000000000000000000000000000000001076163636f756e74074163636f756e7400 }, @@ -58,13 +58,13 @@ Ok( ], }, hash: OnceCell(Uninit), - }: Modification(69e0f505000000000100000000000000), + }: Modification(fde0f505000000000100000000000000), }, }, ), ), events: [], - gas_used: 150, + gas_used: 2, status: Keep( MiscellaneousError( Some( diff --git a/aptos-move/framework/aptos-framework/doc/account.md b/aptos-move/framework/aptos-framework/doc/account.md index 09b387e59f3c8..6eecd1344acaa 100644 --- a/aptos-move/framework/aptos-framework/doc/account.md +++ b/aptos-move/framework/aptos-framework/doc/account.md @@ -626,6 +626,15 @@ Scheme identifier for Ed25519 signatures used to derive authentication keys for + + + + +
const EEXCEEDED_MAX_GUID_CREATION_NUM: u64 = 20;
+
+ + + The caller does not have a valid rotation capability offer from the other account @@ -775,6 +784,16 @@ Specified current public key is not correct + + +Explicitly separate the GUID space between Object and Account to prevent accidental overlap. + + +
const MAX_GUID_CREATION_NUM: u64 = 1125899906842624;
+
+ + + Scheme identifier for MultiEd25519 signatures used to derive authentication keys for MultiEd25519 public keys. @@ -1785,7 +1804,12 @@ GUID management methods.
public fun create_guid(account_signer: &signer): guid::GUID acquires Account {
     let addr = signer::address_of(account_signer);
     let account = borrow_global_mut<Account>(addr);
-    guid::create(addr, &mut account.guid_creation_num)
+    let guid = guid::create(addr, &mut account.guid_creation_num);
+    assert!(
+        account.guid_creation_num < MAX_GUID_CREATION_NUM,
+        error::out_of_range(EEXCEEDED_MAX_GUID_CREATION_NUM),
+    );
+    guid
 }
 
diff --git a/aptos-move/framework/aptos-framework/doc/object.md b/aptos-move/framework/aptos-framework/doc/object.md index 98c8cafe41cee..bf75b8ab76fe7 100644 --- a/aptos-move/framework/aptos-framework/doc/object.md +++ b/aptos-move/framework/aptos-framework/doc/object.md @@ -61,6 +61,7 @@ make it so that a reference to a global object can be returned from a function. - [Function `verify_ungated_and_descendant`](#0x1_object_verify_ungated_and_descendant) - [Function `owner`](#0x1_object_owner) - [Function `is_owner`](#0x1_object_is_owner) +- [Function `owns`](#0x1_object_owns) - [Specification](#@Specification_1) - [Function `exists_at`](#@Specification_1_exists_at) @@ -454,6 +455,16 @@ The resource is not stored at the specified address. + + +Explicitly separate the GUID space between Object and Account to prevent accidental overlap. + + +
const INIT_GUID_CREATION_NUM: u64 = 1125899906842624;
+
+ + + Maximum nesting from one object to another. That is objects can technically have infinte @@ -729,7 +740,7 @@ Create a new object from a GUID generated by an object. assert!(!exists<ObjectCore>(object), error::already_exists(EOBJECT_EXISTS)); let object_signer = create_signer(object); - let guid_creation_num = 0; + let guid_creation_num = INIT_GUID_CREATION_NUM; let transfer_events_guid = guid::create(object, &mut guid_creation_num); move_to( @@ -1164,6 +1175,8 @@ Entry function that can be used to transfer, if allow_ungated_transfer is set tr ## Function `transfer` +Transfers ownership of the object (and all associated resources) at the specified address +for Object to the "to" address.
public fun transfer<T: key>(owner: &signer, object: object::Object<T>, to: address)
@@ -1377,6 +1390,55 @@ Return true if the provided address is the current owner.
 
 
 
+
+
+
+
+## Function `owns`
+
+Return true if the provided address has indirect or direct ownership of the provided object.
+
+
+
public fun owns<T: key>(object: object::Object<T>, owner: address): bool
+
+ + + +
+Implementation + + +
public fun owns<T: key>(object: Object<T>, owner: address): bool acquires ObjectCore {
+    let current_address = object_address(&object);
+    if (current_address == owner) {
+        return true
+    };
+
+    assert!(
+        exists<ObjectCore>(current_address),
+        error::not_found(EOBJECT_DOES_NOT_EXIST),
+    );
+
+    let object = borrow_global<ObjectCore>(current_address);
+    let current_address = object.owner;
+
+    let count = 0;
+    while (owner != current_address) {
+        let count = count + 1;
+        assert!(count < MAXIMUM_OBJECT_NESTING, error::out_of_range(EMAXIMUM_NESTING));
+        if (!exists<ObjectCore>(current_address)) {
+            return false
+        };
+
+        let object = borrow_global<ObjectCore>(current_address);
+        current_address = object.owner;
+    };
+    true
+}
+
+ + +
diff --git a/aptos-move/framework/aptos-framework/sources/account.move b/aptos-move/framework/aptos-framework/sources/account.move index 671b37beaa561..1c4c6fe1fb519 100644 --- a/aptos-move/framework/aptos-framework/sources/account.move +++ b/aptos-move/framework/aptos-framework/sources/account.move @@ -155,7 +155,11 @@ module aptos_framework::account { const ENO_SUCH_ROTATION_CAPABILITY_OFFER: u64 = 18; // The signer capability is not offered to any address const ENO_SIGNER_CAPABILITY_OFFERED: u64 = 19; + // This account has exceeded the allocated GUIDs it can create. It should be impossible to reach this number for real applications. + const EEXCEEDED_MAX_GUID_CREATION_NUM: u64 = 20; + /// Explicitly separate the GUID space between Object and Account to prevent accidental overlap. + const MAX_GUID_CREATION_NUM: u64 = 0x4000000000000; #[test_only] /// Create signer for testing, independently of an Aptos-style `Account`. public fun create_signer_for_test(addr: address): signer { create_signer(addr) } @@ -646,7 +650,12 @@ module aptos_framework::account { public fun create_guid(account_signer: &signer): guid::GUID acquires Account { let addr = signer::address_of(account_signer); let account = borrow_global_mut(addr); - guid::create(addr, &mut account.guid_creation_num) + let guid = guid::create(addr, &mut account.guid_creation_num); + assert!( + account.guid_creation_num < MAX_GUID_CREATION_NUM, + error::out_of_range(EEXCEEDED_MAX_GUID_CREATION_NUM), + ); + guid } /////////////////////////////////////////////////////////////////////////// @@ -1236,4 +1245,14 @@ module aptos_framework::account { assert!(*expected_originating_address == alice_addr, 0); assert!(borrow_global(alice_addr).authentication_key == new_auth_key, 0); } + + #[test(account = @aptos_framework)] + #[expected_failure(abort_code = 0x20014, location = Self)] + public entry fun test_max_guid(account: &signer) acquires Account { + let addr = signer::address_of(account); + create_account_unchecked(addr); + let account_state = borrow_global_mut(addr); + account_state.guid_creation_num = MAX_GUID_CREATION_NUM - 1; + create_guid(account); + } } diff --git a/aptos-move/framework/aptos-framework/sources/object.move b/aptos-move/framework/aptos-framework/sources/object.move index 0681d13faa30e..a3ec99b99cf01 100644 --- a/aptos-move/framework/aptos-framework/sources/object.move +++ b/aptos-move/framework/aptos-framework/sources/object.move @@ -42,6 +42,9 @@ module aptos_framework::object { /// The resource is not stored at the specified address. const ERESOURCE_DOES_NOT_EXIST: u64 = 7; + /// Explicitly separate the GUID space between Object and Account to prevent accidental overlap. + const INIT_GUID_CREATION_NUM: u64 = 0x4000000000000; + /// Maximum nesting from one object to another. That is objects can technically have infinte /// nesting, but any checks such as transfer will only be evaluated this deep. const MAXIMUM_OBJECT_NESTING: u8 = 8; @@ -184,7 +187,7 @@ module aptos_framework::object { assert!(!exists(object), error::already_exists(EOBJECT_EXISTS)); let object_signer = create_signer(object); - let guid_creation_num = 0; + let guid_creation_num = INIT_GUID_CREATION_NUM; let transfer_events_guid = guid::create(object, &mut guid_creation_num); move_to( @@ -320,6 +323,8 @@ module aptos_framework::object { transfer_raw(owner, object, to) } + /// Transfers ownership of the object (and all associated resources) at the specified address + /// for Object to the "to" address. public fun transfer( owner: &signer, object: Object, @@ -420,6 +425,35 @@ module aptos_framework::object { owner(object) == owner } + /// Return true if the provided address has indirect or direct ownership of the provided object. + public fun owns(object: Object, owner: address): bool acquires ObjectCore { + let current_address = object_address(&object); + if (current_address == owner) { + return true + }; + + assert!( + exists(current_address), + error::not_found(EOBJECT_DOES_NOT_EXIST), + ); + + let object = borrow_global(current_address); + let current_address = object.owner; + + let count = 0; + while (owner != current_address) { + let count = count + 1; + assert!(count < MAXIMUM_OBJECT_NESTING, error::out_of_range(EMAXIMUM_NESTING)); + if (!exists(current_address)) { + return false + }; + + let object = borrow_global(current_address); + current_address = object.owner; + }; + true + } + #[test_only] use std::option::{Self, Option}; @@ -505,7 +539,9 @@ module aptos_framework::object { let (_, hero) = create_hero(creator); let (_, weapon) = create_weapon(creator); + assert!(owns(weapon, @0x123), 0); hero_equip(creator, hero, weapon); + assert!(owns(weapon, @0x123), 1); hero_unequip(creator, hero, weapon); } @@ -516,6 +552,7 @@ module aptos_framework::object { let linear_transfer_ref = generate_linear_transfer_ref(&transfer_ref); transfer_with_ref(linear_transfer_ref, @0x456); assert!(owner(hero) == @0x456, 0); + assert!(owns(hero, @0x456), 1); } #[test(creator = @0x123)] diff --git a/aptos-node/src/lib.rs b/aptos-node/src/lib.rs index 7f4416ed9789f..ca318b2d8cba8 100644 --- a/aptos-node/src/lib.rs +++ b/aptos-node/src/lib.rs @@ -123,7 +123,6 @@ impl AptosNodeArgs { error ) }); - println!("Using node config {:?}", &config); // Start the node start(config, None, true).expect("Node should start correctly"); @@ -351,6 +350,9 @@ pub fn setup_environment_and_start_node( remote_log_rx: Option>, logger_filter_update_job: Option, ) -> anyhow::Result { + // Log the node config at node startup + info!("Using node config {:?}", &node_config); + // Start the node inspection service services::start_node_inspection_service(&node_config); diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index 06972b2e36158..b2339590c49bf 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -955,10 +955,6 @@ impl MovePackageDir { .collect() } - pub fn bytecode_version_or_detault(&self) -> u32 { - self.bytecode_version.unwrap_or(5) - } - pub fn add_named_address(&mut self, key: String, value: String) { self.named_addresses .insert(key, AccountAddressWrapper::from_str(&value).unwrap()); diff --git a/crates/aptos/src/governance/mod.rs b/crates/aptos/src/governance/mod.rs index b24df0b4ac773..9bddb3cca2ea5 100644 --- a/crates/aptos/src/governance/mod.rs +++ b/crates/aptos/src/governance/mod.rs @@ -606,7 +606,7 @@ fn compile_in_temp_dir( script_path: &Path, framework_package_args: &FrameworkPackageArgs, prompt_options: PromptOptions, - bytecode_version: u32, + bytecode_version: Option, ) -> CliTypedResult<(Vec, HashValue)> { // Make a temporary directory for compilation let temp_dir = TempDir::new().map_err(|err| { @@ -652,7 +652,7 @@ fn compile_in_temp_dir( fn compile_script( skip_fetch_latest_git_deps: bool, package_dir: &Path, - bytecode_version: u32, + bytecode_version: Option, ) -> CliTypedResult<(Vec, HashValue)> { let build_options = BuildOptions { with_srcs: false, @@ -660,7 +660,7 @@ fn compile_script( with_source_maps: false, with_error_map: false, skip_fetch_latest_git_deps, - bytecode_version: Some(bytecode_version), + bytecode_version, ..BuildOptions::default() }; @@ -777,7 +777,7 @@ impl CompileScriptFunction { script_path, &self.framework_package_args, prompt_options, - self.bytecode_version.unwrap_or(6), + self.bytecode_version, ) } } @@ -833,7 +833,7 @@ impl CliCommand<()> for GenerateUpgradeProposal { let options = included_artifacts.build_options( move_options.skip_fetch_latest_git_deps, move_options.named_addresses(), - move_options.bytecode_version_or_detault(), + move_options.bytecode_version, ); let package = BuiltPackage::build(package_path, options)?; let release = ReleasePackage::new(package)?; diff --git a/crates/aptos/src/move_tool/mod.rs b/crates/aptos/src/move_tool/mod.rs index a5569c2e5167d..c06bc73268305 100644 --- a/crates/aptos/src/move_tool/mod.rs +++ b/crates/aptos/src/move_tool/mod.rs @@ -127,8 +127,6 @@ pub(crate) fn set_bytecode_version(version: Option) { // environment variables. if let Some(ver) = version { env::set_var(VAR_BYTECODE_VERSION, ver.to_string()); - } else if env::var(VAR_BYTECODE_VERSION) == Err(env::VarError::NotPresent) { - env::set_var(VAR_BYTECODE_VERSION, "6"); } } @@ -305,7 +303,7 @@ impl CliCommand> for CompilePackage { .build_options( self.move_options.skip_fetch_latest_git_deps, self.move_options.named_addresses(), - self.move_options.bytecode_version_or_detault(), + self.move_options.bytecode_version, ) }; let pack = BuiltPackage::build(self.move_options.get_package_path()?, build_options) @@ -364,7 +362,7 @@ impl CompileScript { ..IncludedArtifacts::None.build_options( self.move_options.skip_fetch_latest_git_deps, self.move_options.named_addresses(), - self.move_options.bytecode_version_or_detault(), + self.move_options.bytecode_version, ) }; let package_dir = self.move_options.get_package_path()?; @@ -576,7 +574,7 @@ impl CliCommand<&'static str> for DocumentPackage { named_addresses: move_options.named_addresses(), docgen_options: Some(docgen_options), skip_fetch_latest_git_deps: move_options.skip_fetch_latest_git_deps, - bytecode_version: Some(move_options.bytecode_version_or_detault()), + bytecode_version: move_options.bytecode_version, }; BuiltPackage::build(move_options.get_package_path()?, build_options)?; Ok("succeeded") @@ -650,7 +648,7 @@ impl IncludedArtifacts { self, skip_fetch_latest_git_deps: bool, named_addresses: BTreeMap, - bytecode_version: u32, + bytecode_version: Option, ) -> BuildOptions { use IncludedArtifacts::*; match self { @@ -662,7 +660,7 @@ impl IncludedArtifacts { with_error_map: true, named_addresses, skip_fetch_latest_git_deps, - bytecode_version: Some(bytecode_version), + bytecode_version, ..BuildOptions::default() }, Sparse => BuildOptions { @@ -672,7 +670,7 @@ impl IncludedArtifacts { with_error_map: true, named_addresses, skip_fetch_latest_git_deps, - bytecode_version: Some(bytecode_version), + bytecode_version, ..BuildOptions::default() }, All => BuildOptions { @@ -682,7 +680,7 @@ impl IncludedArtifacts { with_error_map: true, named_addresses, skip_fetch_latest_git_deps, - bytecode_version: Some(bytecode_version), + bytecode_version, ..BuildOptions::default() }, } @@ -709,7 +707,7 @@ impl CliCommand for PublishPackage { let options = included_artifacts_args.included_artifacts.build_options( move_options.skip_fetch_latest_git_deps, move_options.named_addresses(), - move_options.bytecode_version_or_detault(), + move_options.bytecode_version, ); let package = BuiltPackage::build(package_path, options)?; let compiled_units = package.extract_code(); @@ -796,7 +794,7 @@ impl CliCommand for CreateResourceAccountAndPublishPackage { let options = included_artifacts_args.included_artifacts.build_options( move_options.skip_fetch_latest_git_deps, move_options.named_addresses(), - move_options.bytecode_version_or_detault(), + move_options.bytecode_version, ); let package = BuiltPackage::build(package_path, options)?; let compiled_units = package.extract_code(); @@ -921,11 +919,11 @@ impl CliCommand<&'static str> for VerifyPackage { // First build the package locally to get the package metadata let build_options = BuildOptions { install_dir: self.move_options.output_dir.clone(), - bytecode_version: Some(self.move_options.bytecode_version_or_detault()), + bytecode_version: self.move_options.bytecode_version, ..self.included_artifacts.build_options( self.move_options.skip_fetch_latest_git_deps, self.move_options.named_addresses(), - self.move_options.bytecode_version_or_detault(), + self.move_options.bytecode_version, ) }; let pack = BuiltPackage::build(self.move_options.get_package_path()?, build_options) diff --git a/developer-docs-site/docs/guides/basics-life-of-txn.md b/developer-docs-site/docs/guides/basics-life-of-txn.md index 2e798877a4179..6302f9b530e2a 100755 --- a/developer-docs-site/docs/guides/basics-life-of-txn.md +++ b/developer-docs-site/docs/guides/basics-life-of-txn.md @@ -180,7 +180,7 @@ The Move VM verifies and executes transaction scripts written in Move bytecode. ### 1. Virtual Machine → Storage -When mempool requests the VM to validate a transaction via `VM::ValidateTransaction()`, the VM loads the transaction sender's account from storage and performs verifications, some of which have been described in the list below. +When mempool requests the VM to validate a transaction via `VMValidator::validate_transaction()`, the VM loads the transaction sender's account from storage and performs verifications, some of which have been described in the list below. * Checks that the input signature on the signed transaction is correct (to reject incorrectly signed transactions). * Checks that the sender's account authentication key is the same as the hash of the public key (corresponding to the private key used to sign the transaction). @@ -190,13 +190,13 @@ When mempool requests the VM to validate a transaction via `VM::ValidateTransact ### 2. Execution → Virtual Machine -The execution component utilizes the VM to execute a transaction via `VM::ExecuteTransaction()`. +The execution component utilizes the VM to execute a transaction via `ExecutorTask::execute_transaction()`. It is important to understand that executing a transaction is different from updating the state of the ledger and persisting the results in storage. A transaction TN is first executed as part of an attempt to reach agreement on blocks during consensus. If agreement is reached with the other validators on the ordering of transactions and their execution results, the results are persisted in storage and the state of the ledger is updated. ### 3. Mempool → Virtual Machine -When mempool receives a transaction from other validators via shared mempool or from the REST service, mempool invokes `VM::ValidateTransaction()` on the VM to validate the transaction. +When mempool receives a transaction from other validators via shared mempool or from the REST service, mempool invokes `VMValidator::validate_transaction()` on the VM to validate the transaction. For implementation details refer to the [Move Virtual Machine README](https://github.com/move-language/move/tree/main/language/move-vm). @@ -232,7 +232,7 @@ Mempool is a shared buffer that holds the transactions that are “waiting” to ### 4. Mempool → VM -When mempool receives a transaction from other validators, mempool invokes VM::ValidateTransaction() on the VM to validate the transaction. +When mempool receives a transaction from other validators, mempool invokes VMValidator::validate_transaction() on the VM to validate the transaction. ## Consensus @@ -251,7 +251,7 @@ The consensus component is responsible for ordering blocks of transactions and a ### 1. Consensus → Mempool -When validator VX is a leader/proposer, the consensus component of VX pulls a block of transactions from its mempool via: `Mempool::GetBlock()`, and forms a proposed block of transactions. +When validator VX is a leader/proposer, the consensus component of VX pulls a block of transactions from its mempool via: `Mempool::get_batch()`, and forms a proposed block of transactions. ### 2. Consensus → Other Validators @@ -259,13 +259,13 @@ If VX is a proposer/leader, its consensus component replicates the pr ### 3. Consensus → Execution, Consensus → Other Validators -* To execute a block of transactions, consensus interacts with the execution component. Consensus executes a block of transactions via `Execution:ExecuteBlock()` (Refer to [Consensus → execution](#1-consensus--execution)) +* To execute a block of transactions, consensus interacts with the execution component. Consensus executes a block of transactions via `BlockExecutorTrait::execute_block()` (Refer to [Consensus → execution](#1-consensus--execution)) * After executing the transactions in the proposed block, the execution component responds to the consensus component with the result of executing these transactions. * The consensus component signs the execution result and attempts to reach agreement on this result with other validators. ### 4. Consensus → Execution -If enough validators vote for the same execution result, the consensus component of VX informs execution via `Execution::CommitBlock()` that this block is ready to be committed. +If enough validators vote for the same execution result, the consensus component of VX informs execution via `BlockExecutorTrait::commit_blocks()` that this block is ready to be committed. ## Execution @@ -283,22 +283,22 @@ The execution component coordinates the execution of a block of transactions and ### 1. Consensus → Execution -* Consensus requests execution to execute a block of transactions via: `Execution::ExecuteBlock()`. +* Consensus requests execution to execute a block of transactions via: `BlockExecutorTrait::execute_block()`. * Execution maintains a “scratchpad,” which holds in-memory copies of the relevant portions of the [Merkle accumulator](../reference/glossary.md#merkle-accumulator). This information is used to calculate the root hash of the current state of the Aptos blockchain. * The root hash of the current state is combined with the information about the transactions in the proposed block to determine the new root hash of the accumulator. This is done prior to persisting any data, and to ensure that no state or transaction is stored until agreement is reached by a quorum of validators. * Execution computes the speculative root hash and then the consensus component of VX signs this root hash and attempts to reach agreement on this root hash with other validators. ### 2. Execution → VM -When consensus requests execution to execute a block of transactions via `Execution::ExecuteBlock()`, execution uses the VM to determine the results of executing the block of transactions. +When consensus requests execution to execute a block of transactions via `BlockExecutorTrait::execute_block()`, execution uses the VM to determine the results of executing the block of transactions. ### 3. Consensus → Execution -If a quorum of validators agrees on the block execution results, the consensus component of each validator informs its execution component via `Execution::CommitBlock()` that this block is ready to be committed. This call to the execution component will include the signatures of the validators to provide proof of their agreement. +If a quorum of validators agrees on the block execution results, the consensus component of each validator informs its execution component via `BlockExecutorTrait::commit_blocks()` that this block is ready to be committed. This call to the execution component will include the signatures of the validators to provide proof of their agreement. ### 4. Execution → Storage -Execution takes the values from its “scratchpad” and sends them to storage for persistence via `Storage::SaveTransactions()`. Execution then prunes the old values from the “scratchpad” that are no longer needed (for example, parallel blocks that cannot be committed). +Execution takes the values from its “scratchpad” and sends them to storage for persistence via `DbWriter::save_transactions()`. Execution then prunes the old values from the “scratchpad” that are no longer needed (for example, parallel blocks that cannot be committed). For implementation details refer to the [Execution README](https://github.com/aptos-labs/aptos-core/tree/main/execution). @@ -323,15 +323,15 @@ Refer to [Merkle accumulator](../reference/glossary.md#merkle-accumulator) for i ### 1. VM → Storage -When mempool invokes `VM::ValidateTransaction()` to validate a transaction, `VM::ValidateTransaction()` loads the sender's account from storage and performs read-only validity checks on the transaction. +When mempool invokes `VMValidator::validate_transaction()` to validate a transaction, `VMValidator::validate_transaction()` loads the sender's account from storage and performs read-only validity checks on the transaction. ### 2. Execution → Storage -When the consensus component calls `Execution::ExecuteBlock()`, execution reads the current state from storage combined with the in-memory “scratchpad” data to determine the execution results. +When the consensus component calls `BlockExecutorTrait::execute_block()`, execution reads the current state from storage combined with the in-memory “scratchpad” data to determine the execution results. ### 3. Execution → Storage -Once consensus is reached on a block of transactions, execution calls storage via `Storage::SaveTransactions()` to save the block of transactions and permanently record them. This will also store the signatures from the validator nodes that agreed on this block of transactions. The in-memory data in “scratchpad” for this block is passed to update storage and persist the transactions. When the storage is updated, every account that was modified by these transactions will have its sequence number incremented by one. +Once consensus is reached on a block of transactions, execution calls storage via `DbWriter::save_transactions()` to save the block of transactions and permanently record them. This will also store the signatures from the validator nodes that agreed on this block of transactions. The in-memory data in “scratchpad” for this block is passed to update storage and persist the transactions. When the storage is updated, every account that was modified by these transactions will have its sequence number incremented by one. Note: The sequence number of an account on the Aptos blockchain increments by one for each committed transaction originating from that account. diff --git a/docker/experimental/docker-bake-rust-all.sh b/docker/experimental/docker-bake-rust-all.sh index 886d4019f5347..84aa734b4749a 100755 --- a/docker/experimental/docker-bake-rust-all.sh +++ b/docker/experimental/docker-bake-rust-all.sh @@ -22,6 +22,7 @@ export NORMALIZED_GIT_BRANCH_OR_PR=$(printf "$TARGET_CACHE_ID" | sed -e 's/[^a-z export PROFILE=${PROFILE:-release} export FEATURES=${FEATURES:-""} export NORMALIZED_FEATURES_LIST=$(printf "$FEATURES" | sed -e 's/[^a-zA-Z0-9]/_/g') +export CUSTOM_IMAGE_TAG_PREFIX=${CUSTOM_IMAGE_TAG_PREFIX:-""} if [ "$PROFILE" = "release" ]; then # Do not prefix image tags if we're building the default profile "release" @@ -31,10 +32,16 @@ else profile_prefix="${PROFILE}_" fi +if [ -n "$CUSTOM_IMAGE_TAG_PREFIX" ]; then + export IMAGE_TAG_PREFIX="${CUSTOM_IMAGE_TAG_PREFIX}_" +else + export IMAGE_TAG_PREFIX="" +fi + if [ -n "$FEATURES" ]; then - export IMAGE_TAG_PREFIX="${profile_prefix}${NORMALIZED_FEATURES_LIST}_" + export IMAGE_TAG_PREFIX="${IMAGE_TAG_PREFIX}${profile_prefix}${NORMALIZED_FEATURES_LIST}_" else - export IMAGE_TAG_PREFIX="${profile_prefix}" + export IMAGE_TAG_PREFIX="${IMAGE_TAG_PREFIX}${profile_prefix}" fi BUILD_TARGET="${1:-forge-images}" diff --git a/mempool/src/core_mempool/mempool.rs b/mempool/src/core_mempool/mempool.rs index be06a6b8877e7..a60ca87e61f52 100644 --- a/mempool/src/core_mempool/mempool.rs +++ b/mempool/src/core_mempool/mempool.rs @@ -20,7 +20,6 @@ use aptos_crypto::HashValue; use aptos_logger::prelude::*; use aptos_types::{ account_address::AccountAddress, - account_config::AccountSequenceInfo, mempool_status::{MempoolStatus, MempoolStatusCode}, transaction::SignedTransaction, }; @@ -116,10 +115,9 @@ impl Mempool { &mut self, txn: SignedTransaction, ranking_score: u64, - sequence_info: AccountSequenceInfo, + db_sequence_number: u64, timeline_state: TimelineState, ) -> MempoolStatus { - let db_sequence_number = sequence_info.min_seq(); trace!( LogSchema::new(LogEntry::AddTxn) .txns(TxnsLog::new_txn(txn.sender(), txn.sequence_number())), @@ -144,7 +142,7 @@ impl Mempool { expiration_time, ranking_score, timeline_state, - AccountSequenceInfo::Sequential(db_sequence_number), + db_sequence_number, now, ); diff --git a/mempool/src/core_mempool/transaction.rs b/mempool/src/core_mempool/transaction.rs index 610834dba28ab..97f04040b7908 100644 --- a/mempool/src/core_mempool/transaction.rs +++ b/mempool/src/core_mempool/transaction.rs @@ -4,10 +4,7 @@ use crate::core_mempool::TXN_INDEX_ESTIMATED_BYTES; use aptos_crypto::HashValue; -use aptos_types::{ - account_address::AccountAddress, account_config::AccountSequenceInfo, - transaction::SignedTransaction, -}; +use aptos_types::{account_address::AccountAddress, transaction::SignedTransaction}; use serde::{Deserialize, Serialize}; use std::{ mem::size_of, @@ -34,13 +31,13 @@ impl MempoolTransaction { expiration_time: Duration, ranking_score: u64, timeline_state: TimelineState, - seqno_type: AccountSequenceInfo, + seqno: u64, insertion_time: SystemTime, ) -> Self { Self { sequence_info: SequenceInfo { transaction_sequence_number: txn.sequence_number(), - account_sequence_number_type: seqno_type, + account_sequence_number: seqno, }, txn, expiration_time, @@ -82,7 +79,7 @@ pub enum TimelineState { #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct SequenceInfo { pub transaction_sequence_number: u64, - pub account_sequence_number_type: AccountSequenceInfo, + pub account_sequence_number: u64, } #[cfg(test)] @@ -91,7 +88,6 @@ mod test { use aptos_crypto::{ed25519::Ed25519PrivateKey, PrivateKey, SigningKey, Uniform}; use aptos_types::{ account_address::AccountAddress, - account_config::AccountSequenceInfo, chain_id::ChainId, transaction::{RawTransaction, Script, SignedTransaction, TransactionPayload}, }; @@ -113,7 +109,7 @@ mod test { Duration::from_secs(1), 1, TimelineState::NotReady, - AccountSequenceInfo::Sequential(0), + 0, SystemTime::now(), ) } diff --git a/mempool/src/core_mempool/transaction_store.rs b/mempool/src/core_mempool/transaction_store.rs index c88b47b4aef0d..5b57bea7ae684 100644 --- a/mempool/src/core_mempool/transaction_store.rs +++ b/mempool/src/core_mempool/transaction_store.rs @@ -23,7 +23,6 @@ use aptos_crypto::HashValue; use aptos_logger::{prelude::*, Level}; use aptos_types::{ account_address::AccountAddress, - account_config::AccountSequenceInfo, mempool_status::{MempoolStatus, MempoolStatusCode}, transaction::SignedTransaction, }; @@ -188,7 +187,8 @@ impl TransactionStore { /// Insert transaction into TransactionStore. Performs validation checks and updates indexes. pub(crate) fn insert(&mut self, txn: MempoolTransaction) -> MempoolStatus { let address = txn.get_sender(); - let sequence_number = txn.sequence_info; + let txn_seq_num = txn.sequence_info.transaction_sequence_number; + let acc_seq_num = txn.sequence_info.account_sequence_number; // If the transaction is already in Mempool, we only allow the user to // increase the gas unit price to speed up a transaction, but not the max gas. @@ -196,9 +196,7 @@ impl TransactionStore { // Transactions with all the same inputs (but possibly signed differently) are idempotent // since the raw transaction is the same if let Some(txns) = self.transactions.get_mut(&address) { - if let Some(current_version) = - txns.get_mut(&sequence_number.transaction_sequence_number) - { + if let Some(current_version) = txns.get_mut(&txn_seq_num) { if current_version.txn.payload() != txn.txn.payload() { return MempoolStatus::new(MempoolStatusCode::InvalidUpdate).with_message( "Transaction already in mempool with a different payload".to_string(), @@ -217,7 +215,7 @@ impl TransactionStore { ); } else if current_version.txn.gas_unit_price() < txn.get_gas_price() { // Update txn if gas unit price is a larger value than before - if let Some(txn) = txns.remove(&sequence_number.transaction_sequence_number) { + if let Some(txn) = txns.remove(&txn_seq_num) { self.index_remove(&txn); }; } else if current_version.get_gas_price() > txn.get_gas_price() { @@ -233,10 +231,7 @@ impl TransactionStore { } } - if self.check_is_full_after_eviction( - &txn, - sequence_number.account_sequence_number_type.min_seq(), - ) { + if self.check_is_full_after_eviction(&txn, acc_seq_num) { return MempoolStatus::new(MempoolStatusCode::MempoolIsFull).with_message(format!( "Mempool is full. Mempool size: {}, Capacity: {}", self.system_ttl_index.size(), @@ -244,10 +239,7 @@ impl TransactionStore { )); } - self.clean_committed_transactions( - &address, - sequence_number.account_sequence_number_type.min_seq(), - ); + self.clean_committed_transactions(&address, acc_seq_num); self.transactions .entry(address) @@ -269,20 +261,15 @@ impl TransactionStore { let sender = txn.get_sender(); self.system_ttl_index.insert(&txn); self.expiration_time_index.insert(&txn); - self.hash_index.insert( - txn.get_committed_hash(), - (sender, sequence_number.transaction_sequence_number), - ); + self.hash_index + .insert(txn.get_committed_hash(), (sender, txn_seq_num)); let txn_size_bytes = txn.get_estimated_bytes(); - txns.insert(sequence_number.transaction_sequence_number, txn); - self.sequence_numbers.insert( - sender, - sequence_number.account_sequence_number_type.min_seq(), - ); + txns.insert(txn_seq_num, txn); + self.sequence_numbers.insert(sender, acc_seq_num); self.size_bytes += txn_size_bytes; self.track_indices(); } - self.process_ready_transactions(&address, sequence_number.account_sequence_number_type); + self.process_ready_transactions(&address, acc_seq_num); MempoolStatus::new(MempoolStatusCode::Accepted) } @@ -420,44 +407,34 @@ impl TransactionStore { /// should be included in both the PriorityIndex (ordering for Consensus) and /// TimelineIndex (txns for SharedMempool). /// - Other txns are considered to be "non-ready" and should be added to ParkingLotIndex. - fn process_ready_transactions( - &mut self, - address: &AccountAddress, - sequence_info: AccountSequenceInfo, - ) { + fn process_ready_transactions(&mut self, address: &AccountAddress, sequence_num: u64) { if let Some(txns) = self.transactions.get_mut(address) { - let mut min_seq = sequence_info.min_seq(); - - match sequence_info { - AccountSequenceInfo::Sequential(_) => { - while let Some(txn) = txns.get_mut(&min_seq) { - let process_ready = !self.priority_index.contains(txn); - self.priority_index.insert(txn); + let mut min_seq = sequence_num; - let process_broadcast_ready = txn.timeline_state == TimelineState::NotReady; - if process_broadcast_ready { - self.timeline_index.insert(txn); - } + while let Some(txn) = txns.get_mut(&min_seq) { + let process_ready = !self.priority_index.contains(txn); + self.priority_index.insert(txn); - if process_ready { - if let Ok(time_delta) = - SystemTime::now().duration_since(txn.insertion_time) - { - Self::log_ready_transaction( - txn.ranking_score, - self.timeline_index.get_bucket(txn.ranking_score), - time_delta, - process_broadcast_ready, - ); - } - } + let process_broadcast_ready = txn.timeline_state == TimelineState::NotReady; + if process_broadcast_ready { + self.timeline_index.insert(txn); + } - // Remove txn from parking lot after it has been promoted to - // priority_index / timeline_index, i.e., txn status is ready. - self.parking_lot_index.remove(txn); - min_seq += 1; + if process_ready { + if let Ok(time_delta) = SystemTime::now().duration_since(txn.insertion_time) { + Self::log_ready_transaction( + txn.ranking_score, + self.timeline_index.get_bucket(txn.ranking_score), + time_delta, + process_broadcast_ready, + ); } - }, + } + + // Remove txn from parking lot after it has been promoted to + // priority_index / timeline_index, i.e., txn status is ready. + self.parking_lot_index.remove(txn); + min_seq += 1; } let mut parking_lot_txns = 0; @@ -470,9 +447,10 @@ impl TransactionStore { }, } } + trace!( LogSchema::new(LogEntry::ProcessReadyTxns).account(*address), - first_ready_seq_num = sequence_info.min_seq(), + first_ready_seq_num = sequence_num, last_ready_seq_num = min_seq, num_parked_txns = parking_lot_txns, ); @@ -516,11 +494,9 @@ impl TransactionStore { /// and potential promotion of sequential txns to PriorityIndex/TimelineIndex. pub fn commit_transaction(&mut self, account: &AccountAddress, sequence_number: u64) { let current_seq_number = self.get_sequence_number(account).map_or(0, |v| *v); - let new_seq_number = - AccountSequenceInfo::Sequential(max(current_seq_number, sequence_number + 1)); - self.sequence_numbers - .insert(*account, new_seq_number.min_seq()); - self.clean_committed_transactions(account, new_seq_number.min_seq()); + let new_seq_number = max(current_seq_number, sequence_number + 1); + self.sequence_numbers.insert(*account, new_seq_number); + self.clean_committed_transactions(account, new_seq_number); self.process_ready_transactions(account, new_seq_number); } diff --git a/mempool/src/shared_mempool/tasks.rs b/mempool/src/shared_mempool/tasks.rs index 623ba04eebfe4..deef549ab629f 100644 --- a/mempool/src/shared_mempool/tasks.rs +++ b/mempool/src/shared_mempool/tasks.rs @@ -25,7 +25,6 @@ use aptos_metrics_core::HistogramTimer; use aptos_network::application::interface::NetworkClientInterface; use aptos_storage_interface::state_view::LatestDbStateCheckpointView; use aptos_types::{ - account_config::AccountSequenceInfo, mempool_status::{MempoolStatus, MempoolStatusCode}, on_chain_config::{OnChainConfigPayload, OnChainConsensusConfig}, transaction::SignedTransaction, @@ -284,9 +283,9 @@ where .into_iter() .enumerate() .filter_map(|(idx, t)| { - if let Ok(sequence_info) = seq_numbers[idx] { - if t.sequence_number() >= sequence_info.min_seq() { - return Some((t, sequence_info)); + if let Ok(sequence_num) = seq_numbers[idx] { + if t.sequence_number() >= sequence_num { + return Some((t, sequence_num)); } else { statuses.push(( t, @@ -319,7 +318,7 @@ where /// validation into the mempool. #[cfg(not(feature = "consensus-only-perf-test"))] fn validate_and_add_transactions( - transactions: Vec<(SignedTransaction, AccountSequenceInfo)>, + transactions: Vec<(SignedTransaction, u64)>, smp: &SharedMempool, timeline_state: TimelineState, statuses: &mut Vec<(SignedTransaction, (MempoolStatus, Option))>, @@ -383,7 +382,7 @@ fn validate_and_add_transactions( /// outstanding sequence numbers. #[cfg(feature = "consensus-only-perf-test")] fn validate_and_add_transactions( - transactions: Vec<(SignedTransaction, AccountSequenceInfo)>, + transactions: Vec<(SignedTransaction, u64)>, smp: &SharedMempool, timeline_state: TimelineState, statuses: &mut Vec<(SignedTransaction, (MempoolStatus, Option))>, diff --git a/mempool/src/tests/common.rs b/mempool/src/tests/common.rs index 6abf6fd35e0f3..3096376f439c3 100644 --- a/mempool/src/tests/common.rs +++ b/mempool/src/tests/common.rs @@ -12,7 +12,6 @@ use aptos_config::config::{NodeConfig, MAX_APPLICATION_MESSAGE_SIZE}; use aptos_crypto::{ed25519::Ed25519PrivateKey, PrivateKey, Uniform}; use aptos_types::{ account_address::AccountAddress, - account_config::AccountSequenceInfo, chain_id::ChainId, mempool_status::MempoolStatusCode, transaction::{RawTransaction, Script, SignedTransaction}, @@ -50,7 +49,7 @@ pub struct TestTransaction { pub(crate) address: usize, pub(crate) sequence_number: u64, pub(crate) gas_price: u64, - pub(crate) account_seqno_type: AccountSequenceInfo, + pub(crate) account_seqno: u64, } impl TestTransaction { @@ -59,7 +58,7 @@ impl TestTransaction { address, sequence_number, gas_price, - account_seqno_type: AccountSequenceInfo::Sequential(0), + account_seqno: 0, } } @@ -120,7 +119,7 @@ pub(crate) fn add_txns_to_mempool( pool.add_txn( txn.clone(), txn.gas_unit_price(), - transaction.account_seqno_type, + transaction.account_seqno, TimelineState::NotReady, ); transactions.push(txn); @@ -137,7 +136,7 @@ pub(crate) fn add_signed_txn(pool: &mut CoreMempool, transaction: SignedTransact .add_txn( transaction.clone(), transaction.gas_unit_price(), - AccountSequenceInfo::Sequential(0), + 0, TimelineState::NotReady, ) .code diff --git a/mempool/src/tests/core_mempool_test.rs b/mempool/src/tests/core_mempool_test.rs index 749a03fc7ba6c..4486c87ce9e40 100644 --- a/mempool/src/tests/core_mempool_test.rs +++ b/mempool/src/tests/core_mempool_test.rs @@ -11,10 +11,7 @@ use crate::{ }; use aptos_config::config::NodeConfig; use aptos_crypto::HashValue; -use aptos_types::{ - account_config::AccountSequenceInfo, mempool_status::MempoolStatusCode, - transaction::SignedTransaction, -}; +use aptos_types::{mempool_status::MempoolStatusCode, transaction::SignedTransaction}; use itertools::Itertools; use std::{ collections::HashSet, @@ -74,14 +71,14 @@ fn test_transaction_metrics() { mempool.add_txn( txn.clone(), txn.gas_unit_price(), - AccountSequenceInfo::Sequential(0), + 0, TimelineState::NotReady, ); let txn = TestTransaction::new(1, 0, 2).make_signed_transaction(); mempool.add_txn( txn.clone(), txn.gas_unit_price(), - AccountSequenceInfo::Sequential(0), + 0, TimelineState::NonQualified, ); @@ -512,7 +509,7 @@ fn test_capacity_bytes() { let status = pool.add_txn( txn.txn, txn.ranking_score, - txn.sequence_info.account_sequence_number_type, + txn.sequence_info.account_sequence_number, txn.timeline_state, ); assert_eq!(status.code, MempoolStatusCode::Accepted); @@ -522,7 +519,7 @@ fn test_capacity_bytes() { let status = pool.add_txn( txn.txn, txn.ranking_score, - txn.sequence_info.account_sequence_number_type, + txn.sequence_info.account_sequence_number, txn.timeline_state, ); assert_eq!(status.code, MempoolStatusCode::MempoolIsFull); @@ -539,7 +536,7 @@ fn new_test_mempool_transaction(address: usize, sequence_number: u64) -> Mempool Duration::from_secs(1), 1, TimelineState::NotReady, - AccountSequenceInfo::Sequential(0), + 0, SystemTime::now(), ) } @@ -609,12 +606,7 @@ fn test_gc_ready_transaction() { // Insert in the middle transaction that's going to be expired. let txn = TestTransaction::new(1, 1, 1).make_signed_transaction_with_expiration_time(0); - pool.add_txn( - txn, - 1, - AccountSequenceInfo::Sequential(0), - TimelineState::NotReady, - ); + pool.add_txn(txn, 1, 0, TimelineState::NotReady); // Insert few transactions after it. // They are supposed to be ready because there's a sequential path from 0 to them. @@ -653,12 +645,7 @@ fn test_clean_stuck_transactions() { } let db_sequence_number = 10; let txn = TestTransaction::new(0, db_sequence_number, 1).make_signed_transaction(); - pool.add_txn( - txn, - 1, - AccountSequenceInfo::Sequential(db_sequence_number), - TimelineState::NotReady, - ); + pool.add_txn(txn, 1, db_sequence_number, TimelineState::NotReady); let block = pool.get_batch(1, 1024, HashSet::new()); assert_eq!(block.len(), 1); assert_eq!(block[0].sequence_number(), 10); @@ -669,12 +656,7 @@ fn test_get_transaction_by_hash() { let mut pool = setup_mempool().0; let db_sequence_number = 10; let txn = TestTransaction::new(0, db_sequence_number, 1).make_signed_transaction(); - pool.add_txn( - txn.clone(), - 1, - AccountSequenceInfo::Sequential(db_sequence_number), - TimelineState::NotReady, - ); + pool.add_txn(txn.clone(), 1, db_sequence_number, TimelineState::NotReady); let hash = txn.clone().committed_hash(); let ret = pool.get_by_hash(hash); assert_eq!(ret, Some(txn)); @@ -688,12 +670,7 @@ fn test_get_transaction_by_hash_after_the_txn_is_updated() { let mut pool = setup_mempool().0; let db_sequence_number = 10; let txn = TestTransaction::new(0, db_sequence_number, 1).make_signed_transaction(); - pool.add_txn( - txn.clone(), - 1, - AccountSequenceInfo::Sequential(db_sequence_number), - TimelineState::NotReady, - ); + pool.add_txn(txn.clone(), 1, db_sequence_number, TimelineState::NotReady); let hash = txn.committed_hash(); // new txn with higher gas price @@ -701,7 +678,7 @@ fn test_get_transaction_by_hash_after_the_txn_is_updated() { pool.add_txn( new_txn.clone(), 1, - AccountSequenceInfo::Sequential(db_sequence_number), + db_sequence_number, TimelineState::NotReady, ); let new_txn_hash = new_txn.clone().committed_hash(); diff --git a/mempool/src/tests/mocks.rs b/mempool/src/tests/mocks.rs index df2e969af29a5..a3fc66a84c7b0 100644 --- a/mempool/src/tests/mocks.rs +++ b/mempool/src/tests/mocks.rs @@ -29,8 +29,8 @@ use aptos_network::{ }; use aptos_storage_interface::{mock::MockDbReaderWriter, DbReaderWriter}; use aptos_types::{ - account_config::AccountSequenceInfo, mempool_status::MempoolStatusCode, - on_chain_config::OnChainConfigPayload, transaction::SignedTransaction, + mempool_status::MempoolStatusCode, on_chain_config::OnChainConfigPayload, + transaction::SignedTransaction, }; use aptos_vm_validator::{ mocks::mock_vm_validator::MockVMValidator, vm_validator::TransactionValidation, @@ -167,7 +167,7 @@ impl MockSharedMempool { .add_txn( txn.clone(), txn.gas_unit_price(), - AccountSequenceInfo::Sequential(0), + 0, TimelineState::NotReady, ) .code diff --git a/mempool/src/tests/node.rs b/mempool/src/tests/node.rs index a72c7d770f5be..2388607b9ace8 100644 --- a/mempool/src/tests/node.rs +++ b/mempool/src/tests/node.rs @@ -34,9 +34,7 @@ use aptos_network::{ ProtocolId, }; use aptos_storage_interface::mock::MockDbReaderWriter; -use aptos_types::{ - account_config::AccountSequenceInfo, on_chain_config::OnChainConfigPayload, PeerId, -}; +use aptos_types::{on_chain_config::OnChainConfigPayload, PeerId}; use aptos_vm_validator::mocks::mock_vm_validator::MockVMValidator; use enum_dispatch::enum_dispatch; use futures::{ @@ -380,7 +378,7 @@ impl Node { mempool.add_txn( transaction.clone(), transaction.gas_unit_price(), - AccountSequenceInfo::Sequential(0), + 0, TimelineState::NotReady, ); } diff --git a/testsuite/smoke-test/src/aptos_cli/account.rs b/testsuite/smoke-test/src/aptos_cli/account.rs index 81608cec1f5fc..78a8bf6233a11 100644 --- a/testsuite/smoke-test/src/aptos_cli/account.rs +++ b/testsuite/smoke-test/src/aptos_cli/account.rs @@ -77,7 +77,7 @@ async fn test_account_flow() { gas_unit_price: None, // NOTE(Gas): This should be equal to the min gas amount allowed. // Read the comment above to understand why. - max_gas: Some(150), + max_gas: Some(2), expiration_secs: 30, }), ) diff --git a/types/src/account_address.rs b/types/src/account_address.rs index 331977bd30e46..3ff3b6004e8f5 100644 --- a/types/src/account_address.rs +++ b/types/src/account_address.rs @@ -146,6 +146,10 @@ pub fn from_identity_public_key(identity_public_key: x25519::PublicKey) -> Accou AccountAddress::new(array) } +pub fn create_collection_address(creator: AccountAddress, collection: &str) -> AccountAddress { + create_object_address(creator, collection.as_bytes()) +} + pub fn create_token_address( creator: AccountAddress, collection: &str, diff --git a/types/src/account_config/resources/mod.rs b/types/src/account_config/resources/mod.rs index 09f1a7965db29..98d07fe15e5c0 100644 --- a/types/src/account_config/resources/mod.rs +++ b/types/src/account_config/resources/mod.rs @@ -6,12 +6,12 @@ pub mod chain_id; pub mod coin_info; pub mod coin_store; pub mod core_account; -pub mod sequence_info; +pub mod object; pub mod transaction_validation; pub use chain_id::*; pub use coin_info::*; pub use coin_store::*; pub use core_account::*; -pub use sequence_info::*; +pub use object::*; pub use transaction_validation::*; diff --git a/types/src/account_config/resources/object.rs b/types/src/account_config/resources/object.rs new file mode 100644 index 0000000000000..0517f362682e4 --- /dev/null +++ b/types/src/account_config/resources/object.rs @@ -0,0 +1,23 @@ +// Copyright © Aptos Foundation +// SPDX-License-Identifier: Apache-2.0 + +use move_core_types::{ + ident_str, + identifier::IdentStr, + move_resource::{MoveResource, MoveStructType}, +}; +#[cfg(any(test, feature = "fuzzing"))] +use proptest_derive::Arbitrary; +use serde::{Deserialize, Serialize}; + +/// A Rust representation of ObjectGroup. +#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)] +#[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))] +pub struct ObjectGroupResource {} + +impl MoveStructType for ObjectGroupResource { + const MODULE_NAME: &'static IdentStr = ident_str!("object"); + const STRUCT_NAME: &'static IdentStr = ident_str!("ObjectGroup"); +} + +impl MoveResource for ObjectGroupResource {} diff --git a/types/src/account_config/resources/sequence_info.rs b/types/src/account_config/resources/sequence_info.rs deleted file mode 100644 index 2238817aabe19..0000000000000 --- a/types/src/account_config/resources/sequence_info.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright © Aptos Foundation -// SPDX-License-Identifier: Apache-2.0 - -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub enum AccountSequenceInfo { - Sequential(u64), -} - -impl AccountSequenceInfo { - pub fn min_seq(&self) -> u64 { - match self { - Self::Sequential(seqno) => *seqno, - } - } -} diff --git a/vm-validator/src/unit_tests/vm_validator_test.rs b/vm-validator/src/unit_tests/vm_validator_test.rs index 2b78f6f8e5164..ecf7162f6b366 100644 --- a/vm-validator/src/unit_tests/vm_validator_test.rs +++ b/vm-validator/src/unit_tests/vm_validator_test.rs @@ -209,9 +209,7 @@ fn test_get_account_sequence_number() { .latest_state_checkpoint_view() .unwrap(); assert_eq!( - get_account_sequence_number(&state_view, root_address,) - .unwrap() - .min_seq(), + get_account_sequence_number(&state_view, root_address).unwrap(), 0 ); assert_eq!( @@ -219,8 +217,7 @@ fn test_get_account_sequence_number() { &state_view, AccountAddress::new([5u8; AccountAddress::LENGTH]), ) - .unwrap() - .min_seq(), + .unwrap(), 0 ); } diff --git a/vm-validator/src/vm_validator.rs b/vm-validator/src/vm_validator.rs index 1f2578a656864..59231ecd94a1f 100644 --- a/vm-validator/src/vm_validator.rs +++ b/vm-validator/src/vm_validator.rs @@ -11,7 +11,6 @@ use aptos_storage_interface::{ }; use aptos_types::{ account_address::AccountAddress, - account_config::AccountSequenceInfo, account_view::AccountView, on_chain_config::OnChainConfigPayload, transaction::{SignedTransaction, VMValidatorResult}, @@ -98,7 +97,7 @@ impl TransactionValidation for VMValidator { pub fn get_account_sequence_number( state_view: &DbStateView, address: AccountAddress, -) -> Result { +) -> Result { fail_point!("vm_validator::get_account_sequence_number", |_| { Err(anyhow::anyhow!( "Injected error in get_account_sequence_number" @@ -108,9 +107,7 @@ pub fn get_account_sequence_number( let account_state_view = state_view.as_account_with_state_view(&address); match account_state_view.get_account_resource()? { - Some(account_resource) => Ok(AccountSequenceInfo::Sequential( - account_resource.sequence_number(), - )), - None => Ok(AccountSequenceInfo::Sequential(0)), + Some(account_resource) => Ok(account_resource.sequence_number()), + None => Ok(0), } }