Skip to content

Commit 458857d

Browse files
committed
Upgrade to evmc 10.0.0
1 parent 5c139b6 commit 458857d

File tree

10 files changed

+860
-229
lines changed

10 files changed

+860
-229
lines changed

test/evmc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# EVMC
22

3-
This is an import of [EVMC](https://github.com/ethereum/evmc) version [9.0.0](https://github.com/ethereum/evmc/releases/tag/v9.0.0).
3+
This is an import of [EVMC](https://github.com/ethereum/evmc) version [10.0.0](https://github.com/ethereum/evmc/releases/tag/v10.0.0).
44

55
Important: The `MockedAccount.storage` is changed to a map from unordered_map as ordering is important for fuzzing.

test/evmc/evmc.h

Lines changed: 172 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* EVMC: Ethereum Client-VM Connector API
33
*
44
* @copyright
5-
* Copyright 2016-2019 The EVMC Authors.
5+
* Copyright 2016 The EVMC Authors.
66
* Licensed under the Apache License, Version 2.0.
77
*
88
* @defgroup EVMC EVMC
@@ -44,7 +44,7 @@ enum
4444
*
4545
* @see @ref versioning
4646
*/
47-
EVMC_ABI_VERSION = 9
47+
EVMC_ABI_VERSION = 10
4848
};
4949

5050

@@ -89,8 +89,9 @@ enum evmc_flags
8989
};
9090

9191
/**
92-
* The message describing an EVM call,
93-
* including a zero-depth calls from a transaction origin.
92+
* The message describing an EVM call, including a zero-depth calls from a transaction origin.
93+
*
94+
* Most of the fields are modelled by the section 8. Message Call of the Ethereum Yellow Paper.
9495
*/
9596
struct evmc_message
9697
{
@@ -103,21 +104,48 @@ struct evmc_message
103104
*/
104105
uint32_t flags;
105106

106-
/** The call depth. */
107+
/**
108+
* The present depth of the message call stack.
109+
*
110+
* Defined as `e` in the Yellow Paper.
111+
*/
107112
int32_t depth;
108113

109-
/** The amount of gas for message execution. */
114+
/**
115+
* The amount of gas available to the message execution.
116+
*
117+
* Defined as `g` in the Yellow Paper.
118+
*/
110119
int64_t gas;
111120

112-
/** The destination of the message. */
113-
evmc_address destination;
121+
/**
122+
* The recipient of the message.
123+
*
124+
* This is the address of the account which storage/balance/nonce is going to be modified
125+
* by the message execution. In case of ::EVMC_CALL, this is also the account where the
126+
* message value evmc_message::value is going to be transferred.
127+
* For ::EVMC_CALLCODE or ::EVMC_DELEGATECALL, this may be different from
128+
* the evmc_message::code_address.
129+
*
130+
* Defined as `r` in the Yellow Paper.
131+
*/
132+
evmc_address recipient;
114133

115-
/** The sender of the message. */
134+
/**
135+
* The sender of the message.
136+
*
137+
* The address of the sender of a message call defined as `s` in the Yellow Paper.
138+
* This must be the message recipient of the message at the previous (lower) depth,
139+
* except for the ::EVMC_DELEGATECALL where recipient is the 2 levels above the present depth.
140+
* At the depth 0 this must be the transaction origin.
141+
*/
116142
evmc_address sender;
117143

118144
/**
119145
* The message input data.
120146
*
147+
* The arbitrary length byte array of the input data of the call,
148+
* defined as `d` in the Yellow Paper.
121149
* This MAY be NULL.
122150
*/
123151
const uint8_t* input_data;
@@ -131,30 +159,49 @@ struct evmc_message
131159

132160
/**
133161
* The amount of Ether transferred with the message.
162+
*
163+
* This is transferred value for ::EVMC_CALL or apparent value for ::EVMC_DELEGATECALL.
164+
* Defined as `v` or `v~` in the Yellow Paper.
134165
*/
135166
evmc_uint256be value;
136167

137168
/**
138169
* The optional value used in new contract address construction.
139170
*
140-
* Ignored unless kind is EVMC_CREATE2.
171+
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2.
172+
* Ignored in evmc_execute_fn().
141173
*/
142174
evmc_bytes32 create2_salt;
175+
176+
/**
177+
* The address of the code to be executed.
178+
*
179+
* For ::EVMC_CALLCODE or ::EVMC_DELEGATECALL this may be different from
180+
* the evmc_message::recipient.
181+
* Not required when invoking evmc_execute_fn(), only when invoking evmc_call_fn().
182+
* Ignored if kind is ::EVMC_CREATE or ::EVMC_CREATE2.
183+
*
184+
* In case of ::EVMC_CAPABILITY_PRECOMPILES implementation, this fields should be inspected
185+
* to identify the requested precompile.
186+
*
187+
* Defined as `c` in the Yellow Paper.
188+
*/
189+
evmc_address code_address;
143190
};
144191

145192

146193
/** The transaction and block data for execution. */
147194
struct evmc_tx_context
148195
{
149-
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
150-
evmc_address tx_origin; /**< The transaction origin account. */
151-
evmc_address block_coinbase; /**< The miner of the block. */
152-
int64_t block_number; /**< The block number. */
153-
int64_t block_timestamp; /**< The block timestamp. */
154-
int64_t block_gas_limit; /**< The block gas limit. */
155-
evmc_uint256be block_difficulty; /**< The block difficulty. */
156-
evmc_uint256be chain_id; /**< The blockchain's ChainID. */
157-
evmc_uint256be block_base_fee; /**< The block base fee per gas (EIP-1559, EIP-3198). */
196+
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
197+
evmc_address tx_origin; /**< The transaction origin account. */
198+
evmc_address block_coinbase; /**< The miner of the block. */
199+
int64_t block_number; /**< The block number. */
200+
int64_t block_timestamp; /**< The block timestamp. */
201+
int64_t block_gas_limit; /**< The block gas limit. */
202+
evmc_uint256be block_prev_randao; /**< The block previous RANDAO (EIP-4399). */
203+
evmc_uint256be chain_id; /**< The blockchain's ChainID. */
204+
evmc_uint256be block_base_fee; /**< The block base fee per gas (EIP-1559, EIP-3198). */
158205
};
159206

160207
/**
@@ -354,6 +401,14 @@ struct evmc_result
354401
*/
355402
int64_t gas_left;
356403

404+
/**
405+
* The refunded gas accumulated from this execution and its sub-calls.
406+
*
407+
* The transaction gas refund limit is not applied.
408+
* If evmc_result::status_code is other than ::EVMC_SUCCESS the value MUST be 0.
409+
*/
410+
int64_t gas_refund;
411+
357412
/**
358413
* The reference to output data.
359414
*
@@ -396,12 +451,11 @@ struct evmc_result
396451
evmc_release_result_fn release;
397452

398453
/**
399-
* The address of the contract created by create instructions.
454+
* The address of the possibly created contract.
400455
*
401-
* This field has valid value only if:
402-
* - it is a result of the Host method evmc_host_interface::call
403-
* - and the result describes successful contract creation
404-
* (evmc_result::status_code is ::EVMC_SUCCESS).
456+
* The create address may be provided even though the contract creation has failed
457+
* (evmc_result::status_code is not ::EVMC_SUCCESS). This is useful in situations
458+
* when the address is observable, e.g. access to it remains warm.
405459
* In all other cases the address MUST be null bytes.
406460
*/
407461
evmc_address create_address;
@@ -452,40 +506,97 @@ typedef evmc_bytes32 (*evmc_get_storage_fn)(struct evmc_host_context* context,
452506
/**
453507
* The effect of an attempt to modify a contract storage item.
454508
*
509+
* See @ref storagestatus for additional information about design of this enum
510+
* and analysis of the specification.
511+
*
455512
* For the purpose of explaining the meaning of each element, the following
456513
* notation is used:
457514
* - 0 is zero value,
458515
* - X != 0 (X is any value other than 0),
459-
* - Y != X, Y != 0 (Y is any value other than X and 0),
460-
* - Z != Y (Z is any value other than Y),
461-
* - the "->" means the change from one value to another.
516+
* - Y != 0, Y != X, (Y is any value other than X and 0),
517+
* - Z != 0, Z != X, Z != X (Z is any value other than Y and X and 0),
518+
* - the "o -> c -> v" triple describes the change status in the context of:
519+
* - o: original value (cold value before a transaction started),
520+
* - c: current storage value,
521+
* - v: new storage value to be set.
522+
*
523+
* The order of elements follows EIPs introducing net storage gas costs:
524+
* - EIP-2200: https://eips.ethereum.org/EIPS/eip-2200,
525+
* - EIP-1283: https://eips.ethereum.org/EIPS/eip-1283.
462526
*/
463527
enum evmc_storage_status
464528
{
465529
/**
466-
* The value of a storage item has been left unchanged: 0 -> 0 and X -> X.
530+
* The new/same value is assigned to the storage item without affecting the cost structure.
531+
*
532+
* The storage value item is either:
533+
* - left unchanged (c == v) or
534+
* - the dirty value (o != c) is modified again (c != v).
535+
* This is the group of cases related to minimal gas cost of only accessing warm storage.
536+
* 0|X -> 0 -> 0 (current value unchanged)
537+
* 0|X|Y -> Y -> Y (current value unchanged)
538+
* 0|X -> Y -> Z (modified previously added/modified value)
539+
*
540+
* This is "catch all remaining" status. I.e. if all other statuses are correctly matched
541+
* this status should be assigned to all remaining cases.
542+
*/
543+
EVMC_STORAGE_ASSIGNED = 0,
544+
545+
/**
546+
* A new storage item is added by changing
547+
* the current clean zero to a nonzero value.
548+
* 0 -> 0 -> Z
549+
*/
550+
EVMC_STORAGE_ADDED = 1,
551+
552+
/**
553+
* A storage item is deleted by changing
554+
* the current clean nonzero to the zero value.
555+
* X -> X -> 0
556+
*/
557+
EVMC_STORAGE_DELETED = 2,
558+
559+
/**
560+
* A storage item is modified by changing
561+
* the current clean nonzero to other nonzero value.
562+
* X -> X -> Z
563+
*/
564+
EVMC_STORAGE_MODIFIED = 3,
565+
566+
/**
567+
* A storage item is added by changing
568+
* the current dirty zero to a nonzero value other than the original value.
569+
* X -> 0 -> Z
467570
*/
468-
EVMC_STORAGE_UNCHANGED = 0,
571+
EVMC_STORAGE_DELETED_ADDED = 4,
469572

470573
/**
471-
* The value of a storage item has been modified: X -> Y.
574+
* A storage item is deleted by changing
575+
* the current dirty nonzero to the zero value and the original value is not zero.
576+
* X -> Y -> 0
472577
*/
473-
EVMC_STORAGE_MODIFIED = 1,
578+
EVMC_STORAGE_MODIFIED_DELETED = 5,
474579

475580
/**
476-
* A storage item has been modified after being modified before: X -> Y -> Z.
581+
* A storage item is added by changing
582+
* the current dirty zero to the original value.
583+
* X -> 0 -> X
477584
*/
478-
EVMC_STORAGE_MODIFIED_AGAIN = 2,
585+
EVMC_STORAGE_DELETED_RESTORED = 6,
479586

480587
/**
481-
* A new storage item has been added: 0 -> X.
588+
* A storage item is deleted by changing
589+
* the current dirty nonzero to the original zero value.
590+
* 0 -> Y -> 0
482591
*/
483-
EVMC_STORAGE_ADDED = 3,
592+
EVMC_STORAGE_ADDED_DELETED = 7,
484593

485594
/**
486-
* A storage item has been deleted: X -> 0.
595+
* A storage item is modified by changing
596+
* the current dirty nonzero to the original nonzero value other than the current value.
597+
* X -> Y -> X
487598
*/
488-
EVMC_STORAGE_DELETED = 4
599+
EVMC_STORAGE_MODIFIED_RESTORED = 8
489600
};
490601

491602

@@ -495,7 +606,7 @@ enum evmc_storage_status
495606
* This callback function is used by a VM to update the given account storage entry.
496607
* The VM MUST make sure that the account exists. This requirement is only a formality because
497608
* VM implementations only modify storage of the account of the current execution context
498-
* (i.e. referenced by evmc_message::destination).
609+
* (i.e. referenced by evmc_message::recipient).
499610
*
500611
* @param context The pointer to the Host execution context.
501612
* @param address The address of the account.
@@ -579,8 +690,10 @@ typedef size_t (*evmc_copy_code_fn)(struct evmc_host_context* context,
579690
* @param context The pointer to the Host execution context. See ::evmc_host_context.
580691
* @param address The address of the contract to be selfdestructed.
581692
* @param beneficiary The address where the remaining ETH is going to be transferred.
693+
* @return The information if the given address has not been registered as
694+
* selfdestructed yet. True if registered for the first time, false otherwise.
582695
*/
583-
typedef void (*evmc_selfdestruct_fn)(struct evmc_host_context* context,
696+
typedef bool (*evmc_selfdestruct_fn)(struct evmc_host_context* context,
584697
const evmc_address* address,
585698
const evmc_address* beneficiary);
586699

@@ -821,26 +934,40 @@ enum evmc_revision
821934
/**
822935
* The Berlin revision.
823936
*
824-
* https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md
937+
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md
825938
*/
826939
EVMC_BERLIN = 8,
827940

828941
/**
829942
* The London revision.
830943
*
831-
* https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/london.md
944+
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md
832945
*/
833946
EVMC_LONDON = 9,
834947

948+
/**
949+
* The Paris revision (aka The Merge).
950+
*
951+
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md
952+
*/
953+
EVMC_PARIS = 10,
954+
835955
/**
836956
* The Shanghai revision.
837957
*
838-
* https://github.com/ethereum/eth1.0-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md
958+
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md
959+
*/
960+
EVMC_SHANGHAI = 11,
961+
962+
/**
963+
* The Cancun revision.
964+
*
965+
* The future next revision after Shanghai.
839966
*/
840-
EVMC_SHANGHAI = 10,
967+
EVMC_CANCUN = 12,
841968

842969
/** The maximum EVM revision supported. */
843-
EVMC_MAX_REVISION = EVMC_SHANGHAI,
970+
EVMC_MAX_REVISION = EVMC_CANCUN,
844971

845972
/**
846973
* The latest known EVM revision with finalized specification.
@@ -894,7 +1021,7 @@ enum evmc_capabilities
8941021

8951022
/**
8961023
* The VM is capable of executing the precompiled contracts
897-
* defined for the range of destination addresses.
1024+
* defined for the range of code addresses.
8981025
*
8991026
* The EIP-1352 (https://eips.ethereum.org/EIPS/eip-1352) specifies
9001027
* the range 0x000...0000 - 0x000...ffff of addresses

0 commit comments

Comments
 (0)