Skip to content

Commit

Permalink
chore: relayers (#1419)
Browse files Browse the repository at this point in the history
* fix bin for relayers

* fmt
  • Loading branch information
greged93 authored Sep 30, 2024
1 parent e162c11 commit 890c7e9
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 104 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ katana-primitives = { git = 'https://github.com/dojoengine/dojo', rev = "7ff6593
"serde",
], optional = true }
mockall = { version = "0.13.0", default-features = false, optional = true }
clap = { version = "4.5.17", optional = true }
clap = { version = "4.5.17" }


starknet_api = { version = "0.13.0-rc.0", optional = true }
Expand Down Expand Up @@ -209,7 +209,6 @@ testing = [
"revm-primitives",
"starknet-crypto",
]
binaries = ["clap"]
hive = []
arbitrary = ["rand", "dep:arbitrary"]

Expand All @@ -219,8 +218,8 @@ required-features = ["testing"]

[[bin]]
name = "hive_genesis"
required-features = ["testing", "binaries"]
required-features = ["testing"]

[[bin]]
name = "hive_chain"
required-features = ["testing", "binaries"]
required-features = ["testing"]
4 changes: 2 additions & 2 deletions docker/hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ COPY --from=compiler /usr/src/compiler/.kakarot/artifacts /usr/src/rpc/.kakarot/
RUN cargo build \
--features hive --release --target-dir /usr/src/rpc/target && \
cargo build \
--bin hive_genesis --release --features "testing,binaries" --target-dir /usr/src/rpc/target && \
--bin hive_genesis --release --features "testing" --target-dir /usr/src/rpc/target && \
cargo build \
--bin hive_chain --release --features "testing,binaries" --target-dir /usr/src/rpc/target
--bin hive_chain --release --features "testing" --target-dir /usr/src/rpc/target

FROM ubuntu:24.10 as base
# Install any necessary dependencies
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::Parser;
use dotenvy::dotenv;
use eyre::Result;
use kakarot_rpc::{
Expand All @@ -11,10 +12,15 @@ use mongodb::options::{DatabaseOptions, ReadConcern, WriteConcern};
use opentelemetry_sdk::runtime::Tokio;
use reth_transaction_pool::PoolConfig;
use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient};
use std::{env::var, sync::Arc};
use std::{env::var, path::PathBuf, sync::Arc};
use tracing_opentelemetry::MetricsLayer;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};

#[derive(Parser)]
struct Cli {
accounts_path: PathBuf,
}

#[tokio::main]
async fn main() -> Result<()> {
// Environment variables are safe to use after this
Expand Down Expand Up @@ -77,7 +83,8 @@ async fn main() -> Result<()> {
}
#[cfg(not(feature = "hive"))]
{
AccountManager::new("./src/pool/accounts.json", Arc::clone(&eth_client)).await?
let args = Cli::parse();
AccountManager::new(args.accounts_path, Arc::clone(&eth_client)).await?
}
};
account_manager.start();
Expand Down
92 changes: 0 additions & 92 deletions src/pool/accounts.json

This file was deleted.

7 changes: 3 additions & 4 deletions src/pool/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use starknet::{
core::types::{BlockTag, Felt},
providers::{jsonrpc::HttpTransport, JsonRpcClient},
};
use std::{collections::HashMap, fs::File, io::Read, str::FromStr, sync::Arc, time::Duration};
use std::{collections::HashMap, fs::File, io::Read, path::PathBuf, str::FromStr, sync::Arc, time::Duration};
use tokio::sync::Mutex;

/// A type alias for the Kakarot Transaction Validator.
Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct AccountManager<SP: starknet::providers::Provider + Send + Sync + Clon

impl<SP: starknet::providers::Provider + Send + Sync + Clone + 'static> AccountManager<SP> {
/// Creates a new [`AccountManager`] instance by initializing account data from a JSON file.
pub async fn new(path: &str, eth_client: Arc<EthClient<SP>>) -> eyre::Result<Self> {
pub async fn new(path: PathBuf, eth_client: Arc<EthClient<SP>>) -> eyre::Result<Self> {
let mut accounts = HashMap::new();

// Open the file specified by `path`
Expand Down Expand Up @@ -368,8 +368,7 @@ mod tests {
write!(temp_file, "{json_data}").unwrap();

// Create an AccountManager instance with the temporary file
let account_manager =
AccountManager::new(temp_file.path().to_str().unwrap(), Arc::new(eth_client)).await.unwrap();
let account_manager = AccountManager::new(temp_file.path().to_path_buf(), Arc::new(eth_client)).await.unwrap();

// Verify that the accounts are loaded correctly
let accounts = account_manager.accounts;
Expand Down
92 changes: 92 additions & 0 deletions src/pool/staging_accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[
{
"address": "196811956655529464938870506963356417265254982755656721182220531581703691722"
},
{
"address": "21957093533996098199893735879676383136588679748311520227589168706310756352"
},
{
"address": "3156983370717363046107439255471720141779327817437045655686255812427584160473"
},
{
"address": "1266699859155881030745853831582690989288270820499403211360777706785321251524"
},
{
"address": "1383285862124284806198255017695143972155822358618284496274717006854914400434"
},
{
"address": "556622474269041273239978518722272168991994308790614400316179417436866885562"
},
{
"address": "863898040113600763634815654889111716414611996024493703975326561137637580397"
},
{
"address": "1049948733640154265069686452829912746649894206825640979196164127637122215704"
},
{
"address": "435094584583033448832295201512088425433478133620062714947210506762034497669"
},
{
"address": "3346228509229892705693151942978582777745110237359153985339946277086349208770"
},
{
"address": "940672080678076973284220857522811867751109665531403734530877519116610543631"
},
{
"address": "1153905432749985401265458683733499773022608046916287656285521728480507290626"
},
{
"address": "3239474275390657297685389416379959181890460903604840916970761026219042521373"
},
{
"address": "250213415159271018200527943072110142874471999830693008856604231562179598802"
},
{
"address": "2198280314339223222557092281776828065489416638847497213783499893084441097963"
},
{
"address": "3128048873093243381876638739685352454173062731516385990432861353508777886705"
},
{
"address": "1555828588265071115262743178862761512333590937219830474927477936652084904587"
},
{
"address": "1771170141088019121607099543715528103387743149193776509961998409196567829256"
},
{
"address": "1391138740407817780135845053928430177089762593084057844256920673963627467438"
},
{
"address": "867729030279064875529548689518070988175185922650816101519059977121980115724"
},
{
"address": "2242984317358998574195157522220615218790909801911372191666690443003473623640"
},
{
"address": "1332644935669106989468987587551966650897687168489438413314411798711369176245"
},
{
"address": "477452606747289630100801764512823550290143451527521169897857094721176773996"
},
{
"address": "3152299787013812409150951128071649069809927970379603418783350452667249428318"
},
{
"address": "2900219484813815244663452001325825033560729068581832394454919729462799825793"
},
{
"address": "3020030869193293942595440056191719689367143055447934973977689404209268663703"
},
{
"address": "396568809214101853914278146231211325536717896034045776470162047322020134406"
},
{
"address": "1701701142581572481335003412606291319941240723790422258957246134847335593845"
},
{
"address": "389430096329694827798034205258091031637534110544741892019394563550374910970"
},
{
"address": "2524233885883809884722481000086760329502676546916492443119822698758295241716"
}
]

0 comments on commit 890c7e9

Please sign in to comment.