Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit c2666d9

Browse files
committed
Add EIP150 opcodes #413
1 parent 0948bb6 commit c2666d9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ethereum/opcodes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,12 @@
111111

112112
GCALLNEWACCOUNT = 25000
113113
GSUICIDEREFUND = 24000
114+
115+
# Anti-DoS HF changes
116+
SLOAD_SUPPLEMENTAL_GAS = 150
117+
CALL_SUPPLEMENTAL_GAS = 660
118+
EXTCODELOAD_SUPPLEMENTAL_GAS = 680
119+
BALANCE_SUPPLEMENTAL_GAS = 380
120+
CALL_CHILD_LIMIT_NUM = 63
121+
CALL_CHILD_LIMIT_DENOM = 64
122+
SUICIDE_SUPPLEMENTAL_GAS = 5000

ethereum/tests/test_opcodes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from ethereum import opcodes
2+
3+
opcode_gas = {
4+
opcode: gas for (opcode, ins, outs, gas) in opcodes.opcodes.values()
5+
}
6+
7+
8+
def test_eip150_opcode_gascost():
9+
"""Ensure gas prices specified in
10+
https://github.com/ethereum/eips/issues/150
11+
"""
12+
assert opcode_gas['EXTCODESIZE'] + opcodes.EXTCODELOAD_SUPPLEMENTAL_GAS == 700
13+
assert opcode_gas['EXTCODECOPY'] + opcodes.EXTCODELOAD_SUPPLEMENTAL_GAS == 700
14+
assert opcode_gas['BALANCE'] + opcodes.BALANCE_SUPPLEMENTAL_GAS == 400
15+
assert opcode_gas['SLOAD'] + opcodes.SLOAD_SUPPLEMENTAL_GAS == 200
16+
17+
assert opcode_gas['CALL'] + opcodes.CALL_SUPPLEMENTAL_GAS == 700
18+
assert opcode_gas['DELEGATECALL'] + opcodes.CALL_SUPPLEMENTAL_GAS == 700
19+
assert opcode_gas['CALLCODE'] + opcodes.CALL_SUPPLEMENTAL_GAS == 700
20+
21+
assert opcode_gas['SUICIDE'] + opcodes.SUICIDE_SUPPLEMENTAL_GAS == 5000

0 commit comments

Comments
 (0)