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

Commit a01ab93

Browse files
vubkonradkonrad
authored andcommitted
Add metropolis config
Cherry-pick 9024224 (was EIP90) Conflicts: ethereum/config.py
1 parent 1d2a0cb commit a01ab93

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ethereum/blocks.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ethereum.pruning_trie import Trie
1515
from ethereum.securetrie import SecureTrie
1616
from ethereum import utils
17-
from ethereum.utils import address, int256, trie_root, hash32, to_string
17+
from ethereum.utils import address, int256, trie_root, hash32, to_string,
1818
from ethereum import processblock
1919
from ethereum.transactions import Transaction
2020
from ethereum import bloom
@@ -477,6 +477,7 @@ def __init__(self, header, transaction_list=[], uncles=[], env=None,
477477
self.transaction_count = 0
478478
self.gas_used = 0
479479
# replay
480+
self.initialize(parent)
480481
for tx in transaction_list:
481482
success, output = processblock.apply_transaction(self, tx)
482483
self.finalize()
@@ -1162,6 +1163,18 @@ def revert(self, mysnapshot):
11621163
self._get_transactions_cache = []
11631164
self.ether_delta = mysnapshot['ether_delta']
11641165

1166+
def initialize(self, parent):
1167+
if self.number == self.config["METROPOLIS_FORK_BLKNUM"]:
1168+
self.set_code(utils.normalize_address(self.config["METROPOLIS_STATEROOT_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
1169+
self.set_code(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
1170+
if self.number >= self.config["METROPOLIS_FORK_BLKNUM"]:
1171+
self.set_storage_data(utils.normalize_address(self.config["METROPOLIS_STATEROOT_STORE"]),
1172+
self.number % self.config["METROPOLIS_WRAPAROUND"],
1173+
parent.state_root)
1174+
self.set_storage_data(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]),
1175+
self.number % self.config["METROPOLIS_WRAPAROUND"],
1176+
self.prevhash)
1177+
11651178
def finalize(self):
11661179
"""Apply rewards and commit."""
11671180
delta = int(self.config['BLOCK_REWARD'] + self.config['NEPHEW_REWARD'] * len(self.uncles))

ethereum/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
# Homestead fork
4747
HOMESTEAD_FORK_BLKNUM=1150000,
4848
HOMESTEAD_DIFF_ADJUSTMENT_CUTOFF=10,
49+
# Metropolis fork
50+
METROPOLIS_FORK_BLKNUM=9999999,
51+
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'),
4956
)
5057
assert default_config['NEPHEW_REWARD'] == \
5158
default_config['BLOCK_REWARD'] // 32

0 commit comments

Comments
 (0)