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

Commit 9725a73

Browse files
vubvub
authored andcommitted
Fixes to state tests
1 parent 5edb90b commit 9725a73

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

ethereum/state_transition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def rp(what, actual, target):
295295
state.add_to_list('receipts', r)
296296
state.set_param('bloom', state.bloom | r.bloom)
297297
state.set_param('txindex', state.txindex + 1)
298-
return success, output, _logs # FIXME, @vub how should the interface look like?
298+
return success, output
299299

300300

301301
def mk_receipt_sha(receipts):

ethereum/testutils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def run_state_test(params, mode):
295295
assert len(env['currentCoinbase']) == 40
296296

297297
konfig = copy.deepcopy(default_config)
298-
konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000
298+
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000
299299

300300
state = State(env=Env(db, konfig),
301301
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)],
@@ -355,7 +355,8 @@ def run_state_test(params, mode):
355355
snapshot = state.snapshot()
356356
try:
357357
print('trying')
358-
success, output, logs = state_transition.apply_transaction(state, tx)
358+
success, output = state_transition.apply_transaction(state, tx)
359+
logs = state.receipts[-1].logs
359360
assert success
360361
state.commit()
361362
print('success')

ethereum/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
TT256 = 2 ** 256
2626
TT256M1 = 2 ** 256 - 1
2727
TT255 = 2 ** 255
28+
SECP256K1P = 2**256 - 4294968273
2829

2930
if sys.version_info.major == 2:
3031
is_numeric = lambda x: isinstance(x, (int, long))
@@ -72,7 +73,10 @@ def bytearray_to_bytestr(value):
7273

7374
def ecrecover_to_pub(rawhash, v, r, s):
7475
if secp256k1:
76+
# Legendre symbol check; the secp256k1 library does not seem to do this
7577
pk = secp256k1.PublicKey(flags=secp256k1.ALL_FLAGS)
78+
xc = r * r * r + 7
79+
assert pow(xc, (SECP256K1P - 1) / 2, SECP256K1P) == 1
7680
try:
7781
pk.public_key = pk.ecdsa_recover(
7882
rawhash,

0 commit comments

Comments
 (0)