Skip to content

Commit dc2a903

Browse files
authored
doc: explain call-stack-depth logic (#436)
1 parent 477f737 commit dc2a903

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fvm/src/call_manager/default.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ where
8686
where
8787
K: Kernel<CallManager = Self>,
8888
{
89+
// We check _then_ set because we don't count the top call. This effectivly allows a
90+
// call-stack depth of `max_call_depth + 1` (or `max_call_depth` sub-calls). While this is
91+
// likely a bug, this is how NV15 behaves so we mimic that behavior here.
92+
//
93+
// By example:
94+
//
95+
// 1. If the max depth is 0, call_stack_depth will be 1 and the top-level message won't be
96+
// able to make sub-calls (1 > 0).
97+
// 2. If the max depth is 1, the call_stack_depth will be 1 in the top-level message, 2 in
98+
// sub-calls, and said sub-calls will not be able to make further subcalls (2 > 1).
99+
//
100+
// NOTE: Unlike the FVM, Lotus adds _then_ checks. It does this because the
101+
// `call_stack_depth` in lotus is 0 for the top-level call, unlike in the FVM where it's 1.
89102
if self.call_stack_depth > self.machine.config().max_call_depth {
90103
return Err(
91104
syscall_error!(LimitExceeded, "message execution exceeds call depth").into(),

0 commit comments

Comments
 (0)