Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
movekevin committed Feb 28, 2023
2 parents 83b261a + b3d6d37 commit 7c0d2fe
Show file tree
Hide file tree
Showing 81 changed files with 675 additions and 385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/experimental-docker-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/experimental-docker-rust-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/workflow-run-forge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
88 changes: 52 additions & 36 deletions api/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<MoveResource>`]
Expand All @@ -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<Vec<MoveResource>> {
// 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
Expand Down Expand Up @@ -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<Vec<MoveModuleBytecode>> {
// 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
Expand Down Expand Up @@ -479,52 +509,38 @@ impl Account {
/// Find a resource associated with an account
fn find_resource(
&self,
struct_tag: &StructTag,
) -> Result<Vec<(Identifier, MoveValue)>, 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<Vec<(Identifier, move_core_types::value::MoveValue)>, 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,
)
})
}
Expand Down
16 changes: 16 additions & 0 deletions api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ impl Context {
.map_err(|e| E::internal_with_code(e, AptosErrorCode::InternalError, ledger_info))
}

pub fn state_view<E: StdApiError>(
&self,
requested_ledger_version: Option<u64>,
) -> 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<DbStateView> {
self.db.state_view_at_version(Some(version))
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 7c0d2fe

Please sign in to comment.