-
Notifications
You must be signed in to change notification settings - Fork 33
SC: enforce max_sync_call_depth for nested and recursive sync calls
#1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… of inline action recurse_depth
libraries/chain/host_context.cpp
Outdated
| // If the call is initiated from an apply_context (an action), it is the first | ||
| // level of a sync call by the action, set the depth to 1. | ||
| // Otherwise the call is from another sync call, increment the depth by 1. | ||
| const uint32_t depth = dynamic_cast<apply_context*>(this) ? 1 : sync_call_depth + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should refactor to remove this dynamic_cast. Can't you just pass in the depth instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be removed because sync_call_depth default initial value is 0. Now the code is cleaner. Thanks.
…f functions which should have never be called
…r returning a 0-length value
SC: Tests for sync calls without parameters, not returning a value, or returning a 0-length value
SC: privilege support
SC: Enforce host function preconditions for sync calls
Enforce on chain configuration parameter
max_sync_call_depthfor nested and recursive sync calls. Once the depth is reached, the call is aborted.Notable things about the two new two tests for the PR:
One test has one function making sync calls to itself recursively, another has two functions on different accounts calling each other recursively. Both tests show sync calls work correctly when max depth is not reached, and calls are aborted when max depth is reached.
The test WASM contracts utilize
senderandreceiverarguments fromsync_callentry point, which demonstrates those two arguments are set correctly.Resolves #1268