From 8442b2d3761795da1902aaa356c7a3468360d205 Mon Sep 17 00:00:00 2001 From: Hannes Karppila Date: Tue, 21 Mar 2023 00:09:41 +0200 Subject: [PATCH] Remove nested call limit (#399) --- fuel-asm/src/panic_reason.rs | 5 +---- fuel-vm/src/interpreter/executors/instruction.rs | 4 ---- fuel-vm/src/tests/flow.rs | 5 +++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/fuel-asm/src/panic_reason.rs b/fuel-asm/src/panic_reason.rs index e469a24da6..72f7e47009 100644 --- a/fuel-asm/src/panic_reason.rs +++ b/fuel-asm/src/panic_reason.rs @@ -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, } @@ -139,7 +137,6 @@ impl From for PanicReason { 0x1f => IllegalJump, 0x20 => ContractIdAlreadyDeployed, 0x21 => ContractMismatch, - 0x22 => NestedCallLimitReached, _ => UnknownPanicReason, } } @@ -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; diff --git a/fuel-vm/src/interpreter/executors/instruction.rs b/fuel-vm/src/interpreter/executors/instruction.rs index 36468ade8c..d125e11946 100644 --- a/fuel-vm/src/interpreter/executors/instruction.rs +++ b/fuel-vm/src/interpreter/executors/instruction.rs @@ -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)?; } diff --git a/fuel-vm/src/tests/flow.rs b/fuel-vm/src/tests/flow.rs index 3cb02dc6bc..0db9257141 100644 --- a/fuel-vm/src/tests/flow.rs +++ b/fuel-vm/src/tests/flow.rs @@ -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(); @@ -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 {