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

Commit 53ad8d6

Browse files
committed
Merge PR #397
This is a manual merge of #397.
1 parent 941f8f0 commit 53ad8d6

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

ethereum/blocks.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,14 +1171,6 @@ def revert(self, mysnapshot):
11711171
self.ether_delta = mysnapshot['ether_delta']
11721172

11731173
def initialize(self, parent):
1174-
# DAO fork
1175-
if self.number == self.config["DAO_FORK_BLKNUM"]:
1176-
dao_main_addr = utils.normalize_address(self.config["DAO_MAIN_ADDR"])
1177-
for acct in map(utils.normalize_address, self.config["DAO_ADDRESS_LIST"]):
1178-
self.delta_balance(dao_main_addr, self.get_balance(acct))
1179-
self.set_balance(acct, 0)
1180-
self.set_code(dao_main_addr, self.config["DAO_NEWCODE"])
1181-
# Likely metropolis changes
11821174
if self.number == self.config["METROPOLIS_FORK_BLKNUM"]:
11831175
self.set_code(utils.normalize_address(self.config["METROPOLIS_STATEROOT_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
11841176
self.set_code(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]), self.config["METROPOLIS_GETTER_CODE"])
@@ -1189,6 +1181,9 @@ def initialize(self, parent):
11891181
self.set_storage_data(utils.normalize_address(self.config["METROPOLIS_BLOCKHASH_STORE"]),
11901182
self.number % self.config["METROPOLIS_WRAPAROUND"],
11911183
self.prevhash)
1184+
if self.number == self.config['DAO_FORK_BLKNUM']:
1185+
for acct in self.config['CHILD_DAO_LIST']:
1186+
self.transfer_value(acct, self.config['DAO_WITHDRAWER'], self.get_balance(acct))
11921187

11931188
def finalize(self):
11941189
"""Apply rewards and commit."""

ethereum/child_dao_list.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from ethereum.utils import mk_contract_address, encode_hex
2+
source = '0x4a574510c7014e4ae985403536074abe582adfc8'
3+
4+
L = []
5+
# DAO
6+
L.append('0xbb9bc244d798123fde783fcc1c72d3bb8c189413')
7+
# DAO extrabalance
8+
L.append('0x807640a13483f8ac783c557fcdf27be11ea4ac7a')
9+
# child DAOs (created by DAO creator)
10+
L.extend([b'0x' + encode_hex(mk_contract_address(source, i)) for i in range(1, 58)])
11+
# child extrabalances
12+
L.extend([b'0x' + encode_hex(mk_contract_address(mk_contract_address(source, i), 0)) for i in range(1, 58)])

ethereum/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from ethereum import utils
44
from ethereum.db import BaseDB
5+
from ethereum.child_dao_list import L as child_dao_list
6+
57

68
default_config = dict(
79
# Genesis block difficulty
@@ -57,10 +59,9 @@
5759
METROPOLIS_GETTER_CODE=decode_hex('6000355460205260206020f3'),
5860
METROPOLIS_DIFF_ADJUSTMENT_CUTOFF=9,
5961
# DAO fork
60-
DAO_FORK_BLKNUM = 9999998,
61-
DAO_ADDRESS_LIST = [],
62-
DAO_MAIN_ADDR = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413',
63-
DAO_NEWCODE = ''
62+
DAO_FORK_BLKNUM=1920000,
63+
CHILD_DAO_LIST=map(utils.normalize_address, child_dao_list),
64+
DAO_WITHDRAWER=utils.normalize_address('0xbf4ed7b27f1d666546e30d74d50d173d20bca754'),
6465
)
6566
assert default_config['NEPHEW_REWARD'] == \
6667
default_config['BLOCK_REWARD'] // 32

ethereum/tests/test_blocks.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import pytest
2-
31
from ethereum import blocks, utils, db
42
from ethereum.exceptions import VerificationFailed, InvalidTransaction
53
import rlp
64
from rlp.utils import decode_hex, encode_hex, str_to_bytes
75
from rlp import DecodingError, DeserializationError
8-
import os
96
import sys
107
import ethereum.testutils as testutils
118
import copy
@@ -44,7 +41,7 @@ def valueconv(k, v):
4441
return v
4542

4643

47-
def run_block_test(params, config_overrides = {}):
44+
def run_block_test(params, config_overrides={}):
4845
b = blocks.genesis(env, start_alloc=params["pre"])
4946
gbh = params["genesisBlockHeader"]
5047
b.bloom = utils.scanners['int256b'](gbh["bloom"])
@@ -109,7 +106,10 @@ def run_block_test(params, config_overrides = {}):
109106

110107

111108
def test_block(filename, testname, testdata):
112-
run_block_test(testdata, {'HOMESTEAD_FORK_BLKNUM':0 if 'Homestead' in filename else 5 if 'TestNetwork' in filename else 1000000 })
109+
run_block_test(testdata, {
110+
'HOMESTEAD_FORK_BLKNUM': 0 if 'Homestead' in filename else 5 if 'TestNetwork' in filename else 1000000,
111+
'DAO_FORK_BLKNUM': 8 if 'bcTheDaoTest' in filename else 1920000
112+
})
113113

114114

115115
excludes = {
@@ -137,14 +137,16 @@ def main():
137137
print("Testing: %s %s" % (filename, testname))
138138
run_block_test(testdata, {
139139
'HOMESTEAD_FORK_BLKNUM': 0 if 'Homestead' in filename else 5 if 'TestNetwork' in filename
140-
else 1000000})
140+
else 1000000,
141+
'DAO_FORK_BLKNUM': 8 if 'bcTheDaoTest' in filename else 1920000})
141142
else:
142143
for filename, tests in list(fixtures.items()):
143144
for testname, testdata in list(tests.items()):
144145
if (filename.split('/')[-1], testname) not in excludes:
145146
print("Testing: %s %s" % (filename, testname))
146147
run_block_test(testdata, {
147-
'HOMESTEAD_FORK_BLKNUM': 0 if 'Homestead' in filename else 5 if 'TestNetwork' in filename else 1000000})
148+
'HOMESTEAD_FORK_BLKNUM': 0 if 'Homestead' in filename else 5 if 'TestNetwork' in filename else 1000000,
149+
'DAO_FORK_BLKNUM': 8 if 'bcTheDaoTest' in filename else 1920000})
148150

149151

150152
if __name__ == '__main__':

0 commit comments

Comments
 (0)