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

block ordering and tx inclusion action rules #1412

Open
joroshiba opened this issue Aug 27, 2024 · 2 comments · May be fixed by #1618
Open

block ordering and tx inclusion action rules #1412

joroshiba opened this issue Aug 27, 2024 · 2 comments · May be fixed by #1618
Assignees

Comments

@joroshiba
Copy link
Member

joroshiba commented Aug 27, 2024

Sudo actions have some interesting side effects to the rest of the block, and as such should be posted at the bottom of the block with no non sudo actions occuring after them. We may even want a hierarchical order in which groupings can occur, and rules about coupling:

I propose the following transaction groupings, all actions in the same groupings have a property of if they can be bundled. If they can, they can only be bundled with same grouping txs. They are in order of how they should appear in a block.

  1. General
    • These are general purpose txs which have no odd implications on later txs
    • Bundlable? ✅
    • Can charge fees
    • Actions
      • TransferAction
      • SequenceAction
      • BridgeLockAction
      • BridgeUnlockAction
      • IbcRelay
      • Ics20Withdrawal
      • ValidatorUpdate
  2. Bridge Control
    • Bundlable? ❌
    • These actions change fundamentals on the signing account. They can't be bundled cleanly because same signer can't do another action after it. Additionally, can have implications on txs in general validity based on ordering. Putting after makes clean break.
    • Charge fees
    • Actions
      • InitBridgeAccountAction
      • BridgeSudoChangeAction
  3. Sudo Actions
    • Bundlable? ✅
    • Most of these have implications on fees charged and valid, affect all txs which have fees and must be after any tx which can charge fees. IbcRelayer affects the validity of IbcRelay actions as such should be towards end of block.
    • No fees, submittable only by sudo actor
    • Actions
      • FeeAssetChangeAction
      • FeeChangeAction
      • IbcRelayerChangeAction
  4. Sudo Control
    • Bundlable? ❌
    • This updates the sudo account, impossible to have more than one in a valid bundle. The sudo account is also the payee of fees, so it needs to be after all fee paying items, it would affect the validity of any sudo actions. I think it's best to include after any such actions occur.
    • SudoAddressChangeAction

I think these might be best viewed as a sort of "action category" where a transaction can only have actions that are all the same category, and categories have two properties (priority, and if it can be bundled). Thus the category of the first action would the that for the whole transaction, and stateless checks can easily be added over this.

┆Issue Number: ENG-750

@noot
Copy link
Collaborator

noot commented Sep 9, 2024

regarding #2 (bridge control):

These actions change fundamentals on the signing account. They can't be bundled cleanly because same signer can't do another action after it. Additionally, can have implications on txs in general validity based on ordering. Putting after makes clean break.

I don't think these necessarily need to go at the end of the block as they don't affect fees/fee recipient. having implications on validity seems fine, as other actions can also do that (eg transfers)

@joroshiba
Copy link
Member Author

I don't think these necessarily need to go at the end of the block as they don't affect fees/fee recipient. having implications on validity seems fine, as other actions can also do that (eg transfers)

transfers are much easier to account for in mempool design by having a pending balance and will generally not lead to otherwise valid txs being kicked out of the mempool. Want to avoid what could be a demotion from being a kicked out of mempool tx.

If we already have multiple priority categories it is an improvement to have these after in terms of UX, I don't see a reason to not have as it's own considered type/priority. I think this alone wouldn't necessarily push us to implement these but if doing so we should do it.

github-merge-queue bot pushed a commit that referenced this issue Sep 30, 2024
## Note for Reviewers
Most of the logic changes are in the files
`crates/astria-core/src/protocol/transaction/v1alpha1/action_group.rs`
and `crates/astria-core/src/protocol/transaction/v1alpha1/mod.rs`. The
rest of the changes are updating the construction of
`UnsignedTransactions` and/or changing the access to the inner fields.

## Summary
Adds restrictions on what type of `Actions` can be included in the same
`UnsignedTransaction`. Implements the categories as described in #1412
but with slightly different names:
- General:
  - TransferAction
  - SequenceAction
  - BridgeLockAction
  - BridgeUnlockAction
  - IbcRelay
  - Ics20Withdrawal
  - ValidatorUpdate
- UnbundeableGeneral (Instead of Bridge Control):
  - InitBridgeAccountAction
  - BridgeSudoChangeAction
- Sudo:
  - FeeAssetChangeAction
  - FeeChangeAction
  - IbcRelayerChangeAction
- UnbundleableSudo (Instead of Sudo Control):
  - SudoAddressChangeAction
  - IbcSudoChangeAction
  
The check is applied at the time of constructing the
`UnsignedTransaction`. The `UnsignedTransaction` 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
- Introduced the `Actions` struct to hold valid groupings of `Actions`.
- Introduced `ActionGroup` enum to represent which `Actions` can be
included together in a transaction and if more than one action can be
included in a transaction.
- Changed the `UnsignedTransaction` struct to have private fields and to
use a new constructor.
- Changed the `UnsignedTransaction`'s `action` to be a `Actions` type
instead of just a vector of `Actions`.

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants