-
Notifications
You must be signed in to change notification settings - Fork 344
[REVIEW] issue244 delegatecall #247
[REVIEW] issue244 delegatecall #247
Conversation
so reasoning is:
|
Did you look at this yet? https://github.com/ethereum/go-ethereum/search?utf8=%E2%9C%93&q=delegatecall This has everywhere that is delegate call related in some way and could be an excellent reference point. |
// DelegateCall is executed by the DELEGATECALL opcode, introduced as off Ethereum Homestead. | ||
// The intent of delegate call is to run the code of the callee in the storage context of the caller; | ||
// while preserving the original caller to the previous callee. | ||
// [ -->] Different to the normal CALL or CALLCODE, the value does not need to be transferred to the callee. [<-- CORRECT?] |
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.
Not entirely correct. See here. https://github.com/ethereum/go-ethereum/blob/b7e3dfc5a2bc7e2f4d653fbe0ec9774277a10643/core/execution.go#L41
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.
Just change these notes here please @benjaminbollen then it should be ready to merge.
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.
done
I'm going to state my understanding of this operation and see if other people agree. "Caller" and "Callee" can get a bit confusing because we an intermediate account (named B below; the delegate) that is both caller and callee. Suppose we have 3 accounts: A, B, and C with the following psuedo-code contracts attached: A:
B:
C:
Then the result of invoking A (message or transaction) should be the following sequence:
That is B acts a 'delegate' for A in terms of the message sender and value, but like with Is this correct? |
I need clarification on what this means, and if it is indeed correct... |
yes, that is also how i understand it and the pseudo-code example is consistent. |
in the code, opcodes I understand that the value sent with the
|
the key diff between CALL and DELEGATECALL is the storage and memory zone in which the code operates. namely CALL will execute in the storage and memory zone of the CALLEE while DELEGATECALL will execute the in the storage and memory zone of the CALLER. |
so in the proposed impl here; for
https://github.com/eris-ltd/eris-db/pull/247/files#diff-cad6213f6a08c87e4110c4006789e2b7R832 where then |
I'm pretty sure there's a few nuances in the proposed |
The original EIP with all the specifications. ethereum/EIPs#23 |
I just want to emphasise the difference between
Do we agree? |
Yes, I agree that the stored address would be now stored as |
@@ -19,4 +19,4 @@ package version | |||
const TENDERMINT_VERSION = "0.5.0" | |||
// IMPORTANT: Eris-DB version must be on the last line of this file for | |||
// the deployment script DOCKER/build.sh to pick up the right label. | |||
const VERSION = "0.12.0" | |||
const VERSION = "0.12.0-rc2" |
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.
@pietv can you review whether for this PR to merge into master we want VERSION="0.12.0-rc2
or simply VERSION=0.12.0
(rc labelling still has me confused)
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.
@benjaminbollen it's "0.12.0" for #master. without rc.
64c5002
to
9528774
Compare
// caller, as such it is not stored on stack for the address | ||
// to be called; for CALL and CALLCODE value is stored on stack | ||
// and needs to be overwritten from the given value. | ||
// TODO: [ben] assert that malicious code cannot produce |
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.
We keeping this as todo?
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.
It is arguably redundant as value cannot be passed to another contract if it did not exist; and value is atomically swapped. However, should a contract rely on CALLVALUE
Im at this point not confident it would not be possible to produce bytecode that would put a malignent value on the stack and as such provide a hidden way to corrupt seemingly valid solidity.
So other than my suggestion for a rewording of the comment describing the crucial implementation fact for DELEGATECALL, this looks good to me! Great work Ben |
…244-delegatecall [REVIEW] issue244 delegatecall
this is for communication, review and testing purposes only. Do not merge this into master, until we have properly reviewed and tested