Skip to content

Commit

Permalink
Remove nested call limit (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal authored Mar 20, 2023
1 parent f0e07aa commit 8442b2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
5 changes: 1 addition & 4 deletions fuel-asm/src/panic_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ pub enum PanicReason {
ContractIdAlreadyDeployed = 0x20,
/// The loaded contract mismatch expectations.
ContractMismatch = 0x21,
/// No more nested calls are allowed.
NestedCallLimitReached = 0x22,
/// The byte can't be mapped to any known `PanicReason`.
UnknownPanicReason = 0x23,
}
Expand Down Expand Up @@ -139,7 +137,6 @@ impl From<u8> for PanicReason {
0x1f => IllegalJump,
0x20 => ContractIdAlreadyDeployed,
0x21 => ContractMismatch,
0x22 => NestedCallLimitReached,
_ => UnknownPanicReason,
}
}
Expand All @@ -166,7 +163,7 @@ mod tests {

#[test]
fn test_u8_panic_reason_round_trip() {
const LAST_PANIC_REASON: u8 = 0x23;
const LAST_PANIC_REASON: u8 = 0x22;
for i in 0..LAST_PANIC_REASON {
let reason = PanicReason::from(i);
let i2 = reason as u8;
Expand Down
4 changes: 0 additions & 4 deletions fuel-vm/src/interpreter/executors/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,6 @@ where
Instruction::CALL(call) => {
let (a, b, c, d) = call.unpack();

if self.frames.len() >= VM_MAX_NESTED_CALLS {
return Err(PanicReason::NestedCallLimitReached.into());
}

// Enter call context
self.prepare_call(a, b, c, d)?;
}
Expand Down
5 changes: 3 additions & 2 deletions fuel-vm/src/tests/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ fn revert_from_call_immediately_ends_execution() {
assert_eq!(revert_receipts.len(), 1);
}

/// Makes sure that infinte recursion with CALL instruction doesn't crash
#[test]
fn nested_call_limit() {
fn repeated_nested_calls() {
let rng = &mut StdRng::seed_from_u64(2322u64);

let mut client = MemoryClient::default();
Expand Down Expand Up @@ -496,7 +497,7 @@ fn nested_call_limit() {
if let Receipt::Panic { reason: pr, .. } = receipts.pop().expect("Missing panic reason receipt") {
assert_eq!(
*pr.reason(),
PanicReason::NestedCallLimitReached,
PanicReason::OutOfGas,
"Panic reason differs for the expected reason"
);
} else {
Expand Down

0 comments on commit 8442b2d

Please sign in to comment.