This PR introduces MAX_TRANSACTION_SIZE which upper bounds the number of bytes in a transaction.
This limit is imposed in check_transaction, however constructing larger transactions is still permitted.
As part of the design, this PR introduces a LimitedWriter which is a wrapper aroound Write. The motivation is to ensure that additional bytes (beyond the maximum) are not written. Without this, the implementation in check_transaction have to write potentially larger amounts of data, before being able to check that the limit is not exceeded.
Note that this implementation requires that MAX_TRANSACTION_SIZE is never decreased.
An alternate implementation was considered where MAX_TRANSACTION_SIZE was enforced in the (de)serializers. That design is prone to backwards compatibility issues. Note that this design is not free of backwards compatibility issues either; if MAX_TRANSACTION_SIZE is decreased, then older transactions can still be invalidated.
This PR introduces
MAX_TRANSACTION_SIZE
which upper bounds the number of bytes in a transaction. This limit is imposed incheck_transaction
, however constructing larger transactions is still permitted.As part of the design, this PR introduces a
LimitedWriter
which is a wrapper arooundWrite
. The motivation is to ensure that additional bytes (beyond the maximum) are not written. Without this, the implementation incheck_transaction
have to write potentially larger amounts of data, before being able to check that the limit is not exceeded.Note that this implementation requires that
MAX_TRANSACTION_SIZE
is never decreased.An alternate implementation was considered where
MAX_TRANSACTION_SIZE
was enforced in the (de)serializers. That design is prone to backwards compatibility issues. Note that this design is not free of backwards compatibility issues either; ifMAX_TRANSACTION_SIZE
is decreased, then older transactions can still be invalidated.