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

Fixing missing override on EVM DeletegateCall instruction? I think it's missing... #622

Closed
wants to merge 1 commit into from

Conversation

msooseth
Copy link
Collaborator

@msooseth msooseth commented Dec 23, 2024

Description

I think the DelegateCall was missing the override check? @elopez what do you think?

Notice that the override will be reset by the delegateCall function:

        \xGas -> do
          resetCaller <- use $ #state % #resetCaller
          when resetCaller $ assign (#state % #overrideCaller) Nothing

But it does not assign the from caller to the value, instead, we do that in e.g.:

        OpStaticcall ->
          case stk of
            xGas:xTo:xInOffset:xInSize:xOutOffset:xOutSize:xs ->
[...]
                Just xTo' ->
                  case gasTryFrom xGas of
                    Left _ -> vmError IllegalOverflow
                    Right gas -> do
                      overrideC <- use $ #state % #overrideCaller
                      delegateCall this gas xTo' xTo' (Lit 0) xInOffset xInSize xOutOffset xOutSize xs $
                        \callee -> do
                          zoom #state $ do
                            assign #callvalue (Lit 0)
                            assign #caller $ fromMaybe self overrideC

[...]

And similarly in other places. But somehow OpDelegateCall is missing this.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@elopez
Copy link
Collaborator

elopez commented Dec 23, 2024

@msooseth DELEGATECALL is special as it normally preserves the context (ie the caller remains the same as it was before the call), I'm not sure if pranking should be touching the caller here. Have you looked at Foundry's behavior to see what it does in this particular case?

@msooseth
Copy link
Collaborator Author

Ah, interesting. So they have a version of prank with a 2nd argument that, if set to true, will also affect delegateCall. But it does not affect delegateCall otherwise.

Discussion: foundry-rs/foundry#8863
The PR that got merged: https://github.com/foundry-rs/foundry/pull/8863/files

So it's good as-is. I am changing this PR to add a note instead so it's documented what's going on.

@msooseth msooseth closed this Dec 23, 2024
@msooseth msooseth deleted the missing-override branch January 2, 2025 18:08
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.

2 participants