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

Add information about current address for DELEGATE call #335

Closed
chfast opened this issue Jun 27, 2019 · 2 comments
Closed

Add information about current address for DELEGATE call #335

chfast opened this issue Jun 27, 2019 · 2 comments

Comments

@chfast
Copy link
Member

chfast commented Jun 27, 2019

In the DELEGATECALL (and legacy CALLCODE) there are 3 addresses involved:

  • the destination address where the code is (msg.destination),
  • the current address where execution should happen,
  • the sender address (msg.sender).

The current address is not provided in the msg so the Host has to store it on its own.

@jlokier
Copy link

jlokier commented May 13, 2021

Related, I don't see where it is documented that msg.destination passed to call must be replaced by a different value in the host before it passes the (copied) message on to execute, when doing DELEGATECALL or CALLCODE. (In call, the host needs to know the code address from the VM, but in execute the child VM needs to know the account address for get_storage etc.)

It would be helpful if the comment for evmc_message::destination in evmc.h mentioned this dual role. As it is, I had to read some implementions to confirm this is what the host is expected to do.

Because the host has to keep track of the current account address for DELEGATECALL anyway, this makes the address parameter in get_storage, set_storage, selfdestruct and access_storage redundant. At least it's cheap to pass, being a pointer.

Knowing the only permitted value supports an optimisation in the host: It can ignore the address parameter and keep an account object handy instead of looking it up on each call.

@chfast
Copy link
Member Author

chfast commented Aug 17, 2022

Done in #611.

@chfast chfast closed this as completed Aug 17, 2022
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

No branches or pull requests

2 participants