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

feat(sequencer): rework fee handling #1526

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Sep 19, 2024

Summary

Implemented calculate_and_pay_fees() for each action, required by a new trait bound FeeHandler in ActionHandler.

Background

This is meant to streamline and standardize fee handling in a way that keeps the same functionality, but makes it more difficult to introduce bugs in fee handling in the future. Offline discussion suggested changing the return type of execute_transaction() to be our own type as opposed to Vec<Event>, but I think this would be best done in a followup, since deposit ABCI events are also recorded via apply().

Changes

  • Added new module fee_handler with trait FeeHandler and struct Fee.
  • Added trait bound FeeHandler to ActionHandler, and created new function check_execute_and_pay_fees(), which first calls check_and_execute() and then calls FeeHandler::calculate_and_pay_fees().
  • Moved all actions' fee handling from check_and_execute() to calculate_and_pay_fees().
  • Changed block fee read/writes on the state delta to use the ephemeral cache with Vec<Fee>. This allows for end_block() to still pay out all fees at the end of the block, and create fee ABCI events at that time.

Testing

All previous tests passing.

Breaking Changelist

  • Changed block fees storage key, as it does not need to incorporate the asset name into the storage key anymore. This breaks the app:state_ext::storage_keys_are_unchanged snapshot

Related Issues

closes #1369
closes #1145
closes #1382

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Sep 19, 2024
@@ -1,14 +1,9 @@
use cnidarium::StateWrite;

/// This trait is a verbatim copy of `cnidarium_component::ActionHandler`.
Copy link
Contributor Author

@ethanoroshiba ethanoroshiba Sep 19, 2024

Choose a reason for hiding this comment

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

Deleted comment because this didn't seem like a super accurate representation of ActionHandler anymore, but can revert if others disagree.

.wrap_err("failed to add to block fees")?;
state
.decrease_balance(self.bridge_address, &self.fee_asset, fee)
.decrease_balance(from, &self.fee_asset, fee)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should bridge sudo change action be deducting the fee from the signer as opposed to the bridge address?

@ethanoroshiba ethanoroshiba marked this pull request as ready for review September 19, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
1 participant