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

Commit 9024224

Browse files
vubvub
authored andcommitted
EIP 90
1 parent 4cb12fc commit 9024224

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ethereum/blocks.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ethereum.pruning_trie import Trie
1414
from ethereum.securetrie import SecureTrie
1515
from ethereum import utils
16-
from ethereum.utils import address, int256, trie_root, hash32, to_string
16+
from ethereum.utils import address, int256, trie_root, hash32, to_string,
1717
from ethereum import processblock
1818
from ethereum.transactions import Transaction
1919
from ethereum import bloom
@@ -453,6 +453,7 @@ def __init__(self, header, transaction_list=[], uncles=[], env=None,
453453
self.transaction_count = 0
454454
self.gas_used = 0
455455
# replay
456+
self.initialize(parent)
456457
for tx in transaction_list:
457458
success, output = processblock.apply_transaction(self, tx)
458459
self.finalize()
@@ -1141,6 +1142,18 @@ def revert(self, mysnapshot):
11411142
self._get_transactions_cache = []
11421143
self.ether_delta = mysnapshot['ether_delta']
11431144

1145+
def initialize(self, parent):
1146+
if self.number == self.config["METROPOLIS_FORK_BLKNUM"]:
1147+
self.set_code(utils.normalize_address(self.config["METROPOLIS_STATEROOT_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
1148+
self.set_code(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
1149+
if self.number >= self.config["METROPOLIS_FORK_BLKNUM"]:
1150+
self.set_storage_data(utils.normalize_address(self.config["METROPOLIS_STATEROOT_STORE"]),
1151+
self.number % self.config["METROPOLIS_WRAPAROUND"],
1152+
parent.state_root)
1153+
self.set_storage_data(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]),
1154+
self.number % self.config["METROPOLIS_WRAPAROUND"],
1155+
self.prevhash)
1156+
11441157
def finalize(self):
11451158
"""Apply rewards and commit."""
11461159
delta = int(self.config['BLOCK_REWARD'] + self.config['NEPHEW_REWARD'] * len(self.uncles))

ethereum/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
# Metropolis fork
5050
METROPOLIS_FORK_BLKNUM=9999999,
5151
METROPOLIS_ENTRY_POINT=2**160 - 1,
52+
METROPOLIS_STATEROOT_STORE=0x10,
53+
METROPOLIS_BLOCKHASH_STORE=0x20,
54+
METROPOLIS_WRAPAROUND=65536,
55+
METROPOLIS_GETTER_CODE='6000355460205260206020f3'.decode('hex'),
5256
)
5357
assert default_config['NEPHEW_REWARD'] == \
5458
default_config['BLOCK_REWARD'] // 32

0 commit comments

Comments
 (0)