Skip to content

Commit

Permalink
Add Tx Pool in settlement submission (#235)
Browse files Browse the repository at this point in the history
* Add Tx Pool in settlement submission
  • Loading branch information
sunce86 authored Jun 8, 2022
1 parent 17f44fd commit 79cba9c
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 421 deletions.
10 changes: 4 additions & 6 deletions crates/e2e/tests/e2e/eth_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use solver::{
metrics::NoopMetrics,
settlement_access_list::{create_priority_estimator, AccessListEstimatorType},
settlement_submission::{
submitter::custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
SolutionSubmitter, StrategyArgs,
submitter::custom_nodes_api::CustomNodesApi, GlobalTxPool, SolutionSubmitter, StrategyArgs,
},
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -202,6 +201,7 @@ async fn eth_integration(web3: Web3) {
zeroex_liquidity: None,
};
let network_id = web3.net().version().await.unwrap();
let submitted_transactions = GlobalTxPool::default();
let mut driver = solver::driver::Driver::new(
contracts.gp_settlement.clone(),
liquidity_collector,
Expand All @@ -227,12 +227,10 @@ async fn eth_integration(web3: Web3) {
retry_interval: Duration::from_secs(5),
transaction_strategies: vec![
solver::settlement_submission::TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
PendingTransactionConfig::Ignore,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}),
],
access_list_estimator: Arc::new(
Expand Down
10 changes: 4 additions & 6 deletions crates/e2e/tests/e2e/onchain_settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use solver::{
metrics::NoopMetrics,
settlement_access_list::{create_priority_estimator, AccessListEstimatorType},
settlement_submission::{
submitter::custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
SolutionSubmitter, StrategyArgs,
submitter::custom_nodes_api::CustomNodesApi, GlobalTxPool, SolutionSubmitter, StrategyArgs,
},
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -207,6 +206,7 @@ async fn onchain_settlement(web3: Web3) {
zeroex_liquidity: None,
};
let network_id = web3.net().version().await.unwrap();
let submitted_transactions = GlobalTxPool::default();
let mut driver = solver::driver::Driver::new(
contracts.gp_settlement.clone(),
liquidity_collector,
Expand All @@ -232,12 +232,10 @@ async fn onchain_settlement(web3: Web3) {
retry_interval: Duration::from_secs(5),
transaction_strategies: vec![
solver::settlement_submission::TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
PendingTransactionConfig::Ignore,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}),
],
access_list_estimator: Arc::new(
Expand Down
10 changes: 4 additions & 6 deletions crates/e2e/tests/e2e/settlement_without_onchain_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use solver::{
metrics::NoopMetrics,
settlement_access_list::{create_priority_estimator, AccessListEstimatorType},
settlement_submission::{
submitter::custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
SolutionSubmitter, StrategyArgs,
submitter::custom_nodes_api::CustomNodesApi, GlobalTxPool, SolutionSubmitter, StrategyArgs,
},
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -196,6 +195,7 @@ async fn onchain_settlement_without_liquidity(web3: Web3) {
decimals: 18,
}
});
let submitted_transactions = GlobalTxPool::default();
let mut driver = solver::driver::Driver::new(
contracts.gp_settlement.clone(),
liquidity_collector,
Expand All @@ -221,12 +221,10 @@ async fn onchain_settlement_without_liquidity(web3: Web3) {
retry_interval: Duration::from_secs(5),
transaction_strategies: vec![
solver::settlement_submission::TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
PendingTransactionConfig::Ignore,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}),
],
access_list_estimator: Arc::new(
Expand Down
10 changes: 4 additions & 6 deletions crates/e2e/tests/e2e/smart_contract_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use solver::{
metrics::NoopMetrics,
settlement_access_list::{create_priority_estimator, AccessListEstimatorType},
settlement_submission::{
submitter::custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
SolutionSubmitter, StrategyArgs,
submitter::custom_nodes_api::CustomNodesApi, GlobalTxPool, SolutionSubmitter, StrategyArgs,
},
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -165,6 +164,7 @@ async fn smart_contract_orders(web3: Web3) {
zeroex_liquidity: None,
};
let network_id = web3.net().version().await.unwrap();
let submitted_transactions = GlobalTxPool::default();
let mut driver = solver::driver::Driver::new(
contracts.gp_settlement.clone(),
liquidity_collector,
Expand All @@ -190,12 +190,10 @@ async fn smart_contract_orders(web3: Web3) {
retry_interval: Duration::from_secs(5),
transaction_strategies: vec![
solver::settlement_submission::TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
PendingTransactionConfig::Ignore,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}),
],
access_list_estimator: Arc::new(
Expand Down
10 changes: 4 additions & 6 deletions crates/e2e/tests/e2e/vault_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use solver::{
metrics::NoopMetrics,
settlement_access_list::{create_priority_estimator, AccessListEstimatorType},
settlement_submission::{
submitter::custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
SolutionSubmitter, StrategyArgs,
submitter::custom_nodes_api::CustomNodesApi, GlobalTxPool, SolutionSubmitter, StrategyArgs,
},
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -146,6 +145,7 @@ async fn vault_balances(web3: Web3) {
zeroex_liquidity: None,
};
let network_id = web3.net().version().await.unwrap();
let submitted_transactions = GlobalTxPool::default();
let mut driver = solver::driver::Driver::new(
contracts.gp_settlement.clone(),
liquidity_collector,
Expand All @@ -171,12 +171,10 @@ async fn vault_balances(web3: Web3) {
retry_interval: Duration::from_secs(5),
transaction_strategies: vec![
solver::settlement_submission::TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
PendingTransactionConfig::Ignore,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}),
],
access_list_estimator: Arc::new(
Expand Down
1 change: 0 additions & 1 deletion crates/solver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod liquidity;
pub mod liquidity_collector;
pub mod metrics;
pub mod orderbook;
pub mod pending_transactions;
pub mod settlement;
pub mod settlement_access_list;
pub mod settlement_post_processing;
Expand Down
25 changes: 9 additions & 16 deletions crates/solver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ use solver::{
settlement_simulation::TenderlyApi,
settlement_submission::{
submitter::{
custom_nodes_api::{CustomNodesApi, PendingTransactionConfig},
eden_api::EdenApi,
flashbots_api::FlashbotsApi,
custom_nodes_api::CustomNodesApi, eden_api::EdenApi, flashbots_api::FlashbotsApi,
},
SolutionSubmitter, StrategyArgs, TransactionStrategy,
GlobalTxPool, SolutionSubmitter, StrategyArgs, TransactionStrategy,
},
solver::{ExternalSolverArg, SolverAccountArg, SolverType},
};
Expand Down Expand Up @@ -310,10 +308,6 @@ struct Arguments {
/// in the settlement are checked for price deviation.
#[clap(long, env, use_value_delimiter = true)]
token_list_restriction_for_price_checks: Option<Vec<H160>>,

/// How pending transactions should be fetched.
#[clap(long, env, arg_enum, default_value = "ignore")]
pending_transaction_config: PendingTransactionConfig,
}

#[derive(Copy, Clone, Debug, clap::ArgEnum)]
Expand Down Expand Up @@ -567,17 +561,16 @@ async fn main() {
"network id of custom node doesn't match main node"
);
}
let submitted_transactions = GlobalTxPool::default();
let mut transaction_strategies = vec![];
for strategy in args.transaction_strategy {
match strategy {
TransactionStrategyArg::PublicMempool => {
transaction_strategies.push(TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
vec![web3.clone()],
args.pending_transaction_config,
)),
submit_api: Box::new(CustomNodesApi::new(vec![web3.clone()])),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}))
}
TransactionStrategyArg::Eden => {
Expand All @@ -587,6 +580,7 @@ async fn main() {
),
max_additional_tip: args.max_additional_eden_tip,
additional_tip_percentage_of_max_fee: args.additional_tip_percentage,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}))
}
TransactionStrategyArg::Flashbots => {
Expand All @@ -597,6 +591,7 @@ async fn main() {
),
max_additional_tip: args.max_additional_flashbot_tip,
additional_tip_percentage_of_max_fee: args.additional_tip_percentage,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}))
}
}
Expand All @@ -606,12 +601,10 @@ async fn main() {
"missing transaction submission nodes"
);
transaction_strategies.push(TransactionStrategy::CustomNodes(StrategyArgs {
submit_api: Box::new(CustomNodesApi::new(
submission_nodes.clone(),
args.pending_transaction_config,
)),
submit_api: Box::new(CustomNodesApi::new(submission_nodes.clone())),
max_additional_tip: 0.,
additional_tip_percentage_of_max_fee: 0.,
sub_tx_pool: submitted_transactions.add_sub_pool(),
}))
}
TransactionStrategyArg::DryRun => {
Expand Down
Loading

0 comments on commit 79cba9c

Please sign in to comment.