Skip to content

Commit

Permalink
add latest contract
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed Jun 4, 2024
1 parent 251962c commit 4b0a390
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="/root/.foundry/bin:${PATH}"
RUN foundryup

RUN git clone https://github.com/ethereum-optimism/optimism.git && \
RUN git clone https://github.com/barnabasbusa/optimism.git && \
cd optimism && \
git checkout develop && \
git checkout bbusa/customize-chain-info && \
pnpm install && \
pnpm build

Expand All @@ -55,6 +55,7 @@ WORKDIR /workspace
RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
direnv \
git \
bash \
curl \
ca-certificates \
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
## Welcome to Optimism Package
default package for Optimism
```yaml
optimism_package:
participants:
- el_type: op-geth
el_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest
cl_type: op-node
cl_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop
count: 1
network_params:
network: kurtosis
network_id: "2151908"
seconds_per_slot: 2
```
39 changes: 30 additions & 9 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ static_files = import_module(
participant_network = import_module("./src/participant_network.star")


def get_l1_stuff(all_l1_participants, l1_network_params):
first_l1_el_node = all_l1_participants[0].el_context.rpc_http_url
first_l1_cl_node = all_l1_participants[0].cl_context.beacon_http_url
l1_chain_id = l1_network_params.network_id
l1_block_time = l1_network_params.seconds_per_slot
return first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time


def run(plan, args={}):
"""Deploy a Optimism L2 with a local L1.
Expand All @@ -25,30 +33,43 @@ def run(plan, args={}):
plan.print("Deploying a local L1")
l1 = ethereum_package.run(plan, ethereum_args)
all_l1_participants = l1.all_participants
l1_network_params = l1.network_params
priv_key = l1.pre_funded_accounts[
12
].private_key # reserved for L2 contract deployer
# Deploy L2 smart contracts
plan.print("Deploying the L2 smart contracts")
first_l1_el_node = all_l1_participants[0].el_context.rpc_http_url
first_l1_cl_node = all_l1_participants[0].cl_context.beacon_http_url
el_cl_data = contract_deployer.launch_contract_deployer(
plan, first_l1_el_node, first_l1_cl_node, priv_key
)

# Parse the values for the args
plan.print("Parsing the L2 input args")
optimism_args = args["optimism_package"]

first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time = get_l1_stuff(
all_l1_participants, l1_network_params
)

args_with_right_defaults = input_parser.input_parser(plan, optimism_args)
network_params = args_with_right_defaults.network_params

l2_block_time = network_params.seconds_per_slot
l2_chain_id = network_params.network_id

el_cl_data = contract_deployer.launch_contract_deployer(
plan,
first_l1_el_node,
first_l1_cl_node,
priv_key,
l1_chain_id,
l2_chain_id,
l1_block_time,
l2_block_time,
)

# Deploy the L2
plan.print("Deploying a local L2")
args_with_right_defaults = input_parser.input_parser(plan, optimism_args)

jwt_file = plan.upload_files(
src=static_files.JWT_PATH_FILEPATH,
name="op_jwt_file",
)
network_params = args_with_right_defaults.network_params

all_participants = participant_network.launch_participant_network(
plan,
Expand Down
24 changes: 15 additions & 9 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGE = "parithoshj/op-test:v3"
IMAGE = "bbusa/op:latest"

ENVRC_PATH = "/workspace/optimism/.envrc"

Expand All @@ -11,6 +11,10 @@ def launch_contract_deployer(
el_rpc_http_url,
cl_rpc_http_url,
priv_key,
l1_chain_id,
l2_chain_id,
l1_block_time,
l2_block_time,
):
op_genesis = plan.run_sh(
description="Deploying L2 contracts (takes a few minutes (30 mins for mainnet preset - 4 mins for minimal preset) -- L1 has to be finalized first)",
Expand All @@ -20,6 +24,15 @@ def launch_contract_deployer(
"WEB3_PRIVATE_KEY": str(priv_key),
"CL_RPC_URL": str(cl_rpc_http_url),
"FUND_VALUE": "10",
"DEPLOYMENT_OUTFILE": "deployments/artifact.json",
"DEPLOY_CONFIG_PATH": "/workspace/optimism/packages/contracts-bedrock/deployments/getting-started/",
"L1_RPC_KIND": "any",
"L1_RPC_URL": str(el_rpc_http_url),
"L1_CHAIN_ID": str(l1_chain_id),
"L2_CHAIN_ID": str(l2_chain_id),
"L1_BLOCK_TIME": str(l1_block_time),
"L2_BLOCK_TIME": str(l2_block_time),
"DEPLOYMENT_CONTEXT": "getting-started",
},
store=[
StoreSpec(src="/network-configs", name="op-genesis-configs"),
Expand All @@ -32,17 +45,11 @@ def launch_contract_deployer(
"sed -i '1d' {0}".format(
ENVRC_PATH
), # Remove the first line (not commented out)
"echo 'export L1_RPC_KIND=any' >> {0}".format(ENVRC_PATH),
"echo 'export L1_RPC_URL={0}' >> {1}".format(
el_rpc_http_url, ENVRC_PATH
),
"echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(
ENVRC_PATH
),
"echo 'export DEPLOYMENT_CONTEXT=getting-started' >> {0}".format(
ENVRC_PATH
),
". {0}".format(ENVRC_PATH),
"mkdir -p /network-configs",
"web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin
"sleep 3",
"web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher
Expand All @@ -65,7 +72,6 @@ def launch_contract_deployer(
"sleep 3",
"cd /workspace/optimism/op-node",
"go run cmd/main.go genesis l2 --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json --l1-deployments ../packages/contracts-bedrock/deployments/getting-started/.deploy --outfile.l2 genesis.json --outfile.rollup rollup.json --l1-rpc $L1_RPC_URL",
"mkdir -p /network-configs",
"mv /workspace/optimism/op-node/genesis.json /network-configs/genesis.json",
"mv /workspace/optimism/op-node/rollup.json /network-configs/rollup.json",
"mv /workspace/optimism/packages/contracts-bedrock/deployments/getting-started/.deploy /network-configs/.deploy",
Expand Down
2 changes: 2 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def input_parser(plan, input_args):
network_params=struct(
network=result["network_params"]["network"],
network_id=result["network_params"]["network_id"],
seconds_per_slot=result["network_params"]["seconds_per_slot"],
),
)

Expand Down Expand Up @@ -95,6 +96,7 @@ def default_network_params():
return {
"network": "kurtosis",
"network_id": "2151908",
"seconds_per_slot": 2,
}


Expand Down

0 comments on commit 4b0a390

Please sign in to comment.