Add assert_msg(cond, "message") emitting Solidity Error(string)#1399
Add assert_msg(cond, "message") emitting Solidity Error(string)#1399cburgdorf wants to merge 1 commit intoargotorg:masterfrom
assert_msg(cond, "message") emitting Solidity Error(string)#1399Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb5af0b111
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0feac7a to
9151f04
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9151f04914
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9151f04 to
404023c
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 404023ca5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Introduces `assert_msg<const N: usize>(b: bool, message: String<N>)` in
the std prelude. On `b == false` it reverts with the 4-byte selector
`0x08c379a0` (keccak256("Error(string)")[..4]) followed by the
ABI-encoded message, matching Solidity's `require(cond, "message")` /
`revert("message")`.
Also improves const-generic inference so a string literal can satisfy a
generic `String<N>` parameter without an annotation at the call site:
when a string literal is passed to a parameter of shape `String<N>` and
the inference key for `N` appears only in that one parameter, the
checker pins `N` to the literal's min length. Keys shared across
multiple parameters are left alone so the other arguments (e.g.
`[u8; N]`) still drive inference for `N`.
404023c to
35defdb
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Proposal: Define assert_msg in terms of Text aka DynString: use super::abi::Text
pub fn assert_msg(_ b: own bool, _ message: own Text) {
if !b {
let (ptr, len) = encode_calldata(0x08c379a0, message)
ops::revert(offset: ptr, len: len)
}
}(this might increase gas usage) and remove the hir changes. There's an issue in hir to be solved, but the current solution isn't the right one. I think we need to modify the type unifier so that it imposes an |
Introduces
assert_msg<const N: usize>(b: bool, message: String<N>)inthe std prelude. On
b == falseit reverts with the 4-byte selector0x08c379a0(keccak256("Error(string)")[..4]) followed by theABI-encoded message, matching Solidity's
require(cond, "message")/revert("message").Also improves const-generic inference so a string literal can satisfy a
generic
String<N>parameter without an annotation at the call site:when a string literal is passed to a parameter of shape
String<N>andthe inference key for
Nappears only in that one parameter, thechecker pins
Nto the literal's min length. Keys shared acrossmultiple parameters are left alone so the other arguments (e.g.
[u8; N]) still drive inference forN.Implements #1348