-
Notifications
You must be signed in to change notification settings - Fork 21
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
runtime-sdk/modules/contracts: Fix subcall dispatch #1066
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1066 +/- ##
==========================================
- Coverage 68.17% 66.80% -1.38%
==========================================
Files 128 127 -1
Lines 11101 11000 -101
==========================================
- Hits 7568 7348 -220
- Misses 3501 3620 +119
Partials 32 32
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
0b59482
to
1d42a37
Compare
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.
need to ask about simulation
@@ -513,7 +513,9 @@ impl Runtime for ContractRuntime { | |||
} | |||
|
|||
#[test] | |||
fn test_hello_contract_subcalls() { | |||
fn test_hello_contract_subcalls_overflow() { |
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.
ℹ️ apparently this was always a stack overflow test. this renames it to something more descriptive. in the same change, we're adding a new non-stack-overflow test with the old name
}; | ||
ctx.with_tx(0, 0, tx, |mut tx_ctx, call| { | ||
let result = Contracts::tx_call(&mut tx_ctx, cbor::from_value(call.body).unwrap()) | ||
.expect("call should succeed"); |
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.
ℹ️ same test as above except once: true
and it succeeds
|
||
// Skip additional checks/gas payment for internally generated transactions. | ||
if ctx.is_internal() && !ctx.is_simulation() { | ||
return Ok(()); |
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.
if things later get more complex, we should move subsets of the checking logic, e.g. the gas price checking and signature verification gas use, to helper functions and call them inside if
blocks instead of early returning
Previously various gas and fee checks were performed even for internal subcalls (e.g. when smart contracts called into other modules) which was wrong and also caused failures due to minimum gas price not being met (the fee is always set to zero for subcalls).
1d42a37
to
6bde461
Compare
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.
explicit internal flag
Previously various gas and fee checks were performed even for internal
subcalls (e.g. when smart contracts called into other modules) which
was wrong and also caused failures due to minimum gas price not being
met (the fee is always set to zero for subcalls).