update with changes from 'redelidevery-fixes' branch

This commit is contained in:
Joe Howarth 2023-01-26 14:01:39 -07:00 committed by chase-45
parent 2cf9fb0dca
commit 3cac2165b4
3 changed files with 33 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { BigNumber, ethers} from "ethers"
import { BigNumber, ethers } from "ethers"
import { arrayify } from "ethers/lib/utils"
export enum RelayerPayloadId {
@ -34,6 +34,8 @@ export interface RedeliveryByTxHashInstruction {
sourceTxHash: Buffer
sourceNonce: BigNumber
targetChain: number
deliveryIndex: number
multisendIndex: number
newMaximumRefundTarget: BigNumber
newApplicationBudgetTarget: BigNumber
executionParameters: ExecutionParameters
@ -123,13 +125,23 @@ export function parseRedeliveryByTxHashInstruction(
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const targetChain = bytes.readUInt16BE(idx)
idx += 2
const deliveryIndex = bytes.readUint8(idx)
idx += 1
const multisendIndex = bytes.readUint8(idx)
idx += 1
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const executionParameters = parseExecutionParameters(bytes, idx)
return {
payloadId,
@ -137,6 +149,8 @@ export function parseRedeliveryByTxHashInstruction(
sourceTxHash,
sourceNonce,
targetChain,
deliveryIndex,
multisendIndex,
newMaximumRefundTarget,
newApplicationBudgetTarget,
executionParameters,

View File

@ -282,9 +282,6 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
).toString("base64")}`
)
const payloadId = parsePayloadType(coreRelayerVaa.payload)
if (payloadId !== RelayerPayloadId.Delivery) {
// todo: support redelivery
}
switch (payloadId) {
case RelayerPayloadId.Delivery:
return this.consumeDeliveryEvent(coreRelayerVaa, db)
@ -561,7 +558,7 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
encodedVMs: payload.vaas,
deliveryIndex: payload.deliveryVaaIndex,
multisendIndex: i,
relayerRefundAddress: relayProvider.address,
relayerRefundAddress: wallet.address,
}
if (!(await relayProvider.approvedSender(wallet.address))) {
@ -611,8 +608,8 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
const budget = newApplicationBudgetTarget.add(newMaximumRefundTarget).add(100)
const input: CoreRelayerStructs.TargetRedeliveryByTxHashParamsSingleStruct = {
sourceEncodedVMs: payload.vaas,
deliveryIndex: payload.deliveryVaaIndex,
multisendIndex: redelivery.ix.mul,
redeliveryVM: redelivery.vaa.bytes,
relayerRefundAddress: wallet.address,
}
relayProvider

View File

@ -1,4 +1,4 @@
import { BigNumber, ethers} from "ethers"
import { BigNumber, ethers } from "ethers"
import { arrayify } from "ethers/lib/utils"
export enum RelayerPayloadId {
@ -34,6 +34,8 @@ export interface RedeliveryByTxHashInstruction {
sourceTxHash: Buffer
sourceNonce: BigNumber
targetChain: number
deliveryIndex: number
multisendIndex: number
newMaximumRefundTarget: BigNumber
newApplicationBudgetTarget: BigNumber
executionParameters: ExecutionParameters
@ -123,13 +125,23 @@ export function parseRedeliveryByTxHashInstruction(
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const targetChain = bytes.readUInt16BE(idx)
idx += 2
const deliveryIndex = bytes.readUint8(idx)
idx += 1
const multisendIndex = bytes.readUint8(idx)
idx += 1
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
idx += 32
const executionParameters = parseExecutionParameters(bytes, idx)
return {
payloadId,
@ -137,6 +149,8 @@ export function parseRedeliveryByTxHashInstruction(
sourceTxHash,
sourceNonce,
targetChain,
deliveryIndex,
multisendIndex,
newMaximumRefundTarget,
newApplicationBudgetTarget,
executionParameters,