Skip to content

Commit

Permalink
separating constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaptos authored and sherry-x committed Dec 2, 2024
1 parent 629850d commit 2dd6b77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 4 additions & 3 deletions api/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ use aptos_api_types::{
AsConverter, EncodeSubmissionRequest, GasEstimation, GasEstimationBcs, HashValue,
HexEncodedBytes, LedgerInfo, MoveType, PendingTransaction, SubmitTransactionRequest,
Transaction, TransactionData, TransactionOnChainData, TransactionsBatchSingleSubmissionFailure,
TransactionsBatchSubmissionResult, UserTransaction, VerifyInput, VerifyInputWithRecursion,
MAX_RECURSIVE_TYPES_ALLOWED, U64,
TransactionsBatchSubmissionResult, UserTransaction, VerifyInput, VerifyInputWithRecursion, U64,
};
use aptos_crypto::{hash::CryptoHash, signing_message};
use aptos_types::{
Expand Down Expand Up @@ -1041,10 +1040,12 @@ impl TransactionsApi {
ledger_info: &LedgerInfo,
data: SubmitTransactionPost,
) -> Result<SignedTransaction, SubmitTransactionError> {
pub const MAX_SIGNED_TRANSACTION_DEPTH: usize = 16;

match data {
SubmitTransactionPost::Bcs(data) => {
let signed_transaction: SignedTransaction =
bcs::from_bytes_with_limit(&data.0, MAX_RECURSIVE_TYPES_ALLOWED as usize)
bcs::from_bytes_with_limit(&data.0, MAX_SIGNED_TRANSACTION_DEPTH)
.context("Failed to deserialize input into SignedTransaction")
.map_err(|err| {
SubmitTransactionError::bad_request_with_code(
Expand Down
7 changes: 1 addition & 6 deletions api/types/src/move_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,7 @@ pub enum MoveType {

/// Maximum number of recursive types - Same as (non-public)
/// move_core_types::safe_serialize::MAX_TYPE_TAG_NESTING
/// We keep 16 for legacy tests
pub const MAX_RECURSIVE_TYPES_ALLOWED: u8 = if cfg!(test) {
16
} else {
8 // = move_core_types::safe_serialize::MAX_TYPE_TAG_NESTING
};
pub const MAX_RECURSIVE_TYPES_ALLOWED: u8 = 8;

impl VerifyInputWithRecursion for MoveType {
fn verify(&self, recursion_count: u8) -> anyhow::Result<()> {
Expand Down

0 comments on commit 2dd6b77

Please sign in to comment.