|
13 | 13 | from ethereum.pruning_trie import Trie
|
14 | 14 | from ethereum.securetrie import SecureTrie
|
15 | 15 | 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, |
17 | 17 | from ethereum import processblock
|
18 | 18 | from ethereum.transactions import Transaction
|
19 | 19 | from ethereum import bloom
|
@@ -453,6 +453,7 @@ def __init__(self, header, transaction_list=[], uncles=[], env=None,
|
453 | 453 | self.transaction_count = 0
|
454 | 454 | self.gas_used = 0
|
455 | 455 | # replay
|
| 456 | + self.initialize(parent) |
456 | 457 | for tx in transaction_list:
|
457 | 458 | success, output = processblock.apply_transaction(self, tx)
|
458 | 459 | self.finalize()
|
@@ -1141,6 +1142,18 @@ def revert(self, mysnapshot):
|
1141 | 1142 | self._get_transactions_cache = []
|
1142 | 1143 | self.ether_delta = mysnapshot['ether_delta']
|
1143 | 1144 |
|
| 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 | + |
1144 | 1157 | def finalize(self):
|
1145 | 1158 | """Apply rewards and commit."""
|
1146 | 1159 | delta = int(self.config['BLOCK_REWARD'] + self.config['NEPHEW_REWARD'] * len(self.uncles))
|
|
0 commit comments