Skip to content

Commit

Permalink
Merge pull request #204 from Vid201/chore/misc
Browse files Browse the repository at this point in the history
chore: misc
  • Loading branch information
Vid201 authored Aug 24, 2023
2 parents ea49b42 + 83c66f0 commit 95f781b
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- uses: actions/checkout@v3
with:
repository: eth-infinitism/bundler-spec-tests
ref: '478ee23631a7d7fee48df930df222da07d6837fd'
ref: '8f830db54809c454059c5648dfd4bdaa842a2303'
submodules: true
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# build
FROM ubuntu:18.04 AS builder

RUN apt-get update && apt-get -y upgrade && apt-get install -y build-essential software-properties-common curl git clang libclang-dev
RUN apt-get update && apt-get -y upgrade && apt-get install -y build-essential software-properties-common curl git clang pkg-config libclang-dev libssl-dev
RUN add-apt-repository ppa:ethereum/ethereum && apt-get update && apt-get install -y solc

RUN curl -sL https://deb.nodesource.com/setup_14.x | sh -
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For more information: https://hackmd.io/@Vid201/aa-bundler-rust

Rust version: 1.71.1

1. libclang, `libclang-dev` on Debian/Ubuntu.
1. libclang, `libclang-dev` and `libssl-dev` on Debian/Ubuntu.
2. 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 (tested with [v1.11.6](https://github.com/ethereum/go-ethereum/releases/tag/v1.11.6)); so you need to install [Geth](https://geth.ethereum.org/docs/getting-started/installing-geth) for running tests.
3. [`solc`](https://docs.soliditylang.org/en/v0.8.17/installing-solidity.html) >=0.8.12.
4. [`cargo-sort`](https://crates.io/crates/cargo-sort) and [`cargo-udeps`](https://crates.io/crates/cargo-udeps).
Expand Down Expand Up @@ -63,10 +63,9 @@ Bundler was tested on the following networks:

## Supported entry point
The address of the entry point smart contract is the same on all EVM networks.
| Address | Commit | Audited |
| :--------: | :-------:| :-------: |
| [0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789](https://blockscan.com/address/0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789) | [9b5f2e4](https://github.com/eth-infinitism/account-abstraction/commit/9b5f2e4bb30a81aa30761749d9e2e43fee64c768) | [April 2023](https://blog.openzeppelin.com/eip-4337-ethereum-account-abstraction-incremental-audit)

| Address | Version | Commit | Audited |
| :--------: | :-------: | :-------: | :-------: |
| [0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789](https://blockscan.com/address/0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789) | 0.6.0 | [9b5f2e4](https://github.com/eth-infinitism/account-abstraction/commit/9b5f2e4bb30a81aa30761749d9e2e43fee64c768) | [April 2023](https://blog.openzeppelin.com/eip-4337-ethereum-account-abstraction-incremental-audit)

## Examples

Expand All @@ -90,7 +89,7 @@ make lint
make test
```

Official [bundler spec tests](https://github.com/eth-infinitism/bundler-spec-tests) developed by the [eth-infinitism](https://github.com/eth-infinitism/) team are also included in the repo's CI pipeline (commit: [f7c993031d4bb5f0940c5282298c911ec15a5fb7](https://github.com/eth-infinitism/bundler-spec-tests/tree/f7c993031d4bb5f0940c5282298c911ec15a5fb7)). You can find more information on how to run tests [here](https://github.com/eth-infinitism/bundler-spec-tests). Make sure your contribution doesn't break the tests!
Official [bundler spec tests](https://github.com/eth-infinitism/bundler-spec-tests) developed by the [eth-infinitism](https://github.com/eth-infinitism/) team are also included in the repo's CI pipeline (commit: [8f830db54809c454059c5648dfd4bdaa842a2303](https://github.com/eth-infinitism/bundler-spec-tests/tree/f7c993031d4bb5f0940c5282298c911ec15a5fb7)). You can find more information on how to run tests [here](https://github.com/eth-infinitism/bundler-spec-tests). Make sure your contribution doesn't break the tests!

## Contact

Expand All @@ -101,6 +100,10 @@ The best place for the discussion is the dedicated [Telegram group](https://t.me
- Vid Kersic: [GitHub](https://github.com/Vid201), [Twitter](https://twitter.com/vidkersic)
- WillQ: [GitHub](https://github.com/zsluedem), [Twitter](https://twitter.com/zsluedem06)

## Projects using Silius

- [Luban the Paymaster](https://github.com/da-bao-jian/luban-the-paymaster): A Cross-chain Tx Sponsorship Protocol.

## Licenses

This project is dual-licensed under Apache 2.0 and MIT terms:
Expand All @@ -120,3 +123,5 @@ Silius is an open-source project and a public good. If you want to help the proj
- [Akula](https://github.com/akula-bft/akula)
- [ethers-rs](https://github.com/gakonst/ethers-rs)
- [Reth](https://github.com/paradigmxyz/reth)
- [Lighthouse](https://github.com/sigp/lighthouse)
- [Alloy](https://github.com/alloy-rs)
5 changes: 2 additions & 3 deletions bin/silius/src/silius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use silius_grpc::{
uopool_service_run,
};
use silius_primitives::{
chain::SUPPORTED_CHAINS,
consts::{flashbots_relay_endpoints, SendBundleMode},
Chain, Wallet,
bundler::SendBundleMode, chain::SUPPORTED_CHAINS, consts::flashbots_relay_endpoints, Chain,
Wallet,
};
use silius_rpc::{
debug_api::{DebugApiServer, DebugApiServerImpl},
Expand Down
2 changes: 1 addition & 1 deletion bundler-spec-test/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ case $1 in
--rpc-listen-address 0.0.0.0:3000 \
--eth-client-address http://localhost:8545 \
--mnemonic-file keys/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--beneficiary 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990 \
--beneficiary 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--entry-points 0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789 \
--http \
--ws \
Expand Down
6 changes: 3 additions & 3 deletions crates/bundler/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use ethers_flashbots::{
};
use silius_contracts::entry_point::EntryPointAPI;
use silius_primitives::{
consts::{flashbots_relay_endpoints, supported_networks, SendBundleMode},
bundler::SendBundleMode,
consts::{flashbots_relay_endpoints, supported_networks},
Chain, UserOperation, Wallet,
};
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -472,8 +473,7 @@ mod test {
};
use jsonrpsee::server::{ServerBuilder, ServerHandle};
use silius_primitives::{
consts::{flashbots_relay_endpoints, SendBundleMode},
Chain, Wallet,
bundler::SendBundleMode, consts::flashbots_relay_endpoints, Chain, Wallet,
};
use std::env;

Expand Down
27 changes: 23 additions & 4 deletions crates/contracts/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub struct Level {
pub opcodes: HashMap<String, u64>,
#[serde(rename = "contractSize")]
pub contract_size: HashMap<Address, ContractSizeInfo>,
#[serde(rename = "extCodeAccessInfo")]
pub ext_code_access_info: HashMap<Address, String>,
pub oog: Option<bool>,
}

Expand Down Expand Up @@ -153,7 +155,8 @@ pub const JS_TRACER: &str = r#"
this.currentLevel = this.numberLevels[this.numberCounter] = {
access: {},
opcodes: {},
contractSize: {}
contractSize: {},
extCodeAccessInfo: {}
};
}
this.lastOp = '';
Expand All @@ -169,13 +172,30 @@ pub const JS_TRACER: &str = r#"
this.countSlot(this.currentLevel.opcodes, opcode);
}
}
// store all addresses touched by EXTCODE* opcodes
if (opcode.match(/^(EXT.*)$/) != null) {
const addr = toAddress(log.stack.peek(0).toString(16))
const addrHex = toHex(addr)
// only store the last EXTCODE* opcode per address - could even be a boolean for our current use-case
this.currentLevel.extCodeAccessInfo[addrHex] = opcode
}
// not using 'isPrecompiled' to only allow the ones defined by the ERC-4337 as stateless precompiles
const isAllowedPrecompiled = function(address) {
const addrHex = toHex(address)
const addressInt = parseInt(addrHex)
// this.debug.push(`isPrecompiled address=${addrHex} addressInt=${addressInt}`)
return addressInt > 0 && addressInt < 10
};
if (opcode.match(/^(EXT.*|CALL|CALLCODE|DELEGATECALL|STATICCALL|CREATE2)$/) != null) {
// this.debug.push('op= opcode + ' last= this.lastOp + ' stacksize= log.stack.length())
const idx = opcode.startsWith('EXT') ? 0 : 1;
const addr = toAddress(log.stack.peek(idx).toString(16));
const addrHex = toHex(addr);
// this.debug.push('op=' + opcode + ' last=' + this.lastOp + ' stacksize=' + log.stack.length() + ' addr=' + addrHex)
if (this.currentLevel.contractSize[addrHex] == null && !isPrecompiled(addr)) {
if (this.currentLevel.contractSize[addrHex] == null && !isAllowedPrecompiled(addr)) {
this.currentLevel.contractSize[addrHex] = {
contractSize: db.getCode(addr).length,
opcode
Expand Down Expand Up @@ -205,8 +225,7 @@ pub const JS_TRACER: &str = r#"
// if (len === 64) {
this.keccak.push(toHex(log.memory.slice(ofs, ofs + len)));
}
}
else if (opcode.startsWith('LOG')) {
} else if (opcode.startsWith('LOG')) {
const count = parseInt(opcode.substring(3));
const ofs = parseInt(log.stack.peek(0).toString());
const len = parseInt(log.stack.peek(1).toString());
Expand Down
2 changes: 1 addition & 1 deletion crates/grpc/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_trait::async_trait;
use ethers::types::{Address, H256, U256};
use parking_lot::Mutex;
use silius_bundler::Bundler;
use silius_primitives::{consts::SendBundleMode, Chain, UserOperation, Wallet};
use silius_primitives::{bundler::SendBundleMode, Chain, UserOperation, Wallet};
use std::{net::SocketAddr, sync::Arc, time::Duration};
use tonic::{Request, Response, Status};
use tracing::{error, info, warn};
Expand Down
9 changes: 9 additions & 0 deletions crates/primitives/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ pub enum Mode {
#[serde(rename = "manual")]
Manual,
}

/// The `SendBundleMode` determines whether to send the bundle to a Ethereum execution client or to Flashbots relay
#[derive(Clone, Debug, PartialEq)]
pub enum SendBundleMode {
/// Send the bundle to a Ethereum execution client
EthClient,
/// Send the bundle to Flashbots relay
Flashbots,
}
9 changes: 0 additions & 9 deletions crates/primitives/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,3 @@ pub mod supported_networks {
pub const DEV: u64 = 1337;
pub const MUMBAI: u64 = 80001;
}

/// The `SendBundleMode` determines whether to send the bundle to a Ethereum execution client or to Flashbots relay
#[derive(Clone, Debug, PartialEq)]
pub enum SendBundleMode {
/// Send the bundle to a Ethereum execution client
EthClient,
/// Send the bundle to Flashbots relay
Flashbots,
}
2 changes: 1 addition & 1 deletion crates/uopool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The UserOperation alternative mempool implementation according to the [ERC-4337
### `reputation` module
* `reputation` module provides the `Reputation` trait that defines the interface for reputation-realted operations.
### `database` and `memory` modules
* `database` and `memory` modules provide different implementations of the `Mempool` trait, depending on the use case.
* `database` and `memory` modules provide different implementations of the `Mempool` and `Reputation` traits, depending on the use case.
10 changes: 10 additions & 0 deletions crates/uopool/src/validate/simulation_trace/external_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ impl<M: Middleware> SimulationTraceCheck<M> for ExternalContracts {
});
}
}

// TODO: uncomment when bundler spec tests updated
// for (addr, info) in l.ext_code_access_info.iter() {
// if *addr == helper.entry_point.address() {
// return Err(SimulationCheckError::Opcode {
// entity: LEVEL_TO_ENTITY[i].to_string(),
// opcode: info.clone(),
// });
// }
// }
}
}

Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3"
services:
silius:
image: ghcr.io/vid201/silius:latest
network_mode: host
volumes:
- ./bundler-spec-test/keys:/data/silius
command:
- --rpc-listen-address
- 0.0.0.0:3000
- --eth-client-address
- http://127.0.0.1:8545
- --mnemonic-file
- data/silius/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
- --beneficiary
- 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
- --entry-points
- 0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789
- --http
- --ws
- --rpc-api
- eth,debug,web3
14 changes: 0 additions & 14 deletions thirdparty/account-abstraction/cache/solidity-files-cache.json

This file was deleted.

0 comments on commit 95f781b

Please sign in to comment.