Skip to content
This repository was archived by the owner on Jul 14, 2020. It is now read-only.

Commit 0c1dd60

Browse files
author
Jan Xie
committed
EIP170 code size limit
1 parent b7f77e0 commit 0c1dd60

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

lib/ethereum/constant.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ module Constant
2424
PRIVKEY_ZERO = ("\x00"*32).freeze
2525
PRIVKEY_ZERO_HEX = ('0'*64).freeze
2626

27+
CONTRACT_CODE_SIZE_LIMIT = 0x6000
28+
2729
end
2830
end

lib/ethereum/external_call.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ def create(msg)
114114
if res.true?
115115
return 1, gas, msg.to if dat.empty?
116116

117-
gcost = dat.size * Opcodes::GCONTRACTBYTE
117+
gcost = if post_hardfork?(:spurious_dragon)
118+
dat.size > Constant::CONTRACT_CODE_SIZE_LIMIT ?
119+
Constant::UINT_MAX : dat.size * Opcodes::GCONTRACTBYTE
120+
else
121+
dat.size * Opcodes::GCONTRACTBYTE
122+
end
118123
if gas >= gcost
119124
gas -= gcost
120125
else

0 commit comments

Comments
 (0)