Skip to content

feat(sequencer)!: rework all fees#1647

Merged
ethanoroshiba merged 40 commits intomainfrom
eoroshiba/fee_finalization
Oct 15, 2024
Merged

feat(sequencer)!: rework all fees#1647
ethanoroshiba merged 40 commits intomainfrom
eoroshiba/fee_finalization

Conversation

@ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Oct 8, 2024

Summary

Gutted all current fee handling and replaced all with single fee calculation method in new trait.

Background

This implementation will simplify not only our fee calculation, but the process for adding new actions in the future.

Changes

  • Created FeeComponents types for all fee-bearing transactions which all have a base fee component and a computed cost multiplier component.
  • Moved all fee checks and payment to one single function within the new sequencer fees component. Fee calculation is now always the following formula: base_fee + computed_cost_base * computed_cost_multiplier
  • Moved all state reads/writes for fees to the new fees component.
  • Initialized all fees in the fee component's init_chain().
  • Changed FeeChange to be an enum which takes any fee-bearing action's fee components.
  • Moved FeeChange and FeeAssetChange's ActionHandler impls to the fees component.
  • Allowed fee assets now stored in verifiable storage instead of non-verifiable.

Testing

All previous tests passing, added new tests for all state fee reads/writes.

Breaking Changelist

  • Changed shape of FeeChange action.
  • Added storage of all the action fees, breaking the app hash.
  • Changed app genesis.
  • Removed a bunch of storage keys, breaking these snapshot tests
  • Allowed fee assets moved from non-verifiable to verifiable storage.

Related Issues

closes #1369
closes #1145

@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate labels Oct 8, 2024
@ethanoroshiba ethanoroshiba changed the base branch from main to ENG-718/rework_fees_again October 8, 2024 22:32
Co-authored-by: Jordan Oroshiba <jordan@astria.org>
Comment on lines +31 to +99
let transfer_fees = app_state.fees().transfer;
state
.put_transfer_fees(transfer_fees)
.wrap_err("failed to store transfer fee components")?;

let sequence_fees = app_state.fees().sequence;
state
.put_sequence_fees(sequence_fees)
.wrap_err("failed to store sequence action fee components")?;

let ics20_withdrawal_fees = app_state.fees().ics20_withdrawal;
state
.put_ics20_withdrawal_fees(ics20_withdrawal_fees)
.wrap_err("failed to store ics20 withdrawal fee components")?;

let init_bridge_account_fees = app_state.fees().init_bridge_account;
state
.put_init_bridge_account_fees(init_bridge_account_fees)
.wrap_err("failed to store init bridge account fee components")?;

let bridge_lock_fees = app_state.fees().bridge_lock;
state
.put_bridge_lock_fees(bridge_lock_fees)
.wrap_err("failed to store bridge lock fee components")?;

let bridge_unlock_fees = app_state.fees().bridge_unlock;
state
.put_bridge_unlock_fees(bridge_unlock_fees)
.wrap_err("failed to store bridge unlock fee components")?;

let bridge_sudo_change_fees = app_state.fees().bridge_sudo_change;
state
.put_bridge_sudo_change_fees(bridge_sudo_change_fees)
.wrap_err("failed to store bridge sudo change fee components")?;

let ibc_relay_fees = app_state.fees().ibc_relay;
state
.put_ibc_relay_fees(ibc_relay_fees)
.wrap_err("failed to store ibc relay fee components")?;

let validator_update_fees = app_state.fees().validator_update;
state
.put_validator_update_fees(validator_update_fees)
.wrap_err("failed to store validator update fee components")?;

let fee_asset_change_fees = app_state.fees().fee_asset_change;
state
.put_fee_asset_change_fees(fee_asset_change_fees)
.wrap_err("failed to store fee asset change fee components")?;

let fee_change_fees = app_state.fees().fee_change;
state
.put_fee_change_fees(fee_change_fees)
.wrap_err("failed to store fee change fee components")?;

let ibc_relayer_change_fees = app_state.fees().ibc_relayer_change;
state
.put_ibc_relayer_change_fees(ibc_relayer_change_fees)
.wrap_err("failed to store ibc relayer change fee components")?;

let sudo_address_change_fees = app_state.fees().sudo_address_change;
state
.put_sudo_address_change_fees(sudo_address_change_fees)
.wrap_err("failed to store sudo address change fee components")?;

let ibc_sudo_change_fees = app_state.fees().ibc_sudo_change;
state
.put_ibc_sudo_change_fees(ibc_sudo_change_fees)
.wrap_err("failed to store ibc sudo change fee components")?;
Copy link
Member

Choose a reason for hiding this comment

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

Should it fail if we have not set a single asset? It seems like the only action which needs to be required to be set in genesis (and thus enabled) is the FeeChange itself? If we can't set the fee then we can't do it for any other actions either?

Comment on lines +563 to +576
pub sequence: SequenceFeeComponents,
pub transfer: TransferFeeComponents,
pub ics20_withdrawal: Ics20WithdrawalFeeComponents,
pub init_bridge_account: InitBridgeAccountFeeComponents,
pub bridge_lock: BridgeLockFeeComponents,
pub bridge_unlock: BridgeUnlockFeeComponents,
pub bridge_sudo_change: BridgeSudoChangeFeeComponents,
pub ibc_relay: IbcRelayFeeComponents,
pub validator_update: ValidatorUpdateFeeComponents,
pub fee_asset_change: FeeAssetChangeFeeComponents,
pub fee_change: FeeChangeFeeComponents,
pub ibc_relayer_change: IbcRelayerChangeFeeComponents,
pub sudo_address_change: SudoAddressChangeFeeComponents,
pub ibc_sudo_change: IbcSudoChangeFeeComponents,
Copy link
Member

Choose a reason for hiding this comment

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

Should most of these be Option? It seems the only which stricly must be set is fee_change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking issue: #1662

Copy link
Member

@joroshiba joroshiba left a comment

Choose a reason for hiding this comment

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

Approval for infra, couple notes on the genesis that I'm not blocking on.

@ethanoroshiba ethanoroshiba added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit b677ce9 Oct 15, 2024
@ethanoroshiba ethanoroshiba deleted the eoroshiba/fee_finalization branch October 15, 2024 23:30
steezeburger added a commit that referenced this pull request Oct 16, 2024
* main:
  feat(sequencer)!: rework all fees (#1647)
  fix(sequencer): fix app hash in horcrux sentries (#1646)
  fix(composer)!: update to work with appside mempool (#1643)
  fix(charts): rollup application monitoring (#1601)
github-merge-queue bot pushed a commit that referenced this pull request Oct 21, 2024
## Summary
Removes an unused variant of the internal storage implementation of
sequencer asset component.t

## Background
As part of #1647 fees were moved
from the assets to the fees component. The present variant was
overlooked.

## Changes
- Remove a storage variant from the assets component.

## Testing
Not applicable. Dead code.

## Breaking Changelist
This is not a breaking change because a) the variant was never used
(there was not even a theoretic way to write it after
#1647) and b) no variants
existed after the variant. If they had, this change would lead to a
shift in the variants, causing breakage.

---------

Co-authored-by: Fraser Hutchison <fraser@astria.org>
github-merge-queue bot pushed a commit that referenced this pull request Oct 23, 2024
## Summary
Made all fees except for `FeeChange` action optional at genesis.

## Background
Tracking PR for [this
comment](#1647 (comment)).
Allows for more flexibility at genesis. Post #1647, an action with no
fees in the state is by default deactivated until it is explicitly given
fees, even if they are 0. This is to allow for actions to be added in
the future without breaking consensus, but also allows for more
flexibility at genesis. Now, all actions can be disabled at genesis by
making the fees optional, except for `FeeChange`, which is needed in
order to activate actions by giving them fees.

## Changes
- Made all fees in `GenesisFees` optional (except for fee_change).

## Testing
Passing all tests.

## Related Issues
closes #1662
github-merge-queue bot pushed a commit that referenced this pull request Oct 24, 2024
## Summary
Moves the initialization of allowed assets from the overall app to the
fees component.

## Background
#1647 moved fee asset state
handling to the new `fees` component. It was overlooked that writing
allowed fee assets should also happen in its init chain logic.

## Changes
- Move initialization of app init state to the fees component.

## Testing
Nothing has changed in terms of how the state is represented. Tests that
rely on init chain still work.

## Breaking Changelist
This is not a breaking change because the state after this change looks
the same.
sgranfield4403-3 added a commit to sgranfield4403-3/astria that referenced this pull request Oct 2, 2025
## Summary
Removes an unused variant of the internal storage implementation of
sequencer asset component.t

## Background
As part of astriaorg/astria#1647 fees were moved
from the assets to the fees component. The present variant was
overlooked.

## Changes
- Remove a storage variant from the assets component.

## Testing
Not applicable. Dead code.

## Breaking Changelist
This is not a breaking change because a) the variant was never used
(there was not even a theoretic way to write it after
astriaorg/astria#1647) and b) no variants
existed after the variant. If they had, this change would lead to a
shift in the variants, causing breakage.

---------

Co-authored-by: Fraser Hutchison <fraser@astria.org>
sgranfield4403-3 added a commit to sgranfield4403-3/astria that referenced this pull request Oct 2, 2025
## Summary
Made all fees except for `FeeChange` action optional at genesis.

## Background
Tracking PR for [this
comment](astriaorg/astria#1647 (comment)).
Allows for more flexibility at genesis. Post #1647, an action with no
fees in the state is by default deactivated until it is explicitly given
fees, even if they are 0. This is to allow for actions to be added in
the future without breaking consensus, but also allows for more
flexibility at genesis. Now, all actions can be disabled at genesis by
making the fees optional, except for `FeeChange`, which is needed in
order to activate actions by giving them fees.

## Changes
- Made all fees in `GenesisFees` optional (except for fee_change).

## Testing
Passing all tests.

## Related Issues
closes #1662
sgranfield4403-3 added a commit to sgranfield4403-3/astria that referenced this pull request Oct 2, 2025
## Summary
Moves the initialization of allowed assets from the overall app to the
fees component.

## Background
astriaorg/astria#1647 moved fee asset state
handling to the new `fees` component. It was overlooked that writing
allowed fee assets should also happen in its init chain logic.

## Changes
- Move initialization of app init state to the fees component.

## Testing
Nothing has changed in terms of how the state is represented. Tests that
rely on init chain still work.

## Breaking Changelist
This is not a breaking change because the state after this change looks
the same.
AngieD101 added a commit to AngieD101/astria that referenced this pull request Oct 10, 2025
## Summary
Removes an unused variant of the internal storage implementation of
sequencer asset component.t

## Background
As part of astriaorg/astria#1647 fees were moved
from the assets to the fees component. The present variant was
overlooked.

## Changes
- Remove a storage variant from the assets component.

## Testing
Not applicable. Dead code.

## Breaking Changelist
This is not a breaking change because a) the variant was never used
(there was not even a theoretic way to write it after
astriaorg/astria#1647) and b) no variants
existed after the variant. If they had, this change would lead to a
shift in the variants, causing breakage.

---------

Co-authored-by: Fraser Hutchison <fraser@astria.org>
AngieD101 added a commit to AngieD101/astria that referenced this pull request Oct 10, 2025
## Summary
Made all fees except for `FeeChange` action optional at genesis.

## Background
Tracking PR for [this
comment](astriaorg/astria#1647 (comment)).
Allows for more flexibility at genesis. Post #1647, an action with no
fees in the state is by default deactivated until it is explicitly given
fees, even if they are 0. This is to allow for actions to be added in
the future without breaking consensus, but also allows for more
flexibility at genesis. Now, all actions can be disabled at genesis by
making the fees optional, except for `FeeChange`, which is needed in
order to activate actions by giving them fees.

## Changes
- Made all fees in `GenesisFees` optional (except for fee_change).

## Testing
Passing all tests.

## Related Issues
closes #1662
AngieD101 added a commit to AngieD101/astria that referenced this pull request Oct 10, 2025
## Summary
Moves the initialization of allowed assets from the overall app to the
fees component.

## Background
astriaorg/astria#1647 moved fee asset state
handling to the new `fees` component. It was overlooked that writing
allowed fee assets should also happen in its init chain logic.

## Changes
- Move initialization of app init state to the fees component.

## Testing
Nothing has changed in terms of how the state is represented. Tests that
rely on init chain still work.

## Breaking Changelist
This is not a breaking change because the state after this change looks
the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cd docker-build used to trigger docker builds on PRs proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework fee reporting sequencer: cleanup/refactor of action fee checks

4 participants