Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "nodekit-l1"]
path = nodekit-l1
url = https://github.com/AnomalyFi/nodekit-l1
[submodule "op-geth-proxy"]
path = op-geth-proxy
url = https://github.com/AnomalyFi/op-geth-proxy
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
state = {
"ansibleDir": "ansible-avalanche-getting-started",
"opDir": "op-integration",
"gethProxyDir": "op-geth-proxy",
"cloudProvider": "multipass",
"terraformWorkingDir": "ansible-avalanche-getting-started/terraform/multipass",
"seqDownloadAddr": "https://github.com/AnomalyFi/nodekit-seq/releases/download",
Expand Down Expand Up @@ -103,6 +104,7 @@ def deploy_seq():
ethL1IP = utils.getEthL1IP(state['terraformWorkingDir'])
print('bootstraping avalanchego validators')
utils.bootstrapValidators(state['ansibleDir'], state['inventoryDir'])
# TODO: update this to query is bootstrapped by a http call, see: https://ash.center/docs/toolkit/ansible-avalanche-collection/tutorials/local-test-network#issue-api-calls
# wait bootstraping to be stable
print('boostraping finished, waiting 30s to let it become stable to bootstrap a subnet')
time.sleep(30)
Expand Down Expand Up @@ -181,7 +183,7 @@ def deploy_op_chain(inc: int = 0):
commitmentAddr = utils.getNodekitZKContractAddr(state['nodekitZKDir'])
utils.deployContractsOnL1(state['opDir'], ethL1RPC, commitmentAddr, l2ChainID=l2_chain_id)
print('deploying op l2')
utils.deployOPL2(state['opDir'], ethL1RPC, ethL1WS, seqRPCURL, l2ChainID=l2_chain_id, portIncrement=inc)
utils.deployOPL2(state['opDir'], state['gethProxyDir'], ethL1RPC, ethL1WS, seqRPCURL, l2ChainID=l2_chain_id, portIncrement=inc)

utils.saveOpDevnetInfo(state['opDir'], state['l2storage'], l2_chain_id)

Expand Down
1 change: 1 addition & 0 deletions op-geth-proxy
Submodule op-geth-proxy added at 382aca
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Then,
./bin/setup.sh
source .venv/bin/activate
# install ash ansible collections and dependencies
ansible-galaxy collection install git+https://github.com/AshAvalanche/ansible-avalanche-collection.git,0.12.1-2
ansible-galaxy collection install git+https://github.com/AshAvalanche/ansible-avalanche-collection.git,v0.13.0
ansible-galaxy install -r ansible_collections/ash/avalanche/requirements.yml
```

Expand Down
53 changes: 49 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ def updateTrackedSubnetNChainConfig(ansibleDir: str, inventoryDir: str, subnetID
nodeConf['avalanchego_chains_configs'][chainID] = {
'ethRPCAddr': f'http://{ethl1IP}:8545',
'ethWSAddr': f'ws://{ethl1IP}:8546',
'mempoolSize': 256
'mempoolSize': 256,
'archiverConfig': {
'enabled': True,
'archiverType': 'sqlite',
'dsn': '/tmp/default.db',
}
}

# clean existing content
Expand Down Expand Up @@ -183,7 +188,8 @@ def deployNodekitZKContracts(nodekitZKDir: str, l1PRC: str, mnenoic: str):
# --l1-rpc-url="http://10.153.238.182:8545"
# --l1-ws-url="ws://10.153.238.182:8546"
# --seq-url="http://10.153.238.150:9650/ext/bc/24ummBEhg4mA8DV1ojNjpHpQVipSiVZUB1zhcmgLF7woWFmgDz"
def deployOPL2(opDir: str, l1RPC: str, l1WS: str, seqRPC: str, l2ChainID='45200', portIncrement=0):
def deployOPL2(opDir: str, gethProxyDir: str,l1RPC: str, l1WS: str, seqRPC: str, l2ChainID='45200', portIncrement=0):
# launch op-geth, op-node, op-proposer and op-batcher
cmd = ['python',
'bedrock-devnet/main.py',
'--monorepo-dir=.',
Expand All @@ -192,7 +198,7 @@ def deployOPL2(opDir: str, l1RPC: str, l1WS: str, seqRPC: str, l2ChainID='45200'
f"--l1-ws-url={l1WS}",
f"--seq-url={seqRPC}",
f"--l2-chain-id={l2ChainID}",
f"--l2-provider-url=http://localhost:{19545+portIncrement}"
f"--l2-provider-url=http://localhost:{19545+portIncrement}",
]

cmdStr = ' '.join(cmd)
Expand All @@ -208,7 +214,20 @@ def deployOPL2(opDir: str, l1RPC: str, l1WS: str, seqRPC: str, l2ChainID='45200'
)

if sub.returncode != 0:
raise Exception(f"unable to deploy contracts on ETH L1, reason: {sub.stderr}")
raise Exception(f"unable to launch op stack, reason: {sub.stderr}")

configureOpGethProxy(gethProxyDir, seqRPC, portIncrement)

cmd = ['docker', 'compose', 'up', '-d']
sub = run_command(
cmd,
stderr=sys.stderr,
stdout=sys.stdout,
cwd=gethProxyDir,
env={
'COMPOSE_PROJECT_NAME': f'proxy-{l2ChainID}'
}
)

def clean_op_deployment_temp_files(opDir: str):
tempfile_dir = pjoin(opDir, '.devnet')
Expand Down Expand Up @@ -392,20 +411,46 @@ def configureOPL2Port(opDir: str, portIncrement=0):
envPath = pjoin(opDir, 'ops-bedrock/.env')

defaultPortMapping = {
'OP1_CHAIN_ID': 45200,
'OP1_L2_RPC_PORT': 19545,
'OP1_L2_P2P_PORT': 30303,
'OP1_NODE_RPC_PORT': 18545,
'OP1_NODE_P2P_PORT': 40404,
'OP1_BATCHER_RPC_PORT': 17545,
'OP1_PROPOSER_RPC_PORT': 16545,
'OP1_GETH_PROXY_PORT': 9090,
}

for key in defaultPortMapping:
defaultPortMapping[key] += portIncrement

# TODO: use `write_dotenv_conf_to` after testing
print(f'writing .env for op chain: {defaultPortMapping}')
with open(envPath, 'w') as f:
for key in defaultPortMapping:
f.write(f'{key}={defaultPortMapping[key]}\n')

def configureOpGethProxy(gethProxyDir: str, seqRpc: str, portIncrement=0):
envPath = pjoin(gethProxyDir, '.env')

l2ChainID = 45200 + portIncrement
seqChainID = seqRpc.split('/')[-1]

config={
'OP1_GETH_PROXY_PORT': f'{9090+portIncrement}',
'OP1_L2_ADDR': f'http://host.docker.internal:{19545+portIncrement}',
'OP1_CHAIN_ID': f'{l2ChainID}',
'SEQ_CHAIN_ID': seqChainID,
'SEQ_ADDR': seqRpc,
'RETRY': '3',
}

write_dotenv_conf_to(config, envPath)

def write_dotenv_conf_to(conf, fname):
with open(fname, 'w') as f:
for key in conf:
f.write(f'{key}={conf[key]}\n')

def ensureDir(dir: str):
if not os.path.exists(dir):
Expand Down