Skip to content

Commit

Permalink
Merge pull request #23 from Vid201/feat/uopool
Browse files Browse the repository at this point in the history
cleanup and renaming
  • Loading branch information
Vid201 authored Dec 5, 2022
2 parents 937e8c1 + a210193 commit d301382
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run-bundler:
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3 --beneficiary 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990 --gas-factor 600 --min-balance 1 --entry-point 0x0000000000000000000000000000000000000000 --helper 0x0000000000000000000000000000000000000000

run-bundler-uopool:
cargo run --bin bundler-uopool
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cargo run --bin create-wallet -- --output-path ${HOME}/.aa-bundler
Run bundler (with user operation pool and JSON-RPC API):

```bash
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3 --beneficiary 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990 --gas-factor 600 --min-balance 1 --entry-point 0x0000000000000000000000000000000000000000 --helper 0x0000000000000000000000000000000000000000
```

Run only user operation pool:
Expand Down
2 changes: 1 addition & 1 deletion bin/bundler-uopool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::future::pending;
#[educe(Debug)]
pub struct Opt {
#[clap(flatten)]
pub uopool_opts: aa_bundler::uopool::Opts,
pub uopool_opts: aa_bundler::uopool::UoPoolOpts,
}

#[tokio::main]
Expand Down
10 changes: 4 additions & 6 deletions bin/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ pub struct Opt {
#[clap(long)]
pub mnemonic_file: ExpandedPathBuf,

// #[clap(long, default_value = "127.0.0.1:3000")]
// pub grpc_listen_address: String,
#[clap(long)]
pub no_uopool: bool,

#[clap(flatten)]
pub uopool_opts: aa_bundler::uopool::Opts,
pub uopool_opts: aa_bundler::uopool::UoPoolOpts,

#[clap(long)]
pub no_rpc: bool,
Expand All @@ -33,11 +31,11 @@ pub struct Opt {
pub rpc_listen_address: String,

// execution client rpc endpoint
#[clap(long)]
#[clap(long, default_value = "127.0.0.1:8545")]
pub eth_client_address: SocketAddr,

#[clap(flatten)]
pub bundler_opts: aa_bundler::bundler::Opts,
pub bundler_opts: aa_bundler::bundler::BundlerOpts,
}

fn main() -> Result<()> {
Expand All @@ -59,7 +57,7 @@ fn main() -> Result<()> {
let wallet = Wallet::from_file(opt.mnemonic_file);
info!("{:?}", wallet.signer);

let bundler = Bundler::new(wallet);
let _bundler = Bundler::new(wallet);

if !opt.no_uopool {
aa_bundler::uopool::run(opt.uopool_opts).await?;
Expand Down
19 changes: 11 additions & 8 deletions src/bundler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use clap::Parser;
use ethers::types::{Address, U256};

#[derive(Debug, Parser, PartialEq)]
pub struct Opts {
pub struct BundlerOpts {
#[clap(long, value_parser=parse_address)]
pub beneficiary: Address,

Expand All @@ -21,6 +21,9 @@ pub struct Opts {

#[clap(long, value_parser=parse_address)]
pub helper: Address,

#[clap(long, default_value = "127.0.0.1:3000")]
pub bundler_grpc_listen_address: String,
}

fn parse_address(s: &str) -> Result<Address, String> {
Expand All @@ -33,10 +36,7 @@ fn parse_u256(s: &str) -> Result<U256, String> {

#[cfg(test)]
mod test {
use super::Opts;
use clap::Parser;
use ethereum_types::{Address, U256};
use std::str::FromStr;
use super::*;

#[test]
fn bundle_opt() {
Expand All @@ -52,17 +52,20 @@ mod test {
"0x0000000000000000000000000000000000000000",
"--helper",
"0x0000000000000000000000000000000000000000",
"--bundler-grpc-listen-address",
"127.0.0.1:3000",
];
assert_eq!(
Opts {
BundlerOpts {
beneficiary: Address::from_str("0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990")
.unwrap(),
gas_factor: U256::from(600),
min_balance: U256::from(1),
entry_point: Address::from([0; 20]),
helper: Address::from([0; 20])
helper: Address::from([0; 20]),
bundler_grpc_listen_address: String::from("127.0.0.1:3000")
},
Opts::try_parse_from(args).unwrap()
BundlerOpts::try_parse_from(args).unwrap()
);
}
}
6 changes: 3 additions & 3 deletions src/contracts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ethers::prelude::*;
use ethers::contract::abigen;

abigen!(
AggregatedWallet,
AggregatedAccount,
"$OUT_DIR/IAggregatedAccount.sol/IAggregatedAccount.json"
);

Expand All @@ -21,7 +21,7 @@ abigen!(
"$OUT_DIR/IStakeManager.sol/IStakeManager.json"
);

abigen!(Wallet, "$OUT_DIR/IAccount.sol/IAccount.json");
abigen!(Account, "$OUT_DIR/IAccount.sol/IAccount.json");

abigen!(
UserOperation,
Expand Down
10 changes: 5 additions & 5 deletions src/uopool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ impl UserOperationPool {

#[derive(Educe, Parser)]
#[educe(Debug)]
pub struct Opts {
pub struct UoPoolOpts {
#[clap(long, default_value = "127.0.0.1:3001")]
pub grpc_listen_address: SocketAddr,
pub uopool_grpc_listen_address: SocketAddr,
}

pub async fn run(opts: Opts) -> Result<()> {
pub async fn run(opts: UoPoolOpts) -> Result<()> {
tokio::spawn(async move {
let mut builder = tonic::transport::Server::builder();
let svc = UoPoolServer::new(UoPoolService::new(Arc::new(UserOperationPool::new())));

info!(
"UoPool gRPC server starting on {}",
opts.grpc_listen_address
opts.uopool_grpc_listen_address
);

builder
.add_service(svc)
.serve(opts.grpc_listen_address)
.serve(opts.uopool_grpc_listen_address)
.await
.unwrap();
});
Expand Down
4 changes: 2 additions & 2 deletions src/uopool/services/uopool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use async_trait::async_trait;
use tonic::Response;

pub struct UoPoolService {
uo_pool: Arc<UserOperationPool>,
_uo_pool: Arc<UserOperationPool>,
}

impl UoPoolService {
pub fn new(uo_pool: Arc<UserOperationPool>) -> Self {
Self { uo_pool }
Self { _uo_pool: uo_pool }
}
}

Expand Down

0 comments on commit d301382

Please sign in to comment.