Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aregnaz Harutyunyan committed Nov 27, 2024
1 parent 03f2801 commit 77cac8c
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 51 deletions.
6 changes: 3 additions & 3 deletions api/types/src/convert.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
30 changes: 19 additions & 11 deletions api/types/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
},
Expand Down Expand Up @@ -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,
}
}

Expand All @@ -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()),
}
}

Expand Down Expand Up @@ -310,13 +312,13 @@ impl
}

impl
From<(
&UserAutomatedTransaction,
TransactionInfo,
TransactionPayload,
Vec<Event>,
u64,
)> for Transaction
From<(
&UserAutomatedTransaction,
TransactionInfo,
TransactionPayload,
Vec<Event>,
u64,
)> for Transaction
{
fn from(
(txn, info, payload, events, timestamp): (
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
13 changes: 8 additions & 5 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -2435,7 +2438,7 @@ impl AptosVM {
},
Transaction::AutomatedTransaction(_) => {
unimplemented!("AutomatedTransaction execution is coming soon")
}
},
})
}
}
Expand Down
13 changes: 9 additions & 4 deletions aptos-move/aptos-vm/src/transaction_metadata.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,7 +15,6 @@ use aptos_types::{
SignedTransaction, TransactionPayload,
},
};
use aptos_types::transaction::automated_transaction::AutomatedTransaction;

pub struct TransactionMetadata {
pub sender: AccountAddress,
Expand All @@ -32,7 +34,7 @@ pub struct TransactionMetadata {
pub is_keyless: bool,
pub entry_function_payload: Option<EntryFunction>,
pub multisig_payload: Option<Multisig>,
pub txn_app_hash: Vec<u8>
pub txn_app_hash: Vec<u8>,
}

impl TransactionMetadata {
Expand Down Expand Up @@ -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(),
}
}

Expand Down Expand Up @@ -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(),
}
}
}
12 changes: 6 additions & 6 deletions aptos-move/framework/src/natives/transaction_context.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -252,15 +254,16 @@ 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),
})
}
}


fn create_option_some_value(value: Value) -> Value {
Value::struct_(Struct::pack(vec![create_singleton_vector(value)]))
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions crates/aptos-rosetta/src/types/objects.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
//
// Copyright (c) 2024 Supra.

//! Objects of the Rosetta spec
//!
Expand Down
27 changes: 14 additions & 13 deletions crates/aptos/src/common/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
//
// Copyright (c) 2024 Supra.

use super::utils::fund_account;
use crate::{
Expand Down Expand Up @@ -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,
},
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
//
// Copyright (c) 2024 Supra.

use crate::{
convert::convert_transaction,
counters::UNABLE_TO_FETCH_TRANSACTION,
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,
Expand Down Expand Up @@ -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
});
Expand Down
2 changes: 2 additions & 0 deletions execution/executor-types/src/parsed_transaction_output.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
//
// Copyright (c) 2024 Supra.

use aptos_types::{
contract_event::ContractEvent,
Expand Down
2 changes: 2 additions & 0 deletions execution/executor/src/components/chunk_output.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
2 changes: 2 additions & 0 deletions protos/proto/aptos/transaction/v1/transaction.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0
//
// Copyright (c) 2024 Supra.

syntax = "proto3";

Expand Down
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
2 changes: 2 additions & 0 deletions types/src/proptest_types.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
3 changes: 1 addition & 2 deletions types/src/transaction/automated_transaction.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 2 additions & 0 deletions types/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
Loading

0 comments on commit 77cac8c

Please sign in to comment.