Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
58 changes: 58 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test & Lint CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Rust CI Checks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
run: |
cargo fmt --all -- --check
if [ $? -ne 0 ]; then
echo "::error::Code is not formatted. Please run 'cargo fmt' locally."
exit 1
fi

- name: Run clippy
run: |
cargo clippy --all --all-targets -- -D warnings
if [ $? -ne 0 ]; then
echo "::error::Clippy found issues. Please fix them locally."
exit 1
fi

- name: Run tests
run: |
cargo test --all
if [ $? -ne 0 ]; then
echo "::error::Tests failed. Please fix them locally."
exit 1
fi
107 changes: 105 additions & 2 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ rayon = "1.10.0"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
once_cell = "1"

#rocksdb
rocksdb = "0.23.0"

# todo: replace it with toml
serde_yaml = "0.9.34"
21 changes: 21 additions & 0 deletions bin/searcher-reth/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#[macro_export]
macro_rules! install_strategy {
(
$builder:expr,
$config:expr,
$wallet:expr,
$signal_manager:expr,
$exex_id:expr,
$strategy_type:ty
) => {{
use searcher_reth_extension::strategy::core::strategy::Strategy;

let cfg = $config.read().unwrap().get_strategy($exex_id).unwrap();
let strategy = <$strategy_type>::new(cfg);
let searcher_exex = searcher_reth_extension::exex::SearcherExEx::new(
$wallet.clone(),
$signal_manager.subscribe(),
);
$builder.install_exex($exex_id, move |ctx| searcher_exex.run(ctx, strategy))
}};
}
40 changes: 24 additions & 16 deletions bin/searcher-reth/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
mod macros;

use std::sync::{Arc, RwLock};

use clap::Parser;
use reth::chainspec::EthereumChainSpecParser;
use reth_node_ethereum::EthereumNode;
use reth_tracing::tracing::error;
use searcher_reth_extension::{
exex::SearcherExEx,
relayer_pool::WalletPool,
strategy::{
core::strategy::Strategy, path_finding::PathFinder, profit_reporter::init_reporter,
},
strategy::{liquidator::Liquidator, path_finding::PathFinder, profit_reporter::init_reporter},
util::signal_manager::SignalManager,
};
use searcher_reth_manager::{common::PATH_FINDER_EXEX_ID, manager::ConfigManager};
use searcher_reth_manager::{
common::{LIQUIDATOR_EXEX_ID, PATH_FINDER_EXEX_ID},
manager::ConfigManager,
};

fn main() -> eyre::Result<()> {
let config = Arc::new(RwLock::new(ConfigManager::from_file("env.toml")?));
Expand All @@ -33,18 +35,24 @@ fn main() -> eyre::Result<()> {
std::process::exit(0);
});

// Install Exex for various strategies
let searcher_exex = SearcherExEx::new(wallet, signal_manager.subscribe());
// Install strategies
let mut node_builder = builder.node(EthereumNode::default());

// Install PathFinder strategy
node_builder = node_builder.install_exex(PATH_FINDER_EXEX_ID, {
let path_finder_cfg =
config.clone().read().unwrap().get_strategy(PATH_FINDER_EXEX_ID).unwrap();
let path_finder = PathFinder::new(path_finder_cfg);
move |ctx| searcher_exex.run(ctx, path_finder)
});

node_builder = install_strategy!(
node_builder,
config,
wallet,
signal_manager,
PATH_FINDER_EXEX_ID,
PathFinder
);
node_builder = install_strategy!(
node_builder,
config,
wallet,
signal_manager,
LIQUIDATOR_EXEX_ID,
Liquidator
);
// TODO: Add other strategies here as needed
let handle = node_builder.launch().await?;
handle.wait_for_node_exit().await
Expand Down
3 changes: 1 addition & 2 deletions crates/extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ searcher-reth-strategy.workspace = true
searcher-reth-manager.workspace = true

rayon.workspace = true
reth-transaction-pool.workspace = true

reth-transaction-pool.workspace = true
3 changes: 1 addition & 2 deletions crates/extension/src/exex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{future::Future, sync::Arc};

use crate::relayer_pool::{RelayerMessage, RelayerPool, WalletPool};
use eyre::Result;
use futures_util::StreamExt;
use reth::network::NetworkInfo;
Expand All @@ -15,8 +16,6 @@ use searcher_reth_manager::SignalType;
use searcher_reth_strategy::core::strategy::Strategy;
use tokio::sync::broadcast;

use crate::relayer_pool::{RelayerMessage, RelayerPool, WalletPool};

pub struct SearcherExEx {
pub wallet: Arc<WalletPool>,
pub signal_rx: broadcast::Receiver<SignalType>,
Expand Down
2 changes: 2 additions & 0 deletions crates/manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ alloy-primitives.workspace = true
reth-revm.workspace = true
serde_json.workspace = true
alloy-serde = "1.0.20"
rocksdb.workspace = true
serde_yaml.workspace = true
Loading
Loading