Page MenuHomePhabricator

[electrum] Sign stakes using Trezor devices
DraftPublic

Authored by Fabien on Tue, Jan 21, 14:22.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

TBD

Test Plan

TBD

Diff Detail

Repository
rABC Bitcoin ABC
Branch
electrum_sign_stake_trezor
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32181
Build 63852: Build Diffelectrum-tests
Build 63851: arc lint + arc unit

Event Timeline

Tail of the build log:

======================================================================
FAIL: test_proof_data (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proof_data)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 445, in test_proof_data
    proof = Proof.from_hex(expected_proof1)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

======================================================================
FAIL: test_proofid (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proofid)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 388, in test_proofid
    proof = Proof.from_hex(
            ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

----------------------------------------------------------------------
Ran 334 tests in 30.140s

FAILED (failures=4, errors=4, skipped=4)
Testing `setup.py --version`: OK

ninja: build stopped: cannot make progress due to previous errors.
Build electrum-tests failed with exit code 1

Back out unrelated changes

Tail of the build log:

======================================================================
FAIL: test_proof_data (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proof_data)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 445, in test_proof_data
    proof = Proof.from_hex(expected_proof1)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

======================================================================
FAIL: test_proofid (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proofid)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 388, in test_proofid
    proof = Proof.from_hex(
            ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

----------------------------------------------------------------------
Ran 334 tests in 22.730s

FAILED (failures=4, errors=5, skipped=4)
Testing `setup.py --version`: OK

ninja: build stopped: cannot make progress due to previous errors.
Build electrum-tests failed with exit code 1

Tail of the build log:

======================================================================
FAIL: test_proof_data (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proof_data)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 445, in test_proof_data
    proof = Proof.from_hex(expected_proof1)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

======================================================================
FAIL: test_proofid (electrumabc.tests.test_avalanche.TestAvalancheProofFromHex.test_proofid)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/work/electrum/electrumabc/tests/test_avalanche.py", line 388, in test_proofid
    proof = Proof.from_hex(
            ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 58, in from_hex
    return cls.deserialize(BytesIO(bytes.fromhex(hex_str)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 221, in deserialize
    return Proof(
           ^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 188, in __init__
    self.limitedid = LimitedProofId.build(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 136, in build
    ss += serialize_sequence(stakes)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/serialize.py", line 128, in serialize_sequence
    b += obj.serialize()
         ^^^^^^^^^^^^^^^
  File "/work/electrum/electrumabc/avalanche/proof.py", line 96, in serialize
    assert self.pubkey
AssertionError

----------------------------------------------------------------------
Ran 334 tests in 42.445s

FAILED (failures=4, errors=5, skipped=4)
Testing `setup.py --version`: OK

ninja: build stopped: cannot make progress due to previous errors.
Build electrum-tests failed with exit code 1
PiRK added inline comments.
electrum/electrumabc/avalanche/proof.py
284 ↗(On Diff #52432)

Optional[AbstractWallet]?

electrum/electrumabc/tests/test_avalanche.py
227 ↗(On Diff #52432)

Wrong indentation? I think the test is doing nothing at the moment.

electrum/electrumabc_gui/qt/main_window.py
956–964 ↗(On Diff #52432)

Is this supposed to dynamically enable the menu action when the device is initialized and the firmware version is known? Or just delay the decision until the time the menu is shown the first time, in the hope that at this time the firmware version number is known?

At the moment it can just disable the tools, not enable it if necessary.

electrum/electrumabc_plugins/trezor/clientbase.py
283 ↗(On Diff #52432)

PublicKey.keydata is already used publicly in other places (e.g. DelegationEditor), so the round trip to/from hex is not necessary.