-
Notifications
You must be signed in to change notification settings - Fork 382
Send priority fees to collators #3120
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
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ae79201
feat: send eth tips to collator
TarekkMA ae978b8
style: fix import order
TarekkMA 903a8a8
fix: tests
TarekkMA 35fe6d2
fix: tests
TarekkMA 059436a
style: fix formatting
TarekkMA 1d80e0a
test: fix test
TarekkMA 0835677
test: fix test
TarekkMA 051d628
style: formatting
TarekkMA da52ecb
fix: test
TarekkMA 1fb8015
fix: test
TarekkMA a286912
fix: test
TarekkMA 71f0618
fix: parameters tests.
TarekkMA 188676a
fix: contract tests.
TarekkMA 0926425
fix: fix test-eth-pool-resubmit-txn.ts
TarekkMA 12631ff
fix: fix test-eth-pool-error.ts
TarekkMA 794001f
fix: Update balance transfer tests to use CHARLETH_ADDRESS in tests
TarekkMA bc8d687
style: fix
TarekkMA c6e887e
fix: Refactor xtokens test and disable tip fee burning
TarekkMA 7ee98f5
fix: fix test-contract tests
TarekkMA 66aff79
fix: commands in update-local-types
TarekkMA 6ca5fce
refactor: fee calculation logic and improve modularity.
TarekkMA ebb4cf8
fix: FeesTreasuryProportion test logic and helpers
TarekkMA 5b5cb0a
fix: argument order in calculateFeePortions function call
TarekkMA 822c78e
test: Add verification for latest block fees and add a check for tips.
TarekkMA ccd3df9
refactor: separate fee and tip calculation
TarekkMA 0b3adaf
fix: fee and tip handling logic for clarity and correctness
TarekkMA f7c64c9
refactor: clean up unused imports in Moonbeam runtime
TarekkMA 8d71ba8
style: correct indentation in runtime lib.rs
TarekkMA 0b11025
test: also check LatestBlockFees in eth transactions
TarekkMA 42e0a69
tmp: check if all tests pass
TarekkMA 6a0346b
refactor: remove unnecessary console logs in tests
TarekkMA 7b16ab2
tmp: change default value
TarekkMA 62301d1
Revert "tmp: change default value"
TarekkMA fdab76f
tmp: change default value
TarekkMA 56b62d3
tmp: change default value
TarekkMA df28273
test: add comment explaining test file
TarekkMA fabaa99
Revert "tmp: change default value"
TarekkMA c41ed41
Revert "tmp: change default value"
TarekkMA e3b5c3d
feature: send substrate tips to block author
TarekkMA f623e04
fix: incorrect generics
TarekkMA 4392ec1
style: fix formatting
TarekkMA 213b022
test: refine fee and tip handling logic for runtime tests
TarekkMA 58bca06
test(runtime): fix incorrect runtime references in tests
TarekkMA 3fdb11d
refactor: move all deal with fees logic into common crate
TarekkMA f53feb5
refactor: remove unused imports
TarekkMA 7001e14
style: add copyright
TarekkMA c199943
Update runtime/common/src/deal_with_fees.rs
RomarQ 0980453
test: fix test
TarekkMA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // Copyright 2024 Moonbeam foundation | ||
| // This file is part of Moonbeam. | ||
|
|
||
| // Moonbeam is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Moonbeam is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Moonbeam. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| use frame_support::__private::Get; | ||
| use frame_support::pallet_prelude::TypedGet; | ||
| use frame_support::traits::fungible::Credit; | ||
| use frame_support::traits::tokens::imbalance::ResolveTo; | ||
| use frame_support::traits::Imbalance; | ||
| use frame_support::traits::OnUnbalanced; | ||
| use pallet_treasury::TreasuryAccountId; | ||
| use sp_runtime::Perbill; | ||
|
|
||
| /// Deal with substrate based fees and tip. This should be used with pallet_transaction_payment. | ||
| pub struct DealWithSubstrateFeesAndTip<R, FeesTreasuryProportion>( | ||
| sp_std::marker::PhantomData<(R, FeesTreasuryProportion)>, | ||
| ); | ||
| impl<R, FeesTreasuryProportion> DealWithSubstrateFeesAndTip<R, FeesTreasuryProportion> | ||
| where | ||
| R: pallet_balances::Config + pallet_treasury::Config + pallet_author_inherent::Config, | ||
| pallet_author_inherent::Pallet<R>: Get<R::AccountId>, | ||
| FeesTreasuryProportion: Get<Perbill>, | ||
| { | ||
| fn deal_with_fees(amount: Credit<R::AccountId, pallet_balances::Pallet<R>>) { | ||
| // Balances pallet automatically burns dropped Credits by decreasing | ||
| // total_supply accordingly | ||
| let treasury_proportion = FeesTreasuryProportion::get(); | ||
| let treasury_part = treasury_proportion.deconstruct(); | ||
| let burn_part = Perbill::one().deconstruct() - treasury_part; | ||
| let (_, to_treasury) = amount.ration(burn_part, treasury_part); | ||
| ResolveTo::<TreasuryAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(to_treasury); | ||
| } | ||
|
|
||
| fn deal_with_tip(amount: Credit<R::AccountId, pallet_balances::Pallet<R>>) { | ||
| ResolveTo::<BlockAuthorAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(amount); | ||
| } | ||
| } | ||
|
|
||
| impl<R, FeesTreasuryProportion> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> | ||
| for DealWithSubstrateFeesAndTip<R, FeesTreasuryProportion> | ||
| where | ||
| R: pallet_balances::Config + pallet_treasury::Config + pallet_author_inherent::Config, | ||
| pallet_author_inherent::Pallet<R>: Get<R::AccountId>, | ||
| FeesTreasuryProportion: Get<Perbill>, | ||
| { | ||
| fn on_unbalanceds( | ||
| mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pallet_balances::Pallet<R>>>, | ||
| ) { | ||
| if let Some(fees) = fees_then_tips.next() { | ||
| Self::deal_with_fees(fees); | ||
| if let Some(tip) = fees_then_tips.next() { | ||
| Self::deal_with_tip(tip); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Deal with ethereum based fees. To handle tips/priority fees, use DealWithEthereumPriorityFees. | ||
| pub struct DealWithEthereumBaseFees<R, FeesTreasuryProportion>( | ||
| sp_std::marker::PhantomData<(R, FeesTreasuryProportion)>, | ||
| ); | ||
| impl<R, FeesTreasuryProportion> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> | ||
| for DealWithEthereumBaseFees<R, FeesTreasuryProportion> | ||
| where | ||
| R: pallet_balances::Config + pallet_treasury::Config, | ||
| FeesTreasuryProportion: Get<Perbill>, | ||
| { | ||
| fn on_nonzero_unbalanced(amount: Credit<R::AccountId, pallet_balances::Pallet<R>>) { | ||
| // Balances pallet automatically burns dropped Credits by decreasing | ||
| // total_supply accordingly | ||
| let treasury_proportion = FeesTreasuryProportion::get(); | ||
| let treasury_part = treasury_proportion.deconstruct(); | ||
| let burn_part = Perbill::one().deconstruct() - treasury_part; | ||
| let (_, to_treasury) = amount.ration(burn_part, treasury_part); | ||
| ResolveTo::<TreasuryAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(to_treasury); | ||
| } | ||
| } | ||
|
|
||
| pub struct BlockAuthorAccountId<R>(sp_std::marker::PhantomData<R>); | ||
| impl<R> TypedGet for BlockAuthorAccountId<R> | ||
| where | ||
| R: frame_system::Config + pallet_author_inherent::Config, | ||
| pallet_author_inherent::Pallet<R>: Get<R::AccountId>, | ||
| { | ||
| type Type = R::AccountId; | ||
| fn get() -> Self::Type { | ||
| <pallet_author_inherent::Pallet<R> as Get<R::AccountId>>::get() | ||
| } | ||
| } | ||
|
|
||
| /// Deal with ethereum based priority fees/tips. See DealWithEthereumBaseFees for base fees. | ||
| pub struct DealWithEthereumPriorityFees<R>(sp_std::marker::PhantomData<R>); | ||
| impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> | ||
| for DealWithEthereumPriorityFees<R> | ||
| where | ||
| R: pallet_balances::Config + pallet_author_inherent::Config, | ||
| pallet_author_inherent::Pallet<R>: Get<R::AccountId>, | ||
| { | ||
| fn on_nonzero_unbalanced(amount: Credit<R::AccountId, pallet_balances::Pallet<R>>) { | ||
| ResolveTo::<BlockAuthorAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(amount); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.