Skip to content

Commit

Permalink
Add proto files for gRPC services and build script, link to architect…
Browse files Browse the repository at this point in the history
…ure blog, finish skeleton for uopool gRPC server
  • Loading branch information
Vid201 committed Nov 14, 2022
1 parent c73886b commit d1f09e4
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 103 deletions.
127 changes: 71 additions & 56 deletions Cargo.lock

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

15 changes: 11 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@ anyhow = "1"
async-trait = "0.1"
bytes = { version = "1", features = ["serde"] }
clap = { version = "4", features = ["derive"] }
educe = { version = "0.4", features = ["Debug", "Default"] }
ethereum-interfaces = { git = "https://github.com/ledgerwatch/interfaces" }
ethereum-types = { version = "0.14", features = ["codec"] }
ethers = "1.0.0"
expanded-pathbuf = "0.1"
jsonrpsee = { version = "0.15", features = ["server", "macros"] }
jsonrpsee = { version = "0.16", features = ["server", "macros"] }
prost = "0.11"
ron = "0.8"
serde = "1"
tokio = { version = "1.18", features = ["full"] }
tonic = { version = "0.8", default-features = false, features = [
"codegen",
"prost",
"transport",
"codegen",
"prost",
"transport",
] }
tracing = "0.1"
tracing-subscriber = "0.3"

[build-dependencies]
protobuf-src = "1.1.0"
prost-build = "0.11"
tonic-build = "0.8"

[[bin]]
path = "bin/bundler.rs"
name = "bundler"
Expand Down
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 ./src/res/bundler/0xD00D3EEc454D05d3d9bB48532BabED0c89941f17 --no-uopool --no-rpc
cargo run -- --mnemonic-file ./src/res/bundler/0xD00D3EEc454D05d3d9bB48532BabED0c89941f17

run-bundler-uopool:
cargo run --bin bundler-uopool
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<p align="center"><a href="https://huggingface.co/spaces/stabilityai/stable-diffusion">Stable Diffusion</a> prompt: ethereum bundler account abstraction rust vector logo<p>

For more information: https://hackmd.io/@Vid201/aa-bundler-rust

## How to run?

Bundler:
Expand Down
10 changes: 5 additions & 5 deletions bin/bundler-rpc.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use anyhow::Result;
use clap::Parser;
use jsonrpsee::{core::server::rpc_module::Methods, http_server::HttpServerBuilder, tracing::info};
use jsonrpsee::{core::server::rpc_module::Methods, server::ServerBuilder, tracing::info};
use std::future::pending;
use tracing_subscriber;

use aa_bundler::rpc::{eth::EthApiServerImpl, eth_api::EthApiServer};

#[derive(Parser)]
#[clap(
name = "AA - Bundler RPC",
name = "aa-bundler-rpc",
about = "RPC server for EIP-4337 Account Abstraction Bundler"
)]
pub struct Opt {
Expand All @@ -22,7 +22,7 @@ async fn main() -> Result<()> {

tracing_subscriber::fmt::init();

let http_server = HttpServerBuilder::default()
let jsonrpc_server = ServerBuilder::default()
.build(&opt.rpc_listen_address)
.await?;

Expand All @@ -35,8 +35,8 @@ async fn main() -> Result<()> {
)
.unwrap();

let _http_server_handle = http_server.start(api.clone())?;
info!("HTTP server listening on {}", opt.rpc_listen_address);
let _jsonrpc_server_handle = jsonrpc_server.start(api.clone())?;
info!("JSONRPC server listening on {}", opt.rpc_listen_address);

pending().await
}
24 changes: 7 additions & 17 deletions bin/bundler-uopool.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use anyhow::Result;
use clap::Parser;
use jsonrpsee::tracing::info;
use educe::Educe;
use std::future::pending;

#[derive(Parser)]
#[derive(Educe, Parser)]
#[clap(
name = "AA - Bundler UoPool",
name = "aa-bundler-uopool",
about = "User operation pool for EIP-4337 Account Abstraction Bundler"
)]
#[educe(Debug)]
pub struct Opt {
#[clap(long, default_value = "127.0.0.1:3001")]
pub grpc_listen_address: String,
#[clap(flatten)]
pub uopool_opts: aa_bundler::uopool::Opts,
}

#[tokio::main]
Expand All @@ -19,18 +20,7 @@ async fn main() -> Result<()> {

tracing_subscriber::fmt::init();

let mut builder = tonic::transport::Server::builder();
aa_bundler::uopool::run(opt.uopool_opts).await?;

#[cfg(feature = "grpc-reflection")]
builder.add_service(
tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(ethereum_interfaces::FILE_DESCRIPTOR_SET)
.build()
.unwrap(),
);

println!("{:?}", builder);

info!("gRPC server listening on {}", opt.grpc_listen_address);
pending().await
}
Loading

0 comments on commit d1f09e4

Please sign in to comment.