Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Feb 5, 2025
1 parent 9ff05bd commit 2317ceb
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 6 deletions.
75 changes: 74 additions & 1 deletion contracts/scripts/DeployDevnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,43 @@ import {EntryPoint} from "@account-abstraction/contracts/core/EntryPoint.sol";
import {IWorldID} from "@world-id-contracts/interfaces/IWorldID.sol";
import {IPBHEntryPoint} from "../src/interfaces/IPBHEntryPoint.sol";
import {IEntryPoint} from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import {Safe} from "@safe-global/safe-contracts/contracts/Safe.sol";
import {SafeProxyFactory} from "@safe-global/safe-contracts/contracts/proxies/SafeProxyFactory.sol";
import {SafeProxy} from "@safe-global/safe-contracts/contracts/proxies/SafeProxy.sol";
import {Enum} from "@safe-global/safe-contracts/contracts/common/Enum.sol";
import {SafeModuleSetup} from "@4337/SafeModuleSetup.sol";
import {PBHSafe4337Module} from "../src/PBH4337Module.sol";
import {Safe4337Module} from "@4337/Safe4337Module.sol";

contract DeployDevnet is Script {
address public entryPoint;
address public pbhEntryPoint;
address public pbhEntryPointImpl;
address public pbhSignatureAggregator;

PBHSafe4337Module public module;
Safe public singleton;
Safe public safe;
SafeProxyFactory public factory;
SafeModuleSetup public moduleSetup;

address public constant WORLD_ID = 0x5FbDB2315678afecb367f032d93F642f64180aa3;
/// @dev The root of the Test tree.
uint256 constant INITIAL_ROOT = 0x5276AD6D825269EB0B67A2E1589123DED27C8B8EABFA898FF7E878AD61071AD;
uint256 public constant MAX_PBH_GAS_LIMIT = 10000000;
uint192 public constant PBH_NONCE_KEY = 1123123123;

function run() public {
console.log(
"Deploying: EntryPoint, PBHEntryPoint, PBHEntryPointImplV1, PBHSignatureAggregator"
"Deploying: EntryPoint, PBHEntryPoint, PBHEntryPointImplV1, PBHSignatureAggregator, PBHSafe4337Module"
);

uint256 privateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(privateKey);
deployEntryPoint();
deployPBHEntryPoint();
deployPBHSignatureAggregator();
deploySafeAndModule();
updateWorldID();
vm.stopBroadcast();
}
Expand Down Expand Up @@ -65,6 +80,64 @@ contract DeployDevnet is Script {
console.log("PBHSignatureAggregator Deployed at: ", pbhSignatureAggregator);
}

function deploySafeAndModule() public {
uint256 ownerKey = vm.envUint("PRIVATE_KEY");
address owner = vm.addr(ownerKey);

module = new PBHSafe4337Module(entryPoint, pbhSignatureAggregator, PBH_NONCE_KEY);

console.log("PBH4337Module Deployed at: ", address(module));

// Deploy SafeModuleSetup
moduleSetup = new SafeModuleSetup();

console.log("SafeModuleSetup Deployed at: ", address(moduleSetup));

// Deploy Safe singleton and factory
singleton = new Safe();

console.log("Safe Singleton Deployed at: ", address(singleton));
factory = new SafeProxyFactory();

console.log("SafeProxyFactory Deployed at: ", address(factory));

// Prepare module initialization
address[] memory modules = new address[](1);
modules[0] = address(module);

// Encode the moduleSetup.enableModules call
bytes memory moduleSetupCall = abi.encodeCall(SafeModuleSetup.enableModules, (modules));

// Create owners array with single owner
address[] memory owners = new address[](1);
owners[0] = owner;

// Encode initialization data for proxy
bytes memory initData = abi.encodeCall(
Safe.setup,
(
owners,
1, // threshold
address(moduleSetup), // to
moduleSetupCall, // data
address(module), // fallbackHandler
address(0), // paymentToken
0, // payment
payable(address(0)) // paymentReceiver
)
);

// Deploy and initialize Safe proxy
SafeProxy proxy = factory.createProxyWithNonce(
address(singleton),
initData,
0 // salt nonce
);

// Cast proxy to Safe for easier interaction
safe = Safe(payable(address(proxy)));
}

function updateWorldID() public {
bytes memory data = abi.encodeWithSelector(
bytes4(keccak256("receiveRoot(uint256)")),
Expand Down
99 changes: 99 additions & 0 deletions devnet/src/bundler/rundler/rundler_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
shared_utils = import_module(
"github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star"
)

constants = import_module(
"github.com/ethpandaops/ethereum-package/src/package_io/constants.star"
)

#
# ---------------------------------- Rundler client -------------------------------------
# The Docker container runs as the "op-batcher" user so we can't write to root
BATCHER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-batcher/op-batcher-data"

# Port IDs
BATCHER_HTTP_PORT_ID = "http"

# Port nums
BATCHER_HTTP_PORT_NUM = 8548


def get_used_ports():
used_ports = {
BATCHER_HTTP_PORT_ID: shared_utils.new_port_spec(
BATCHER_HTTP_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
}
return used_ports


ENTRYPOINT_ARGS = ["sh", "-c"]


def launch(
plan,
service_name,
image,
el_context,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
):
batcher_service_name = "{0}".format(service_name)

config = get_batcher_config(
plan,
image,
service_name,
el_context,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
)

batcher_service = plan.add_service(service_name, config)

batcher_http_port = batcher_service.ports[BATCHER_HTTP_PORT_ID]
batcher_http_url = "http://{0}:{1}".format(
batcher_service.ip_address, batcher_http_port.number
)

return "op_batcher"


def get_batcher_config(
plan,
image,
service_name,
el_context,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
):
cmd = [
"op-batcher",
"--l2-eth-rpc=" + el_context.rpc_http_url,
"--rollup-rpc=" + cl_context.beacon_http_url,
"--poll-interval=1s",
"--sub-safety-margin=6",
"--num-confirmations=1",
"--safe-abort-nonce-too-low-count=3",
"--resubmission-timeout=30s",
"--rpc.addr=0.0.0.0",
"--rpc.port=" + str(BATCHER_HTTP_PORT_NUM),
"--rpc.enable-admin",
"--max-channel-duration=1",
"--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"],
"--private-key=" + gs_batcher_private_key,
"--data-availability-type=blobs",
]

ports = get_used_ports()
return ServiceConfig(
image=image,
ports=ports,
cmd=cmd,
private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
)
14 changes: 14 additions & 0 deletions devnet/src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ input_parser = import_module("./package_io/input_parser.star")
static_files = import_module(
"github.com/ethpandaops/ethereum-package/src/static_files/static_files.star"
)
static = import_module("./static/static_files.star")


def launch_l2(
Expand Down Expand Up @@ -45,10 +46,23 @@ def launch_l2(
name="op_jwt_file{0}".format(l2_services_suffix),
)

entrypoint_config_file = plan.upload_files(
src=static_files.ENTRYPOINT_CONFIG_FILEPATH,
name="entrypoint_config",
)

mempool_config_file = plan.upload_files(
src=static_files.MEMPOOL_CONFIG_FILEPATH,
name="mempool_config",
)


all_l2_participants = participant_network.launch_participant_network(
plan,
args_with_right_defaults.participants,
jwt_file,
entrypoint_config_file,
mempool_config_file,
network_params,
el_cl_data,
gs_private_keys,
Expand Down
4 changes: 4 additions & 0 deletions devnet/src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ DEFAULT_ENGINE_IMAGES = {
"rollup-boost": "leytont/rollup-boost:latest",
}

DEFAULT_BUNDLER_IMAGES = {
"rundler": "leytont/rundler:latest",
}

DEFAULT_CL_IMAGES = {
"op-node": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop",
"hildr": "ghcr.io/optimism-java/hildr:latest",
Expand Down
9 changes: 6 additions & 3 deletions devnet/src/participant_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ op_batcher_launcher = import_module("./batcher/op-batcher/op_batcher_launcher.st
op_proposer_launcher = import_module(
"github.com/ethpandaops/optimism-package/src/proposer/op-proposer/op_proposer_launcher.star@914a80895376625c8866943b517df47ce4c28170"
)

rundler_launcher = import_module("./bundler/rundler/rundler_launcher.star")

def launch_participant_network(
plan,
participants,
jwt_file,
entrypoint_config_file,
mempool_config_file,
network_params,
el_cl_data,
gs_private_keys,
Expand Down Expand Up @@ -50,8 +52,6 @@ def launch_participant_network(

all_participants.append(participant_entry)

plan.print("Point rollup-boost at the op-batcher {0}".format(all_cl_contexts[0]))

op_batcher_launcher.launch(
plan,
"op-batcher{0}".format(l2_services_suffix),
Expand All @@ -72,4 +72,7 @@ def launch_participant_network(
l2oo_address,
)

# Launch Rundler
plan.print("Launching Rundler")

return all_participants
12 changes: 12 additions & 0 deletions devnet/src/static/static_files.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The path on the module container where static files are housed
STATIC_FILES_DIRPATH = "/static_files"

# Entry Point Config
ENTRYPOINT_CONFIG_FILE_PATH = (
STATIC_FILES_DIRPATH + "/rundler/entrypoint_config.json"
)

# Mempool Config
MEMPOOL_CONFIG_FILE_PATH = (
STATIC_FILES_DIRPATH + "/rundler/mempool_config.json"
)
17 changes: 17 additions & 0 deletions devnet/static_files/rundler/entrypoint_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"entryPoints": [
{
"address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"builders": [
{
"count": 1,
"proxy": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"filterId": "pbh-aggregator"
},
{
"count": 1
}
]
}
]
}
16 changes: 16 additions & 0 deletions devnet/static_files/rundler/mempool_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"0x0000000000000000000000000000000000000000000000000000000000000000": {
"description": "WorldChain Devnet Mempool",
"chainIds": ["0x20D5E4"],
"entryPoint": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"allowlist": [],
"filters": [
{
"id": "pbh-aggregator",
"filter": {
"aggregator": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"
}
}
]
}
}
10 changes: 10 additions & 0 deletions ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
== Logs ==
Deploying: EntryPoint, PBHEntryPoint, PBHEntryPointImplV1, PBHSignatureAggregator, PBHSafe4337Module
EntryPoint Deployed at: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
PBHEntryPointImplV1 Deployed at: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
PBHEntryPoint Deployed at: 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
PBHSignatureAggregator Deployed at: 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9
PBH4337Module Deployed at: 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
SafeModuleSetup Deployed at: 0x0165878A594ca255338adfa4d48449f69242Eb8F
Safe Singleton Deployed at: 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853
SafeProxyFactory Deployed at: 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6
4 changes: 2 additions & 2 deletions world-chain-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ world-chain-builder-pool = { path = "crates/world/pool" }

# reth
reth = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4"}
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "b97d9b4" }
Expand Down Expand Up @@ -137,7 +137,7 @@ clap = { version = "4", features = ["derive", "env"] }
eyre = { version = "0.6", package = "color-eyre" }
serde = { version = "1", features = ["derive"] }
tracing = "0.1"
tracing-subscriber = {version = "0.3.18", features = ["env-filter"]}
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
parking_lot = "0.12"
derive_more = "1"
dotenvy = "0.15.7"
Expand Down

0 comments on commit 2317ceb

Please sign in to comment.