-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(sequencer)!: transaction categories on UnsignedTransaction #1512
Conversation
c12d6e6
to
bdc9301
Compare
2bccf24
to
5898ffd
Compare
.actions(this.bundle.clone().into_actions()) | ||
.params(params) | ||
.build() | ||
.expect("failed to build transaction from actions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
6dbf4f5
to
becf939
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an elegant solution to me, and I am always a fan of locking down types.
I think this is ready to be merged, but I would like to see the errors for the wire-type -> domain-type conversion to contain more information.
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial (incomplete) review.
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_groups.rs
Outdated
Show resolved
Hide resolved
e226fb3
to
ed325e8
Compare
Since last set of reviews:
|
crates/astria-core/src/protocol/transaction/v1alpha1/action_group.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_group.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_group.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_group/mod.rs
Outdated
Show resolved
Hide resolved
crates/astria-core/src/protocol/transaction/v1alpha1/action_group/mod.rs
Outdated
Show resolved
Hide resolved
@@ -169,6 +169,14 @@ impl Action { | |||
}; | |||
Some(transfer_action) | |||
} | |||
|
|||
pub fn is_fee_asset_change(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make a tracking issue to add unit tests for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created and commented in code: #1593
5b31346
to
613993f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for going going through the many review comments, online and offline!
/// Constructs an [`UnsignedTransaction`] from the actions contained in the bundle and `params`. | ||
// Method is expected to never panic because only `SequenceActions` are added to the bundle, | ||
// which should produce a valid variant of the `ActionGroup` type. | ||
#[allow(clippy::panic)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads-up: with #1561 being merged we switch everything to expect
and require a reason
:
#[allow(clippy::panic)] | |
#[expect(clippy::panic, reason = "method is expected to never panic because only `SequenceActions` are added to the bundle, which should produce a valid variant of the `ActionGroup` type; this is checked by `tests::transaction_construction_should_not_panic")] |
General, | ||
UnbundleableGeneral, | ||
Sudo, | ||
UnbundleableSudo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshed:
@noot left some comments on these where Bundleable*
was removed and Unbundleable*
introduced.
My preference would have been to go all out and use General -> BundleableGeneral
and Sudo -> BundleableSudo
(and keep Unbundleable*
) so that this is always spelled out explicitly.
But I am going to leave the final call on this one to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to BundleableXXX. Agree it's easier to understand
impl fmt::Display for ActionGroup { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
ActionGroup::General => write!(f, "general"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving a note that should you go with my bikeshedding to rename prefix with Bundleable*
, to also change the display name.
* main: (34 commits) feat(proto): add bundle and optimistic block apis (#1519) feat(sequencer)!: make empty transactions invalid (#1609) chore(sequencer): simplify boolean expressions in `transaction container` (#1595) refactor(cli): merge argument parsing and command execution (#1568) feat(charts): astrotrek chart (#1513) chore(charts): genesis template to support latest changes (#1594) fix(ci): code freeze action fix (#1610) chore(sequencer)!: exclusively use Borsh encoding for stored data (ENG-768) (#1492) ci: code freeze through github actions (#1588) refactor(sequencer): use builder pattern for transaction container tests (#1592) feat(conductor)!: implement chain ID checks (#1482) chore(ci): upgrade audit-check (#1577) feat(sequencer)!: transaction categories on UnsignedTransaction (#1512) fix(charts): sequencer prometheus rules (#1598) chore(all): Migrate all instances of `#[allow]` to `#[expect]` (#1561) chore(charts,sequencer-faucet): asset precision (#1517) chore(docs): endpoints (#1543) fix(docker): use target binary build param as name of image entrypoint (#1573) fix(ci): ibc bridge test timeout (#1587) Feature: Add `graph-node` to charts. (#1489) ...
## Summary We want to order blocks by the transaction categories introduced in #1512 to finish the goals of #1412. ## Background Certain transactions have the ability to cause other transactions to become invalid. For example, `FeeChangeActions` can cause transactions that were valid to become invalid. For the sake of UX we want to order the potentially-invalidating actions after others so we don't needlessly execute transactions that were just invalidated. More background can be found in #1412. ## Changes - The mempool now orders the transactions it feeds to `prepare_proposal` by `ActionGroup`. - `prepare_proposal` will now skip any transactions in it's block construction process that are out of group order. - `process_proposal` will now reject any blocks that contain out-of-order transactions. Note: the mempool does not check for out of order actions inside of the pending queue. This was decided because the amount of times that actions besides `BundleableGeneral` are expected to be ran is low. Instead we let `prepare_proposal` gracefully ignore out-of-order actions in a way that allows them to be included in future blocks. For example, let's say an account sends these two transactions into the mempool: - `tx_0: {nonce: 0, action_group: UnbundleableGeneral}` - `tx_1: {nonce: 1, action_group: BundleableGeneral}` The mempool will feed these transaction in the order of `{tx_1, tx_0}` to `prepare_proposal`, which is correct on a group ordering level but incorrect on a nonce ordering level. `prepare_proposal` will handle this by skipping `tx_1` and only including `tx_0` in the block. The mempool will re-feed `tx_1` on the next round to `prepare_proposal` to be included. ## Testing Unit tests and ran locally. ## Breaking Changelist Block that would've passed before with incorrect transaction ordering will now fail. ## Related Issues closes #1412 #1417
Note for Reviewers
Most of the logic changes are in the files
crates/astria-core/src/protocol/transaction/v1alpha1/action_group.rs
andcrates/astria-core/src/protocol/transaction/v1alpha1/mod.rs
. The rest of the changes are updating the construction ofUnsignedTransactions
and/or changing the access to the inner fields.Summary
Adds restrictions on what type of
Actions
can be included in the sameUnsignedTransaction
. Implements the categories as described in #1412 but with slightly different names:The check is applied at the time of constructing the
UnsignedTransaction
. TheUnsignedTransaction
additionally had its struct fields changed to private and now uses a new constructor to prevent the contained actions from being modified.Background
We want transactions that can affect the validity of other transactions to be ordered last in blocks to reduce the amount of failed transactions we process. These logic changes are the first code changes being made to realize this goal.
Changes
Actions
struct to hold valid groupings ofActions
.ActionGroup
enum to represent whichActions
can be included together in a transaction and if more than one action can be included in a transaction.UnsignedTransaction
struct to have private fields and to use a new constructor.UnsignedTransaction
'saction
to be aActions
type instead of just a vector ofActions
.Testing
Unit testing and ran locally.
Breaking Changelist
Transactions that contain invalid
ActionGroup
combos (due to mixed groups or multiple actions in non-bundleable group types) are now 'invalid' transactions. I had to update one of the snapshot tests due to having to unbundle some of the transactions, creating a new state.Related Issues
Initial steps for #1412
closes #1414, #1416