From 77cac8c7cd7dc53095971b4e928397237c822c98 Mon Sep 17 00:00:00 2001 From: Aregnaz Harutyunyan <> Date: Wed, 27 Nov 2024 19:11:17 +0400 Subject: [PATCH] Addressed review comments --- api/types/src/convert.rs | 6 ++-- api/types/src/transaction.rs | 30 ++++++++++++------- .../src/gas_schedule/aptos_framework.rs | 2 ++ aptos-move/aptos-vm/src/aptos_vm.rs | 13 ++++---- .../aptos-vm/src/transaction_metadata.rs | 13 +++++--- .../src/natives/transaction_context.rs | 12 ++++---- crates/aptos-rosetta/src/types/objects.rs | 2 ++ crates/aptos/src/common/types.rs | 27 +++++++++-------- .../indexer-grpc-fullnode/src/convert.rs | 11 ++++--- .../src/stream_coordinator.rs | 9 ++++-- .../src/parsed_transaction_output.rs | 2 ++ .../executor/src/components/chunk_output.rs | 2 ++ .../aptos/transaction/v1/transaction.proto | 2 ++ .../src/backup_types/transaction/analysis.rs | 2 ++ types/src/proptest_types.rs | 2 ++ .../src/transaction/automated_transaction.rs | 3 +- types/src/transaction/mod.rs | 2 ++ .../transaction/user_transaction_context.rs | 2 ++ 18 files changed, 91 insertions(+), 51 deletions(-) diff --git a/api/types/src/convert.rs b/api/types/src/convert.rs index f4c8a3677c288..2eb7dedb3682f 100644 --- a/api/types/src/convert.rs +++ b/api/types/src/convert.rs @@ -1,6 +1,6 @@ -// Copyright © Aptos Foundation -// Parts of the project are originally copyright © Meta Platforms, Inc. -// SPDX-License-Identifier: Apache-2.0 +/* + * Copyright (c) 2024 Supra. + */ use crate::{ transaction::{ diff --git a/api/types/src/transaction.rs b/api/types/src/transaction.rs index cff8f76bb8d04..f3f0b525558be 100755 --- a/api/types/src/transaction.rs +++ b/api/types/src/transaction.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use crate::{ Address, AptosError, EntryFunctionId, EventGuid, HashValue, HexEncodedBytes, @@ -25,11 +27,11 @@ use aptos_types::{ jwks::{jwk::JWK, ProviderJWKs, QuorumCertifiedUpdate}, keyless, transaction::{ - automated_transaction::AutomatedTransaction as UserAutomatedTransaction, authenticator::{ AccountAuthenticator, AnyPublicKey, AnySignature, MultiKey, MultiKeyAuthenticator, SingleKeyAuthenticator, TransactionAuthenticator, MAX_NUM_OF_SIGS, }, + automated_transaction::AutomatedTransaction as UserAutomatedTransaction, webauthn::{PartialAuthenticatorAssertionResponse, MAX_WEBAUTHN_SIGNATURE_BYTES}, Script, SignedTransaction, TransactionOutput, TransactionWithProof, }, @@ -196,7 +198,7 @@ impl Transaction { Transaction::StateCheckpointTransaction(txn) => txn.timestamp.0, Transaction::BlockEpilogueTransaction(txn) => txn.timestamp.0, Transaction::ValidatorTransaction(txn) => txn.timestamp().0, - Transaction::AutomatedTransaction(txn) => {txn.timestamp.0} + Transaction::AutomatedTransaction(txn) => txn.timestamp.0, } } @@ -209,7 +211,7 @@ impl Transaction { Transaction::StateCheckpointTransaction(txn) => Some(txn.info.version.into()), Transaction::BlockEpilogueTransaction(txn) => Some(txn.info.version.into()), Transaction::ValidatorTransaction(txn) => Some(txn.transaction_info().version.into()), - Transaction::AutomatedTransaction(txn ) => Some(txn.info.version.into()), + Transaction::AutomatedTransaction(txn) => Some(txn.info.version.into()), } } @@ -310,13 +312,13 @@ impl } impl -From<( - &UserAutomatedTransaction, - TransactionInfo, - TransactionPayload, - Vec, - u64, -)> for Transaction + From<( + &UserAutomatedTransaction, + TransactionInfo, + TransactionPayload, + Vec, + u64, + )> for Transaction { fn from( (txn, info, payload, events, timestamp): ( @@ -397,7 +399,13 @@ impl From<(&SignedTransaction, TransactionPayload)> for UserTransactionRequest { } impl From<(HashValue, &UserAutomatedTransaction, TransactionPayload)> for AutomatedTaskMeta { - fn from((registration_hash, txn, payload): (HashValue, &UserAutomatedTransaction, TransactionPayload)) -> Self { + fn from( + (registration_hash, txn, payload): ( + HashValue, + &UserAutomatedTransaction, + TransactionPayload, + ), + ) -> Self { Self { sender: txn.sender().into(), index: txn.sequence_number().into(), diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs index 4ae8ac8794502..b5deaba210745 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. //! This module defines the gas parameters for Aptos Framework & Stdlib. diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index 464ca9e57d111..c6aecd8125340 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use crate::{ block_executor::{AptosTransactionOutput, BlockAptosVM}, @@ -761,10 +763,11 @@ impl AptosVM { let module_id = traversal_context .referenced_module_ids .alloc(entry_fn.module().clone()); - session.check_dependencies_and_charge_gas(gas_meter, traversal_context, [( - module_id.address(), - module_id.name(), - )])?; + session.check_dependencies_and_charge_gas( + gas_meter, + traversal_context, + [(module_id.address(), module_id.name())], + )?; } let function = @@ -2435,7 +2438,7 @@ impl AptosVM { }, Transaction::AutomatedTransaction(_) => { unimplemented!("AutomatedTransaction execution is coming soon") - } + }, }) } } diff --git a/aptos-move/aptos-vm/src/transaction_metadata.rs b/aptos-move/aptos-vm/src/transaction_metadata.rs index 9d2c174f47eb6..4d5eadcd9424f 100644 --- a/aptos-move/aptos-vm/src/transaction_metadata.rs +++ b/aptos-move/aptos-vm/src/transaction_metadata.rs @@ -1,9 +1,12 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use aptos_crypto::HashValue; use aptos_gas_algebra::{FeePerGasUnit, Gas, NumBytes}; +use aptos_types::transaction::automated_transaction::AutomatedTransaction; use aptos_types::{ account_address::AccountAddress, chain_id::ChainId, @@ -12,7 +15,6 @@ use aptos_types::{ SignedTransaction, TransactionPayload, }, }; -use aptos_types::transaction::automated_transaction::AutomatedTransaction; pub struct TransactionMetadata { pub sender: AccountAddress, @@ -32,7 +34,7 @@ pub struct TransactionMetadata { pub is_keyless: bool, pub entry_function_payload: Option, pub multisig_payload: Option, - pub txn_app_hash: Vec + pub txn_app_hash: Vec, } impl TransactionMetadata { @@ -82,7 +84,10 @@ impl TransactionMetadata { TransactionPayload::Multisig(m) => Some(m.clone()), _ => None, }, - txn_app_hash: HashValue::sha3_256_of(&bcs::to_bytes(&txn).expect("Unable to serialize SignedTransaction")).to_vec(), + txn_app_hash: HashValue::sha3_256_of( + &bcs::to_bytes(&txn).expect("Unable to serialize SignedTransaction"), + ) + .to_vec(), } } @@ -192,7 +197,7 @@ impl From<&AutomatedTransaction> for TransactionMetadata { _ => None, }, multisig_payload: None, - txn_app_hash: txn.hash().to_vec() + txn_app_hash: txn.hash().to_vec(), } } } diff --git a/aptos-move/framework/src/natives/transaction_context.rs b/aptos-move/framework/src/natives/transaction_context.rs index c55280a868a5b..6965a2d7d3453 100644 --- a/aptos-move/framework/src/natives/transaction_context.rs +++ b/aptos-move/framework/src/natives/transaction_context.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use aptos_gas_schedule::gas_params::natives::aptos_framework::*; use aptos_native_interface::{ @@ -252,7 +254,9 @@ fn native_txn_app_hash_internal( let user_transaction_context_opt = get_user_transaction_context_opt_from_context(context); if let Some(transaction_context) = user_transaction_context_opt { - Ok(smallvec![Value::vector_u8(transaction_context.txn_app_hash())]) + Ok(smallvec![Value::vector_u8( + transaction_context.txn_app_hash() + )]) } else { Err(SafeNativeError::Abort { abort_code: error::invalid_state(abort_codes::ETRANSACTION_CONTEXT_NOT_AVAILABLE), @@ -260,7 +264,6 @@ fn native_txn_app_hash_internal( } } - fn create_option_some_value(value: Value) -> Value { Value::struct_(Struct::pack(vec![create_singleton_vector(value)])) } @@ -429,10 +432,7 @@ pub fn make_all( "multisig_payload_internal", native_multisig_payload_internal, ), - ( - "txn_app_hash_internal", - native_txn_app_hash_internal, - ), + ("txn_app_hash_internal", native_txn_app_hash_internal), ]; builder.make_named_natives(natives) diff --git a/crates/aptos-rosetta/src/types/objects.rs b/crates/aptos-rosetta/src/types/objects.rs index 3fca903e86e84..11f19bd151c65 100644 --- a/crates/aptos-rosetta/src/types/objects.rs +++ b/crates/aptos-rosetta/src/types/objects.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. //! Objects of the Rosetta spec //! diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index 4d2631c782b4b..e08fd02974ccc 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use super::utils::fund_account; use crate::{ @@ -1376,19 +1378,18 @@ impl From<&Transaction> for TransactionSummary { version: Some(txn.transaction_info().version.0), vm_status: Some(txn.transaction_info().vm_status.clone()), }, - Transaction::AutomatedTransaction(txn) => - TransactionSummary { - transaction_hash: txn.info.hash, - sender: Some(*txn.meta.sender.inner()), - gas_used: Some(txn.info.gas_used.0), - gas_unit_price: Some(txn.meta.gas_unit_price.0), - success: Some(txn.info.success), - version: Some(txn.info.version.0), - vm_status: Some(txn.info.vm_status.clone()), - sequence_number: Some(txn.meta.index.0), - timestamp_us: Some(txn.timestamp.0), - pending: None, - }, + Transaction::AutomatedTransaction(txn) => TransactionSummary { + transaction_hash: txn.info.hash, + sender: Some(*txn.meta.sender.inner()), + gas_used: Some(txn.info.gas_used.0), + gas_unit_price: Some(txn.meta.gas_unit_price.0), + success: Some(txn.info.success), + version: Some(txn.info.version.0), + vm_status: Some(txn.info.vm_status.clone()), + sequence_number: Some(txn.meta.index.0), + timestamp_us: Some(txn.timestamp.0), + pending: None, + }, } } } diff --git a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs index b5c427fb70c1f..10d4e02150990 100644 --- a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs +++ b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use aptos_api_types::{ transaction::ValidatorTransaction as ApiValidatorTransactionEnum, AccountSignature, @@ -766,7 +768,9 @@ pub fn convert_transaction( Transaction::ValidatorTransaction(_) => { transaction::transaction::TransactionType::Validator }, - Transaction::AutomatedTransaction(_) => transaction::transaction::TransactionType::Automated + Transaction::AutomatedTransaction(_) => { + transaction::transaction::TransactionType::Automated + }, }; let txn_data = match &transaction { @@ -837,7 +841,6 @@ pub fn convert_transaction( convert_validator_transaction(api_validator_txn) }, Transaction::AutomatedTransaction(at) => { - timestamp = Some(convert_timestamp_usecs(at.timestamp.0)); let expiration_timestamp_secs = Some(convert_timestamp_secs(std::cmp::min( at.meta.expiration_timestamp_secs.0, @@ -851,11 +854,11 @@ pub fn convert_transaction( gas_unit_price: at.meta.gas_unit_price.0, expiration_timestamp_secs, payload: Some(convert_transaction_payload(&at.meta.payload)), - registration_hash: at.meta.registration_hash.0.to_vec() + registration_hash: at.meta.registration_hash.0.to_vec(), }), events: convert_events(&at.events), }) - } + }, }; transaction::Transaction { diff --git a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/stream_coordinator.rs b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/stream_coordinator.rs index 864012b3e6fa0..79b734b4361b9 100644 --- a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/stream_coordinator.rs +++ b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/stream_coordinator.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use crate::{ convert::convert_transaction, @@ -7,7 +9,9 @@ use crate::{ runtime::{DEFAULT_NUM_RETRIES, RETRY_TIME_MILLIS}, }; use aptos_api::context::Context; -use aptos_api_types::{AsConverter, Transaction as APITransaction, Transaction, TransactionOnChainData}; +use aptos_api_types::{ + AsConverter, Transaction as APITransaction, Transaction, TransactionOnChainData, +}; use aptos_indexer_grpc_utils::{ chunk_transactions, constants::MESSAGE_SIZE_LIMIT, @@ -415,8 +419,7 @@ impl IndexerStreamCoordinator { Transaction::AutomatedTransaction(ref mut at) => { at.info.block_height = Some(block_height_bcs); at.info.epoch = Some(epoch_bcs); - - } + }, }; txn }); diff --git a/execution/executor-types/src/parsed_transaction_output.rs b/execution/executor-types/src/parsed_transaction_output.rs index 0a4f2e0b47d2b..a9c26508700c9 100644 --- a/execution/executor-types/src/parsed_transaction_output.rs +++ b/execution/executor-types/src/parsed_transaction_output.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use aptos_types::{ contract_event::ContractEvent, diff --git a/execution/executor/src/components/chunk_output.rs b/execution/executor/src/components/chunk_output.rs index 504c8f317e891..30a9011313923 100644 --- a/execution/executor/src/components/chunk_output.rs +++ b/execution/executor/src/components/chunk_output.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. #![forbid(unsafe_code)] diff --git a/protos/proto/aptos/transaction/v1/transaction.proto b/protos/proto/aptos/transaction/v1/transaction.proto index 348467f9124ac..bab5b63cb0f60 100644 --- a/protos/proto/aptos/transaction/v1/transaction.proto +++ b/protos/proto/aptos/transaction/v1/transaction.proto @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. syntax = "proto3"; diff --git a/storage/backup/backup-cli/src/backup_types/transaction/analysis.rs b/storage/backup/backup-cli/src/backup_types/transaction/analysis.rs index 5f07a7bc103bf..c329a50afcd54 100644 --- a/storage/backup/backup-cli/src/backup_types/transaction/analysis.rs +++ b/storage/backup/backup-cli/src/backup_types/transaction/analysis.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use anyhow::Result; use aptos_types::{ diff --git a/types/src/proptest_types.rs b/types/src/proptest_types.rs index 62f715507db2b..a0f57b16d1650 100644 --- a/types/src/proptest_types.rs +++ b/types/src/proptest_types.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. #![allow(clippy::arc_with_non_send_sync)] diff --git a/types/src/transaction/automated_transaction.rs b/types/src/transaction/automated_transaction.rs index a7f152625477f..05ce57d48149f 100644 --- a/types/src/transaction/automated_transaction.rs +++ b/types/src/transaction/automated_transaction.rs @@ -1,5 +1,4 @@ -// Copyright (c) Supra Oracles -// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2024 Supra. use crate::chain_id::ChainId; use crate::transaction::{RawTransaction, Transaction, TransactionPayload}; diff --git a/types/src/transaction/mod.rs b/types/src/transaction/mod.rs index f54ad50db27f6..b1d9ba491aaad 100644 --- a/types/src/transaction/mod.rs +++ b/types/src/transaction/mod.rs @@ -1,6 +1,8 @@ // Copyright © Aptos Foundation // Parts of the project are originally copyright © Meta Platforms, Inc. // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. #![allow(clippy::arc_with_non_send_sync)] diff --git a/types/src/transaction/user_transaction_context.rs b/types/src/transaction/user_transaction_context.rs index eae814ce6bb14..7cf32598d7aae 100644 --- a/types/src/transaction/user_transaction_context.rs +++ b/types/src/transaction/user_transaction_context.rs @@ -1,5 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 +// +// Copyright (c) 2024 Supra. use move_core_types::account_address::AccountAddress;