Skip to content

Commit

Permalink
speed up ci by installing wait-on
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Cory authored and Will Cory committed Mar 30, 2024
1 parent 861e603 commit 9c6ed27
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@
"lint-staged": "15.2.0",
"mocha": "^10.2.0",
"nx": "18.1.2",
"nx-cloud": "latest",
"nyc": "^15.1.0",
"prettier": "^2.8.0",
"rimraf": "^5.0.5",
"ts-mocha": "^10.0.0",
"typescript": "^5.3.3",
"nx-cloud": "latest"
"wait-on": "^7.2.0"
},
"dependencies": {
"@changesets/cli": "^2.27.1"
Expand Down
36 changes: 18 additions & 18 deletions packages/sdk/src/cross-chain-messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1249,13 +1249,13 @@ export class CrossChainMessenger {
const challengePeriod =
oracleVersion === '1.0.0'
? // The ABI in the SDK does not contain FINALIZATION_PERIOD_SECONDS
// in OptimismPortal, so making an explicit call instead.
BigNumber.from(
await this.contracts.l1.OptimismPortal.provider.call({
to: this.contracts.l1.OptimismPortal.address,
data: '0xf4daa291', // FINALIZATION_PERIOD_SECONDS
})
)
// in OptimismPortal, so making an explicit call instead.
BigNumber.from(
await this.contracts.l1.OptimismPortal.provider.call({
to: this.contracts.l1.OptimismPortal.address,
data: '0xf4daa291', // FINALIZATION_PERIOD_SECONDS
})
)
: await this.contracts.l1.L2OutputOracle.FINALIZATION_PERIOD_SECONDS()
return challengePeriod.toNumber()
}
Expand Down Expand Up @@ -1496,7 +1496,7 @@ export class CrossChainMessenger {
// latest games are all invalid and the SDK would be forced to make a bunch of archive calls.
for (let i = matches.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[matches[i], matches[j]] = [matches[j], matches[i]]
;[matches[i], matches[j]] = [matches[j], matches[i]]
}

// Now we verify the proposals in the matches array.
Expand Down Expand Up @@ -2328,18 +2328,18 @@ export class CrossChainMessenger {
messageHashV1
)


// if failed we need to replay the message rather than finalizing it
if (isFailed === true) {
const tx = await this.contracts.l1.L1CrossDomainMessenger.populateTransaction.relayMessage(
xdmWithdrawal._nonce,
xdmWithdrawal._sender,
xdmWithdrawal._target,
xdmWithdrawal._value,
xdmWithdrawal._minGasLimit,
xdmWithdrawal._message,
opts?.overrides || {}
)
const tx =
await this.contracts.l1.L1CrossDomainMessenger.populateTransaction.relayMessage(
xdmWithdrawal._nonce,
xdmWithdrawal._sender,
xdmWithdrawal._target,
xdmWithdrawal._value,
xdmWithdrawal._minGasLimit,
xdmWithdrawal._message,
opts?.overrides || {}
)
return tx
}
if ('todo remove me') {
Expand Down
21 changes: 12 additions & 9 deletions packages/sdk/test-next/failedMessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Address, Hex, encodePacked, keccak256, toHex } from 'viem'
import { ethers } from 'ethers'
import { z } from 'zod'
import { hashCrossDomainMessagev1 } from '@eth-optimism/core-utils'
import { optimismSepolia } from 'viem/chains'

import { CONTRACT_ADDRESSES, CrossChainMessenger } from '../src'
import { sepoliaPublicClient, sepoliaTestClient } from './testUtils/viemClients'
import { sepoliaProvider, opSepoliaProvider } from './testUtils/ethersProviders'
import { optimismSepolia } from 'viem/chains'

/**
* Generated on Mar 28 2024 using
Expand All @@ -22,8 +22,9 @@ const failedMessagesStorageLayout = {
type: 't_mapping(t_bytes32,t_bool)',
}

const sepoliaCrossDomainMessengerAddress =
CONTRACT_ADDRESSES[optimismSepolia.id].l1.L1CrossDomainMessenger as Address
const sepoliaCrossDomainMessengerAddress = CONTRACT_ADDRESSES[
optimismSepolia.id
].l1.L1CrossDomainMessenger as Address

const setMessageAsFailed = async (tx: Hex) => {
const message = await crossChainMessenger.toCrossChainMessage(tx)
Expand All @@ -36,11 +37,12 @@ const setMessageAsFailed = async (tx: Hex) => {
message.message
) as Hex

const keySlotHash = keccak256(encodePacked(
['bytes32', 'uint256'],
[messageHash, failedMessagesStorageLayout.slot]

))
const keySlotHash = keccak256(
encodePacked(
['bytes32', 'uint256'],
[messageHash, failedMessagesStorageLayout.slot]
)
)
return sepoliaTestClient.setStorageAt({
address: sepoliaCrossDomainMessengerAddress,
index: keySlotHash,
Expand Down Expand Up @@ -75,7 +77,8 @@ describe('replaying failed messages', () => {

// debugging ethers.js is brutal because of error message so let's instead
// send the tx with viem. If it succeeds we will then test with ethers
const txData = await crossChainMessenger.populateTransaction.finalizeMessage(tx)
const txData =
await crossChainMessenger.populateTransaction.finalizeMessage(tx)

await sepoliaPublicClient.call({
data: txData.data as Hex,
Expand Down
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c6ed27

Please sign in to comment.