Skip to content

Commit

Permalink
Local: Log keys/addresses for chain operator roles & readme updates
Browse files Browse the repository at this point in the history
* Log private keys and addresses for Chain Operator roles when running
  a local L1. Removed trace logs in bash script fund.sh since the relevant
  info is now logged.
* Updates to readme with info on helpful kurtosis commands for inspecting
  local state.
  • Loading branch information
vdamle committed Dec 9, 2024
1 parent 0505def commit 5866632
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,30 @@ Note: if configuring multiple L2s, make sure that the `network_id` and `name` ar

### Additional configurations
Please find examples of additional configurations in the [test folder](.github/tests/).

### Useful Kurtosis commands

#### Inspect enclave -- Container/Port information

* List information about running containers and open ports

```
kurtosis enclave ls
kurtosis enclave inspect <enclave-name>
```
* Inspect chain state.
```
kurtosis files inspect <enclave-name> op-deployer-configs
```
* Dump all files generated by kurtosis to disk (for inspecting chain state/deploy configs/contract addresses etc.). A file that contains an exhaustive
set of information about the current deployment is `files/op-deployer-configs/state.json`. Deployed contract address, roles etc can all be found here.
```
kurtosis enclave dump <enclave-name> -- dumps all files to a enclave-name prefixed directory under the current directory
kurtosis files download <enclave-name> op-deployer-configs <where-to-download>
```
* `docker log <container-id>` for each running container can used to inspect logs for the appropriate container.
2 changes: 2 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def run(plan, args):
plan.print(l1.network_params)
# Get L1 info
all_l1_participants = l1.all_participants
l1_network = "local"
l1_network_params = l1.network_params
l1_network_id = l1.network_id
l1_rpc_url = all_l1_participants[0].el_context.rpc_http_url
Expand All @@ -78,6 +79,7 @@ def run(plan, args):
l1_priv_key,
l1_config_env_vars,
optimism_args_with_right_defaults,
l1_network
)

for chain in optimism_args_with_right_defaults.chains:
Expand Down
3 changes: 2 additions & 1 deletion src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def deploy_contracts(
priv_key,
l1_config_env_vars,
optimism_args,
l1_network
):
l2_chain_ids = ",".join(
[str(chain.network_params.network_id) for chain in optimism_args.chains]
Expand Down Expand Up @@ -163,7 +164,7 @@ def deploy_contracts(
name="op-deployer-fund",
description="Collect keys, and fund addresses",
image=utils.DEPLOYMENT_UTILS_IMAGE,
env_vars={"PRIVATE_KEY": str(priv_key), "FUND_VALUE": "10ether"}
env_vars={"PRIVATE_KEY": str(priv_key), "FUND_VALUE": "10ether", "L1_NETWORK": str(l1_network)}
| l1_config_env_vars,
store=[
StoreSpec(
Expand Down
36 changes: 19 additions & 17 deletions static_files/scripts/fund.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

set -euxo pipefail
set -euo pipefail

export ETH_RPC_URL="$L1_RPC_URL"

addr=$(cast wallet address "$PRIVATE_KEY")
nonce=$(cast nonce "$addr")
mnemonic="test test test test test test test test test test test junk"
roles=("proposer" "batcher" "sequencer" "challenger" "L2ProxyAdmin" "L1ProxyAdmin" "BaseFeeVaultRecipient" "L1FeeVaultRecipient" "SequencerFeeVaultRecipient" "SystemConfigOwner")

IFS=',';read -r -a chain_ids <<< "$1"

Expand All @@ -20,21 +21,22 @@ send() {
}

for chain_id in "${chain_ids[@]}"; do
proposer_priv=$(cast wallet private-key "$mnemonic" "m/44'/60'/2'/$chain_id/1")
proposer_addr=$(cast wallet address "$proposer_priv")
write_keyfile "$proposer_addr" "$proposer_priv" "proposer-$chain_id"
batcher_priv=$(cast wallet private-key "$mnemonic" "m/44'/60'/2'/$chain_id/2")
batcher_addr=$(cast wallet address "$batcher_priv")
write_keyfile "$batcher_addr" "$batcher_priv" "batcher-$chain_id"
sequencer_priv=$(cast wallet private-key "$mnemonic" "m/44'/60'/2'/$chain_id/3")
sequencer_addr=$(cast wallet address "$sequencer_priv")
write_keyfile "$sequencer_addr" "$sequencer_priv" "sequencer-$chain_id"
challenger_priv=$(cast wallet private-key "$mnemonic" "m/44'/60'/2'/$chain_id/4")
challenger_addr=$(cast wallet address "$challenger_priv")
write_keyfile "$challenger_addr" "$challenger_priv" "challenger-$chain_id"
send "$proposer_addr"
send "$batcher_addr"
send "$challenger_addr"
for index in "${!roles[@]}"; do
role="${roles[$index]}"
role_idx=$((index+1))

# Skip wallet addrs for anything other Proposer/Batcher/Sequencer/Challenger if not on local L1
if [[ "${L1_NETWORK}" != "local" && $role_idx -gt 4 ]]; then
continue
fi

private_key=$(cast wallet private-key "$mnemonic" "m/44'/60'/2'/$chain_id/$role_idx")
address=$(cast wallet address "${private_key}")
write_keyfile "${address}" "${private_key}" "${role}-$chain_id"
send "${address}"

echo "${role} on chain $chain_id, private key:"${private_key}", address:"${address}""
done

cat "/network-data/genesis-$chain_id.json" | jq --from-file /fund-script/gen2spec.jq > "/network-data/chainspec-$chain_id.json"
done
done

0 comments on commit 5866632

Please sign in to comment.