Skip to content

Commit 418461e

Browse files
author
Andrei Maiboroda
committed
Add Prague revision
1 parent b6a8a49 commit 418461e

File tree

8 files changed

+543
-2
lines changed

8 files changed

+543
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ Documentation of all notable changes to the **EVMC** project.
55
The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

8+
## [11.0.0] — unreleased
9+
10+
### Added
11+
12+
- The Prague EVM revision (anticipated after Cancun)
13+
[#683](https://github.com/ethereum/evmc/pull/683)
14+
15+
816
## [10.0.0] — 2022-08-25
917

1018
### Added

bindings/go/evmc/evmc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const (
108108
Paris Revision = C.EVMC_PARIS
109109
Shanghai Revision = C.EVMC_SHANGHAI
110110
Cancun Revision = C.EVMC_CANCUN
111+
Prague Revision = C.EVMC_PRAGUE
111112
MaxRevision Revision = C.EVMC_MAX_REVISION
112113
LatestStableRevision Revision = C.EVMC_LATEST_STABLE_REVISION
113114
)

bindings/go/evmc/evmc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestExecuteEmptyCode(t *testing.T) {
6161
}
6262

6363
func TestRevision(t *testing.T) {
64-
if MaxRevision != Cancun {
64+
if MaxRevision != Prague {
6565
t.Errorf("missing constant for revision %d", MaxRevision)
6666
}
6767
if LatestStableRevision != Paris {

include/evmc/evmc.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,19 @@ enum evmc_revision
964964
* The Cancun revision.
965965
*
966966
* The future next revision after Shanghai.
967+
* https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md
967968
*/
968969
EVMC_CANCUN = 12,
969970

971+
/**
972+
* The Prague revision.
973+
*
974+
* The future next revision after Cancun.
975+
*/
976+
EVMC_PRAGUE = 13,
977+
970978
/** The maximum EVM revision supported. */
971-
EVMC_MAX_REVISION = EVMC_CANCUN,
979+
EVMC_MAX_REVISION = EVMC_PRAGUE,
972980

973981
/**
974982
* The latest known EVM revision with finalized specification.

include/evmc/helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ static inline const char* evmc_revision_to_string(enum evmc_revision rev)
297297
return "Shanghai";
298298
case EVMC_CANCUN:
299299
return "Cancun";
300+
case EVMC_PRAGUE:
301+
return "Prague";
300302
}
301303
return "<unknown>";
302304
}

lib/instructions/instruction_metrics.c

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,264 @@ enum
3333
WARM_STORAGE_READ_COST = 100
3434
};
3535

36+
static struct evmc_instruction_metrics prague_metrics[256] = {
37+
/* STOP = 0x00 */ {ZERO, 0, 0},
38+
/* ADD = 0x01 */ {VERYLOW, 2, -1},
39+
/* MUL = 0x02 */ {LOW, 2, -1},
40+
/* SUB = 0x03 */ {VERYLOW, 2, -1},
41+
/* DIV = 0x04 */ {LOW, 2, -1},
42+
/* SDIV = 0x05 */ {LOW, 2, -1},
43+
/* MOD = 0x06 */ {LOW, 2, -1},
44+
/* SMOD = 0x07 */ {LOW, 2, -1},
45+
/* ADDMOD = 0x08 */ {MID, 3, -2},
46+
/* MULMOD = 0x09 */ {MID, 3, -2},
47+
/* EXP = 0x0a */ {HIGH, 2, -1},
48+
/* SIGNEXTEND = 0x0b */ {LOW, 2, -1},
49+
/* = 0x0c */ {UNDEFINED, 0, 0},
50+
/* = 0x0d */ {UNDEFINED, 0, 0},
51+
/* = 0x0e */ {UNDEFINED, 0, 0},
52+
/* = 0x0f */ {UNDEFINED, 0, 0},
53+
/* LT = 0x10 */ {VERYLOW, 2, -1},
54+
/* GT = 0x11 */ {VERYLOW, 2, -1},
55+
/* SLT = 0x12 */ {VERYLOW, 2, -1},
56+
/* SGT = 0x13 */ {VERYLOW, 2, -1},
57+
/* EQ = 0x14 */ {VERYLOW, 2, -1},
58+
/* ISZERO = 0x15 */ {VERYLOW, 1, 0},
59+
/* AND = 0x16 */ {VERYLOW, 2, -1},
60+
/* OR = 0x17 */ {VERYLOW, 2, -1},
61+
/* XOR = 0x18 */ {VERYLOW, 2, -1},
62+
/* NOT = 0x19 */ {VERYLOW, 1, 0},
63+
/* BYTE = 0x1a */ {VERYLOW, 2, -1},
64+
/* SHL = 0x1b */ {VERYLOW, 2, -1},
65+
/* SHR = 0x1c */ {VERYLOW, 2, -1},
66+
/* SAR = 0x1d */ {VERYLOW, 2, -1},
67+
/* = 0x1e */ {UNDEFINED, 0, 0},
68+
/* = 0x1f */ {UNDEFINED, 0, 0},
69+
/* KECCAK256 = 0x20 */ {30, 2, -1},
70+
/* = 0x21 */ {UNDEFINED, 0, 0},
71+
/* = 0x22 */ {UNDEFINED, 0, 0},
72+
/* = 0x23 */ {UNDEFINED, 0, 0},
73+
/* = 0x24 */ {UNDEFINED, 0, 0},
74+
/* = 0x25 */ {UNDEFINED, 0, 0},
75+
/* = 0x26 */ {UNDEFINED, 0, 0},
76+
/* = 0x27 */ {UNDEFINED, 0, 0},
77+
/* = 0x28 */ {UNDEFINED, 0, 0},
78+
/* = 0x29 */ {UNDEFINED, 0, 0},
79+
/* = 0x2a */ {UNDEFINED, 0, 0},
80+
/* = 0x2b */ {UNDEFINED, 0, 0},
81+
/* = 0x2c */ {UNDEFINED, 0, 0},
82+
/* = 0x2d */ {UNDEFINED, 0, 0},
83+
/* = 0x2e */ {UNDEFINED, 0, 0},
84+
/* = 0x2f */ {UNDEFINED, 0, 0},
85+
/* ADDRESS = 0x30 */ {BASE, 0, 1},
86+
/* BALANCE = 0x31 */ {WARM_STORAGE_READ_COST, 1, 0},
87+
/* ORIGIN = 0x32 */ {BASE, 0, 1},
88+
/* CALLER = 0x33 */ {BASE, 0, 1},
89+
/* CALLVALUE = 0x34 */ {BASE, 0, 1},
90+
/* CALLDATALOAD = 0x35 */ {VERYLOW, 1, 0},
91+
/* CALLDATASIZE = 0x36 */ {BASE, 0, 1},
92+
/* CALLDATACOPY = 0x37 */ {VERYLOW, 3, -3},
93+
/* CODESIZE = 0x38 */ {BASE, 0, 1},
94+
/* CODECOPY = 0x39 */ {VERYLOW, 3, -3},
95+
/* GASPRICE = 0x3a */ {BASE, 0, 1},
96+
/* EXTCODESIZE = 0x3b */ {WARM_STORAGE_READ_COST, 1, 0},
97+
/* EXTCODECOPY = 0x3c */ {WARM_STORAGE_READ_COST, 4, -4},
98+
/* RETURNDATASIZE = 0x3d */ {BASE, 0, 1},
99+
/* RETURNDATACOPY = 0x3e */ {VERYLOW, 3, -3},
100+
/* EXTCODEHASH = 0x3f */ {WARM_STORAGE_READ_COST, 1, 0},
101+
/* BLOCKHASH = 0x40 */ {20, 1, 0},
102+
/* COINBASE = 0x41 */ {BASE, 0, 1},
103+
/* TIMESTAMP = 0x42 */ {BASE, 0, 1},
104+
/* NUMBER = 0x43 */ {BASE, 0, 1},
105+
/* PREVRANDAO = 0x44 */ {BASE, 0, 1},
106+
/* GASLIMIT = 0x45 */ {BASE, 0, 1},
107+
/* CHAINID = 0x46 */ {BASE, 0, 1},
108+
/* SELFBALANCE = 0x47 */ {LOW, 0, 1},
109+
/* BASEFEE = 0x48 */ {BASE, 0, 1},
110+
/* = 0x49 */ {UNDEFINED, 0, 0},
111+
/* = 0x4a */ {UNDEFINED, 0, 0},
112+
/* = 0x4b */ {UNDEFINED, 0, 0},
113+
/* = 0x4c */ {UNDEFINED, 0, 0},
114+
/* = 0x4d */ {UNDEFINED, 0, 0},
115+
/* = 0x4e */ {UNDEFINED, 0, 0},
116+
/* = 0x4f */ {UNDEFINED, 0, 0},
117+
/* POP = 0x50 */ {BASE, 1, -1},
118+
/* MLOAD = 0x51 */ {VERYLOW, 1, 0},
119+
/* MSTORE = 0x52 */ {VERYLOW, 2, -2},
120+
/* MSTORE8 = 0x53 */ {VERYLOW, 2, -2},
121+
/* SLOAD = 0x54 */ {WARM_STORAGE_READ_COST, 1, 0},
122+
/* SSTORE = 0x55 */ {0, 2, -2},
123+
/* JUMP = 0x56 */ {MID, 1, -1},
124+
/* JUMPI = 0x57 */ {HIGH, 2, -2},
125+
/* PC = 0x58 */ {BASE, 0, 1},
126+
/* MSIZE = 0x59 */ {BASE, 0, 1},
127+
/* GAS = 0x5a */ {BASE, 0, 1},
128+
/* JUMPDEST = 0x5b */ {1, 0, 0},
129+
/* = 0x5c */ {UNDEFINED, 0, 0},
130+
/* = 0x5d */ {UNDEFINED, 0, 0},
131+
/* = 0x5e */ {UNDEFINED, 0, 0},
132+
/* PUSH0 = 0x5f */ {BASE, 0, 1},
133+
/* PUSH1 = 0x60 */ {VERYLOW, 0, 1},
134+
/* PUSH2 = 0x61 */ {VERYLOW, 0, 1},
135+
/* PUSH3 = 0x62 */ {VERYLOW, 0, 1},
136+
/* PUSH4 = 0x63 */ {VERYLOW, 0, 1},
137+
/* PUSH5 = 0x64 */ {VERYLOW, 0, 1},
138+
/* PUSH6 = 0x65 */ {VERYLOW, 0, 1},
139+
/* PUSH7 = 0x66 */ {VERYLOW, 0, 1},
140+
/* PUSH8 = 0x67 */ {VERYLOW, 0, 1},
141+
/* PUSH9 = 0x68 */ {VERYLOW, 0, 1},
142+
/* PUSH10 = 0x69 */ {VERYLOW, 0, 1},
143+
/* PUSH11 = 0x6a */ {VERYLOW, 0, 1},
144+
/* PUSH12 = 0x6b */ {VERYLOW, 0, 1},
145+
/* PUSH13 = 0x6c */ {VERYLOW, 0, 1},
146+
/* PUSH14 = 0x6d */ {VERYLOW, 0, 1},
147+
/* PUSH15 = 0x6e */ {VERYLOW, 0, 1},
148+
/* PUSH16 = 0x6f */ {VERYLOW, 0, 1},
149+
/* PUSH17 = 0x70 */ {VERYLOW, 0, 1},
150+
/* PUSH18 = 0x71 */ {VERYLOW, 0, 1},
151+
/* PUSH19 = 0x72 */ {VERYLOW, 0, 1},
152+
/* PUSH20 = 0x73 */ {VERYLOW, 0, 1},
153+
/* PUSH21 = 0x74 */ {VERYLOW, 0, 1},
154+
/* PUSH22 = 0x75 */ {VERYLOW, 0, 1},
155+
/* PUSH23 = 0x76 */ {VERYLOW, 0, 1},
156+
/* PUSH24 = 0x77 */ {VERYLOW, 0, 1},
157+
/* PUSH25 = 0x78 */ {VERYLOW, 0, 1},
158+
/* PUSH26 = 0x79 */ {VERYLOW, 0, 1},
159+
/* PUSH27 = 0x7a */ {VERYLOW, 0, 1},
160+
/* PUSH28 = 0x7b */ {VERYLOW, 0, 1},
161+
/* PUSH29 = 0x7c */ {VERYLOW, 0, 1},
162+
/* PUSH30 = 0x7d */ {VERYLOW, 0, 1},
163+
/* PUSH31 = 0x7e */ {VERYLOW, 0, 1},
164+
/* PUSH32 = 0x7f */ {VERYLOW, 0, 1},
165+
/* DUP1 = 0x80 */ {VERYLOW, 1, 1},
166+
/* DUP2 = 0x81 */ {VERYLOW, 2, 1},
167+
/* DUP3 = 0x82 */ {VERYLOW, 3, 1},
168+
/* DUP4 = 0x83 */ {VERYLOW, 4, 1},
169+
/* DUP5 = 0x84 */ {VERYLOW, 5, 1},
170+
/* DUP6 = 0x85 */ {VERYLOW, 6, 1},
171+
/* DUP7 = 0x86 */ {VERYLOW, 7, 1},
172+
/* DUP8 = 0x87 */ {VERYLOW, 8, 1},
173+
/* DUP9 = 0x88 */ {VERYLOW, 9, 1},
174+
/* DUP10 = 0x89 */ {VERYLOW, 10, 1},
175+
/* DUP11 = 0x8a */ {VERYLOW, 11, 1},
176+
/* DUP12 = 0x8b */ {VERYLOW, 12, 1},
177+
/* DUP13 = 0x8c */ {VERYLOW, 13, 1},
178+
/* DUP14 = 0x8d */ {VERYLOW, 14, 1},
179+
/* DUP15 = 0x8e */ {VERYLOW, 15, 1},
180+
/* DUP16 = 0x8f */ {VERYLOW, 16, 1},
181+
/* SWAP1 = 0x90 */ {VERYLOW, 2, 0},
182+
/* SWAP2 = 0x91 */ {VERYLOW, 3, 0},
183+
/* SWAP3 = 0x92 */ {VERYLOW, 4, 0},
184+
/* SWAP4 = 0x93 */ {VERYLOW, 5, 0},
185+
/* SWAP5 = 0x94 */ {VERYLOW, 6, 0},
186+
/* SWAP6 = 0x95 */ {VERYLOW, 7, 0},
187+
/* SWAP7 = 0x96 */ {VERYLOW, 8, 0},
188+
/* SWAP8 = 0x97 */ {VERYLOW, 9, 0},
189+
/* SWAP9 = 0x98 */ {VERYLOW, 10, 0},
190+
/* SWAP10 = 0x99 */ {VERYLOW, 11, 0},
191+
/* SWAP11 = 0x9a */ {VERYLOW, 12, 0},
192+
/* SWAP12 = 0x9b */ {VERYLOW, 13, 0},
193+
/* SWAP13 = 0x9c */ {VERYLOW, 14, 0},
194+
/* SWAP14 = 0x9d */ {VERYLOW, 15, 0},
195+
/* SWAP15 = 0x9e */ {VERYLOW, 16, 0},
196+
/* SWAP16 = 0x9f */ {VERYLOW, 17, 0},
197+
/* LOG0 = 0xa0 */ {1 * 375, 2, -2},
198+
/* LOG1 = 0xa1 */ {2 * 375, 3, -3},
199+
/* LOG2 = 0xa2 */ {3 * 375, 4, -4},
200+
/* LOG3 = 0xa3 */ {4 * 375, 5, -5},
201+
/* LOG4 = 0xa4 */ {5 * 375, 6, -6},
202+
/* = 0xa5 */ {UNDEFINED, 0, 0},
203+
/* = 0xa6 */ {UNDEFINED, 0, 0},
204+
/* = 0xa7 */ {UNDEFINED, 0, 0},
205+
/* = 0xa8 */ {UNDEFINED, 0, 0},
206+
/* = 0xa9 */ {UNDEFINED, 0, 0},
207+
/* = 0xaa */ {UNDEFINED, 0, 0},
208+
/* = 0xab */ {UNDEFINED, 0, 0},
209+
/* = 0xac */ {UNDEFINED, 0, 0},
210+
/* = 0xad */ {UNDEFINED, 0, 0},
211+
/* = 0xae */ {UNDEFINED, 0, 0},
212+
/* = 0xaf */ {UNDEFINED, 0, 0},
213+
/* = 0xb0 */ {UNDEFINED, 0, 0},
214+
/* = 0xb1 */ {UNDEFINED, 0, 0},
215+
/* = 0xb2 */ {UNDEFINED, 0, 0},
216+
/* = 0xb3 */ {UNDEFINED, 0, 0},
217+
/* = 0xb4 */ {UNDEFINED, 0, 0},
218+
/* = 0xb5 */ {UNDEFINED, 0, 0},
219+
/* = 0xb6 */ {UNDEFINED, 0, 0},
220+
/* = 0xb7 */ {UNDEFINED, 0, 0},
221+
/* = 0xb8 */ {UNDEFINED, 0, 0},
222+
/* = 0xb9 */ {UNDEFINED, 0, 0},
223+
/* = 0xba */ {UNDEFINED, 0, 0},
224+
/* = 0xbb */ {UNDEFINED, 0, 0},
225+
/* = 0xbc */ {UNDEFINED, 0, 0},
226+
/* = 0xbd */ {UNDEFINED, 0, 0},
227+
/* = 0xbe */ {UNDEFINED, 0, 0},
228+
/* = 0xbf */ {UNDEFINED, 0, 0},
229+
/* = 0xc0 */ {UNDEFINED, 0, 0},
230+
/* = 0xc1 */ {UNDEFINED, 0, 0},
231+
/* = 0xc2 */ {UNDEFINED, 0, 0},
232+
/* = 0xc3 */ {UNDEFINED, 0, 0},
233+
/* = 0xc4 */ {UNDEFINED, 0, 0},
234+
/* = 0xc5 */ {UNDEFINED, 0, 0},
235+
/* = 0xc6 */ {UNDEFINED, 0, 0},
236+
/* = 0xc7 */ {UNDEFINED, 0, 0},
237+
/* = 0xc8 */ {UNDEFINED, 0, 0},
238+
/* = 0xc9 */ {UNDEFINED, 0, 0},
239+
/* = 0xca */ {UNDEFINED, 0, 0},
240+
/* = 0xcb */ {UNDEFINED, 0, 0},
241+
/* = 0xcc */ {UNDEFINED, 0, 0},
242+
/* = 0xcd */ {UNDEFINED, 0, 0},
243+
/* = 0xce */ {UNDEFINED, 0, 0},
244+
/* = 0xcf */ {UNDEFINED, 0, 0},
245+
/* = 0xd0 */ {UNDEFINED, 0, 0},
246+
/* = 0xd1 */ {UNDEFINED, 0, 0},
247+
/* = 0xd2 */ {UNDEFINED, 0, 0},
248+
/* = 0xd3 */ {UNDEFINED, 0, 0},
249+
/* = 0xd4 */ {UNDEFINED, 0, 0},
250+
/* = 0xd5 */ {UNDEFINED, 0, 0},
251+
/* = 0xd6 */ {UNDEFINED, 0, 0},
252+
/* = 0xd7 */ {UNDEFINED, 0, 0},
253+
/* = 0xd8 */ {UNDEFINED, 0, 0},
254+
/* = 0xd9 */ {UNDEFINED, 0, 0},
255+
/* = 0xda */ {UNDEFINED, 0, 0},
256+
/* = 0xdb */ {UNDEFINED, 0, 0},
257+
/* = 0xdc */ {UNDEFINED, 0, 0},
258+
/* = 0xdd */ {UNDEFINED, 0, 0},
259+
/* = 0xde */ {UNDEFINED, 0, 0},
260+
/* = 0xdf */ {UNDEFINED, 0, 0},
261+
/* = 0xe0 */ {UNDEFINED, 0, 0},
262+
/* = 0xe1 */ {UNDEFINED, 0, 0},
263+
/* = 0xe2 */ {UNDEFINED, 0, 0},
264+
/* = 0xe3 */ {UNDEFINED, 0, 0},
265+
/* = 0xe4 */ {UNDEFINED, 0, 0},
266+
/* = 0xe5 */ {UNDEFINED, 0, 0},
267+
/* = 0xe6 */ {UNDEFINED, 0, 0},
268+
/* = 0xe7 */ {UNDEFINED, 0, 0},
269+
/* = 0xe8 */ {UNDEFINED, 0, 0},
270+
/* = 0xe9 */ {UNDEFINED, 0, 0},
271+
/* = 0xea */ {UNDEFINED, 0, 0},
272+
/* = 0xeb */ {UNDEFINED, 0, 0},
273+
/* = 0xec */ {UNDEFINED, 0, 0},
274+
/* = 0xed */ {UNDEFINED, 0, 0},
275+
/* = 0xee */ {UNDEFINED, 0, 0},
276+
/* = 0xef */ {UNDEFINED, 0, 0},
277+
/* CREATE = 0xf0 */ {32000, 3, -2},
278+
/* CALL = 0xf1 */ {WARM_STORAGE_READ_COST, 7, -6},
279+
/* CALLCODE = 0xf2 */ {WARM_STORAGE_READ_COST, 7, -6},
280+
/* RETURN = 0xf3 */ {ZERO, 2, -2},
281+
/* DELEGATECALL = 0xf4 */ {WARM_STORAGE_READ_COST, 6, -5},
282+
/* CREATE2 = 0xf5 */ {32000, 4, -3},
283+
/* = 0xf6 */ {UNDEFINED, 0, 0},
284+
/* = 0xf7 */ {UNDEFINED, 0, 0},
285+
/* = 0xf8 */ {UNDEFINED, 0, 0},
286+
/* = 0xf9 */ {UNDEFINED, 0, 0},
287+
/* STATICCALL = 0xfa */ {WARM_STORAGE_READ_COST, 6, -5},
288+
/* = 0xfb */ {UNDEFINED, 0, 0},
289+
/* = 0xfc */ {UNDEFINED, 0, 0},
290+
/* REVERT = 0xfd */ {ZERO, 2, -2},
291+
/* INVALID = 0xfe */ {ZERO, 0, 0},
292+
/* SELFDESTRUCT = 0xff */ {5000, 1, -1},
293+
};
36294

37295
static struct evmc_instruction_metrics cancun_metrics[256] = {
38296
/* STOP = 0x00 */ {ZERO, 0, 0},
@@ -2629,6 +2887,8 @@ const struct evmc_instruction_metrics* evmc_get_instruction_metrics_table(
26292887
{
26302888
switch (revision)
26312889
{
2890+
case EVMC_PRAGUE:
2891+
return prague_metrics;
26322892
case EVMC_CANCUN:
26332893
return cancun_metrics;
26342894
case EVMC_SHANGHAI:

0 commit comments

Comments
 (0)