Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix builds, update build containers, update dependencies, and fix ci. #724

Merged
merged 12 commits into from
Mar 29, 2024
Merged
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
exclude = *.pyc,__pycache__,hwilib/devices/ledger_bitcoin/,hwilib/devices/btchip,hwilib/devices/ckcc/,hwilib/devices/jadepy/,hwilib/devices/trezorlib/,test/work/,hwilib/ui,hwilib/devices/bitbox02_lib
ignore = E261,E302,E305,E501,E722,W5
ignore = E261,E302,E305,E501,E722,W5,E231
per-file-ignores = setup.py:E122
6 changes: 3 additions & 3 deletions .github/actions/build-bitcoind/action.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ runs:
sudo apt-get install -y ccache
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"

- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
id: ccache-cache
with:
path: ${{ env.CCACHE_DIR }}
@@ -25,13 +25,13 @@ runs:
ccache --show-stats --verbose
tar -czf bitcoind.tar.gz test/work/bitcoin/src/bitcoind

- uses: actions/cache/save@v3
- uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ github.job }}-ccache-${{ github.run_id }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: bitcoind
path: bitcoind.tar.gz
4 changes: 2 additions & 2 deletions .github/actions/install-sim/action.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ inputs:
runs:
using: composite
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.device == 'ledger-legacy' && 'ledger' || inputs.device }}-sim

@@ -55,7 +55,7 @@ runs:
pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract

- if: inputs.device == 'ledger'
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ledger_app

13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ jobs:
find dist -type f -exec sha256sum {} \;
"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
@@ -173,7 +173,7 @@ jobs:
cd test; ./setup_environment.sh --${{ matrix.device.name }}; cd ..
tar -czf ${{ matrix.device.archive }}.tar.gz ${{ matrix.device.paths }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.device.name }}-sim
path: ${{ matrix.device.archive }}.tar.gz
@@ -188,7 +188,7 @@ jobs:
cd app-bitcoin-new
make DEBUG=1

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ledger_app
path: app-bitcoin-new/bin/app.elf
@@ -240,15 +240,15 @@ jobs:
- run: |
pip install poetry

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- run: |
${{ matrix.script.install }}

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: bitcoind

@@ -272,6 +272,7 @@ jobs:
name: Python ${{ matrix.python-version }} ${{ matrix.device }} ${{ matrix.interface }}
runs-on: ubuntu-latest
needs: [ sim-builder, ledger-app-builder, bitcoind-builder ]
timeout-minutes: 45

strategy:
fail-fast: false
@@ -297,7 +298,7 @@ jobs:
pip install poetry
poetry install

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: bitcoind

4 changes: 2 additions & 2 deletions contrib/build-wine.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:oldoldstable-slim
FROM debian:bookworm-slim

SHELL ["/bin/bash", "-c"]

@@ -15,7 +15,7 @@ RUN apt-get install -y \
RUN dpkg --add-architecture i386
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key
RUN apt-key add winehq.key
RUN echo "deb https://dl.winehq.org/wine-builds/debian/ stretch main" >> /etc/apt/sources.list
RUN echo "deb https://dl.winehq.org/wine-builds/debian/ bookworm main" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install --install-recommends -y \
wine-stable-amd64 \
5 changes: 3 additions & 2 deletions contrib/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:oldoldstable-slim
FROM debian:bookworm-slim

SHELL ["/bin/bash", "-c"]

@@ -27,7 +27,8 @@ RUN apt-get install -y \
libudev-dev \
faketime \
zip \
qt5-default
pyqt5-dev \
libglib2.0-0

RUN curl https://pyenv.run | bash
ENV PYENV_ROOT="/root/.pyenv"
2 changes: 1 addition & 1 deletion contrib/build_bin.sh
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ target_dir="$target_tarfile.dir"
mkdir $target_dir
mv hwi $target_dir

if [[ $gui_support == "--with-gui" && $arch == "x86_64" ]]; then
if [[ $gui_support == "--with-gui" && $ARCH == "x86_64" ]]; then
mv hwi-qt $target_dir
fi

1 change: 1 addition & 0 deletions hwilib/devices/keepkey.py
Original file line number Diff line number Diff line change
@@ -149,6 +149,7 @@ def __init__(self, path: str, password: Optional[str] = None, expert: bool = Fal
"""
model = TrezorModel(
name="K1-14M",
internal_name="keepkey",
minimum_version=(0, 0, 0),
vendors=("keepkey.com"),
usb_ids=(), # unused
2 changes: 1 addition & 1 deletion hwilib/devices/ledger.py
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ def check_keypath(key_path: str) -> bool:
AddressType.LEGACY: 3,
}

def handle_chip_exception(e, func_name: str) -> bool:
def handle_chip_exception(e: Union[BTChipException, ApduException], func_name: str) -> bool:
if e.sw in bad_args:
raise BadArgumentError('Bad argument')
elif e.sw == 0x6F00: # BTCHIP_SW_TECHNICAL_PROBLEM
2 changes: 1 addition & 1 deletion hwilib/devices/trezor.py
Original file line number Diff line number Diff line change
@@ -612,7 +612,7 @@ def ignore_input() -> None:
script_pubkey=vout.scriptPubKey,
)
t.bin_outputs.append(o)
assert(psbt_in.non_witness_utxo.hash is not None)
assert psbt_in.non_witness_utxo.hash is not None
logging.debug(psbt_in.non_witness_utxo.hash.hex())
assert psbt_in.non_witness_utxo.sha256 is not None
prevtxs[ser_uint256(psbt_in.non_witness_utxo.sha256)[::-1]] = t
918 changes: 461 additions & 457 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/data/speculos-automation.json
Original file line number Diff line number Diff line change
@@ -25,6 +25,14 @@
[ "setbool", "seen_msg_hash", true ]
]
},
{
"regexp": "^Message content.*",
"actions": [
[ "button", 2, true ],
[ "button", 2, false ],
[ "setbool", "seen_msg_hash", true ]
]
},
{
"text": "message",
"conditions": [
1 change: 1 addition & 0 deletions test/setup_environment.sh
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ if [[ -n ${build_trezor_1} || -n ${build_trezor_t} ]]; then
rustup toolchain uninstall nightly
rustup toolchain install nightly
rustup default nightly
rustup component add rustfmt
# Build trezor t emulator. This is pretty fast, so rebuilding every time is ok
# But there should be some caching that makes this faster
poetry install
4 changes: 2 additions & 2 deletions test/test_device.py
Original file line number Diff line number Diff line change
@@ -619,7 +619,7 @@ def test_display_address_path(self):

def test_display_address_bad_path(self):
result = self.do_command(self.dev_args + ['displayaddress', '--path', 'f'])
self.assertEquals(result['code'], -7)
self.assertEqual(result['code'], -7)

def test_display_address_descriptor(self):
account_xpub = self.do_command(self.dev_args + ['getxpub', 'm/84h/1h/0h'])['xpub']
@@ -743,4 +743,4 @@ def test_sign_msg(self):

def test_bad_path(self):
result = self.do_command(self.dev_args + ['signmessage', "Message signing test", 'f'])
self.assertEquals(result['code'], -7)
self.assertEqual(result['code'], -7)
24 changes: 12 additions & 12 deletions test/test_digitalbitbox.py
Original file line number Diff line number Diff line change
@@ -110,20 +110,20 @@ def test_display(self):
def test_setup_wipe(self):
# Device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup', '--label', 'setup_test', '--backup_passphrase', 'testpass'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

# Wipe
result = self.do_command(self.dev_args + ['wipe'])
self.assertTrue(result['success'])

# Check arguments
result = self.do_command(self.dev_args + ['-i', 'setup', '--label', 'setup_test'])
self.assertEquals(result['code'], -7)
self.assertEquals(result['error'], 'The label and backup passphrase for a new Digital Bitbox wallet must be specified and cannot be empty')
self.assertEqual(result['code'], -7)
self.assertEqual(result['error'], 'The label and backup passphrase for a new Digital Bitbox wallet must be specified and cannot be empty')
result = self.do_command(self.dev_args + ['-i', 'setup', '--backup_passphrase', 'testpass'])
self.assertEquals(result['code'], -7)
self.assertEquals(result['error'], 'The label and backup passphrase for a new Digital Bitbox wallet must be specified and cannot be empty')
self.assertEqual(result['code'], -7)
self.assertEqual(result['error'], 'The label and backup passphrase for a new Digital Bitbox wallet must be specified and cannot be empty')

# Setup
result = self.do_command(self.dev_args + ['-i', 'setup', '--label', 'setup_test', '--backup_passphrase', 'testpass'])
@@ -137,17 +137,17 @@ def test_setup_wipe(self):

# Make sure device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup', '--label', 'setup_test', '--backup_passphrase', 'testpass'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

def test_backup(self):
# Check arguments
result = self.do_command(self.dev_args + ['backup', '--label', 'backup_test'])
self.assertEquals(result['code'], -7)
self.assertEquals(result['error'], 'The label and backup passphrase for a Digital Bitbox backup must be specified and cannot be empty')
self.assertEqual(result['code'], -7)
self.assertEqual(result['error'], 'The label and backup passphrase for a Digital Bitbox backup must be specified and cannot be empty')
result = self.do_command(self.dev_args + ['backup', '--backup_passphrase', 'key'])
self.assertEquals(result['code'], -7)
self.assertEquals(result['error'], 'The label and backup passphrase for a Digital Bitbox backup must be specified and cannot be empty')
self.assertEqual(result['code'], -7)
self.assertEqual(result['error'], 'The label and backup passphrase for a Digital Bitbox backup must be specified and cannot be empty')

# Wipe
result = self.do_command(self.dev_args + ['wipe'])
13 changes: 7 additions & 6 deletions test/test_keepkey.py
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ def start(self):
# Setup the emulator
model = TrezorModel(
name="K1-14M",
internal_name="keepkey_emu",
minimum_version=(0, 0, 0),
vendors=("keepkey.com"),
usb_ids=(), # unused
@@ -208,8 +209,8 @@ def setUp(self):
def test_setup_wipe(self):
# Device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

# Wipe
result = self.do_command(self.dev_args + ['wipe'])
@@ -224,8 +225,8 @@ def test_setup_wipe(self):

# Make sure device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

def test_label(self):
result = self.do_command(self.dev_args + ['wipe'])
@@ -371,7 +372,7 @@ def test_passphrase(self):
for dev in result:
if dev['type'] == 'keepkey' and dev['path'] == 'udp:127.0.0.1:11044':
self.assertFalse(dev['needs_passphrase_sent'])
self.assertEquals(dev['fingerprint'], '95d8f670')
self.assertEqual(dev['fingerprint'], '95d8f670')
break
else:
self.fail("Did not enumerate device")
@@ -380,7 +381,7 @@ def test_passphrase(self):
for dev in result:
if dev['type'] == 'keepkey' and dev['path'] == 'udp:127.0.0.1:11044':
self.assertFalse(dev['needs_passphrase_sent'])
self.assertEquals(dev['fingerprint'], '95d8f670')
self.assertEqual(dev['fingerprint'], '95d8f670')
break
else:
self.fail("Did not enumerate device")
12 changes: 6 additions & 6 deletions test/test_trezor.py
Original file line number Diff line number Diff line change
@@ -217,8 +217,8 @@ def setUp(self):
def test_setup_wipe(self):
# Device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

# Wipe
result = self.do_command(self.dev_args + ['wipe'])
@@ -233,8 +233,8 @@ def test_setup_wipe(self):

# Make sure device is init, setup should fail
result = self.do_command(self.dev_args + ['-i', 'setup'])
self.assertEquals(result['code'], -10)
self.assertEquals(result['error'], 'Device is already initialized. Use wipe first and try again')
self.assertEqual(result['code'], -10)
self.assertEqual(result['error'], 'Device is already initialized. Use wipe first and try again')

def test_label(self):
result = self.do_command(self.dev_args + ['wipe'])
@@ -401,7 +401,7 @@ def test_passphrase(self):
for dev in result:
if dev['type'] == 'trezor' and dev['path'] == 'udp:127.0.0.1:21324':
self.assertFalse(dev['needs_passphrase_sent'])
self.assertEquals(dev['fingerprint'], '95d8f670')
self.assertEqual(dev['fingerprint'], '95d8f670')
break
else:
self.fail("Did not enumerate device")
@@ -410,7 +410,7 @@ def test_passphrase(self):
for dev in result:
if dev['type'] == 'trezor' and dev['path'] == 'udp:127.0.0.1:21324':
self.assertFalse(dev['needs_passphrase_sent'])
self.assertEquals(dev['fingerprint'], '95d8f670')
self.assertEqual(dev['fingerprint'], '95d8f670')
break
else:
self.fail("Did not enumerate device")