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

Commit 7ae7622

Browse files
vubvub
authored andcommitted
Added more EIP86 compatibility
1 parent 6d95df5 commit 7ae7622

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

ethereum/new_statetest_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,19 @@ def compute_state_test_unit(state, txdata, indices, konfig):
101101
to=decode_hex(remove_0x_head(txdata['to'])),
102102
value=parse_int_or_hex(txdata['value'][indices["value"]] or b"0"),
103103
data=decode_hex(remove_0x_head(txdata['data'][indices["data"]])))
104-
tx.sign(decode_hex(remove_0x_head(txdata['secretKey'])))
104+
if 'secretKey' in txdata:
105+
tx.sign(decode_hex(remove_0x_head(txdata['secretKey'])))
106+
else:
107+
tx.v = parse_int_or_hex(txdata['v'])
105108
# Run it
106109
prev = state.to_dict()
107110
success, output = state_transition.apply_transaction(state, tx)
108-
post = state.to_dict()
109111
print("Applied tx")
110112
except InvalidTransaction as e:
111113
print("Exception: %r" % e)
112-
post = state.to_dict()
113114
success, output = False, b''
114115
state.commit()
116+
post = state.to_dict()
115117
output_decl = {
116118
"hash": '0x' + encode_hex(state.trie.root_hash),
117119
"indexes": indices,
@@ -167,7 +169,7 @@ def verify_state_test(test):
167169
parse_int_or_hex(test["transaction"]['value'][result["indexes"]["value"]]),
168170
data))
169171
computed = compute_state_test_unit(_state, test["transaction"], result["indexes"], configs[config_name])
170-
if computed["hash"] != result["hash"]:
172+
if computed["hash"][-64:] != result["hash"][-64:]:
171173
for k in computed["diff"]:
172174
print(k, computed["diff"][k])
173175
raise Exception("Hash mismatch, computed: %s, supplied: %s" % (computed["hash"], result["hash"]))

ethereum/processblock.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
# contract creating transactions send to an empty address
3131
CREATE_CONTRACT_ADDRESS = b''
3232

33+
null_address = b'\xff' * 20
34+
3335

3436
class Log(rlp.Serializable):
3537

@@ -120,10 +122,11 @@ def create_contract(ext, msg):
120122
code = msg.data.extract_all()
121123
if ext.tx_origin != msg.sender:
122124
ext.increment_nonce(msg.sender)
123-
nonce = utils.encode_int(ext.get_nonce(msg.sender) - 1)
124-
if ext.post_metropolis_hardfork() and msg.sender == ext.tx_origin and False:
125-
msg.to = sha3(msg.sender + code)[12:]
125+
if ext.post_metropolis_hardfork() and msg.sender == null_address:
126+
msg.to = mk_contract_address(sender, 0)
127+
# msg.to = sha3(msg.sender + code)[12:]
126128
else:
129+
nonce = utils.encode_int(ext.get_nonce(msg.sender) - 1)
127130
msg.to = mk_contract_address(sender, nonce)
128131
b = ext.get_balance(msg.to)
129132
if b > 0:
@@ -159,4 +162,4 @@ def create_contract(ext, msg):
159162
return 1, gas, msg.to
160163
else:
161164
ext.revert(snapshot)
162-
return 0, gas, b''
165+
return 0, gas, dat

ethereum/state_transition.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,13 @@ def rp(what, actual, target):
242242
txdict["data"] = "data<%d>" % (len(txdict["data"]) // 2 - 1)
243243
log_tx.debug('TX NEW', tx_dict=txdict)
244244
# start transacting #################
245-
state.increment_nonce(tx.sender)
245+
if tx.sender != null_address:
246+
state.increment_nonce(tx.sender)
247+
else:
248+
if tx.gasprice != 0 or tx.value != 0 or tx.nonce != 0:
249+
raise InvalidTransaction("EIP86 transactions must have 0 gasprice and value")
250+
if tx.v != state.config['NETWORK_ID']:
251+
raise InvalidTransaction("Wrong network ID for EIP86 transaction")
246252

247253
# buy startgas
248254
assert state.get_balance(tx.sender) >= tx.startgas * tx.gasprice

0 commit comments

Comments
 (0)