Skip to content

Commit

Permalink
Account for full transaction encoding when batching messages (#2575)
Browse files Browse the repository at this point in the history
* Remove a useless clone

* De-clone estimate_tx_fees

* cosmos: More de-owning around sign_and_encode_tx

* Simplify prepending of ClientUpdate

* cosmos: encoded_tx_len function

The function evaluates the length of an encoded transaction,
to perform more accurate batching.

* Account for field encoding in tx batch size

* Account for tx envelope in message batching

* More credible test fixture for batch_messages

* Fix calculations in batch_messages, adjust tests

* Initialize KeyEntry data from a seed file

* relayer: module chain::cosmos::test_utils

Move utilities from chain::cosmos::batch to share them with other
modules' unit tests.

* Take tx_body varint lenth delimiter into account

In batch_messages, the varint encoding of the length of the tx_body
field of TxRaw may increase the length of the envelope
as the body size grows.

* Account for body encoding when batching messages

The tx_body member of TxRaw encodes more than the messages,
so its total length needs to be taken into account when estimating
the total transaction size from the previously computed envelope
and the vector of messages.

* Document EncodedTxMetrics

* Revert "relayer: module chain::cosmos::test_utils"

This reverts commit 6a8e31f.

* batch: fix size estimation for empty body

When the TxBody struct is completely empty (all fields have default
values), it is encoded as an empty array and the body_bytes field is
then also omitted from the encoding of TxRaw.

Add transaction size verification to the unit tests of batch_messages,
by creating encoded tx from the batched messages (using the maximum fee
to keep unit tests simple) and checking the size corresponds to the
`MaxTxSize` parameter.

* Improve batch_does_not_exceed_max_tx_size test

Test larger numbers of messages, up to 100 (maximum allowed per
MaxMsgNum limits), with length increasing in the arithmetic progression.
For each round, make sure that the size limit is just equal to the
size of an encoded tx with all messages except the last one.
Verify that the last message is spilled into the next batch and the
resulting tx size for the first batch equals the limit.

* Remove an unnecessary branch

* Add changelog entry

Co-authored-by: Romain Ruetschi <romain@informal.systems>
  • Loading branch information
mzabaluev and romac authored Aug 30, 2022
1 parent c1a5fe7 commit a087c47
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Account for full transaction encoding when batching messages
([#2575](https://github.com/informalsystems/ibc-rs/issues/2575))
Loading

0 comments on commit a087c47

Please sign in to comment.