Skip to content

Commit

Permalink
Merge pull request ethereum-optimism#331 from ethereum-optimism/sc/fi…
Browse files Browse the repository at this point in the history
…x-bridge-tutorial-ci

fix: tweak bridging tutorial CI job
  • Loading branch information
sbvegan authored Dec 19, 2023
2 parents 37b31e8 + 16c72e6 commit 4df38ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,21 @@ On OP Mainnet, this takes 7 days.

Once the withdrawal is ready to be relayed you can finally complete the withdrawal process.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L72 hash=f8d30944dad1664d82b9fdf14da59f9e
```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L85 hash=f8d30944dad1664d82b9fdf14da59f9e
```

{<h3>Wait until the withdrawal is relayed</h3>}

Now you simply wait until the message is relayed.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L75 hash=c2c14a739c44011a058e9848a0019f15
```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L88 hash=c2c14a739c44011a058e9848a0019f15
```

{<h3>Check your token balance on L1</h3>}

You should now have one more token on L1.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L78 hash=d7a60aa394d1055555c2aeab2a2e111d
```js file=<rootDir>/public/tutorials/cross-dom-bridge-erc20.js#L91 hash=d7a60aa394d1055555c2aeab2a2e111d
```

</Steps>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,21 @@ On OP Mainnet, this takes 7 days.

Once the withdrawal is ready to be relayed you can finally complete the withdrawal process.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L53 hash=f8d30944dad1664d82b9fdf14da59f9e
```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L66 hash=f8d30944dad1664d82b9fdf14da59f9e
```

{<h3>Wait until the withdrawal is relayed</h3>}

Now you simply wait until the message is relayed.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L56 hash=c2c14a739c44011a058e9848a0019f15
```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L69 hash=c2c14a739c44011a058e9848a0019f15
```

{<h3>Check your wallet balance on L1</h3>}

You should now have more ETH on L1.

```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L59 hash=3be1dd9a6019e9f59ad6fab38e168e99
```js file=<rootDir>/public/tutorials/cross-dom-bridge-eth.js#L72 hash=3be1dd9a6019e9f59ad6fab38e168e99
```

</Steps>
Expand Down
13 changes: 13 additions & 0 deletions public/tutorials/cross-dom-bridge-erc20.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ await messenger.proveMessage(withdrawal.hash)
console.log('Waiting for withdrawal to be relayable...')
await messenger.waitForMessageStatus(withdrawal.hash, optimism.MessageStatus.READY_FOR_RELAY)

// Wait for the next block to be produced, only necessary for CI because messenger can return
// READY_FOR_RELAY before the RPC we're using is caught up to the latest block. Waiting for an
// additional block ensures that the RPC is caught up and the message can be relayed. Users
// should not need to do this when running the tutorial.
const maxWaitTime = 120000 // 2 minutes in milliseconds
const currentBlock = await l1Provider.getBlockNumber()
while (await l1Provider.getBlockNumber() < currentBlock + 1) {
if (Date.now() > maxWaitTime) {
throw new Error('Timed out waiting for block to be produced')
}
await new Promise(resolve => setTimeout(resolve, 1000))
}

console.log('Relaying withdrawal...')
await messenger.finalizeMessage(withdrawal.hash)

Expand Down
13 changes: 13 additions & 0 deletions public/tutorials/cross-dom-bridge-eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ await messenger.proveMessage(withdrawal.hash)
console.log('Waiting for withdrawal to be relayable...')
await messenger.waitForMessageStatus(withdrawal.hash, optimism.MessageStatus.READY_FOR_RELAY)

// Wait for the next block to be produced, only necessary for CI because messenger can return
// READY_FOR_RELAY before the RPC we're using is caught up to the latest block. Waiting for an
// additional block ensures that the RPC is caught up and the message can be relayed. Users
// should not need to do this when running the tutorial.
const maxWaitTime = 120000 // 2 minutes in milliseconds
const currentBlock = await l1Provider.getBlockNumber()
while (await l1Provider.getBlockNumber() < currentBlock + 1) {
if (Date.now() > maxWaitTime) {
throw new Error('Timed out waiting for block to be produced')
}
await new Promise(resolve => setTimeout(resolve, 1000))
}

console.log('Relaying withdrawal...')
await messenger.finalizeMessage(withdrawal.hash)

Expand Down

0 comments on commit 4df38ea

Please sign in to comment.