Skip to content

Commit

Permalink
feat(types): add entrypoint 0.7 contract types
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Mar 29, 2024
1 parent 0054d2b commit 6c4b2f4
Show file tree
Hide file tree
Showing 33 changed files with 218 additions and 74 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
20 changes: 14 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
[submodule "crates/types/contracts/lib/account-abstraction"]
path = crates/types/contracts/lib/account-abstraction
[submodule "crates/types/contracts/lib/account-abstraction-versions/v0_7"]
path = crates/types/contracts/lib/account-abstraction-versions/v0_7
url = https://github.com/eth-infinitism/account-abstraction
branch = v0.5
branch = releases/v0.7
[submodule "crates/types/contracts/lib/account-abstraction-versions/v0_6"]
path = crates/types/contracts/lib/account-abstraction-versions/v0_6
url = https://github.com/eth-infinitism/account-abstraction
branch = releases/v0.6
[submodule "crates/types/contracts/lib/forge-std"]
path = crates/types/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = chore/v1.5.0
[submodule "crates/types/contracts/lib/openzeppelin-contracts"]
path = crates/types/contracts/lib/openzeppelin-contracts
[submodule "crates/types/contracts/lib/openzeppelin-contracts-versions/v5_0"]
path = crates/types/contracts/lib/openzeppelin-contracts-versions/v5_0
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = release-v5.0
[submodule "crates/types/contracts/lib/openzeppelin-contracts-versions/v4_9"]
path = crates/types/contracts/lib/openzeppelin-contracts-versions/v4_9
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = release-v4.8
branch = release-v4.9
[submodule "test/spec-tests/bundler-spec-tests"]
path = test/spec-tests/bundler-spec-tests
url = https://github.com/alchemyplatform/bundler-spec-tests.git
Expand Down
2 changes: 1 addition & 1 deletion bin/tools/src/bin/send_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() -> anyhow::Result<()> {
// simply call the nonce method multiple times
for i in 0..10 {
println!("Sending op {i}");
let op = clients.new_wallet_op(wallet.nonce(), 0.into()).await?;
let op = clients.new_wallet_op(wallet.get_nonce(), 0.into()).await?;
let call = entry_point.handle_ops(vec![op], bundler_client.address());
rundler_dev::await_mined_tx(call.send(), "send user operation").await?;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use ethers::{
utils::{self, hex, keccak256},
};
use rundler_types::{
contracts::{
contracts::v0_6::{
entry_point::EntryPoint, simple_account::SimpleAccount,
simple_account_factory::SimpleAccountFactory, verifying_paymaster::VerifyingPaymaster,
},
Expand Down Expand Up @@ -470,7 +470,7 @@ impl DevClients {
.context("call executed by wallet should have to address")?;
let nonce = self
.wallet
.nonce()
.get_nonce()
.await
.context("should read nonce from wallet")?;
let call_data = Bytes::clone(
Expand Down
2 changes: 1 addition & 1 deletion crates/pool/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use futures::future;
use rundler_provider::Provider;
use rundler_task::block_watcher;
use rundler_types::{
contracts::{
contracts::v0_6::{
entry_point::{DepositedFilter, WithdrawnFilter},
i_entry_point::UserOperationEventFilter,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/ethers/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use ethers::{
utils::hex,
};
use rundler_types::{
contracts::{
contracts::v0_6::{
get_balances::{GetBalancesResult, GETBALANCES_BYTECODE},
i_entry_point::{ExecutionResult, FailedOp, IEntryPoint, SignatureValidationFailed},
shared_types::UserOpsPerAggregator,
Expand Down
5 changes: 3 additions & 2 deletions crates/provider/src/ethers/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ use ethers::{
use reqwest::Url;
use rundler_types::{
contracts::{
gas_price_oracle::GasPriceOracle, i_aggregator::IAggregator, i_entry_point::IEntryPoint,
node_interface::NodeInterface,
arbitrum::node_interface::NodeInterface,
optimism::gas_price_oracle::GasPriceOracle,
v0_6::{i_aggregator::IAggregator, i_entry_point::IEntryPoint},
},
UserOperation,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/traits/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ethers::types::{
#[cfg(feature = "test-utils")]
use mockall::automock;
use rundler_types::{
contracts::{i_entry_point::ExecutionResult, shared_types::UserOpsPerAggregator},
contracts::v0_6::{i_entry_point::ExecutionResult, shared_types::UserOpsPerAggregator},
DepositInfo, GasFees, UserOperation, ValidationOutput,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use rundler_sim::{
};
use rundler_types::{
chain::ChainSpec,
contracts::i_entry_point::{
contracts::v0_6::i_entry_point::{
IEntryPointCalls, UserOperationEventFilter, UserOperationRevertReasonFilter,
},
UserOperation,
Expand Down Expand Up @@ -567,7 +567,7 @@ mod tests {
use rundler_pool::{MockPoolServer, PoolOperation};
use rundler_provider::{MockEntryPoint, MockProvider};
use rundler_sim::PriorityFeeMode;
use rundler_types::contracts::i_entry_point::HandleOpsCall;
use rundler_types::contracts::v0_6::i_entry_point::HandleOpsCall;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/sim/src/estimation/estimation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rand::Rng;
use rundler_provider::{EntryPoint, Provider};
use rundler_types::{
chain::ChainSpec,
contracts::{
contracts::v0_6::{
call_gas_estimation_proxy::{
EstimateCallGasArgs, EstimateCallGasCall, EstimateCallGasContinuation,
EstimateCallGasResult, EstimateCallGasRevertAtMax,
Expand Down Expand Up @@ -479,7 +479,7 @@ mod tests {
use rundler_provider::{MockEntryPoint, MockProvider};
use rundler_types::{
chain::L1GasOracleContractType,
contracts::{get_gas_used::GasUsedResult, i_entry_point::ExecutionResult},
contracts::{utils::get_gas_used::GasUsedResult, v0_6::i_entry_point::ExecutionResult},
};

use super::*;
Expand Down
6 changes: 3 additions & 3 deletions crates/sim/src/simulation/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use indexmap::IndexSet;
use mockall::automock;
use rundler_provider::{AggregatorOut, AggregatorSimOut, Provider};
use rundler_types::{
contracts::i_entry_point::FailedOp, Entity, EntityType, StakeInfo, StorageSlot, UserOperation,
ValidTimeRange, ValidationOutput, ValidationReturnInfo,
contracts::v0_6::i_entry_point::FailedOp, Entity, EntityType, StakeInfo, StorageSlot,
UserOperation, ValidTimeRange, ValidationOutput, ValidationReturnInfo,
};
use strum::IntoEnumIterator;

Expand Down Expand Up @@ -1064,7 +1064,7 @@ mod tests {
utils::hex,
};
use rundler_provider::{AggregatorOut, MockProvider};
use rundler_types::contracts::get_code_hashes::CodeHashesResult;
use rundler_types::contracts::utils::get_code_hashes::CodeHashesResult;

use super::*;
use crate::simulation::tracer::{MockSimulateValidationTracer, Phase};
Expand Down
2 changes: 1 addition & 1 deletion crates/sim/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ethers::{
types::{spoof, Address, BlockId, Bytes, Selector, H256, U256},
};
use rundler_provider::Provider;
use rundler_types::contracts::{
use rundler_types::contracts::utils::{
get_code_hashes::{CodeHashesResult, GETCODEHASHES_BYTECODE},
get_gas_used::{GasUsedResult, GETGASUSED_BYTECODE},
};
Expand Down
6 changes: 5 additions & 1 deletion crates/types/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Generated code
/src/contracts
/src/contracts/v0_6
/src/contracts/v0_7
/src/contracts/arbitrum
/src/contracts/optimism
/src/contracts/utils
148 changes: 123 additions & 25 deletions crates/types/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,146 @@ fn main() -> Result<(), Box<dyn error::Error>> {
println!("cargo:rerun-if-changed=contracts/lib");
println!("cargo:rerun-if-changed=contracts/src");
println!("cargo:rerun-if-changed=contracts/foundry.toml");
generate_contract_bindings()?;
generate_v0_6_bindings()?;
generate_v0_7_bindings()?;
generate_utils_bindings()?;
generate_arbitrum_bindings()?;
generate_optimism_bindings()?;
Ok(())
}

fn generate_contract_bindings() -> Result<(), Box<dyn error::Error>> {
generate_abis()?;
fn generate_v0_6_bindings() -> Result<(), Box<dyn error::Error>> {
run_command(
Command::new("forge")
.arg("build")
.arg("--root")
.arg("./contracts")
.arg("--contracts")
.arg("src/v0_6")
.arg("--out")
.arg("out/v0_6")
.arg("--remappings")
.arg("@openzeppelin/=lib/openzeppelin-contracts-versions/v4_9"),
"https://getfoundry.sh/",
"generate ABIs",
)?;

MultiAbigen::from_abigens([
abigen_of("IEntryPoint")?,
abigen_of("EntryPoint")?,
abigen_of("IAggregator")?,
abigen_of("IStakeManager")?,
abigen_of("GetCodeHashes")?,
abigen_of("GetBalances")?,
abigen_of("GetGasUsed")?,
abigen_of("CallGasEstimationProxy")?,
abigen_of("SimpleAccount")?,
abigen_of("SimpleAccountFactory")?,
abigen_of("VerifyingPaymaster")?,
abigen_of("NodeInterface")?,
abigen_of("GasPriceOracle")?,
abigen_of("v0_6", "IEntryPoint")?,
abigen_of("v0_6", "EntryPoint")?,
abigen_of("v0_6", "IAggregator")?,
abigen_of("v0_6", "IStakeManager")?,
abigen_of("v0_6", "GetBalances")?,
abigen_of("v0_6", "CallGasEstimationProxy")?,
abigen_of("v0_6", "SimpleAccount")?,
abigen_of("v0_6", "SimpleAccountFactory")?,
abigen_of("v0_6", "VerifyingPaymaster")?,
])
.build()?
.write_to_module("src/contracts", false)?;
.write_to_module("src/contracts/v0_6", false)?;

Ok(())
}

fn abigen_of(contract: &str) -> Result<Abigen, Box<dyn error::Error>> {
Ok(Abigen::new(
contract,
format!("contracts/out/{contract}.sol/{contract}.json"),
)?)
fn generate_v0_7_bindings() -> Result<(), Box<dyn error::Error>> {
run_command(
Command::new("forge")
.arg("build")
.arg("--root")
.arg("./contracts")
.arg("--contracts")
.arg("src/v0_7")
.arg("--out")
.arg("out/v0_7")
.arg("--remappings")
.arg("@openzeppelin/=lib/openzeppelin-contracts-versions/v5_0"),
"https://getfoundry.sh/",
"generate ABIs",
)?;

MultiAbigen::from_abigens([
abigen_of("v0_7", "IEntryPoint")?,
abigen_of("v0_7", "EntryPoint")?,
abigen_of("v0_7", "IAggregator")?,
abigen_of("v0_7", "IStakeManager")?,
])
.build()?
.write_to_module("src/contracts/v0_7", false)?;

Ok(())
}

fn generate_utils_bindings() -> Result<(), Box<dyn error::Error>> {
run_command(
Command::new("forge")
.arg("build")
.arg("--root")
.arg("./contracts")
.arg("--contracts")
.arg("src/utils")
.arg("--out")
.arg("out/utils"),
"https://getfoundry.sh/",
"generate ABIs",
)?;

MultiAbigen::from_abigens([
abigen_of("utils", "GetCodeHashes")?,
abigen_of("utils", "GetGasUsed")?,
])
.build()?
.write_to_module("src/contracts/utils", false)?;

Ok(())
}

fn generate_arbitrum_bindings() -> Result<(), Box<dyn error::Error>> {
run_command(
Command::new("forge")
.arg("build")
.arg("--root")
.arg("./contracts")
.arg("--contracts")
.arg("src/arbitrum")
.arg("--out")
.arg("out/arbitrum"),
"https://getfoundry.sh/",
"generate ABIs",
)?;

MultiAbigen::from_abigens([abigen_of("arbitrum", "NodeInterface")?])
.build()?
.write_to_module("src/contracts/arbitrum", false)?;

Ok(())
}

fn generate_abis() -> Result<(), Box<dyn error::Error>> {
fn generate_optimism_bindings() -> Result<(), Box<dyn error::Error>> {
run_command(
Command::new("forge")
.arg("build")
.arg("--root")
.arg("./contracts"),
.arg("./contracts")
.arg("--contracts")
.arg("src/optimism")
.arg("--out")
.arg("out/optimism"),
"https://getfoundry.sh/",
"generate ABIs",
)
)?;

MultiAbigen::from_abigens([abigen_of("optimism", "GasPriceOracle")?])
.build()?
.write_to_module("src/contracts/optimism", false)?;

Ok(())
}

fn abigen_of(extra_path: &str, contract: &str) -> Result<Abigen, Box<dyn error::Error>> {
Ok(Abigen::new(
contract,
format!("contracts/out/{extra_path}/{contract}.sol/{contract}.json"),
)?)
}

fn run_command(
Expand Down
5 changes: 3 additions & 2 deletions crates/types/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ out = 'out'
libs = ['lib']
test = 'test'
cache_path = 'cache'
solc_version = '0.8.23'

remappings = [
'forge-std/=lib/forge-std/src',
'ds-test/=lib/forge-std/lib/ds-test/src/',
'account-abstraction/=lib/account-abstraction/contracts/',
'@openzeppelin/=lib/openzeppelin-contracts/'
'account-abstraction/v0_6=lib/account-abstraction-versions/v0_6/contracts/',
'account-abstraction/v0_7=lib/account-abstraction-versions/v0_7/contracts/',
]
1 change: 0 additions & 1 deletion crates/types/contracts/lib/account-abstraction
Submodule account-abstraction deleted from f3b5f7
Submodule v0_6 added at fa6129
Submodule v0_7 added at 7af70c
1 change: 0 additions & 1 deletion crates/types/contracts/lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from 0a25c1
Submodule v4_9 added at dc44c9
Submodule v5_0 added at dbb610
11 changes: 0 additions & 11 deletions crates/types/contracts/src/imports.sol

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/v0_6/interfaces/IEntryPoint.sol";
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";

Expand Down
Loading

0 comments on commit 6c4b2f4

Please sign in to comment.