Skip to content

Commit

Permalink
chore: move builder from grpc to uopool, refactor examples, storage e…
Browse files Browse the repository at this point in the history
…xamples
  • Loading branch information
Vid201 committed Oct 21, 2023
1 parent cbd6735 commit e8d1536
Show file tree
Hide file tree
Showing 21 changed files with 250 additions and 77 deletions.
58 changes: 40 additions & 18 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
"crates/primitives",
"crates/rpc",
"crates/uopool",
"examples",
"examples/*",
"tests",
]
default-members = ["bin/silius"]
Expand Down
1 change: 0 additions & 1 deletion crates/grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dashmap = "5.4.0"
ethers = { workspace = true }
expanded-pathbuf = { workspace = true }
eyre = { workspace = true }
futures-util = { workspace = true }
parking_lot = { workspace = true }
prost = "0.11"
serde_json = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion crates/grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(dead_code)]

mod builder;
mod bundler;
mod proto;
mod uopool;
Expand Down
3 changes: 1 addition & 2 deletions crates/grpc/src/uopool.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::proto::uopool::*;
use crate::{
builder::UoPoolBuilder,
proto::types::{GetChainIdResponse, GetSupportedEntryPointsResponse},
utils::{parse_addr, parse_hash, parse_uo},
};
Expand All @@ -20,7 +19,7 @@ use silius_uopool::{
};
use silius_uopool::{
mempool_id, validate::validator::StandardUserOperationValidator, MempoolId, Reputation,
UoPool as UserOperationPool,
UoPool as UserOperationPool, UoPoolBuilder,
};
use std::fmt::{Debug, Display};
use std::{net::SocketAddr, sync::Arc, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions crates/uopool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ educe = { version = "0.4", features = ["Debug", "Default"] }
enumset = "1.1.2"
ethers = { workspace = true }
eyre = { workspace = true }
futures-util = { workspace = true }
page_size = "0.5.0"
parking_lot = { workspace = true }
prost = "0.11"
Expand Down
8 changes: 4 additions & 4 deletions crates/grpc/src/builder.rs → crates/uopool/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use crate::{
validate::validator::StandardUserOperationValidator, Mempool, MempoolBox, Reputation,
ReputationBox, UoPool, VecCh, VecUo,
};
use ethers::{
providers::Middleware,
types::{Address, H256, U256},
Expand All @@ -14,10 +18,6 @@ use silius_primitives::{
reputation::ReputationEntry,
Chain, UserOperation,
};
use silius_uopool::{
validate::validator::StandardUserOperationValidator, Mempool, MempoolBox, Reputation,
ReputationBox, UoPool, VecCh, VecUo,
};
use std::sync::Arc;
use std::{
fmt::{Debug, Display},
Expand Down
2 changes: 2 additions & 0 deletions crates/uopool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The UserOperation alternative mempool implementation according to the [ERC-4337 specifications](https://eips.ethereum.org/EIPS/eip-4337#Alternative%20Mempools).
#![allow(dead_code)]

mod builder;
mod database;
mod memory;
mod mempool;
Expand All @@ -9,6 +10,7 @@ mod uopool;
mod utils;
pub mod validate;

pub use builder::UoPoolBuilder;
pub use database::{
init_env, mempool::DatabaseMempool, reputation::DatabaseReputation, DBError, WriteMap,
};
Expand Down
2 changes: 2 additions & 0 deletions crates/uopool/src/validate/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ where
.with_sanity_check(Paymaster)
.with_sanity_check(Entities)
.with_sanity_check(UnstakedEntities)
.with_simulation_check(Signature)
.with_simulation_check(Timestamp)
}

/// Simulates validation of a [UserOperation](UserOperation) via the [simulate_validation](crate::entry_point::EntryPoint::simulate_validation) method of the [entry_point](crate::entry_point::EntryPoint).
Expand Down
44 changes: 0 additions & 44 deletions examples/Cargo.toml

This file was deleted.

26 changes: 22 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,41 @@
### Creating your first user operation

```bash
cd user-operation
cargo run --example user-operation
```

### Simple account - create

```bash
SEED_PHRASE="test test test test test test test test test test test junk" BUNDLER_URL="http://127.0.0.1:3000" cargo run --example simple-account-create
cd simple-account
SEED_PHRASE="test test test test test test test test test test test junk" BUNDLER_URL="http://127.0.0.1:3000" cargo run --example create
```

### Simple account - deposit funds to entrypoint

```bash
SEED_PHRASE="test test test test test test test test test test test junk" PROVIDER_URL="http://127.0.0.1:3000" cargo run --example simple-account-deposit
cd simple-account
SEED_PHRASE="test test test test test test test test test test test junk" PROVIDER_URL="http://127.0.0.1:3000" cargo run --example deposit
```

### Simple account - transfer

```bash
SEED_PHRASE="test test test test test test test test test test test junk" BUNDLER_URL="http://127.0.0.1:3000" cargo run --example simple-account-transfer
```
cd simple-account
SEED_PHRASE="test test test test test test test test test test test junk" BUNDLER_URL="http://127.0.0.1:3000" cargo run --example transfer
```

### Storage - memory

```bash
cd storage
PROVIDER_URL="http://127.0.0.1:8545" cargo run --example memory
```

### Storage - database

```bash
cd storage
PROVIDER_URL="http://127.0.0.1:8545" cargo run --example database
```
39 changes: 39 additions & 0 deletions examples/simple-account/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "examples-simple-account"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
description = """
AA (ERC-4337) bundler examples - simple account
"""

[dependencies]
alloy-primitives = "0.3"
alloy-sol-types = "0.3"
ethers = { workspace = true }
eyre = { workspace = true }
reqwest = { version = "0.11.4", features = ["json"] }
serde = "1"
serde_json = "1"
silius-contracts = { path = "../../crates/contracts" }
silius-primitives = { path = "../../crates/primitives" }
silius-tests = { path = "../../tests" }
tokio = { workspace = true }

[package.metadata.cargo-udeps.ignore]
normal = ["silius-contracts", "silius-primitives", "silius-tests"]

[[example]]
name = "create"
path = "examples/create.rs"

[[example]]
name = "deposit"
path = "examples/deposit.rs"

[[example]]
name = "transfer"
path = "examples/transfer.rs"
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use ethers::{
signers::{coins_bip39::English, MnemonicBuilder, Signer},
types::{transaction::eip2718::TypedTransaction, Address, Bytes, U256},
};
use examples_simple_account::{
simple_account::SimpleAccountExecute, EstimateResult, Request, Response,
};
use reqwest;
use silius_examples::{simple_account::SimpleAccountExecute, EstimateResult, Request, Response};
use silius_primitives::consts::entry_point::ADDRESS;
use silius_primitives::UserOperation;
use silius_primitives::Wallet as UoWallet;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use ethers::{
types::{Address, Bytes, U256},
utils::parse_ether,
};
use examples_simple_account::{
simple_account::SimpleAccountExecute, EstimateResult, Request, Response,
};
use reqwest;
use silius_contracts::EntryPoint;
use silius_examples::{simple_account::SimpleAccountExecute, EstimateResult, Request, Response};
use silius_primitives::consts::entry_point::ADDRESS;
use silius_primitives::UserOperation;
use silius_primitives::Wallet as UoWallet;
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions examples/storage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "examples-storage"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
description = """
AA (ERC-4337) bundler examples - storage
"""

[dependencies]
ethers = { workspace = true }
eyre = { workspace = true }
silius-primitives = { path = "../../crates/primitives" }
silius-uopool = { path = "../../crates/uopool" }
tempdir = "0.3.7"
tokio = { workspace = true }

[[example]]
name = "memory"
path = "examples/memory.rs"

[[example]]
name = "database"
path = "examples/database.rs"

Loading

0 comments on commit e8d1536

Please sign in to comment.