debugging
This commit is contained in:
parent
58760cc12e
commit
b1da1930be
|
@ -48,7 +48,7 @@ contract CoreRelayerDelivery is CoreRelayerGovernance {
|
||||||
|
|
||||||
// Checks if enough funds were passed into the forward (should always be true as it was already checked)
|
// Checks if enough funds were passed into the forward (should always be true as it was already checked)
|
||||||
if (fundsForForward < forwardInstruction.totalFee) {
|
if (fundsForForward < forwardInstruction.totalFee) {
|
||||||
revert IDelivery.ForwardNotSufficientlyFunded();
|
revert IDelivery.ForwardNotSufficientlyFunded(fundsForForward, forwardInstruction.totalFee);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRelayProvider relayProvider = IRelayProvider(forwardInstruction.relayProvider);
|
IRelayProvider relayProvider = IRelayProvider(forwardInstruction.relayProvider);
|
||||||
|
|
|
@ -14,7 +14,7 @@ contract ForwardWrapper {
|
||||||
IWormhole wormhole;
|
IWormhole wormhole;
|
||||||
|
|
||||||
error RequesterNotCoreRelayer();
|
error RequesterNotCoreRelayer();
|
||||||
error ForwardNotSufficientlyFunded(uint256 extraAmountNeeded);
|
error ForwardNotSufficientlyFunded(uint256 amountOfFunds, uint256 amountOfFundsNeeded);
|
||||||
|
|
||||||
constructor(address _wormholeRelayer, address _wormhole) {
|
constructor(address _wormholeRelayer, address _wormhole) {
|
||||||
forwardInstructionViewer = IForwardInstructionViewer(_wormholeRelayer);
|
forwardInstructionViewer = IForwardInstructionViewer(_wormholeRelayer);
|
||||||
|
@ -55,7 +55,7 @@ contract ForwardWrapper {
|
||||||
if (forwardInstruction.isValid) {
|
if (forwardInstruction.isValid) {
|
||||||
uint256 feeForForward = transactionFeeRefundAmount + forwardInstruction.msgValue;
|
uint256 feeForForward = transactionFeeRefundAmount + forwardInstruction.msgValue;
|
||||||
if (feeForForward < forwardInstruction.totalFee) {
|
if (feeForForward < forwardInstruction.totalFee) {
|
||||||
revert ForwardNotSufficientlyFunded(forwardInstruction.totalFee - feeForForward);
|
revert ForwardNotSufficientlyFunded(feeForForward, forwardInstruction.totalFee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,5 +53,5 @@ interface IDelivery {
|
||||||
error ReentrantCall(); // A delivery cannot occur during another delivery
|
error ReentrantCall(); // A delivery cannot occur during another delivery
|
||||||
error MessageInfosDoNotMatchVaas(uint8 index); // The VAA at index 'index' does not match the 'index'-th description given on the source chain in the 'messages' field
|
error MessageInfosDoNotMatchVaas(uint8 index); // The VAA at index 'index' does not match the 'index'-th description given on the source chain in the 'messages' field
|
||||||
error MessageInfosLengthDoesNotMatchVaasLength(); // The VAA array has a different length than the original array of MessageInfo descriptions from the source chain
|
error MessageInfosLengthDoesNotMatchVaasLength(); // The VAA array has a different length than the original array of MessageInfo descriptions from the source chain
|
||||||
error ForwardNotSufficientlyFunded(); // Should never happen as this should have already been checked for
|
error ForwardNotSufficientlyFunded(uint256 amountOfFunds, uint256 amountOfFundsNeeded); // Should never happen as this should have already been checked for
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ contract AttackForwardIntegration is IWormholeReceiver {
|
||||||
|
|
||||||
// Capture 30k gas for fees
|
// Capture 30k gas for fees
|
||||||
// This just needs to be enough to pay for the call to the destination address.
|
// This just needs to be enough to pay for the call to the destination address.
|
||||||
uint32 SAFE_DELIVERY_GAS_CAPTURE = 30000;
|
uint32 SAFE_DELIVERY_GAS_CAPTURE = 50000;
|
||||||
|
|
||||||
constructor(IWormhole initWormhole, IWormholeRelayer initCoreRelayer, uint16 chainId, address initAttackerReward) {
|
constructor(IWormhole initWormhole, IWormholeRelayer initCoreRelayer, uint16 chainId, address initAttackerReward) {
|
||||||
attackerReward = initAttackerReward;
|
attackerReward = initAttackerReward;
|
||||||
|
|
|
@ -405,9 +405,9 @@ contract WormholeRelayerTests is Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testForward(GasParameters memory gasParams, FeeParameters memory feeParams, bytes memory message) public {
|
function testForward(GasParameters memory gasParams, FeeParameters memory feeParams, bytes memory message) public {
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1400000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
|
|
||||||
uint256 payment = assumeAndGetForwardPayment(gasParams.targetGasLimit, 500000, setup, gasParams, feeParams);
|
uint256 payment = assumeAndGetForwardPayment(gasParams.targetGasLimit, 700000, setup, gasParams, feeParams);
|
||||||
|
|
||||||
vm.recordLogs();
|
vm.recordLogs();
|
||||||
|
|
||||||
|
@ -1045,7 +1045,7 @@ contract WormholeRelayerTests is Test {
|
||||||
new ForwardTester(address(setup.target.wormhole), address(setup.target.coreRelayer), address(setup.target.wormholeSimulator));
|
new ForwardTester(address(setup.target.wormhole), address(setup.target.coreRelayer), address(setup.target.wormholeSimulator));
|
||||||
vm.deal(address(forwardTester), type(uint256).max / 2);
|
vm.deal(address(forwardTester), type(uint256).max / 2);
|
||||||
stack.targetAddress = setup.source.coreRelayer.toWormholeFormat(address(forwardTester));
|
stack.targetAddress = setup.source.coreRelayer.toWormholeFormat(address(forwardTester));
|
||||||
stack.payment = assumeAndGetForwardPayment(gasParams.targetGasLimit, 500000, setup, gasParams, feeParams);
|
stack.payment = assumeAndGetForwardPayment(gasParams.targetGasLimit, 700000, setup, gasParams, feeParams);
|
||||||
stack.wormholeFee = setup.source.wormhole.messageFee();
|
stack.wormholeFee = setup.source.wormhole.messageFee();
|
||||||
uint64 sequence =
|
uint64 sequence =
|
||||||
setup.source.wormhole.publishMessage{value: stack.wormholeFee}(1, abi.encodePacked(uint8(test)), 200);
|
setup.source.wormhole.publishMessage{value: stack.wormholeFee}(1, abi.encodePacked(uint8(test)), 200);
|
||||||
|
@ -1063,7 +1063,7 @@ contract WormholeRelayerTests is Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testForwardTester(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
function testForwardTester(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1400000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.WorksCorrectly, DeliveryStatus.FORWARD_REQUEST_SUCCESS, setup, gasParams, feeParams
|
ForwardTester.Action.WorksCorrectly, DeliveryStatus.FORWARD_REQUEST_SUCCESS, setup, gasParams, feeParams
|
||||||
);
|
);
|
||||||
|
@ -1084,7 +1084,7 @@ contract WormholeRelayerTests is Test {
|
||||||
function testRevertForwardMultipleForwardsRequested(GasParameters memory gasParams, FeeParameters memory feeParams)
|
function testRevertForwardMultipleForwardsRequested(GasParameters memory gasParams, FeeParameters memory feeParams)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.MultipleForwardsRequested, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
ForwardTester.Action.MultipleForwardsRequested, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
||||||
);
|
);
|
||||||
|
@ -1093,7 +1093,7 @@ contract WormholeRelayerTests is Test {
|
||||||
function testRevertForwardMultichainSendEmpty(GasParameters memory gasParams, FeeParameters memory feeParams)
|
function testRevertForwardMultichainSendEmpty(GasParameters memory gasParams, FeeParameters memory feeParams)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
|
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.MultichainSendEmpty, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
ForwardTester.Action.MultichainSendEmpty, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
||||||
|
@ -1104,7 +1104,7 @@ contract WormholeRelayerTests is Test {
|
||||||
GasParameters memory gasParams,
|
GasParameters memory gasParams,
|
||||||
FeeParameters memory feeParams
|
FeeParameters memory feeParams
|
||||||
) public {
|
) public {
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
|
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.ForwardRequestFromWrongAddress,
|
ForwardTester.Action.ForwardRequestFromWrongAddress,
|
||||||
|
@ -1116,7 +1116,7 @@ contract WormholeRelayerTests is Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRevertDeliveryReentrantCall(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
function testRevertDeliveryReentrantCall(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.ReentrantCall, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
ForwardTester.Action.ReentrantCall, DeliveryStatus.RECEIVER_FAILURE, setup, gasParams, feeParams
|
||||||
);
|
);
|
||||||
|
@ -1125,7 +1125,7 @@ contract WormholeRelayerTests is Test {
|
||||||
function testRevertForwardMaxTransactionFeeNotEnough(GasParameters memory gasParams, FeeParameters memory feeParams)
|
function testRevertForwardMaxTransactionFeeNotEnough(GasParameters memory gasParams, FeeParameters memory feeParams)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
|
|
||||||
executeForwardTest(
|
executeForwardTest(
|
||||||
ForwardTester.Action.MaxTransactionFeeNotEnough,
|
ForwardTester.Action.MaxTransactionFeeNotEnough,
|
||||||
|
@ -1137,7 +1137,7 @@ contract WormholeRelayerTests is Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRevertForwardFundsTooMuch(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
function testRevertForwardFundsTooMuch(GasParameters memory gasParams, FeeParameters memory feeParams) public {
|
||||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1200000);
|
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||||
|
|
||||||
setup.target.relayProvider.updateMaximumBudget(
|
setup.target.relayProvider.updateMaximumBudget(
|
||||||
setup.sourceChainId, uint256(10000 - 1) * gasParams.sourceGasPrice
|
setup.sourceChainId, uint256(10000 - 1) * gasParams.sourceGasPrice
|
||||||
|
|
|
@ -4,31 +4,31 @@
|
||||||
"relayProviders": [
|
"relayProviders": [
|
||||||
{
|
{
|
||||||
"chainId": 2,
|
"chainId": 2,
|
||||||
"address": "0xB349FB172D6D5f693b0aA1C6eEc4c61cFd6846f4"
|
"address": "0xb4fFe5983B0B748124577Af4d16953bd096b6897"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chainId": 4,
|
"chainId": 4,
|
||||||
"address": "0x9ce4cd6D7f5e8b14c7a3e8e6A257A86Bd5a6EeA0"
|
"address": "0xdFccc9C59c7361307d47c558ffA75840B32DbA29"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"coreRelayers": [
|
"coreRelayers": [
|
||||||
{
|
{
|
||||||
"chainId": 2,
|
"chainId": 2,
|
||||||
"address": "0x68b86Cd90A44C805b1cCF4808b29C9c7cf73FDFF"
|
"address": "0x42D4BA5e542d9FeD87EA657f0295F1968A61c00A"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chainId": 4,
|
"chainId": 4,
|
||||||
"address": "0xd45A464a2412A2f83498d13635698a041b9dBe9b"
|
"address": "0xFF5181e2210AB92a5c9db93729Bc47332555B9E9"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"mockIntegrations": [
|
"mockIntegrations": [
|
||||||
{
|
{
|
||||||
"chainId": 2,
|
"chainId": 2,
|
||||||
"address": "0xB0015714B541A99265f529c7c0d34DA47deCA5b2"
|
"address": "0xe93e3B649d4E01e47dd2170CAFEf0651477649Da"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"chainId": 4,
|
"chainId": 4,
|
||||||
"address": "0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093"
|
"address": "0x6793E8E0E8ac22d71c65c2bf82e9B142dEf9eCDb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -18,7 +18,7 @@
|
||||||
"@types/koa": "^2.13.5",
|
"@types/koa": "^2.13.5",
|
||||||
"clone": "^2.1.2",
|
"clone": "^2.1.2",
|
||||||
"koa": "^2.14.1",
|
"koa": "^2.14.1",
|
||||||
"wormhole-relayer": "github:gabzim/wormhole-relayer#03c7c62",
|
"wormhole-relayer": "file:../../wormhole-relayer",
|
||||||
"yargs": "^17.7.1"
|
"yargs": "^17.7.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -125,8 +125,6 @@ export function parseWormholeRelayerSend(bytes: Buffer): DeliveryInstructionsCon
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
||||||
const payloadId = bytes.readUint8(idx)
|
|
||||||
idx += 1
|
|
||||||
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
||||||
idx += 1
|
idx += 1
|
||||||
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
||||||
|
|
|
@ -7,7 +7,8 @@ import {
|
||||||
StandardRelayerApp,
|
StandardRelayerApp,
|
||||||
StandardRelayerContext,
|
StandardRelayerContext,
|
||||||
} from "wormhole-relayer"
|
} from "wormhole-relayer"
|
||||||
import { EVMChainId } from "@certusone/wormhole-sdk"
|
import { defaultLogger } from "wormhole-relayer/lib/logging"
|
||||||
|
import { CHAIN_ID_ETH, CHAIN_ID_BSC, EVMChainId } from "@certusone/wormhole-sdk"
|
||||||
import { rootLogger } from "./log"
|
import { rootLogger } from "./log"
|
||||||
import { processGenericRelayerVaa } from "./processor"
|
import { processGenericRelayerVaa } from "./processor"
|
||||||
import { Logger } from "winston"
|
import { Logger } from "winston"
|
||||||
|
@ -39,10 +40,22 @@ type ContractsJson = {
|
||||||
async function main() {
|
async function main() {
|
||||||
let opts = yargs(process.argv.slice(2)).argv as unknown as Opts
|
let opts = yargs(process.argv.slice(2)).argv as unknown as Opts
|
||||||
const contracts = await loadContractsJson(opts.flag)
|
const contracts = await loadContractsJson(opts.flag)
|
||||||
|
console.log("hi")
|
||||||
const app = new StandardRelayerApp<GRContext>(flagToEnvironment(opts.flag), {
|
const app = new StandardRelayerApp<GRContext>(flagToEnvironment(opts.flag), {
|
||||||
name: "GenericRelayer",
|
name: "GenericRelayer",
|
||||||
privateKeys: privateKeys(contracts),
|
privateKeys: privateKeys(contracts),
|
||||||
|
spyEndpoint: "localhost:7072",
|
||||||
|
wormholeRpcs: ["http://localhost:7071"],
|
||||||
|
providers: { chains: {
|
||||||
|
[CHAIN_ID_ETH]: {
|
||||||
|
endpoints: ["http://localhost:8545/"]
|
||||||
|
},
|
||||||
|
[CHAIN_ID_BSC]: {
|
||||||
|
endpoints: ["http://localhost:8546/"]
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
logger: defaultLogger,
|
||||||
|
fetchSourceTxhash: false,
|
||||||
// redis: {},
|
// redis: {},
|
||||||
// redisCluster: {},
|
// redisCluster: {},
|
||||||
// redisClusterEndpoints: [],
|
// redisClusterEndpoints: [],
|
||||||
|
|
|
@ -28,7 +28,7 @@ async function processDelivery(ctx: GRContext) {
|
||||||
const payload = parseWormholeRelayerSend(ctx.vaa!.payload)
|
const payload = parseWormholeRelayerSend(ctx.vaa!.payload)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
payload.messages.findIndex((m) => m.payloadType !== MessageInfoType.EMITTER_SEQUENCE)
|
payload.messages.findIndex((m) => m.payloadType !== MessageInfoType.EMITTER_SEQUENCE) != -1
|
||||||
) {
|
) {
|
||||||
throw new Error(`Only supports EmitterSequence MessageInfoType`)
|
throw new Error(`Only supports EmitterSequence MessageInfoType`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,6 @@ export function parseWormholeRelayerSend(bytes: Buffer): DeliveryInstructionsCon
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
||||||
const payloadId = bytes.readUint8(idx)
|
|
||||||
idx += 1
|
|
||||||
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
||||||
idx += 1
|
idx += 1
|
||||||
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
||||||
|
|
|
@ -125,8 +125,6 @@ export function parseWormholeRelayerSend(bytes: Buffer): DeliveryInstructionsCon
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
function parseMessageInfo(bytes: Buffer, idx: number): [MessageInfo, number] {
|
||||||
const payloadId = bytes.readUint8(idx)
|
|
||||||
idx += 1
|
|
||||||
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
const payloadType = bytes.readUint8(idx) as MessageInfoType
|
||||||
idx += 1
|
idx += 1
|
||||||
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
if (payloadType == MessageInfoType.EMITTER_SEQUENCE) {
|
||||||
|
|
Loading…
Reference in New Issue