Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix withdraw/deposit e2e test #261

Draft
wants to merge 3 commits into
base: celo10
Choose a base branch
from
Draft
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
18 changes: 8 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
cp -r .devnet/ .devnet-mt-cannon/
- run:
name: Generate Celo allocs
command: DEVNET_L2OO="true" DEVNET_CELO="true" make devnet-allocs
command: DEVNET_L2OO="false" DEVNET_ALTDA="true" GENERIC_ALTDA="true" DEVNET_CELO="true" make devnet-allocs
- run:
name: Copy Celo allocs to .devnet-celo
command: cp -r .devnet/ .devnet-celo/
Expand Down Expand Up @@ -259,12 +259,7 @@ jobs:
- ".devnet-altda"
- ".devnet-altda-generic"
- ".devnet-mt-cannon"
- ".devnet-celo/addresses.json"
- ".devnet-celo/allocs-l1.json"
- ".devnet-celo/allocs-l2-delta.json"
- ".devnet-celo/allocs-l2-ecotone.json"
- ".devnet-celo/allocs-l2-fjord.json"
- ".devnet-celo/addresses.json"
- ".devnet-celo"
- notify-failures-on-develop

docker-build:
Expand Down Expand Up @@ -1039,12 +1034,15 @@ jobs:
condition:
equal: ['celo', <<parameters.variant>>]
steps:
- run:
name: Set DEVNET_ALTDA = true
command: echo 'export DEVNET_ALTDA=true' >> $BASH_ENV
- run:
name: Set GENERIC_ALTDA = true
command: echo 'export GENERIC_ALTDA=true' >> $BASH_ENV
- run:
name: Set DEVNET_CELO = true
command: echo 'export DEVNET_CELO=true' >> $BASH_ENV
- run:
name: Set DEVNET_L2OO = true
command: echo 'export DEVNET_L2OO=true' >> $BASH_ENV
- when:
condition:
equal: ['altda-generic', <<parameters.variant>>]
Expand Down
6 changes: 5 additions & 1 deletion bedrock-devnet/devnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ def init_devnet_l1_deploy_config(paths, update_timestamp=False):
deploy_config['daCommitmentType'] = "GenericCommitment"
if DEVNET_CELO:
deploy_config['useFaultProofs'] = True
deploy_config['useCustomGasToken'] = True
deploy_config['gasPriceOracleScalar'] = 0
# 'gasPriceOracleScalar' has to be zero in order for those
# to work
deploy_config['gasPriceOracleBlobBaseFeeScalar'] = 0
deploy_config['gasPriceOracleBaseFeeScalar'] = 0

deploy_config['useCustomGasToken'] = True
deploy_config['deployCeloContracts'] = True
# Usage of the zero address in combination of the useCustomGasToken == True
# will deploy a new contract
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/celo/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [[ $spawn_devnet != false ]]; then
## Start geth
cd "$SCRIPT_DIR/../.." || exit 1
trap 'cd "$SCRIPT_DIR/../.." && make devnet-down' EXIT # kill bg job at exit
DEVNET_CELO=true make devnet-up
DEVNET_L2OO=false GENERIC_ALTDA=true DEVNET_ALTDA=true DEVNET_CELO=true make devnet-up
fi

cd "$SCRIPT_DIR" || exit 1
Expand Down
3 changes: 3 additions & 0 deletions op-e2e/celo/src/deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export async function deposit(args, config) {
const approveReceipt =
await config.client.l1.public.waitForTransactionReceipt({
hash: approveHash,
timeout: 30_000,
})

spentGas += approveReceipt.gasUsed * approveReceipt.effectiveGasPrice
Expand All @@ -108,6 +109,7 @@ export async function deposit(args, config) {
// Wait for the L1 transaction to be processed.
const receipt = await config.client.l1.public.waitForTransactionReceipt({
hash: hash,
timeout: 30_000,
})

spentGas += receipt.gasUsed * receipt.effectiveGasPrice
Expand All @@ -118,6 +120,7 @@ export async function deposit(args, config) {
// Wait for the L2 transaction to be processed.
const l2Receipt = await config.client.l2.public.waitForTransactionReceipt({
hash: l2Hash,
timeout: 30_000,
})

return {
Expand Down
23 changes: 12 additions & 11 deletions op-e2e/celo/src/withdraw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const withdraw = async function (args, config) {
export const withdraw = async function(args, config) {
const initiateHash = await config.client.l2.wallet.initiateWithdrawal({
request: {
gas: args.gas,
Expand All @@ -8,32 +8,32 @@ export const withdraw = async function (args, config) {
})
const receipt = await config.client.l2.public.waitForTransactionReceipt({
hash: initiateHash,
timeout: 30_000,
})
console.log('receipt', receipt)

const l2GasPayment =
receipt.gasUsed * receipt.effectiveGasPrice + receipt.l1fee
receipt.gasUsed * receipt.effectiveGasPrice + receipt.l1Fee

// FIXME: this blocks longer, the longer the devnet is running, see
// https://github.com/ethereum-optimism/optimism/issues/7668
// NOTE: this function requires the mulitcall contract to be deployed
// NOTE: this function requires the mulitcall3 contract to be deployed
// on the L1 chain.
const { output, withdrawal } = await config.client.l1.public.waitToProve({
receipt,
targetChain: config.client.l2.public.chain,
})
//
const { output, game, withdrawal } =
await config.client.l1.public.waitToProve({
receipt,
targetChain: config.client.l2.public.chain,
})

const proveWithdrawalArgs =
await config.client.l2.public.buildProveWithdrawal({
output,
game,
withdrawal,
})
const proveHash =
await config.client.l1.wallet.proveWithdrawal(proveWithdrawalArgs)

const proveReceipt = await config.client.l1.public.waitForTransactionReceipt({
hash: proveHash,
timeout: 30_000,
})
if (proveReceipt.status != 'success') {
return {
Expand Down Expand Up @@ -61,6 +61,7 @@ export const withdraw = async function (args, config) {
const finalizeReceipt =
await config.client.l1.public.waitForTransactionReceipt({
hash: finalizeHash,
timeout: 30_000,
})

return {
Expand Down
13 changes: 1 addition & 12 deletions op-e2e/celo/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function waitForNoError(func, timeout) {
try {
await func()
return true
} catch (error) {}
} catch (error) { }
await new Promise((r) => setTimeout(r, 1000))
}
return false
Expand All @@ -27,16 +27,6 @@ async function waitReachable(client, timeout) {
return waitForNoError(f, timeout)
}

async function waitForNextGame(client, l2ChainConfig, timeout) {
const f = async () =>
client.waitForNextGame({
pollingInterval: 500,
l2BlockNumber: 0,
targetChain: l2ChainConfig,
})
return waitForNoError(f, timeout)
}

export async function setup() {
const contractAddrs = JSON.parse(
readFileSync('../../.devnet/addresses.json', 'utf8')
Expand All @@ -55,7 +45,6 @@ export async function setup() {
const success = await Promise.all([
waitReachable(config.client.l1.public, 10_000),
waitReachable(config.client.l2.public, 10_000),
waitForNextGame(config.client.l1.public, chainConfig.l2, 60_000),
])
if (success.every((v) => v == true)) {
return config
Expand Down
1 change: 1 addition & 0 deletions op-e2e/celo/tests/tokenduality.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test(
const transferHash = await config.client.l2.wallet.writeContract(request)
const receipt = await config.client.l2.public.waitForTransactionReceipt({
hash: transferHash,
timeout: 30_000,
})
expect(receipt.status).toBe('success')
const balanceAfter = await config.client.l2.public.getBalance({
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/celo/tests/withdraw_deposit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ test(
balanceL2Before - withdrawResult.l2GasPayment
)
},
15 * minute
10 * minute
)
Loading