Skip to content

Commit

Permalink
fix(ci): fix e2e test failures after merge (ethereum-optimism#125)
Browse files Browse the repository at this point in the history
Co-authored-by: bnoieh <135800952+bnoieh@users.noreply.github.com>
  • Loading branch information
welkin22 and bnoieh authored Mar 8, 2024
1 parent ba7fb82 commit 0d298b1
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 94 deletions.
80 changes: 76 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,42 @@ jobs:
with:
go-version-file: go.mod

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Build dependencies
run: pnpm build

- name: Make file
run: make cannon-prestate && make devnet-allocs

- name: Install gotestsum
uses: autero1/action-gotestsum@v2.0.0
with:
Expand All @@ -172,9 +208,9 @@ jobs:
- name: Run tests
working-directory: op-e2e
run: |
OP_TESTLOG_DISABLE_COLOR=true OP_E2E_DISABLE_PARALLEL=false OP_E2E_USE_HTTP=true gotestsum \
OP_E2E_CANNON_ENABLED=false OP_TESTLOG_DISABLE_COLOR=true OP_E2E_DISABLE_PARALLEL=false OP_E2E_USE_HTTP=true gotestsum \
--format=testname --junitfile=/tmp/test-results/op-e2e_http_true.xml \
-- -timeout=20m -parallel=2 ./...
-- -timeout=30m -parallel=2 . ./...
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
Expand All @@ -195,6 +231,42 @@ jobs:
with:
go-version-file: go.mod

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Build dependencies
run: pnpm build

- name: Make file
run: make cannon-prestate && make devnet-allocs

- name: Install gotestsum
uses: autero1/action-gotestsum@v2.0.0
with:
Expand All @@ -203,9 +275,9 @@ jobs:
- name: Run tests
working-directory: op-e2e
run: |
OP_TESTLOG_DISABLE_COLOR=true OP_E2E_DISABLE_PARALLEL=false OP_E2E_USE_HTTP=false gotestsum \
OP_E2E_CANNON_ENABLED=false OP_TESTLOG_DISABLE_COLOR=true OP_E2E_DISABLE_PARALLEL=false OP_E2E_USE_HTTP=false gotestsum \
--format=testname --junitfile=/tmp/test-results/op-e2e_http_false.xml \
-- -timeout=20m -parallel=2 ./...
-- -timeout=30m -parallel=2 . ./...
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ cannon:
.PHONY: cannon

cannon-prestate: op-program cannon
./cannon/bin/cannon load-elf --path op-program/bin/op-program-client.elf --out op-program/bin/prestate.json --meta op-program/bin/meta.json
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate.json --meta op-program/bin/meta.json --proof-fmt 'op-program/bin/%d.json' --output ""
mv op-program/bin/0.json op-program/bin/prestate-proof.json
#./cannon/bin/cannon load-elf --path op-program/bin/op-program-client.elf --out op-program/bin/prestate.json --meta op-program/bin/meta.json
#./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate.json --meta op-program/bin/meta.json --proof-fmt 'op-program/bin/%d.json' --output ""
#mv op-program/bin/0.json op-program/bin/prestate-proof.json

mod-tidy:
# Below GOPRIVATE line allows mod-tidy to be run immediately after
Expand All @@ -112,12 +112,10 @@ pre-devnet:
@if [ ! -e op-program/bin ]; then \
make cannon-prestate; \
fi
pip3 install python-dotenv requests
.PHONY: pre-devnet

devnet-up: pre-devnet
pip3 install python-dotenv requests
./ops/scripts/newer-file.sh .devnet/addresses.json ./packages/contracts-bedrock \
|| make devnet-allocs
PYTHONPATH=./bedrock-devnet $(PYTHON) ./bedrock-devnet/main.py --monorepo-dir=.
.PHONY: devnet-up

Expand Down
9 changes: 4 additions & 5 deletions bedrock-devnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ It allows us to quickly start the devnet locally (with L1 network as BSC network

# requirement

docker, nodejs 16+, yarn, foundry, python2, python3
docker, nodejs 16+, yarn, foundry, python2, python3, pnpm

Tips:

Expand Down Expand Up @@ -46,10 +46,9 @@ make devnet-logs
```

# Notes
1. If you encounter a ValueError: invalid mode: 'rU' while trying to load binding.gyp error when executing `pnpm install`, this may be caused by python3 installed on your computer but Npm requires python 2.7. You need to install python 2.7 and configure the environment variable to specify the python version to use: `export npm_config_python=/path/to/executable/python`.
2. When executing for the first time, please be patient if you see the message "Waiting for RPC server at...", as the BSC network takes time to initialize.
3. If you encounter an error during the "Deploying contracts" step, please try again as it usually recovers.
4. L1 is accessible at http://localhost:8545, and L2 is accessible at http://localhost:9545
1. When executing for the first time, please be patient if you see the message "Waiting for RPC server at...", as the BSC network takes time to initialize.
2. If you encounter an error during the "Deploying contracts" step, please try again as it usually recovers.
3. L1 is accessible at http://localhost:8545, and L2 is accessible at http://localhost:9545

# Additional Information
L1 chain ID is 714.
Expand Down
157 changes: 109 additions & 48 deletions bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,81 @@ def main():
def deploy_contracts(paths):
wait_up(8545)
wait_for_rpc_server('http://127.0.0.1:8545')
# log.info('Wait for L1 for a period of time to avoid submitting transactions in the first few block heights.')
# time.sleep(10)
res = eth_accounts('127.0.0.1:8545')

response = json.loads(res)
account = response['result'][0]
log.info(f'Deploying with {account}')

# send some ether to the create2 deployer account
run_command([
'cast', 'send', '--from', account,
'--rpc-url', 'http://127.0.0.1:8545',
'--unlocked', '--value', '1ether', '0x3fAB184622Dc19b6109349B94811493BF2a45362'
], env={}, cwd=paths.contracts_bedrock_dir)

# deploy the create2 deployer
run_command([
'cast', 'publish', '--rpc-url', 'http://127.0.0.1:8545',
'0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222'
], env={}, cwd=paths.contracts_bedrock_dir)

fqn = 'scripts/Deploy.s.sol:Deploy'
run_command([
'forge', 'script', fqn, '--sender', account,
'--rpc-url', 'http://127.0.0.1:8545', '--broadcast',
'--unlocked'
], env={}, cwd=paths.contracts_bedrock_dir)

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)

def init_devnet_l1_deploy_config(paths, update_timestamp=False):
deploy_config = read_json(paths.devnet_config_template_path)
if update_timestamp:
deploy_config['l1GenesisBlockTimestamp'] = '{:#x}'.format(int(time.time()))
write_json(paths.devnet_config_path, deploy_config)

def devnet_l1_genesis(paths):
log.info('Generating L1 genesis state')
init_devnet_l1_deploy_config(paths)

geth = subprocess.Popen([
'geth', '--dev', '--http', '--http.api', 'eth,debug',
'--verbosity', '4', '--gcmode', 'archive', '--dev.gaslimit', '30000000',
'--rpc.allow-unprotected-txs'
])

try:
forge = ChildProcess(deploy_contracts, paths)
forge.start()
forge.join()
err = forge.get_error()
if err:
raise Exception(f"Exception occurred in child process: {err}")

res = debug_dumpBlock('127.0.0.1:8545')
response = json.loads(res)
allocs = response['result']

write_json(paths.allocs_path, allocs)
finally:
geth.terminate()

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
})
wait_up(8545)
wait_for_rpc_server('http://127.0.0.1:8545')
time.sleep(3)

l1env = dotenv_values('./ops-bedrock/l1.env')
log.info(l1env)
Expand Down Expand Up @@ -166,68 +239,35 @@ def deploy_contracts(paths):
'forge', 'script', fqn, '--sig', 'sync()',
'--rpc-url', 'http://127.0.0.1:8545'
], env={}, cwd=paths.contracts_bedrock_dir)

def init_devnet_l1_deploy_config(paths, update_timestamp=False):
deploy_config = read_json(paths.devnet_config_template_path)
if update_timestamp:
deploy_config['l1GenesisBlockTimestamp'] = '{:#x}'.format(int(time.time()))
write_json(paths.devnet_config_path, deploy_config)

def devnet_l1_genesis(paths):
log.info('Starting L1.')
init_devnet_l1_deploy_config(paths)

run_command(['docker-compose', 'up', '-d', 'l1'], cwd=paths.ops_bedrock_dir, env={
'PWD': paths.ops_bedrock_dir
})

forge = ChildProcess(deploy_contracts, paths)
forge.start()
forge.join()
err = forge.get_error()
if err:
raise Exception(f"Exception occurred in child process: {err}")

log.info('Start and Deploy L1 success.')

log.info('Deployed L1 contracts.')

# Bring up the devnet where the contracts are deployed to L1
def devnet_deploy(paths):
if os.path.exists(paths.addresses_json_path):
log.info('L1 genesis already generated.')
log.info('Starting L1.')
init_devnet_l1_deploy_config(paths)

run_command(['docker-compose', 'up', '-d', 'l1'], cwd=paths.ops_bedrock_dir, env={
'PWD': paths.ops_bedrock_dir
})
wait_up(8545)
wait_for_rpc_server('http://127.0.0.1:8545')
else:
log.info('Generating L1 genesis.')
if os.path.exists(paths.allocs_path) == False:
devnet_l1_genesis(paths)

init_devnet_l1_deploy_config(paths)
l1env = dotenv_values('./ops-bedrock/l1.env')
log.info(l1env)
bscChainId = l1env['BSC_CHAIN_ID']
l1_init_holder = l1env['INIT_HOLDER']
l1_init_holder_prv = l1env['INIT_HOLDER_PRV']
proposer_address = l1env['PROPOSER_ADDRESS']
proposer_address_prv = l1env['PROPOSER_ADDRESS_PRV']
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')
shutil.copy(devnet_cfg_orig, devnet_cfg_backup)
deploy_config = read_json(devnet_cfg_orig)
l1BlockTag = l1BlockTagGet()["result"]
log.info(l1BlockTag)
l1BlockTimestamp = l1BlockTimestampGet(l1BlockTag)["result"]["timestamp"]
log.info(l1BlockTimestamp)
deploy_config['l1GenesisBlockTimestamp'] = l1BlockTimestamp
deploy_config['l1StartingBlockTag'] = l1BlockTag
deploy_config['l1ChainID'] = int(bscChainId,10)
deploy_config['l2BlockTime'] = 1
deploy_config['sequencerWindowSize'] = 14400
deploy_config['channelTimeout'] = 1200
deploy_config['l2OutputOracleSubmissionInterval'] = 240
deploy_config['finalizationPeriodSeconds'] = 3
deploy_config['enableGovernance'] = False
deploy_config['eip1559Denominator'] = 8
deploy_config['eip1559DenominatorCanyon'] = 8
deploy_config['eip1559Elasticity'] = 2
deploy_config['batchSenderAddress'] = l1_init_holder
deploy_config['l2OutputOracleProposer'] = l1_init_holder
deploy_config['l2OutputOracleProposer'] = proposer_address
deploy_config['baseFeeVaultRecipient'] = l1_init_holder
deploy_config['l1FeeVaultRecipient'] = l1_init_holder
deploy_config['sequencerFeeVaultRecipient'] = l1_init_holder
Expand All @@ -237,6 +277,27 @@ def devnet_deploy(paths):
deploy_config['governanceTokenOwner'] = l1_init_holder
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
})
wait_up(8545)
wait_for_rpc_server('http://127.0.0.1:8545')
else:
log.info('Deploying L1 contracts.')
deployL1ContractsForDeploy(paths)

l1BlockTag = l1BlockTagGet()["result"]
log.info(l1BlockTag)
l1BlockTimestamp = l1BlockTimestampGet(l1BlockTag)["result"]["timestamp"]
log.info(l1BlockTimestamp)
deploy_config['l1GenesisBlockTimestamp'] = l1BlockTimestamp
deploy_config['l1StartingBlockTag'] = l1BlockTag
write_json(devnet_cfg_orig, deploy_config)

if os.path.exists(paths.genesis_l2_path):
log.info('L2 genesis and rollup configs already generated.')
else:
Expand Down
4 changes: 2 additions & 2 deletions cannon/example/claim/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ toolchain go1.21.1
require github.com/ethereum-optimism/optimism v0.0.0

require (
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
)

replace github.com/ethereum-optimism/optimism v0.0.0 => ../../..
2 changes: 2 additions & 0 deletions cannon/example/claim/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 0d298b1

Please sign in to comment.