Logging in relayer engine processor

This commit is contained in:
Joe Howarth 2023-04-06 18:36:19 +00:00
parent 8737177208
commit 58760cc12e
2 changed files with 13 additions and 4 deletions

View File

@ -14,7 +14,7 @@
"@types/koa": "^2.13.5",
"clone": "^2.1.2",
"koa": "^2.14.1",
"wormhole-relayer": "github:gabzim/wormhole-relayer#0c82a15",
"wormhole-relayer": "github:gabzim/wormhole-relayer#03c7c62",
"yargs": "^17.7.1"
},
"devDependencies": {
@ -11469,7 +11469,7 @@
"wormhole-relayer": {
"version": "git+ssh://git@github.com/gabzim/wormhole-relayer.git#fcc1b7f05e19f4bfdbc2d44c919ee088b5fe5cf3",
"integrity": "sha512-m4n7D0kGKalw/Ag0IeEKgdeSPdNH//QRfg/Oz0eNpXENWHhPPe/aXN45xtmJzvzMKCwZNu2K6dhTJgDjDXE81A==",
"from": "wormhole-relayer@github:gabzim/wormhole-relayer#0c82a15",
"from": "wormhole-relayer@github:gabzim/wormhole-relayer#03c7c62",
"requires": {
"@bull-board/api": "^5.0.0",
"@bull-board/koa": "^5.0.0",

View File

@ -12,6 +12,7 @@ import { EVMChainId } from "@certusone/wormhole-sdk"
import { GRContext } from "./app"
export async function processGenericRelayerVaa(ctx: GRContext, next: Next) {
ctx.logger.info(`Processing generic relayer vaa`)
const payloadId = parseWormholeRelayerPayloadType(ctx.vaa!.payload)
// route payload types
if (payloadId != RelayerPayloadId.Delivery) {
@ -31,6 +32,9 @@ async function processDelivery(ctx: GRContext) {
) {
throw new Error(`Only supports EmitterSequence MessageInfoType`)
}
ctx.logger.info(`Fetching vaas from parsed delivery vaa manifest...`, {
manifest: payload.messages,
})
const fetchedVaas = await ctx.fetchVaas({
ids: payload.messages.map((m) => ({
emitterAddress: m.emitterAddress!,
@ -39,11 +43,16 @@ async function processDelivery(ctx: GRContext) {
})),
txHash: ctx.sourceTxHash,
})
ctx.logger.debug(`Vaas fetched`)
for (let i = 0; i < payload.instructions.length; i++) {
const ix = payload.instructions[i]
ctx.logger.debug(
`Processing instruction ${i + 1} of ${payload.instructions.length}`,
{ instruction: ix }
)
// const chainId = assertEvmChainId(ix.targetChain)
const chainId = ix.targetChain as EVMChainId
const budget = ix.receiverValueTarget.add(ix.maximumRefundTarget).add(100)
const budget = ix.receiverValueTarget.add(ix.maximumRefundTarget)
await ctx.wallets.onEVM(chainId, async ({ wallet }) => {
const coreRelayer = CoreRelayer__factory.connect(
@ -58,8 +67,8 @@ async function processDelivery(ctx: GRContext) {
relayerRefundAddress: wallet.address,
}
ctx.logger.debug("Sending 'deliver' tx...")
await coreRelayer
// @ts-ignore
.deliver(input, { value: budget, gasLimit: 3000000 })
.then((x) => x.wait())