-
Notifications
You must be signed in to change notification settings - Fork 87
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(sequencer): refactor fees #1739
Conversation
.ok_or_eyre( | ||
"fees not found for `ValidatorUpdate` action, hence it is disabled", | ||
)?; | ||
get_or_init_fees::<ValidatorUpdate, _, _>( |
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.
it doesn't look like there's a point to calling get_or_init_fees
in this action or any of the ones below that are feeless, as they don't update fees_by_asset
, which is the point of this function
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.
This was done so that the check would fail if the transaction would fail during execution (due to a given action not having fees). I think it may be worth it to keep this logic since it is used in mempool as well as check_and_execute
and may catch a failure-bound transaction before it gets executed.
Closing in favor of #1794 |
## Summary This reduces a lot of boilerplate around fees. ## Background The boilerplate code is very prone to copy-paste errors. Changing the 14 different (but structurally identical) `FeeComponent` structs into a single one with a generic arg reduces a lot of the boilerplate code. This PR replaces #1739 (an initial, more restricted refactor) and #1794 (a PR on top of #1739). It comprises the net changes of these two PRs in [the first commit](a8ec424), followed by most of the changes suggested by @eoroshiba's review of #1794 in [the second commit](c92dc98). [The third commit](1316e07) is also in response to @eoroshiba's suggestion to remove the fee aliases, and is a single commit in case others prefer that change to be reverted. ## Changes - In core, replaced fee component structs with a new `FeeComponents<T>` where `T` will be some action type. - In sequencer, changed the `FeeHandler` trait fairly radically to support the new form of fees. ## Testing Existing tests are sufficient - there should be no changed functionality to the business logic. ## Changelogs No updates required. ## Related Issues Closes #1715.
## Summary This reduces a lot of boilerplate around fees. ## Background The boilerplate code is very prone to copy-paste errors. Changing the 14 different (but structurally identical) `FeeComponent` structs into a single one with a generic arg reduces a lot of the boilerplate code. This PR replaces #1739 (an initial, more restricted refactor) and #1794 (a PR on top of #1739). It comprises the net changes of these two PRs in [the first commit](a8ec424), followed by most of the changes suggested by @eoroshiba's review of #1794 in [the second commit](c92dc98). [The third commit](1316e07) is also in response to @eoroshiba's suggestion to remove the fee aliases, and is a single commit in case others prefer that change to be reverted. ## Changes - In core, replaced fee component structs with a new `FeeComponents<T>` where `T` will be some action type. - In sequencer, changed the `FeeHandler` trait fairly radically to support the new form of fees. ## Testing Existing tests are sufficient - there should be no changed functionality to the business logic. ## Changelogs No updates required. ## Related Issues Closes #1715.
Summary
Added trait for fee components to allow generic usage of them.
Background
Previously, there was a lot of boilerplate required when testing fee components, since we are usually testing them for each and every action. Additionally, this introduces a lot of room for human error, since it's easy to mismatch an action and its associated methods. This change aims to rely more heavily on trait methods and helper functions, so that generic types can be used to eliminate boilerplate and room for error.
Changes
FeeComponents
trait and implemented it for all fee components.FeeHandler
trait.fees::query::get_fees_for_transaction
) to use helper functions with generic inputs.Testing
Passing all tests
Related Issues
closes #1715