forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix devnet after 1.7.2 upstream merge (ethereum-optimism#194)
- Loading branch information
Showing
7 changed files
with
93 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
parser.add_argument('--monorepo-dir', help='Directory of the monorepo', default=os.getcwd()) | ||
parser.add_argument('--allocs', help='Only create the allocs and exit', type=bool, action=argparse.BooleanOptionalAction) | ||
parser.add_argument('--test', help='Tests the deployment, must already be deployed', type=bool, action=argparse.BooleanOptionalAction) | ||
parser.add_argument('--init', help='init BSC L1 devnet chain', type=bool, action=argparse.BooleanOptionalAction) | ||
|
||
log = logging.getLogger() | ||
|
||
|
@@ -63,6 +64,9 @@ def main(): | |
|
||
monorepo_dir = os.path.abspath(args.monorepo_dir) | ||
devnet_dir = pjoin(monorepo_dir, '.devnet') | ||
bsc_dir = pjoin(devnet_dir, 'bsc') | ||
node_deploy_dir = pjoin(devnet_dir, 'node-deploy') | ||
node_deploy_genesis_dir = pjoin(node_deploy_dir, 'genesis') | ||
contracts_bedrock_dir = pjoin(monorepo_dir, 'packages', 'contracts-bedrock') | ||
deployment_dir = pjoin(contracts_bedrock_dir, 'deployments', 'devnetL1') | ||
forge_dump_path = pjoin(contracts_bedrock_dir, 'Deploy-900.json') | ||
|
@@ -77,6 +81,9 @@ def main(): | |
paths = Bunch( | ||
mono_repo_dir=monorepo_dir, | ||
devnet_dir=devnet_dir, | ||
bsc_dir=bsc_dir, | ||
node_deploy_dir=node_deploy_dir, | ||
node_deploy_genesis_dir=node_deploy_genesis_dir, | ||
contracts_bedrock_dir=contracts_bedrock_dir, | ||
deployment_dir=deployment_dir, | ||
forge_dump_path=forge_dump_path, | ||
|
@@ -107,6 +114,10 @@ def main(): | |
devnet_l1_genesis(paths) | ||
return | ||
|
||
if args.init: | ||
bsc_l1_init(paths) | ||
return | ||
|
||
git_commit = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True, text=True).stdout.strip() | ||
git_date = subprocess.run(['git', 'show', '-s', "--format=%ct"], capture_output=True, text=True).stdout.strip() | ||
|
||
|
@@ -204,9 +215,7 @@ def devnet_l1_genesis(paths): | |
def deployL1ContractsForDeploy(paths): | ||
log.info('Starting L1.') | ||
|
||
run_command(['docker-compose', 'up', '-d', 'l1'], cwd=paths.ops_bedrock_dir, env={ | ||
'PWD': paths.ops_bedrock_dir | ||
}) | ||
run_command(['./start_cluster.sh','start'], cwd=paths.node_deploy_dir) | ||
wait_up(8545) | ||
wait_for_rpc_server('http://127.0.0.1:8545') | ||
time.sleep(3) | ||
|
@@ -247,15 +256,16 @@ def deployL1ContractsForDeploy(paths): | |
|
||
shutil.copy(paths.l1_deployments_path, paths.addresses_json_path) | ||
|
||
log.info('Syncing contracts.') | ||
run_command([ | ||
'forge', 'script', fqn, '--sig', 'sync()', | ||
'--rpc-url', 'http://127.0.0.1:8545' | ||
], env={}, cwd=paths.contracts_bedrock_dir) | ||
# log.info('Syncing contracts.') | ||
# run_command([ | ||
# 'forge', 'script', fqn, '--sig', 'sync()', | ||
# '--rpc-url', 'http://127.0.0.1:8545' | ||
# ], env={}, cwd=paths.contracts_bedrock_dir) | ||
log.info('Deployed L1 contracts.') | ||
|
||
# Bring up the devnet where the contracts are deployed to L1 | ||
def devnet_deploy(paths): | ||
bsc_l1_init(paths) | ||
init_devnet_l1_deploy_config(paths) | ||
l1env = dotenv_values('./ops-bedrock/l1.env') | ||
log.info(l1env) | ||
|
@@ -267,6 +277,7 @@ def devnet_deploy(paths): | |
log.info('Generating network config.') | ||
devnet_cfg_orig = pjoin(paths.contracts_bedrock_dir, 'deploy-config', 'devnetL1.json') | ||
devnet_cfg_backup = pjoin(paths.devnet_dir, 'devnetL1.json.bak') | ||
devnet_cfg_final = pjoin(paths.devnet_dir, 'devnetL1.json') | ||
shutil.copy(devnet_cfg_orig, devnet_cfg_backup) | ||
deploy_config = read_json(devnet_cfg_orig) | ||
deploy_config['l1ChainID'] = int(bscChainId,10) | ||
|
@@ -286,17 +297,17 @@ def devnet_deploy(paths): | |
deploy_config['sequencerFeeVaultRecipient'] = l1_init_holder | ||
deploy_config['proxyAdminOwner'] = l1_init_holder | ||
deploy_config['finalSystemOwner'] = l1_init_holder | ||
deploy_config['portalGuardian'] = l1_init_holder | ||
deploy_config['governanceTokenOwner'] = l1_init_holder | ||
deploy_config['l2GenesisDeltaTimeOffset'] = "0x1" | ||
deploy_config['fermat'] = 0 | ||
deploy_config['L2GenesisEcotoneTimeOffset'] = "0x2" | ||
write_json(devnet_cfg_orig, deploy_config) | ||
|
||
if os.path.exists(paths.addresses_json_path): | ||
log.info('L1 contracts already deployed.') | ||
log.info('Starting L1.') | ||
|
||
run_command(['docker-compose', 'up', '-d', 'l1'], cwd=paths.ops_bedrock_dir, env={ | ||
'PWD': paths.ops_bedrock_dir | ||
}) | ||
run_command(['./start_cluster.sh','start'], cwd=paths.node_deploy_dir) | ||
wait_up(8545) | ||
wait_for_rpc_server('http://127.0.0.1:8545') | ||
else: | ||
|
@@ -310,6 +321,7 @@ def devnet_deploy(paths): | |
deploy_config['l1GenesisBlockTimestamp'] = l1BlockTimestamp | ||
deploy_config['l1StartingBlockTag'] = l1BlockTag | ||
write_json(devnet_cfg_orig, deploy_config) | ||
write_json(devnet_cfg_final, deploy_config) | ||
|
||
if os.path.exists(paths.genesis_l2_path): | ||
log.info('L2 genesis and rollup configs already generated.') | ||
|
@@ -351,6 +363,44 @@ def devnet_deploy(paths): | |
|
||
log.info('Devnet ready.') | ||
|
||
def bsc_l1_init(paths): | ||
l1env = dotenv_values('./ops-bedrock/l1.env') | ||
log.info(l1env) | ||
l1_init_holder = l1env['INIT_HOLDER'] | ||
l1_init_holder_prv = l1env['INIT_HOLDER_PRV'] | ||
if os.path.exists(paths.bsc_dir): | ||
log.info('bsc path exists, skip git clone') | ||
else: | ||
run_command(['git','clone','https://github.com/bnb-chain/bsc.git'], cwd=paths.devnet_dir) | ||
run_command(['git','checkout','v1.4.5'], cwd=paths.bsc_dir) | ||
run_command(['make','geth'], cwd=paths.bsc_dir) | ||
run_command(['go','build','-o', './build/bin/bootnode', './cmd/bootnode'], cwd=paths.bsc_dir) | ||
if os.path.exists(paths.node_deploy_dir): | ||
log.info('node-deploy path exists, skip git clone') | ||
else: | ||
run_command(['git','clone','https://github.com/bnb-chain/node-deploy.git'], cwd=paths.devnet_dir) | ||
run_command(['git','checkout','27e7ca669a27c8fd259eeb88ba33ef5a1b4ac182'], cwd=paths.node_deploy_dir) | ||
run_command(['git','submodule','update','--init','--recursive'], cwd=paths.node_deploy_dir) | ||
run_command(['pip3','install','-r','requirements.txt'], cwd=paths.node_deploy_dir) | ||
run_command(['npm','install'], cwd=paths.node_deploy_genesis_dir) | ||
run_command(['forge','install','--no-git','--no-commit','foundry-rs/[email protected]'], cwd=paths.node_deploy_genesis_dir) | ||
run_command(['poetry','install'], cwd=paths.node_deploy_genesis_dir) | ||
with open(pjoin(paths.node_deploy_dir,'.env'), 'r') as file: | ||
file_content = file.read() | ||
file_content = file_content.replace('0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186', l1_init_holder) | ||
file_content = file_content.replace('59ba8068eb256d520179e903f43dacf6d8d57d72bd306e1bd603fdb8c8da10e8', l1_init_holder_prv) | ||
with open(pjoin(paths.node_deploy_dir,'.env'), 'w') as file: | ||
file.write(file_content) | ||
|
||
shutil.copy(pjoin(paths.bsc_dir,'build','bin','geth'), pjoin(paths.node_deploy_dir,'bin','geth')) | ||
shutil.copy(pjoin(paths.bsc_dir,'build','bin','bootnode'), pjoin(paths.node_deploy_dir,'bin','bootnode')) | ||
if os.path.exists(pjoin(paths.node_deploy_dir,'.local')): | ||
log.info('already init .local config file, skip init script') | ||
else: | ||
run_command(['chmod','+x','start_cluster.sh'], cwd=paths.node_deploy_dir) | ||
run_command(['./start_cluster.sh','reset'], cwd=paths.node_deploy_dir) | ||
run_command(['./start_cluster.sh','stop'], cwd=paths.node_deploy_dir) | ||
|
||
def wait_for_rpc_server(url): | ||
log.info(f'Waiting for RPC server at {url}') | ||
body = '{"id":1, "jsonrpc":"2.0", "method": "eth_chainId", "params":[]}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
FROM golang:1.19-alpine3.18 as build | ||
FROM golang:1.21-alpine3.18 as build | ||
RUN apk add --no-cache git make cmake gcc musl-dev linux-headers build-base libc-dev gcompat | ||
RUN git clone https://github.com/bnb-chain/bsc.git | ||
RUN cd bsc && git checkout v1.2.12 && make geth && go build -o ./build/bin/bootnode ./cmd/bootnode | ||
RUN git clone https://github.com/bnb-chain/node.git | ||
RUN cd node && git checkout v0.10.16 && make build | ||
RUN cd bsc && git checkout v1.4.5 && make geth && go build -o ./build/bin/bootnode ./cmd/bootnode | ||
|
||
FROM golang:1.19-alpine3.18 | ||
FROM golang:1.21-alpine3.18 | ||
|
||
RUN apk add --no-cache bash expect wget nodejs npm git jq make cmake gcc musl-dev linux-headers build-base libc-dev gcompat python3 | ||
|
||
RUN mkdir /db | ||
RUN cd /db && git clone https://github.com/bnb-chain/node-deploy.git | ||
RUN cd /db/node-deploy && git checkout 7492b04275c6e802acc90868e29b6a0a34b8849b && make tool | ||
RUN cd /db/node-deploy && git checkout 27e7ca669a27c8fd259eeb88ba33ef5a1b4ac182 | ||
COPY --from=build /go/bsc/build/bin/geth /db/node-deploy/bin/geth | ||
COPY --from=build /go/bsc/build/bin/bootnode /db/node-deploy/bin/bootnode | ||
COPY --from=build /go/node/build/tbnbcli /db/node-deploy/bin/tbnbcli | ||
COPY --from=build /go/node/build/bnbchaind /db/node-deploy/bin/bnbchaind | ||
|
||
ENTRYPOINT ["/bin/sh", "/l1-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.