Skip to content

Commit

Permalink
Merge pull request #40 from zsluedem/use-geth
Browse files Browse the repository at this point in the history
Replace anvil with Geth
  • Loading branch information
zsluedem authored Jan 30, 2023
2 parents d2e14ba + 762cbbe commit ae1e715
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 57 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ jobs:
- name: Setup third party dependencies
run: |
make fetch-thirdparty
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install solc
- name: Install Geth and solc
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo add-apt-repository ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install solc
sudo apt-get install ethereum
- name: Build
run: |
make build
Expand Down
90 changes: 72 additions & 18 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ tonic = { version = "0.8", default-features = false, features = [
tracing = "0.1"
tracing-subscriber = "0.3"

[dev-dependencies]
tempdir = "0.3.7"

[build-dependencies]
anyhow = "1"
ethers = { git = "https://github.com/gakonst/ethers-rs.git", rev = "c60990d7b6e6b3034f1e50b27b495aeda30e35e8", features = ["ethers-solc"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information: https://hackmd.io/@Vid201/aa-bundler-rust

## Prerequisites

1. Ethereum execution client JSON-RPC API with enabled [`debug_traceCall`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_tracecall). For production, you can use [Geth](https://github.com/ethereum/go-ethereum) or [Erigon](https://github.com/ledgerwatch/erigon). For testing purposes, you can use [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#anvil), which provides enough functionalities of execution clients like Geth. To install Anvil, use [foundryup](https://getfoundry.sh/)
1. Ethereum execution client JSON-RPC API with enabled [`debug_traceCall`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debug_tracecall). For production, you can use [Geth](https://github.com/ethereum/go-ethereum) or [Erigon](https://github.com/ledgerwatch/erigon). For testing, we are using Geth dev mode; so you need to install [Geth](https://geth.ethereum.org/docs/getting-started/installing-geth) for running tests.
2. [solc](https://docs.soliditylang.org/en/v0.8.17/installing-solidity.html) >=0.8.12

## How to run?
Expand Down
21 changes: 8 additions & 13 deletions src/contracts/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ impl<M: Middleware + 'static> EntryPoint<M> {
) -> Result<entry_point_api::EntryPointAPIErrors, EntryPointErr> {
JsonRpcError::from_str(err_msg)
.map_err(|_| {
EntryPointErr::DecodeErr(format!(
"{:?} is not a valid JsonRpcError message",
err_msg
))
EntryPointErr::DecodeErr(format!("{err_msg:?} is not a valid JsonRpcError message"))
})
.and_then(|json_error| {
json_error.data.ok_or_else(|| {
EntryPointErr::DecodeErr("{:?} doesn't have valid data field".to_string())
EntryPointErr::DecodeErr(
"{json_error:?} doesn't have valid data field".to_string(),
)
})
})
.and_then(|data: String| {
AbiDecode::decode_hex(data).map_err(|_| {
EntryPointErr::DecodeErr(format!(
"{:?} data field could not be deserialize to EntryPointAPIErrors",
err_msg
"{err_msg:?} data field could not be deserialize to EntryPointAPIErrors"
))
})
})
Expand Down Expand Up @@ -84,8 +82,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
))
}
_ => Err(EntryPointErr::UnknownErr(format!(
"Simulate validation with invalid error: {:?}",
op
"Simulate validation with invalid error: {op:?}"
))),
})
}
Expand All @@ -107,8 +104,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
Err(EntryPointErr::FailedOp(failed_op))
}
_ => Err(EntryPointErr::UnknownErr(format!(
"Handle ops with invalid error: {:?}",
op
"Handle ops with invalid error: {op:?}"
))),
})
})
Expand All @@ -132,8 +128,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
Err(EntryPointErr::FailedOp(failed_op))
}
_ => Err(EntryPointErr::UnknownErr(format!(
"Simulate validation with invalid error: {:?}",
op
"Simulate validation with invalid error: {op:?}"
))),
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use ethers::types::{Address, U256};
use std::str::FromStr;

pub fn parse_address(s: &str) -> Result<Address, String> {
Address::from_str(s).map_err(|_| format!("Adress {} is not a valid address", s))
Address::from_str(s).map_err(|_| format!("Adress {s} is not a valid address"))
}
pub fn parse_u256(s: &str) -> Result<U256, String> {
U256::from_str_radix(s, 10).map_err(|_| format!("{} is not a valid U256", s))
U256::from_str_radix(s, 10).map_err(|_| format!("{s} is not a valid U256"))
}
3 changes: 1 addition & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use self::gen::{
};
pub mod gen;

pub const ANVIL_TEST_KEY_PHRASE: &str =
"test test test test test test test test test test test junk";
pub const KEY_PHRASE: &str = "test test test test test test test test test test test junk";

pub struct DeployedContract<C> {
contract: C,
Expand Down
Loading

0 comments on commit ae1e715

Please sign in to comment.