1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00
Commit Graph

20 Commits

Author SHA1 Message Date
matejcik
aac7726824 trezorlib: transport/protocol reshuffle
This commit breaks session handling (which matters with Bridge) and
regresses Bridge to an older code state. Both of these issues will be
rectified in subsequent commits.

Explanation of this big API reshuffle follows:

* protocols are moved to trezorlib.transport, and to a single common file.
* there is a cleaner definition of Transport and Protocol API (see below)
* fully valid mypy type hinting
* session handle counters and open handle counters mostly went away. Transports
  and Protocols are meant to be "raw" APIs; TrezorClient will implement
  context-handler-based sessions, session tracking, etc.

I'm calling this a "reshuffle" because it involved very small number of
code changes. Most of it is moving things around where they sit better.

The API changes are as follows.

Transport is now a thing that can:
* open and close sessions
* read and write protobuf messages
* enumerate and find devices

Some transports (all except bridge) are technically bytes-based and need
a separate protocol implementation (because we have two existing protocols,
although only the first one is actually used). Hence a protocol superclass.

Protocol is a thing that *also* can:
* open and close sessions
* read and write protobuf messages
For that, it requires a `handle`.

Handle is a physical layer for a protocol. It can:
* open and close some sort of device connection
  (this is distinct from session! Connection is a channel over which you can
  send data. Session is a logical arrangement on top of that; you can have
  multiple sessions on a single connection.)
* read and write 64-byte chunks of data

With that, we introduce ProtocolBasedTransport, which simply delegates
the appropriate Transport functionality to respective Protocol methods.

hid and webusb transports are ProtocolBasedTransport-s that provide separate
device handles. HidHandle and WebUsbHandle existed before, but the distinction
of functionality between a Transport and its Handle was unclear. Some methods
were moved and now the handles implement the Handle API, while the transports
provide the enumeration parts of the Transport API, as well as glue between
the respective Protocols and Handles.

udp transport is also a ProtocolBasedTransport, but it acts as its own handle.
(That might be changed. For now, I went with the pre-existing structure.)

In addition, session_begin/end is renamed to begin/end_session to keep
consistent verb_noun naming.
2018-11-12 12:22:26 +01:00
matejcik
2d7c74c535 switch to click 7.0 2018-10-10 13:15:28 +02:00
matejcik
7b98b5ac7c build: drop python<3.5 compatibility in CI and markers 2018-10-01 13:52:41 +02:00
matejcik
f30ea76d24 build: do not require pip in requirements.txt
it makes little sense and breaks python3.3 for mysterious reasons

(the "mysterious" reason is that everyone dropped support for py3.3
and so dependencies are messed up)
2018-08-21 16:50:45 +02:00
matejcik
8f03bd0165 build: add Construct to requires, use package autodetection 2018-07-09 13:56:22 +02:00
matejcik
a289d16838 build: require typing module for python < 3.4 2018-05-09 17:43:41 +02:00
matejcik
76fea5afc4 build: move ethereum requirements to their own extra
We only need ethereum libraries for `ethereum_sign_tx` in trezorctl,
and rlp has caused us dependency problems in the past already.
Also we required ethjsonrpc for the same thing but never listed
that dependency anywhere.

That changes now.
2018-05-07 13:05:48 +02:00
matejcik
41d99764c6 build: reorganize requirements, mark hidapi as optional
This drops the command line options. `libusb` is now required
unconditionally (it's cffi so no harm there). hidapi is an extra.
You either need to install it manually, or specify it in your
requirements.txt like so:

trezor[hidapi] >= 0.9.2
2018-05-04 15:54:23 +02:00
matejcik
2d3e890c6b setup: add missing requirement for rlp (#220) 2018-02-28 18:03:27 +01:00
Pavol Rusnak
1a046b524c
setup: add dependency for libusb1 2018-02-02 01:22:16 +01:00
Karel Bilek
759316e96f Add webusb to transports
V2 protocol with debug link is not tested.
2018-02-01 10:25:01 +01:00
slush
a27217811b Rework from Google's protobuf to pure-python protobuf implementation 2017-12-17 02:19:16 +01:00
Pavol Rusnak
1ab602423c
requirements: add pyblake2 2017-11-06 11:10:23 +01:00
Pavol Rusnak
2d643031ac
change dependency to protobuf>=3.0.0 2017-07-10 14:41:56 +02:00
Pavol Rusnak
b335d30b8d
use click in trezorctl 2017-07-05 12:55:38 +02:00
Pavol Rusnak
65985b30f3
bump requirements for protobuf to 3.1.0 2017-06-18 23:19:15 +02:00
Pavol Rusnak
dccc1b08ed
update requirement for hidapi to 0.7.99.post20 2017-03-06 12:02:49 +01:00
Pavol Rusnak
18bd3e6197
update mnemonic requirement 2017-02-22 15:07:58 +01:00
Pavol Rusnak
fe4662d389
bump version 2017-02-11 20:16:11 +01:00
Pavol Rusnak
883ebf0e03
add tox 2016-10-17 14:17:42 +02:00