Skip to content
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

Open
wants to merge 1 commit into
base: cl/eip-3074
Choose a base branch
from

Conversation

clabby
Copy link
Owner

@clabby clabby commented Dec 9, 2023

Overview

Addresses some review comments from #1

  • Rename ActiveAccountUnsetAuthCall error -> UnauthorizedAuthCall
  • Fix panic case on AUTH; At a minimum, the opcode should expand memory to offset + 97 if it is not already allocated. More expansion can occur if length > 97 and the memory is not already allocated.
  • Fix divergence from spec in AUTH: "If the signature is instead invalid or the signer address does not equal authority, authorized is reset to an unset value."

@@ -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;

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);

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?

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;

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants