Skip to content

Commit

Permalink
test: test 4337 aggregated, and ops validation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Nov 21, 2024
1 parent b5ac4b1 commit e659299
Show file tree
Hide file tree
Showing 11 changed files with 564 additions and 198 deletions.
404 changes: 238 additions & 166 deletions world-chain-builder/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions world-chain-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ alloy-rpc-types = { version = "0.5.4", features = [
alloy-rlp = "0.3.4"
alloy-eips = { version = "0.5.4", default-features = false }
alloy-genesis = { version = "0.5.4", default-features = false }
alloy-sol-types = { version = "0.5.4", default-features = false }

# revm
# revm
Expand Down
3 changes: 2 additions & 1 deletion world-chain-builder/benches/validate_transaction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::future::Future;

use alloy_primitives::Address;
use criterion::{criterion_group, criterion_main, Criterion};
use reth::transaction_pool::blobstore::InMemoryBlobStore;
use reth::transaction_pool::{Pool, PoolTransaction as _, TransactionPool, TransactionValidator};
Expand Down Expand Up @@ -36,7 +37,7 @@ where

fn validator_setup() -> WorldChainTransactionValidator<MockEthProvider, WorldChainPooledTransaction>
{
let validator = world_chain_validator();
let validator = world_chain_validator(Address::with_last_byte(1));
let transaction = get_pbh_transaction(0);
validator.inner().client().add_account(
transaction.sender(),
Expand Down
2 changes: 1 addition & 1 deletion world-chain-builder/src/node/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct WorldChainBuilderArgs {
/// Sets the ERC-4337 EntryPoint contract address
/// This contract is used to verify World-Id Proofs attached to 4337 payloads.
#[arg(long = "builder.entry_point_contract")]
pub entry_point_contract: Address,
pub entry_point: Address,

/// Sets the max blockspace reserved for verified transactions. If there are not enough
/// verified transactions to fill the capacity, the remaining blockspace will be filled with
Expand Down
4 changes: 2 additions & 2 deletions world-chain-builder/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl WorldChainBuilder {
clear_nullifiers,
num_pbh_txs,
verified_blockspace_capacity,
entry_point_contract,
entry_point,
} = args.builder_args;

let RollupArgs {
Expand All @@ -78,7 +78,7 @@ impl WorldChainBuilder {
num_pbh_txs,
clear_nullifiers,
db: db.clone(),
entry_point_contract,
entry_point,
})
.payload(WorldChainPayloadServiceBuilder::new(
compute_pending_block,
Expand Down
36 changes: 36 additions & 0 deletions world-chain-builder/src/pool/bindings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use alloy_sol_types::sol;

sol! {
#[allow(missing_docs)]
contract IEntryPoint {
#[derive(Default)]
struct PackedUserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
bytes32 accountGasLimits;
uint256 preVerificationGas;
bytes32 gasFees;
bytes paymasterAndData;
bytes signature;
}

#[derive(Default)]
struct UserOpsPerAggregator {
PackedUserOperation[] userOps;
address aggregator;
bytes signature;
}

function handleOps(
PackedUserOperation[] calldata,
address payable
) external;

function handleAggregatedOps(
UserOpsPerAggregator[] calldata,
address payable
) public;
}
}
4 changes: 2 additions & 2 deletions world-chain-builder/src/pool/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct WorldChainPoolBuilder {
pub clear_nullifiers: bool,
pub num_pbh_txs: u16,
pub db: Arc<DatabaseEnv>,
pub entry_point_contract: Address,
pub entry_point: Address,
}

impl<Node> PoolBuilder<Node> for WorldChainPoolBuilder
Expand Down Expand Up @@ -59,7 +59,7 @@ where
root_validator,
self.db.clone(),
self.num_pbh_txs,
self.entry_point_contract,
self.entry_point,
)
});

Expand Down
6 changes: 6 additions & 0 deletions world-chain-builder/src/pool/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ pub enum WorldChainTransactionPoolInvalid {
InvalidRoot,
#[error("invalid 4337 EntryPoint calldata length")]
Invalid4337CalldataLength,
#[error("invalid 4337 EntryPoint Selector")]
Invalid4337EntryPointSelector,
#[error("4337 Abi decode error")]
AbiDecodeError,
#[error("4337 More than one user operation")]
Invalid4337UserOpsLength,
}

#[derive(Debug, thiserror::Error)]
Expand Down
1 change: 1 addition & 0 deletions world-chain-builder/src/pool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod bindings;
pub mod builder;
pub mod error;
pub mod noop;
Expand Down
Loading

0 comments on commit e659299

Please sign in to comment.