forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relayer: Generic Relayer SDK for Merging into Main (wormhole-foundati…
…on#3040) * gRelayer: surrounding files * modification to get compilation * restore devnet * remove generic relayer docker * remove wait for relayer engine * keep build time 20 * sh -> bash * sh -> bash * Remove comment * bash -> sh * Revert "bash -> sh" This reverts commit 5c37e92. * bash->sh * gRelayer: ethereum folder changes for generic-relayer-merge * add eth-devnet * Adds .github because workflow needs to install forge * sdk-ci-tests need to install forge * don't wait for nonexistent relayer engine * update package.json and package-lock.json * Remove unnecessary types from package.json * ts-node * gRelayer: ethereum folder changes for generic-relayer-merge * sdk-ci-tests need to install forge * don't wait for nonexistent relayer engine * update package.json and package-lock.json * remove these changes * Relayer: Natspec documentation in IWormholeRelayer (wormhole-foundation#3032) * WIP * Fixes * Updated interfaces * remove bash * Forward uses same refund chain id and refund address (wormhole-foundation#3034) * WIP * Fixes * Forward uses same refund chain id and refund address * Updated interfaces * Adds .github because workflow needs to install forge * sdk-ci-tests need to install forge * don't wait for nonexistent relayer engine * SDK minus payload tests * Rename sdk relayer folder and file * modify index.ts * modify path * Remove forge build warnings * Add note to interface for resend * Verify additional VAAs in SDK * via-ir on unless in Tilt * Correct IWormholeReceiver interface * Wormhole message fee now part of quoteDeliveryPrice (wormhole-foundation#3043) * Fix to PR 3043 * Remove compiler warning * Remove files * remove generic relayer docker * Relayer/address drew review (wormhole-foundation#3060) * Fix typo in Create2Factory * Add event for contract upgrades * Prevent registering contract if it is already registered * Prevent allowing unset chainId for default delivery provider governance VAA * memory to calldata for external functions in WormholeRelayerSend * continue memory to calldata for external functions * Fix pricing in delivery provider * Sanity check new default delivery provider isn't 0 address * Don't save vaaKey as local variable * cache the length of array rather than iterate every time for vaaKeys * Replacing memory with calldata in few locations * Remove stale file DeliveryProviderMessages * Remove batch VAA sender script * Remove batch VAA from WormholeSimulator * Wait for a confirmation in deploy scripts * remove unnecessary comments * Fix Delivery Provider Pricing and add a test * remove console logs * Revert "continue memory to calldata for external functions" This reverts commit f322afb. * Revert "memory to calldata for external functions in WormholeRelayerSend" This reverts commit 42fcaad. * Revert "Don't save vaaKey as local variable" This reverts commit a917237. * Revert "cache the length of array rather than iterate every time for vaaKeys" This reverts commit d61380a. * Revert "Replacing memory with calldata in few locations" This reverts commit 94e47b6. * Revert "Fix typo in Create2Factory" This reverts commit a9f7bdf. * Update contract addresses for via-ir * Update register chain test to only do one registration * Slight improvements to delivery provider implementation * typed errors for delivery provider * Update SDK to have via-ir devnet address * Fix test * enable VIA-IR in CI and not in Tilt * Fix chain id * get register chain test to work * correct contract address for via ir * update sdk consts for via ir address * base 32 address * chain 24 not 26 * remove unintended line removal * restore WormholeRelayerSend
- Loading branch information
1 parent
7885acb
commit c83e889
Showing
14 changed files
with
2,483 additions
and
115 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
const copydir = require("copy-dir"); | ||
copydir.sync("../../ethereum/build/contracts", "./contracts"); | ||
console.log("Copying from ../../ethereum/ethers-contracts"); | ||
copydir.sync("../../ethereum/ethers-contracts", "src/ethers-contracts"); |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { afterAll, beforeEach, describe, expect, jest, test} from "@jest/globals"; | ||
import { ethers } from "ethers"; | ||
import { DeliveryProvider__factory } from "../../ethers-contracts" | ||
import {getAddressInfo} from "../consts" | ||
import {getDefaultProvider} from "../relayer/helpers" | ||
import {CHAINS, ChainId, ChainName, Network} from "../../../" | ||
import {getNetwork, PRIVATE_KEY, isCI} from "./utils/utils"; | ||
|
||
|
||
const network: Network = getNetwork(); | ||
const ci: boolean = isCI(); | ||
|
||
const sourceChain = network == 'DEVNET' ? "ethereum" : "avalanche"; | ||
const targetChain = network == 'DEVNET' ? "bsc" : "celo"; | ||
|
||
const sourceChainId = CHAINS[sourceChain]; | ||
const targetChainId = CHAINS[targetChain]; | ||
|
||
describe("Relay Provider Test", () => { | ||
|
||
|
||
const addressInfo = getAddressInfo(sourceChain, network); | ||
const provider = getDefaultProvider(network, sourceChain, ci); | ||
|
||
// signers | ||
const oracleDeployer = new ethers.Wallet(PRIVATE_KEY, provider); | ||
const deliveryProviderAddress = addressInfo.mockDeliveryProviderAddress; | ||
if(!deliveryProviderAddress) throw Error("No relay provider address"); | ||
const deliveryProvider = DeliveryProvider__factory.connect(deliveryProviderAddress, oracleDeployer); | ||
|
||
|
||
describe("Read Prices Correctly", () => { | ||
test("readPrices", async () => { | ||
const tokenPrice = ethers.BigNumber.from("100000"); | ||
const gasPrice = ethers.utils.parseUnits("300", "gwei"); | ||
|
||
const tokenPriceReturned = await deliveryProvider.nativeCurrencyPrice(targetChainId); | ||
const gasPriceReturned = await deliveryProvider.gasPrice(targetChainId); | ||
|
||
expect(tokenPriceReturned.toString()).toBe(tokenPrice.toString()); | ||
expect(gasPriceReturned.toString()).toBe(gasPrice.toString()); | ||
|
||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Network } from "../../../utils"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { ethers } from "ethers"; | ||
import {ETH_PRIVATE_KEY, Environment} from "../../../token_bridge/__tests__/utils/consts"; | ||
|
||
const SAFE_RELAY_DELAY = 10000; | ||
|
||
const characters = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
|
||
export const PRIVATE_KEY = process.env['WALLET_KEY'] || ETH_PRIVATE_KEY; | ||
|
||
export const networkOptions = ["MAINNET", "TESTNET", "DEVNET"]; | ||
|
||
export const isCI = (): boolean => { | ||
return !!process.env['CI']; | ||
} | ||
|
||
export const getNetwork = (): Network => { | ||
const network = process.env['NETWORK'] || ""; | ||
if(!(networkOptions.includes(network))) throw Error(`Invalid Network: ${network}. Options ${networkOptions.join(", ")}`); | ||
return network as Network; | ||
} | ||
|
||
export const generateRandomString = (length: number) => { | ||
let randomString = ""; | ||
for (let i = 0; i < length; i++) { | ||
randomString += characters.charAt( | ||
Math.floor(Math.random() * characters.length) | ||
); | ||
} | ||
return randomString; | ||
}; | ||
|
||
export const getArbitraryBytes32 = (): string => { | ||
return ethers.utils.hexlify( | ||
ethers.utils.toUtf8Bytes(generateRandomString(32)) | ||
); | ||
} | ||
|
||
export async function waitForRelay(quantity?: number) { | ||
await new Promise((resolve) => | ||
setTimeout(resolve, SAFE_RELAY_DELAY * (quantity || 1)) | ||
); | ||
} | ||
|
||
export const getGuardianRPC = (network: Network, ci: boolean) => { | ||
return process.env.GUARDIAN_RPC || (ci ? "http://guardian:7071" : network == "DEVNET" ? "http://localhost:7071" : network == "TESTNET" ? "https://wormhole-v2-testnet-api.certus.one" : "https://wormhole-v2-mainnet-api.certus.one"); | ||
} | ||
|
||
// These variables also live in testing/solana-test-validator/sdk-tests/helpers | ||
// Ideally we find a better home for these (probably somewhere in the SDK) | ||
// These are used to mock a devnet/CI guardian | ||
|
||
export const GUARDIAN_KEYS = process.env.GUARDIAN_KEY ? [process.env.GUARDIAN_KEY] : [ | ||
"cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0", | ||
"c3b2e45c422a1602333a64078aeb42637370b0f48fe385f9cfa6ad54a8e0c47e", | ||
"9f790d3f08bc4b5cd910d4278f3deb406e57bb5e924906ccd52052bb078ccd47", | ||
"b20cc49d6f2c82a5e6519015fc18aa3e562867f85f872c58f1277cfbd2a0c8e4", | ||
"eded5a2fdcb5bbbfa5b07f2a91393813420e7ac30a72fc935b6df36f8294b855", | ||
"00d39587c3556f289677a837c7f3c0817cb7541ce6e38a243a4bdc761d534c5e", | ||
"da534d61a8da77b232f3a2cee55c0125e2b3e33a5cd8247f3fe9e72379445c3b", | ||
"cdbabfc2118eb00bc62c88845f3bbd03cb67a9e18a055101588ca9b36387006c", | ||
"c83d36423820e7350428dc4abe645cb2904459b7d7128adefe16472fdac397ba", | ||
"1cbf4e1388b81c9020500fefc83a7a81f707091bb899074db1bfce4537428112", | ||
"17646a6ba14a541957fc7112cc973c0b3f04fce59484a92c09bb45a0b57eb740", | ||
"eb94ff04accbfc8195d44b45e7c7da4c6993b2fbbfc4ef166a7675a905df9891", | ||
"053a6527124b309d914a47f5257a995e9b0ad17f14659f90ed42af5e6e262b6a", | ||
"3fbf1e46f6da69e62aed5670f279e818889aa7d8f1beb7fd730770fd4f8ea3d7", | ||
"53b05697596ba04067e40be8100c9194cbae59c90e7870997de57337497172e9", | ||
"4e95cb2ff3f7d5e963631ad85c28b1b79cb370f21c67cbdd4c2ffb0bf664aa06", | ||
"01b8c448ce2c1d43cfc5938d3a57086f88e3dc43bb8b08028ecb7a7924f4676f", | ||
"1db31a6ba3bcd54d2e8a64f8a2415064265d291593450c6eb7e9a6a986bd9400", | ||
"70d8f1c9534a0ab61a020366b831a494057a289441c07be67e4288c44bc6cd5d", | ||
]; | ||
export const GUARDIAN_SET_INDEX = process.env.GUARDIAN_SET_INDEX ? parseInt(process.env.GUARDIAN_SET_INDEX) : 0; | ||
export const GOVERNANCE_EMITTER_ADDRESS = process.env.GOVERNANCE_EMITTER_ADDRESS || new PublicKey( | ||
"11111111111111111111111111111115" | ||
).toBuffer().toString("hex"); | ||
|
Oops, something went wrong.