trezor / trezor-firmware

:lock: Trezor Firmware Monorepo
https://trezor.io
Other
1.36k stars 658 forks source link

Limit total size of one protobuf message #1840

Open matejcik opened 3 years ago

matejcik commented 3 years ago

Currently, core has a fixed 8kB buffer for receiving incoming messages, and tries to dynamically allocate more if the incoming message is larger.

For the vast majority of workflows, 8kB is wastefully large. The only exceptions that we know of are:

We should resolve these separately: introduce streaming for homescreen #1120 and probably for the credential list too.

It seems that 4096 bytes per message should be Enough For Everyone (tm). We need to test if that is really the case. If yes, we should:

matejcik commented 3 years ago

A MultisigRedeemScriptType can carry 3660 bytes of data, not counting the encoding overhead. This means that a standard TxInput message can end up very close to the 4kB limit.

6kB should be enough, but at that point maybe we can keep the 8kB buffer and just make it a hard limit.