Skip to content

Commit

Permalink
feat(sequencer)!: rework all fees (#1647)
Browse files Browse the repository at this point in the history
## 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

---------

Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
Co-authored-by: Fraser Hutchison <fraser@astria.org>
Co-authored-by: Jordan Oroshiba <jordan@astria.org>
  • Loading branch information
4 people authored Oct 15, 2024
1 parent 10441af commit b677ce9
Show file tree
Hide file tree
Showing 118 changed files with 7,209 additions and 3,409 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions charts/sequencer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.23.2
version: 0.24.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.17.0"
appVersion: "0.18.0"

dependencies:
- name: sequencer-relayer
Expand Down
73 changes: 66 additions & 7 deletions charts/sequencer/files/cometbft/config/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,72 @@
"app_state": {
"native_asset_base_denomination": "{{ .Values.genesis.nativeAssetBaseDenomination }}",
"fees": {
"transfer_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.transferBaseFee }},
"sequence_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequenceBaseFee }},
"sequence_byte_cost_multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequenceByteCostMultiplier }},
"init_bridge_account_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.initBridgeAccountBaseFee }},
"bridge_lock_byte_cost_multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeLockByteCostMultiplier }},
"bridge_sudo_change_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeSudoChangeFee }},
"ics20_withdrawal_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ics20WithdrawalBaseFee }}
{{- if not .Values.global.dev }}
"transfer_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.transfer.base }},
"sequence_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequence.base }},
"sequence_byte_cost_multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequence.multiplier }},
"init_bridge_account_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.initBridgeAccount.base }},
"bridge_lock_byte_cost_multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeLock.multiplier }},
"bridge_sudo_change_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeSudoChange.base }},
"ics20_withdrawal_base_fee": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ics20Withdrawal.base }}
{{- else }}
"bridge_lock": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeLock.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeLock.multiplier }}
},
"bridge_sudo_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeSudoChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeSudoChange.multiplier }}
},
"bridge_unlock": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeUnlock.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.bridgeUnlock.multiplier }}
},
"fee_asset_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.feeAssetChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.feeAssetChange.multiplier }}
},
"fee_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.feeChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.feeChange.multiplier }}
},
"ibc_relay": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcRelay.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcRelay.multiplier }}
},
"ibc_relayer_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcRelayerChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcRelayerChange.multiplier }}
},
"ibc_sudo_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcSudoChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ibcSudoChange.multiplier }}
},
"ics20_withdrawal": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ics20Withdrawal.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.ics20Withdrawal.multiplier }}
},
"init_bridge_account": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.initBridgeAccount.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.initBridgeAccount.multiplier }}
},
"sequence": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequence.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sequence.multiplier }}
},
"sudo_address_change": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sudoAddressChange.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.sudoAddressChange.multiplier }}
},
"transfer": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.transfer.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.transfer.multiplier }}
},
"validator_update": {
"base": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.validatorUpdate.base }},
"multiplier": {{ include "sequencer.toUint128Proto" .Values.genesis.fees.validatorUpdate.multiplier }}
}
{{- end }}
},
"allowed_fee_assets": [
{{- range $index, $value := .Values.genesis.allowedFeeAssets }}
Expand Down
51 changes: 43 additions & 8 deletions charts/sequencer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ images:
sequencer:
repo: ghcr.io/astriaorg/sequencer
pullPolicy: IfNotPresent
tag: "0.17.0"
tag: "0.18.0"
devTag: latest

moniker: ""
Expand Down Expand Up @@ -56,13 +56,48 @@ genesis:
maxBytes: "1048576"

fees:
transferBaseFee: "12"
sequenceBaseFee: "32"
sequenceByteCostMultiplier: "1"
initBridgeAccountBaseFee: "48"
bridgeLockByteCostMultiplier: "1"
bridgeSudoChangeFee: "24"
ics20WithdrawalBaseFee: "24"
bridgeLock:
base: "0"
multiplier: "1"
bridgeSudoChange:
base: "24"
multiplier: "0"
bridgeUnlock:
base: "0"
multiplier: "0"
feeAssetChange:
base: "0"
multiplier: "0"
feeChange:
base: "0"
multiplier: "0"
ibcRelay:
base: "0"
multiplier: "0"
ibcRelayerChange:
base: "0"
multiplier: "0"
ibcSudoChange:
base: "0"
multiplier: "0"
ics20Withdrawal:
base: "24"
multiplier: "0"
initBridgeAccount:
base: "48"
multiplier: "0"
sequence:
base: "32"
multiplier: "1"
sudoAddressChange:
base: "0"
multiplier: "0"
transfer:
base: "12"
multiplier: "0"
validatorUpdate:
base: "0"
multiplier: "0"

validators: []
# - name: core
Expand Down
Loading

0 comments on commit b677ce9

Please sign in to comment.