-
Notifications
You must be signed in to change notification settings - Fork 2
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
@lightclient + @anna-carroll reviews #7
base: cl/eip-3074
Are you sure you want to change the base?
Conversation
@@ -368,6 +368,9 @@ pub fn static_call<H: Host, SPEC: Spec>(interpreter: &mut Interpreter<'_>, host: | |||
|
|||
// EIP-3074 | |||
pub fn auth<H: Host, SPEC: Spec>(interpreter: &mut Interpreter<'_>, host: &mut H) { | |||
// The minimum amount of memory expansion (in bytes) required to hold the signature and commit. | |||
const MINIMUM_EXPANSION: usize = 97; |
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 don't believe this is necessarily true. It's possible to specify a memory region less than 97 bytes and the eip says to treat the rest of the expected bytes as zeros.
let mem_slice = interpreter | ||
.shared_memory | ||
.slice(signature_offset, signature_len); | ||
.slice(signature_offset, MINIMUM_EXPANSION); |
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.
this might be an ignorant question, but why do we expand memory by the full pointer length if we are only always going to slice exactly 97 bytes?
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.
what happens if we slice MINIMUM_EXPANSION
length if signature_len
is less than MINIMUM_EXPANSION
length? could we slice into "dirty" memory region on accident?
// The spec states that the `AUTH` opcode returns 0 and unsets the authorized account | ||
// if the signature is either invalid, or the recovered address does not match the | ||
// authority. | ||
interpreter.authorized = None; |
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.
super super nit, but the order of these operations is switched between the success and failure cases, which makes it ever so slightly less readable
Overview
Addresses some review comments from #1
ActiveAccountUnsetAuthCall
error ->UnauthorizedAuthCall
AUTH
; At a minimum, the opcode should expand memory tooffset + 97
if it is not already allocated. More expansion can occur iflength
>97
and the memory is not already allocated.AUTH
: "If the signature is instead invalid or the signer address does not equalauthority
,authorized
is reset to an unset value."