|
14 | 14 | from ethereum.pruning_trie import Trie
|
15 | 15 | from ethereum.securetrie import SecureTrie
|
16 | 16 | 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, |
18 | 18 | from ethereum import processblock
|
19 | 19 | from ethereum.transactions import Transaction
|
20 | 20 | from ethereum import bloom
|
@@ -477,6 +477,7 @@ def __init__(self, header, transaction_list=[], uncles=[], env=None,
|
477 | 477 | self.transaction_count = 0
|
478 | 478 | self.gas_used = 0
|
479 | 479 | # replay
|
| 480 | + self.initialize(parent) |
480 | 481 | for tx in transaction_list:
|
481 | 482 | success, output = processblock.apply_transaction(self, tx)
|
482 | 483 | self.finalize()
|
@@ -1162,6 +1163,18 @@ def revert(self, mysnapshot):
|
1162 | 1163 | self._get_transactions_cache = []
|
1163 | 1164 | self.ether_delta = mysnapshot['ether_delta']
|
1164 | 1165 |
|
| 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 | + |
1165 | 1178 | def finalize(self):
|
1166 | 1179 | """Apply rewards and commit."""
|
1167 | 1180 | delta = int(self.config['BLOCK_REWARD'] + self.config['NEPHEW_REWARD'] * len(self.uncles))
|
|
0 commit comments