Skip to content

Commit 10289ae

Browse files
committed
doc: EVM-semantic vs raw addresses
1 parent 4a3a32f commit 10289ae

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

libevm/libevm.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,29 @@ type StateReader interface {
6161
// AddressContext carries addresses available to contexts such as calls and
6262
// contract creation.
6363
//
64-
// With respect to contract creation, the Self address MAY be the predicted
65-
// address of the contract about to be deployed, which may not exist yet.
64+
// With respect to contract creation, the EVMSemantic.Self address MAY be the
65+
// predicted address of the contract about to be deployed, which might not exist
66+
// yet.
6667
type AddressContext struct {
67-
Origin common.Address // always equivalent to vm.ORIGIN op code
68+
Origin common.Address // equivalent to vm.ORIGIN op code
69+
// EVMSemantic addresses are those defined by the rules of the EVM, based on
70+
// the type of call made to a contract; i.e. the addresses pushed to the
71+
// stack by the vm.CALLER and vm.SELF op codes, respectively.
6872
EVMSemantic CallerAndSelf
69-
Raw *CallerAndSelf
73+
// Raw addresses are those that would be available to a contract under a
74+
// standard CALL; i.e. not interpreted according EVM rules. They are the
75+
// "intuitive" addresses such that the `Caller` is the account that called
76+
// `Self` even if it did so via DELEGATECALL or CALLCODE (in which cases
77+
// `Raw` and `EVMSemantic` would differ).
78+
//
79+
// Raw MUST NOT be nil when returned to a precompile implementation but MAY
80+
// be nil in other situations (e.g. hooks), which MUST document behaviour on
81+
// a case-by-case basis.
82+
Raw *CallerAndSelf
7083
}
7184

85+
// CallerAndSelf carries said addresses for use in an [AddressContext], where
86+
// the definitions of `Caller` and `Self` are defined based on context.
7287
type CallerAndSelf struct {
7388
Caller common.Address
7489
Self common.Address

0 commit comments

Comments
 (0)