-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
EIP 7: DELEGATECALL #23
Comments
This is a very important update for reusable standard libraries |
+1 |
The |
Note that this works well with #8 , as otherwise sub-delegations will have to specify a fairly low return data size limit. |
For this to really support call delegation without having to inspect which function is actually called, we also need a way to retrieve the size of the returned data. |
Previous comment is not 100% true, see EIP5 - |
Should it be symmetric to |
@CJentzsch I would rather argue for the remove of |
@wanderer . I also like to have 6 values instead of 7. But changing |
Just to double-check: Like CALLCODE, this will use the state of the delegator contract, not the delegatee contract, right? If so, this seems like a good idea. If not, it's a pretty big security hole. |
@vbuterin that one should be closed right ? |
can we close this now that this has been done? |
@wanderer @vbuterin @alexvandesande EIP is merged and on mainnet, please close issue |
👍 |
I have a small doubt here, does delegate call allows the callee contracted to access the msg.sender(ethereum address of the account) of the caller contract? |
yes. |
@VoR0220 will be available in the msg.sender itself or in some other variable? |
you would have to send it alongside another variable. Also tx.origin could do it as well I suppose. But then you expose your own contract to security faults in there as well. |
@CJentzsch actually, when you callcode with value, you really make a transfer to the address containing the code (and not to caller itself). |
Overview
Add a new opcode,
DELEGATECALL
at0xf4
, which is similar in idea toCALLCODE
, except that it propagates the sender and value from the parent scope to the child scope, ie. the call created has the same sender and value as the original call.Specification
DELEGATECALL
:0xf4
, takes 6 operands:gas
: the amount of gas the code may use in order to execute;to
: the destination address whose code is to be executed;in_offset
: the offset into memory of the input;in_size
: the size of the input in bytes;out_offset
: the offset into memory of the output;out_size
: the size of the scratch pad for the output.Notes on Gas
gas
is the total amount the callee receives.CALLCODE
, account creation never happens, so the upfront gas cost is alwaysschedule.callGas
+gas
.Notes on Sender
CALLER
behaves exactly in the callee's environment as it does in the caller's environment.Other Notes
Rationale
Propagating the sender and value from the parent scope to the child scope makes it much easier for a contract to store another address as a mutable source of code and ''pass through'' calls to it, as the child code would execute in essentially the same environment (except for reduced gas and increased callstack depth) as the parent.
Use case 1: split code to get around 3m gas barrier
Use case 2: mutable address for storing the code of a contract:
The child functions called by these methods can now freely reference
msg.sender
andmsg.value
.Possible arguments against
The text was updated successfully, but these errors were encountered: