-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Added blacklisting transaction on the TxPool
#1743
Merged
xgreenx
merged 3 commits into
release/v0.22.4
from
feature/support-blacklisting-on-txpool-level
Mar 9, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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,104 @@ | ||
//! Clap configuration related to consensus parameters | ||
use fuel_core::txpool::types::ContractId; | ||
use fuel_core_types::{ | ||
fuel_tx::{ | ||
Address, | ||
UtxoId, | ||
}, | ||
fuel_types::Nonce, | ||
}; | ||
|
||
#[derive(Debug, Clone, clap::Args)] | ||
pub struct TxPoolArgs { | ||
/// The max time to live of the transaction inside of the `TxPool`. | ||
#[clap(long = "tx-pool-ttl", default_value = "5m", env)] | ||
pub tx_pool_ttl: humantime::Duration, | ||
|
||
/// The max number of transactions that the `TxPool` can simultaneously store. | ||
#[clap(long = "tx-max-number", default_value = "4064", env)] | ||
pub tx_max_number: usize, | ||
|
||
/// The max depth of the dependent transactions that supported by the `TxPool`. | ||
#[clap(long = "tx-max-depth", default_value = "10", env)] | ||
pub tx_max_depth: usize, | ||
|
||
/// The maximum number of active subscriptions that supported by the `TxPool`. | ||
#[clap(long = "tx-number-active-subscriptions", default_value = "4064", env)] | ||
pub tx_number_active_subscriptions: usize, | ||
|
||
/// The list of banned addresses ignored by the `TxPool`. | ||
#[clap(long = "tx-blacklist-addresses", value_delimiter = ',', env)] | ||
pub tx_blacklist_addresses: Vec<Address>, | ||
|
||
/// The list of banned coins ignored by the `TxPool`. | ||
#[clap(long = "tx-blacklist-coins", value_delimiter = ',', env)] | ||
pub tx_blacklist_coins: Vec<UtxoId>, | ||
|
||
/// The list of banned messages ignored by the `TxPool`. | ||
#[clap(long = "tx-blacklist-messages", value_delimiter = ',', env)] | ||
pub tx_blacklist_messages: Vec<Nonce>, | ||
|
||
/// The list of banned contracts ignored by the `TxPool`. | ||
#[clap(long = "tx-blacklist-contracts", value_delimiter = ',', env)] | ||
pub tx_blacklist_contracts: Vec<ContractId>, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use clap::Parser; | ||
use fuel_core::txpool::config::BlackList; | ||
use test_case::test_case; | ||
|
||
#[derive(Debug, Clone, Parser)] | ||
pub struct Command { | ||
#[clap(flatten)] | ||
tx_pool: TxPoolArgs, | ||
} | ||
|
||
fn blacklist( | ||
a: Vec<Address>, | ||
c: Vec<UtxoId>, | ||
m: Vec<Nonce>, | ||
ct: Vec<ContractId>, | ||
) -> BlackList { | ||
BlackList::new(a, c, m, ct) | ||
} | ||
|
||
#[test_case(&[""] => Ok(blacklist(vec![], vec![], vec![], vec![])); "defaults works")] | ||
#[test_case(&["", "--tx-blacklist-addresses=\ | ||
0x0000000000000000000000000000000000000000000000000000000000000000,\ | ||
0101010101010101010101010101010101010101010101010101010101010101" | ||
] | ||
=> Ok(blacklist(vec![[0; 32].into(), [1; 32].into()], vec![], vec![], vec![])); "addresses works")] | ||
#[test_case(&["", "--tx-blacklist-coins=\ | ||
0x000000000000000000000000000000000000000000000000000000000000000002,\ | ||
010101010101010101010101010101010101010101010101010101010101010103" | ||
] | ||
=> Ok(blacklist(vec![], vec![UtxoId::new([0; 32].into(), 2), UtxoId::new([1; 32].into(), 3)], vec![], vec![])); "coins works")] | ||
#[test_case(&["", "--tx-blacklist-messages=\ | ||
0x0000000000000000000000000000000000000000000000000000000000000000,\ | ||
0101010101010101010101010101010101010101010101010101010101010101" | ||
] | ||
=> Ok(blacklist(vec![], vec![], vec![[0; 32].into(), [1; 32].into()], vec![])); "messages works")] | ||
#[test_case(&["", "--tx-blacklist-contracts=\ | ||
0x0000000000000000000000000000000000000000000000000000000000000000,\ | ||
0101010101010101010101010101010101010101010101010101010101010101" | ||
] | ||
=> Ok(blacklist(vec![], vec![], vec![], vec![[0; 32].into(), [1; 32].into()])); "contracts works")] | ||
fn parse(args: &[&str]) -> Result<BlackList, String> { | ||
let command: Command = | ||
Command::try_parse_from(args).map_err(|e| e.to_string())?; | ||
let args = command.tx_pool; | ||
|
||
let blacklist = blacklist( | ||
args.tx_blacklist_addresses, | ||
args.tx_blacklist_coins, | ||
args.tx_blacklist_messages, | ||
args.tx_blacklist_contracts, | ||
); | ||
|
||
Ok(blacklist) | ||
} | ||
} |
This file contains 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 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 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.
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.
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.
Where did the "4064" come from?
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.
looks like it was just copied over from before