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

[draft] THP #4050

Draft
wants to merge 84 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
9cd96a4
test(core): update tests to reflect cache refactor
M1nd3r Nov 15, 2024
76de534
style: fix article
M1nd3r Nov 15, 2024
38a152a
refactor(core): abstract cache and context
M1nd3r Nov 15, 2024
ace14f5
chore(core): update core to reflect cache and context refactor
M1nd3r Nov 15, 2024
5d47f48
fixup! refactor(core): abstract cache and context [no changelog]
M1nd3r Nov 18, 2024
e071e99
fixup! chore(core): update core to reflect cache and context refactor…
M1nd3r Nov 18, 2024
c241d39
fixup! fixup! chore(core): update core to reflect cache and context r…
M1nd3r Nov 18, 2024
933c568
fixup! test(core): update tests to reflect cache refactor [no changelog]
M1nd3r Nov 19, 2024
63c61b4
test(core): add setUpClass and tearDownClass to core unit tests
M1nd3r Nov 19, 2024
98cdc4e
test(core): replace __init__ in unit tests with setUpClass and tearDo…
M1nd3r Nov 19, 2024
93457e8
fixup! test(core): add setUpClass and tearDownClass to core unit test…
M1nd3r Nov 19, 2024
a446f51
feat: implement THP
M1nd3r Nov 15, 2024
b58c37c
test: try fix screen_recording
M1nd3r Nov 19, 2024
8699f1f
temporary disabling of appdirs variables
M1nd3r Nov 18, 2024
c1961ad
fixup! temporary disabling of appdirs variables
M1nd3r Nov 18, 2024
70bbe55
fix: try fix ci tests
M1nd3r Nov 18, 2024
97d708a
fix: fix protobuf trailing whitespaces
M1nd3r Nov 19, 2024
9d8742a
fix: remove trailing whitespaces sconscripts
M1nd3r Nov 19, 2024
c1a3a13
fixup: fix unit tests
M1nd3r Nov 19, 2024
a9aa823
fixup base.py style
M1nd3r Nov 19, 2024
6655ad9
refactor(python): rename NewTrezorConnection to TrezorConnection
M1nd3r Nov 19, 2024
b0ee4ba
fix(python): fix list devices session resumption
M1nd3r Nov 19, 2024
92e307f
feat(python): delete `channel_data.json` when clearing all channels
M1nd3r Nov 19, 2024
495ff68
chore(core): fix core Makefile style'
M1nd3r Nov 19, 2024
a0173c0
feat(python): rework channel database
M1nd3r Nov 19, 2024
8d0d66d
fixup! feat(python): rework channel database [no changelog]
M1nd3r Nov 19, 2024
6488ce1
chore(legacy): add options (max_size) to updated debug messages
M1nd3r Nov 20, 2024
b34de73
fix: try to fix emu.py
M1nd3r Nov 20, 2024
131c611
fix: try fix fido2-test
M1nd3r Nov 21, 2024
08c0c94
fix(python): protocol_v2 database init
M1nd3r Nov 22, 2024
7415c96
wip
M1nd3r Nov 22, 2024
c15a1b5
wip fix cardano part 1
M1nd3r Nov 22, 2024
0074b62
wip fix cardano part 2
M1nd3r Nov 22, 2024
ac8d853
wip fix cardano part 3
M1nd3r Nov 22, 2024
f1fd4e8
fix cardano final part
M1nd3r Nov 22, 2024
497de15
fix misc
M1nd3r Nov 22, 2024
9e6a9c3
wip
M1nd3r Nov 22, 2024
e22a141
fix bitcoin tests
M1nd3r Nov 22, 2024
5a069d8
fix: improve debug writing in tests
M1nd3r Nov 25, 2024
ddc204a
fix(python): change default of client.get_session to have passphrase=""
M1nd3r Nov 25, 2024
b1821b7
fix(python): fix device tests for test_session
M1nd3r Nov 25, 2024
1609fa9
fix(python): fix test_msg_backup_device interruption
M1nd3r Nov 25, 2024
8cd9b03
fix(python): test_session_id_and_passphrase device test
M1nd3r Nov 25, 2024
f916aa7
fixup! fix(python): fix device tests for test_session [no changelog]
M1nd3r Nov 25, 2024
9e9814a
fixup! fixup! fix(python): fix device tests for test_session [no chan…
M1nd3r Nov 25, 2024
017d234
fix(python): fix test_autolock
M1nd3r Nov 25, 2024
d7e1570
test(python): fix test_protection_levels device tests
M1nd3r Nov 25, 2024
1575a6f
test(python): fix text_basic device test
M1nd3r Nov 25, 2024
fbfc3d6
test(python): fix test_debuglink device test
M1nd3r Nov 25, 2024
7da9113
test(python): fix test_msg_applysettings device tests
M1nd3r Nov 25, 2024
2c14356
test(python): fix click_tests
M1nd3r Nov 25, 2024
0a80574
test(python): fix upgrade_tests (partially)
M1nd3r Nov 26, 2024
6a7ce0e
test(python): fix persistence_tests
M1nd3r Nov 26, 2024
643dd53
fix: remove print
M1nd3r Nov 26, 2024
bb87825
test: fix style
M1nd3r Nov 26, 2024
02c19f2
fix: return Bridge to all_transports by default
M1nd3r Nov 26, 2024
2d12634
test(python): fix device tests
M1nd3r Nov 26, 2024
a6568fc
fix(trezorlib): fix cli commands
M1nd3r Nov 26, 2024
2e4776e
test: fix conftest setting of language
M1nd3r Nov 26, 2024
4d6cf0d
test: fix style
M1nd3r Nov 26, 2024
c27e3d6
fix(trezorlib): fix style
M1nd3r Nov 26, 2024
df6595f
test: fix client.reset_debug_features for codec
M1nd3r Nov 27, 2024
c891066
test: fix obtaining sessions with passphrase and setting language
M1nd3r Nov 27, 2024
2b51be1
fix(core): update structure of common seed so it works on BTC_ONLY
M1nd3r Nov 27, 2024
76daf9d
test: try fix pin callback
M1nd3r Nov 27, 2024
147c458
test: fix test_protection_levels device test
M1nd3r Nov 27, 2024
987b92f
test: allow session to be locked by default
M1nd3r Nov 27, 2024
cc49648
test: fix legacy test_firmware_upgrades device tests
M1nd3r Nov 27, 2024
f1772c6
test: try fix test_firmware_upgrades on legacy
M1nd3r Nov 27, 2024
75803e4
test: fix handling of PASSPHRASE_ON_DEVICE
M1nd3r Nov 27, 2024
1da4f17
test: fix test_msg_wipedevice locking in test_autolock_not_retained
M1nd3r Nov 28, 2024
c122018
test: fix UI-diffs in test_session_id_and_passphrase
M1nd3r Nov 28, 2024
1b832ea
test: remove unused code
M1nd3r Nov 28, 2024
93300fd
refactor(python): unify decorators for sessions under one uber-decorator
M1nd3r Nov 28, 2024
6f7613c
fix(trezorlib): fix issues in cli
M1nd3r Nov 28, 2024
e3fcd80
fix(trezorlib): make style-checker happy
M1nd3r Nov 28, 2024
0e3e59f
fix(trezorlib): fox ping command, add ping to session
M1nd3r Nov 28, 2024
dbb0d44
fix(trezorlib): re-allow usage of passphrases on codec sessions
M1nd3r Nov 28, 2024
a29f21b
chore(python): unify session and protocol versions under one IntEnum
M1nd3r Nov 29, 2024
ac03e08
test(core): fix thp test on various models of trezor
M1nd3r Nov 29, 2024
e823791
wip - add comment where T3T1 test fails
M1nd3r Nov 29, 2024
e50521f
build(ci): add (a few) THP builds and tests into core workflow
M1nd3r Nov 29, 2024
a2e6204
chore(core): improve loading of sessions from cache, add docstrings
M1nd3r Nov 29, 2024
495009e
refactor(core): improve create_new_session func
M1nd3r Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
73 changes: 54 additions & 19 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ jobs:
model: [T2T1, T3B1, T3T1, T3W1]
coins: [universal, btconly]
type: ${{ fromJSON(github.event_name == 'schedule' && '["normal", "debuglink", "production"]' || '["normal", "debuglink"]') }}
protocol: [v1]
include:
- model: D001
coins: universal
type: normal
- model: T2T1
coins: universal
type: debuglink
protocol: v2
- model: T2T1
coins: btconly
type: debuglink
protocol: v2
exclude:
- model: T3W1
type: production
Expand All @@ -67,6 +76,7 @@ jobs:
PYOPT: ${{ matrix.type == 'debuglink' && '0' || '1' }}
PRODUCTION: ${{ matrix.type == 'production' && '1' || '0' }}
BOOTLOADER_DEVEL: ${{ matrix.model == 'T3W1' && '1' || '0' }}
THP: ${{ matrix.protocol == 'v2' && '1' || '0'}}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -87,7 +97,7 @@ jobs:
if: matrix.coins == 'btconly' && matrix.type != 'debuglink'
- uses: actions/upload-artifact@v4
with:
name: core-firmware-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.type }}
name: core-firmware-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.type }}-protocol_${{ matrix.protocol }}
path: |
core/build/boardloader/*.bin
core/build/bootloader/*.bin
Expand All @@ -109,15 +119,28 @@ jobs:
# type: [normal, debuglink]
type: [debuglink]
asan: ${{ fromJSON(needs.param.outputs.asan) }}
protocol: [v1]
exclude:
- type: normal
asan: asan
include:
- model: T2T1
coins: universal
type: debuglink
asan: noasan
protocol: v2
- model: T2T1
coins: btconly
type: debuglink
asan: noasan
protocol: v2
env:
TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }}
BITCOIN_ONLY: ${{ matrix.coins == 'universal' && '0' || '1' }}
PYOPT: ${{ matrix.type == 'debuglink' && '0' || '1' }}
ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }}
LSAN_OPTIONS: "suppressions=../../asan_suppressions.txt"
THP: ${{ matrix.protocol == 'v2' && '1' || '0'}}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -129,7 +152,7 @@ jobs:
- run: cp core/build/unix/trezor-emu-core core/build/unix/trezor-emu-core-${{ matrix.model }}-${{ matrix.coins }}
- uses: actions/upload-artifact@v4
with:
name: core-emu-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.type }}-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.type }}-${{ matrix.asan }}-protocol_${{ matrix.protocol }}
path: |
core/build/unix/trezor-emu-core*
core/build/bootloader_emu/bootloader.elf
Expand Down Expand Up @@ -174,18 +197,20 @@ jobs:
retention-days: 2

core_unit_python_test:
name: Python unit tests
name: Python unit tests (${{ matrix.model }}, ${{ matrix.asan }}, protocol_${{ matrix.protocol}})
runs-on: ubuntu-latest
needs: param
strategy:
fail-fast: false
matrix:
model: [T2T1, T3B1, T3T1, T3W1]
asan: ${{ fromJSON(needs.param.outputs.asan) }}
protocol: [v1, v2]
env:
TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }}
ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }}
LSAN_OPTIONS: "suppressions=../../asan_suppressions.txt"
THP: ${{ matrix.protocol == 'v2' && '1' || '0'}}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -195,7 +220,7 @@ jobs:
- run: nix-shell --run "poetry run make -C core test"

core_unit_rust_test:
name: Rust unit tests
name: Rust unit tests (${{ matrix.model }}, ${{ matrix.asan }}, protocol_${{ matrix.protocol}})
runs-on: ubuntu-latest
needs:
- param
Expand All @@ -205,12 +230,14 @@ jobs:
matrix:
model: [T2T1, T3B1, T3T1, T3W1]
asan: ${{ fromJSON(needs.param.outputs.asan) }}
protocol: [v1, v2]
env:
TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }}
ADDRESS_SANITIZER: ${{ matrix.asan == 'asan' && '1' || '0' }}
RUSTC_BOOTSTRAP: ${{ matrix.asan == 'asan' && '1' || '0' }}
RUSTFLAGS: ${{ matrix.asan == 'asan' && '-Z sanitizer=address' || '' }}
LSAN_OPTIONS: "suppressions=../../asan_suppressions.txt"
THP: ${{ matrix.protocol == 'v2' && '1' || '0'}}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -234,7 +261,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-noasan
name: core-emu-${{ matrix.model }}-universal-debuglink-noasan-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand All @@ -257,6 +284,13 @@ jobs:
coins: [universal, btconly]
asan: ${{ fromJSON(needs.param.outputs.asan) }}
lang: ${{ fromJSON(needs.param.outputs.test_lang) }}
protocol: [v1]
include:
- model: T2T1
coins: universal
asan: noasan
lang: en
protocol: v2
env:
TREZOR_PROFILING: ${{ matrix.asan == 'noasan' && '1' || '0' }}
TREZOR_MODEL: ${{ matrix.model == 'T2T1' && 'T' || matrix.model }}
Expand All @@ -265,13 +299,14 @@ jobs:
PYTEST_TIMEOUT: ${{ matrix.asan == 'asan' && 600 || 400 }}
ACTIONS_DO_UI_TEST: ${{ matrix.coins == 'universal' && matrix.asan == 'noasan' }}
TEST_LANG: ${{ matrix.lang }}
THP: ${{ matrix.protocol == 'v2' && '1' || '0'}}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-${{ matrix.coins }}-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-${{ matrix.coins }}-debuglink-${{ matrix.asan }}-protocol_${{ matrix.protocol }}
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand All @@ -280,7 +315,7 @@ jobs:
if: failure()
- uses: actions/upload-artifact@v4
with:
name: core-test-device-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.lang }}-${{ matrix.asan }}
name: core-test-device-${{ matrix.model }}-${{ matrix.coins }}-${{ matrix.lang }}-${{ matrix.asan }}-protocol_${{ matrix.protocol }}
path: tests/trezor.log
retention-days: 7
if: always()
Expand Down Expand Up @@ -319,7 +354,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand All @@ -329,7 +364,7 @@ jobs:
if: ${{ matrix.asan == 'asan' }}
- uses: actions/upload-artifact@v4
with:
name: core-test-click-${{ matrix.model }}-${{ matrix.lang }}-${{ matrix.asan }}
name: core-test-click-${{ matrix.model }}-${{ matrix.lang }}-${{ matrix.asan }}-protocol_v1
path: tests/trezor.log
retention-days: 7
if: always()
Expand Down Expand Up @@ -367,7 +402,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand Down Expand Up @@ -397,7 +432,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand Down Expand Up @@ -430,7 +465,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-noasan
name: core-emu-${{ matrix.model }}-universal-debuglink-noasan-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment # XXX poetry maybe not needed
Expand Down Expand Up @@ -488,7 +523,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-firmware-${{ matrix.model }}-universal-normal # FIXME: s/normal/debuglink/
name: core-firmware-${{ matrix.model }}-universal-normal-protocol_v1 # FIXME: s/normal/debuglink/
path: core/build
- uses: ./.github/actions/environment
- run: nix-shell --run "poetry run core/tools/size/checker.py core/build/firmware/firmware.elf"
Expand All @@ -512,7 +547,7 @@ jobs:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: core-firmware-${{ matrix.model }}-universal-normal
name: core-firmware-${{ matrix.model }}-universal-normal-protocol_v1
path: core/build
- uses: ./.github/actions/environment
- run: nix-shell --run "poetry run core/tools/size/compare_master.py core/build/firmware/firmware.elf -r firmware_elf_size_report.txt"
Expand Down Expand Up @@ -543,7 +578,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: cachix/install-nix-action@v23
Expand Down Expand Up @@ -584,7 +619,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand Down Expand Up @@ -619,7 +654,7 @@ jobs:
submodules: recursive
- uses: actions/download-artifact@v4
with:
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}
name: core-emu-${{ matrix.model }}-universal-debuglink-${{ matrix.asan }}-protocol_v1
path: core/build
- run: chmod +x core/build/unix/trezor-emu-core*
- uses: ./.github/actions/environment
Expand Down Expand Up @@ -724,7 +759,7 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
pattern: core-emu*debuglink-noasan
pattern: core-emu*debuglink-noasan-protocol_v*
merge-multiple: true
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -747,7 +782,7 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
pattern: core-emu*debuglink-noasan
pattern: core-emu*debuglink-noasan-protocol_v*
merge-multiple: true
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
1 change: 1 addition & 0 deletions ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ core unix frozen debug build:
needs: []
variables:
PYOPT: "0"
THP: "1"
script:
- $NIX_SHELL --run "poetry run make -C core build_unix_frozen"
artifacts:
Expand Down
2 changes: 2 additions & 0 deletions common/protob/messages-common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ message Failure {
Failure_PinMismatch = 12;
Failure_WipeCodeMismatch = 13;
Failure_InvalidSession = 14;
Failure_ThpUnallocatedSession=15;
Failure_InvalidProtocol=16;
Failure_FirmwareError = 99;
}
}
Expand Down
5 changes: 5 additions & 0 deletions common/protob/messages-debug.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ message DebugLinkGetState {
// trezor-core only - wait until current layout changes
// changed in 2.6.4: multiple wait types instead of true/false.
optional DebugWaitType wait_layout = 3 [default=IMMEDIATE];
// THP only - it is used to get information from specified channel
optional bytes thp_channel_id=4;
}

/**
Expand All @@ -130,6 +132,9 @@ message DebugLinkState {
optional uint32 reset_word_pos = 11; // index of mnemonic word the device is expecting during ResetDevice workflow
optional management.BackupType mnemonic_type = 12; // current mnemonic type (BIP-39/SLIP-39)
repeated string tokens = 13; // current layout represented as a list of string tokens
optional uint32 thp_pairing_code_entry_code = 14;
optional bytes thp_pairing_code_qr_code = 15;
optional bytes thp_pairing_code_nfc_unidirectional = 16;
}

/**
Expand Down
Loading
Loading