diff --git a/.gitmodules b/.gitmodules index 206eac9..44504d8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/ansible-avalanche-getting-started b/ansible-avalanche-getting-started index 49e5cfb..db41834 160000 --- a/ansible-avalanche-getting-started +++ b/ansible-avalanche-getting-started @@ -1 +1 @@ -Subproject commit 49e5cfb8cbff413fec5003aa43f6252a1e789b28 +Subproject commit db41834b863aa8b78c3fd6e6603507d2875c0690 diff --git a/main.py b/main.py index 7beb3cc..777ca23 100644 --- a/main.py +++ b/main.py @@ -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", @@ -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) @@ -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) diff --git a/op-geth-proxy b/op-geth-proxy new file mode 160000 index 0000000..382aca3 --- /dev/null +++ b/op-geth-proxy @@ -0,0 +1 @@ +Subproject commit 382aca3827d5b59c4490d0b20a4dd3c6bb403593 diff --git a/op-integration b/op-integration index d072b55..698ddb5 160000 --- a/op-integration +++ b/op-integration @@ -1 +1 @@ -Subproject commit d072b550b21a7ee6c6b810657a170ca9bea8edc0 +Subproject commit 698ddb55e8680e796e88c54a86a1b27c8985e9a1 diff --git a/readme.md b/readme.md index 411f40d..f6e9f78 100644 --- a/readme.md +++ b/readme.md @@ -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 ``` diff --git a/utils.py b/utils.py index 7f8746b..c50a197 100644 --- a/utils.py +++ b/utils.py @@ -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 @@ -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=.', @@ -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) @@ -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') @@ -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):