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
feat: return any value type from execute_contract_allow_private
#4520
Conversation
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 this should be epoch-gated so we don't accidentally use it prior to epoch 2.5
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #4520 +/- ##
==========================================
- Coverage 83.22% 83.07% -0.16%
==========================================
Files 452 453 +1
Lines 326058 327375 +1317
Branches 323 323
==========================================
+ Hits 271359 271956 +597
- Misses 54691 55411 +720
Partials 8 8
... and 43 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@jcnelson @kantai else if allow_private && cfg!(feature = "developer-mode") {
self.commit()?;
Ok(result)
}
Ideally, I'd like to be able to use it for any epoch in simnet |
Yep -- I agree with this, as long as its controlled with a compile flag, this does not need to be epoch gated. My only comment is that I'd like to be a little more paranoid again, and introduce a new feature flag -- something specifically like |
Right now i'm using the pub fn handle_tx_result(
&mut self,
result: Result<Value>,
allow_private: bool,
) -> Result<Value> {
if let Ok(result) = result {
if let Value::Response(data) = result {
if data.committed {
self.commit()?;
} else {
self.roll_back()?;
}
Ok(Value::Response(data))
} else {
#[cfg(feature = "developer-mode")]
if allow_private {
self.commit()?;
return Ok(result);
}
Err(
CheckErrors::PublicFunctionMustReturnResponse(TypeSignature::type_of(&result)?)
.into(),
)
}
} else {
self.roll_back()?;
result
}
}
I'm starting to think that just "allow-private" is confusing. Because it should really be Should I just introduce a flag like "devtools" or "clarinet"? I'm sure I can find tons of usage for such a flag in the future |
Ah, yes, the
Yes -- either works. |
Done @kantai, I went for "devtools" |
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.
LGTM!
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.
LGTM, but before merging, please add a comment to handle_tx_result()
to indicate that allow_private
is ignored unless the node is compiled with the devtools
feature (the comment should include the line that they'd have to add to their Cargo.toml
or the build flags to pass to cargo
).
Done @jcnelson |
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.
LGTM!
The helper
execute_contract_allow_private
does not allow the private function to return any type and can throwPublicFunctionMustReturnResponse
if the private function return a non-Response value.On Clarinet, we get recurrent requests from the community and internal teams to add the ability to call private function in unit tests
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml