Removed the serpent dependency

This commit is contained in:
vub 2017-03-26 03:18:45 -04:00
parent eb049462e8
commit e790aaf02f
2 changed files with 12 additions and 6 deletions

View File

@ -105,7 +105,7 @@ def __init__():
# Initialize the epoch counter
self.current_epoch = block.number / self.epoch_length
# Set the sighash calculator address
self.sighasher = 0x38920146f10f3956fc09970beededcb2d9638712
self.sighasher = 0x476c2ca9a7f3b16feca86512276271faf63b6a24
# Set an initial root of the epoch hash chain
self.consensus_messages[0].ancestry_hash_justified[0x0000000000000000000000000000000000000000000000000000000000000000] = True
# Set initial total deposit counter

View File

@ -18,17 +18,22 @@ assert s.state.get_code('0x0b8178879f97f2ada01fb8d219ee3d0ad74e91e0')
# Install sig hasher
sighasher = s.contract(open('sighash.se.py').read(), language='serpent')
s.state.set_balance('0x6e7406512b244843c1171840dfcd3d7532d979fe', 7291200000000000)
state_transition.apply_transaction(s.state, rlp.decode(utils.decode_hex('f902b9808506fc23ac008303b5608080b902a66102948061000e6000396102a2567f01000000000000000000000000000000000000000000000000000000000000006000350460205260c0602051121561003857fe6100a7565b60f8602051121561005657600160405260c0602051036060526100a6565b60f76020510360010160405260007f010000000000000000000000000000000000000000000000000000000000000060013504141561009157fe5b60f7602051036020036101000a600135046060525b5b36606051604051011415156100b857fe5b604051608052600060a0525b3660405112156101c0577f0100000000000000000000000000000000000000000000000000000000000000604051350460c052608060c05112156101165760405160a0526001604051016040526101bb565b60b860c051121561014257608060c0510360605260405160a052600160605101604051016040526101ba565b60c060c05112156101b75760007f01000000000000000000000000000000000000000000000000000000000000006001604051013504141561018057fe5b60b760c051036020036101000a600160405101350460605260405160a052600160b760c051036060510101604051016040526101b9565bfe5b5b5b6100c4565b60805160a0510360e0526103e861010052603860e051121561020f5760e05160c001610100515360e051608051600161010051013760e0516001016101005120610120526020610120f3610293565b60006101405260e051610160525b610160511561024257600161014051016101405261010061016051046101605261021d565b6101405160f7016101005153610140516020036101000a60e05102600161010051015260e0516080516101405160016101005101013760e05161014051600101016101005120610180526020610180f35b5b6000f31b2d4f'), transactions.Transaction))
assert s.state.get_code('0x476c2ca9a7f3b16feca86512276271faf63b6a24')
casper_code = open('simple_casper.v.py').read().replace('0x1db3439a222c519ab44bb1144fc28167b4fa6ee6', '0x'+utils.encode_hex(t.a0)) \
.replace('0x38920146f10f3956fc09970beededcb2d9638712', '0x'+utils.encode_hex(sighasher))
# Install Casper
casper_code = open('simple_casper.v.py').read().replace('0x1db3439a222c519ab44bb1144fc28167b4fa6ee6', '0x'+utils.encode_hex(t.a0))
print('Casper code length', len(compiler.compile(casper_code)))
casper = s.abi_contract(casper_code, language='viper', startgas=5555555)
print('Gas consumed', s.state.receipts[-1].gas_used - s.state.receipts[-2].gas_used)
print('Gas consumed to launch Casper', s.state.receipts[-1].gas_used - s.state.receipts[-2].gas_used)
# Helper functions for making a prepare, commit, login and logout message
def mk_prepare(epoch, hash, ancestry_hash, source_epoch, source_ancestry_hash, key):
sighash = utils.sha3(rlp.encode([epoch, hash, ancestry_hash, source_epoch, source_ancestry_hash]))
@ -48,9 +53,10 @@ def mk_status_flicker(epoch, login, key):
sig = utils.encode_int32(v) + utils.encode_int32(r) + utils.encode_int32(s)
return rlp.encode([epoch, login, sig])
s.state.block_number = EPOCH_LENGTH
# Begin the test
# Initialize the first epoch
s.state.block_number = EPOCH_LENGTH
casper.initialize_epoch(1)
assert casper.get_nextValidatorIndex() == 1
start = s.snapshot()