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

chore(bridge-withdrawer, composer): encode submission payload only once #2053

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Mar 24, 2025

Summary

Changed submission logic to only encode retried transaction submissions to bytes once.

Background

Previously, Bridge Withdrawer and Composer utilized SequencerClientExt::submit_transaction_sync(), which encodes the transaction to bytes within the method. Within a retry configuration, this unnecessarily performs the conversion each time. These changes eliminate these superfluous encodings in favor of retrying with the same bytes each time.

Changes

  • Changed submit_transaction_sync() calls to broadcast_tx_sync() calls.
  • Moved Tx encoding to outside the retry logic.

Testing

Passing all tests, no additional ones needed since the functionality is the same.

Changelogs

No updates required.

Related Issues

closes #2050

@github-actions github-actions bot added sequencer pertaining to the astria-sequencer crate composer pertaining to composer labels Mar 24, 2025
@ethanoroshiba ethanoroshiba marked this pull request as ready for review March 25, 2025 13:48
Copy link
Member

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would push back on the primary change of this PR: it is a useful feature for a user not having to know how to transform a Transaction -> proto Transaction -> bytes in order to submit it to Sequencer.

With that said - what this PR does reveal is that there are some easy optimizations to be had in composer, bridge-withdrawer (and less so) auctioneer: we don't need to re-encode the bytes every time. It's sufficient to encode them once and resubmit the same bytes on certain kinds of errors (unless we need to bump the nonce, say).

/// # Errors
///
/// - If calling the tendermint RPC endpoint fails.
async fn submit_transaction_sync(&self, tx: Transaction) -> Result<tx_sync::Response, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is actually useful because here the caller need not know about how to transform a Transaction into a payload sequencer understands.

I would leave this.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@ethanoroshiba ethanoroshiba force-pushed the eoroshiba/remove-submit-tx-sync branch from c50c675 to fa5e7ee Compare March 25, 2025 14:39
@ethanoroshiba ethanoroshiba changed the title chore(sequencer-client): remove superfluous TX submission method chore(bridge-withdrawer, composer): only encode submission TX as bytes once Mar 25, 2025
@ethanoroshiba ethanoroshiba removed sequencer pertaining to the astria-sequencer crate sequencer-client labels Mar 25, 2025
@SuperFluffy SuperFluffy changed the title chore(bridge-withdrawer, composer): only encode submission TX as bytes once chore(bridge-withdrawer, composer): encode submission paylaod only once Mar 25, 2025
@SuperFluffy SuperFluffy changed the title chore(bridge-withdrawer, composer): encode submission paylaod only once chore(bridge-withdrawer, composer): encode submission payload only once Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality composer pertaining to composer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: don't re-encode transaction bytes for submission retries
2 participants