Skip to content

Commit

Permalink
Remove num contract call arguments limit
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Nov 14, 2024
1 parent 88707b4 commit cf66212
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/rust/src/parser/transaction_payload/arguments.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use nom::{bytes::complete::take, number::complete::be_u32};

use crate::{
check_canary, is_expert_mode,
check_canary,
parser::{ParserError, Value, TX_DEPTH_LIMIT},
};

// The number of contract call arguments we can handle.
// this can be adjusted, but keep in mind that higher values could
// hit stack overflows issues.
pub const MAX_NUM_ARGS: u32 = 30;
// pub const MAX_NUM_ARGS: u32 = 30;

#[repr(C)]
#[derive(Clone, PartialEq)]
Expand All @@ -22,9 +22,13 @@ impl<'a> Arguments<'a> {

let (mut rem, num_args) = be_u32::<_, ParserError>(bytes)?;

if num_args > MAX_NUM_ARGS && !is_expert_mode() {
return Err(ParserError::InvalidTransactionPayload.into());
}
// Remove this check, this does not affect memory consumption
// and allow user to sign streamline contract calls that in practice have
// more that 30 arguments, for example swap transactions.
// see: https://github.com/Zondax/ledger-stacks/issues/176
// if num_args > MAX_NUM_ARGS && !is_expert_mode() {
// return Err(ParserError::InvalidTransactionPayload.into());
// }

// Parse all arguments so we can be sure that at runtime when each
// argument is retrieved it does not crashes
Expand Down

0 comments on commit cf66212

Please sign in to comment.