From c78975556a6305c71c2f043f13106d7f3257eee2 Mon Sep 17 00:00:00 2001 From: NicholasDotSol Date: Fri, 15 Dec 2023 09:55:18 -0600 Subject: [PATCH] modify BridgeAggregationHookMetadata to only include Axelar payment data --- .../libs/BridgeAggregationHookMetadata.sol | 33 +++---------------- solidity/test/hooks/AxelarHook.t.sol | 10 +++--- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/solidity/contracts/hooks/libs/BridgeAggregationHookMetadata.sol b/solidity/contracts/hooks/libs/BridgeAggregationHookMetadata.sol index 26008be52a..8863350bd7 100644 --- a/solidity/contracts/hooks/libs/BridgeAggregationHookMetadata.sol +++ b/solidity/contracts/hooks/libs/BridgeAggregationHookMetadata.sol @@ -4,20 +4,16 @@ pragma solidity >=0.8.0; /** * Format of metadata: * - * [0:2] variant - * [2:34] Axelar Payment - * [34:66] Wormhole Payment - * [66:] additional metadata + * [0:32] variant + * [32:] additional metadata */ library BridgeAggregationHookMetadata { struct Metadata { uint256 AxelarPayment; - uint256 WormholePayment; } uint8 private constant AXELAR_PAYMENT_OFFSET = 0; - uint8 private constant WORMHOLE_PAYMENT_OFFSET = 32; - uint8 private constant MIN_METADATA_LENGTH = 64; + uint8 private constant MIN_METADATA_LENGTH = 32; /** * @notice Returns the required payment for Axelar bridging. @@ -36,24 +32,6 @@ library BridgeAggregationHookMetadata { ); } - /** - * @notice Returns the required payment for Wormhole bridging. - * @param _metadata ABI encoded standard hook metadata. - * @return uint256 Payment amount. - */ - function wormholeGasPayment( - bytes calldata _metadata - ) internal pure returns (uint256) { - if (_metadata.length < WORMHOLE_PAYMENT_OFFSET + 32) return 0; - return - uint256( - bytes32( - _metadata[WORMHOLE_PAYMENT_OFFSET:WORMHOLE_PAYMENT_OFFSET + - 32] - ) - ); - } - /** * @notice Returs any additional metadata. * @param _metadata ABI encoded standard hook metadata. @@ -69,16 +47,13 @@ library BridgeAggregationHookMetadata { /** * @notice Formats the specified Axelar and Wormhole payments. * @param _axelarPayment msg.value for the message. - * @param _wormholePayment Gas limit for the message. * @param _customMetadata Additional metadata to include. * @return ABI encoded standard hook metadata. */ function formatMetadata( uint256 _axelarPayment, - uint256 _wormholePayment, bytes memory _customMetadata ) internal pure returns (bytes memory) { - return - abi.encodePacked(_axelarPayment, _wormholePayment, _customMetadata); + return abi.encodePacked(_axelarPayment, _customMetadata); } } diff --git a/solidity/test/hooks/AxelarHook.t.sol b/solidity/test/hooks/AxelarHook.t.sol index 707e19131a..b02c7ecbe5 100644 --- a/solidity/test/hooks/AxelarHook.t.sol +++ b/solidity/test/hooks/AxelarHook.t.sol @@ -31,7 +31,6 @@ contract AxelarHookTest is Test { string destionationContract = "neutronContract"; address axelarGateway = address(0); address axelarGasReceiver = address(0); - bytes gmp_call_code = abi.encodePacked(uint8(1)); error BadQuote(uint256 balance, uint256 required); function setUp() public { @@ -42,8 +41,7 @@ contract AxelarHookTest is Test { destinationChain, destionationContract, axelarGateway, - axelarGasReceiver, - gmp_call_code + axelarGasReceiver ); testMessage = _encodeTestMessage(); } @@ -66,7 +64,7 @@ contract AxelarHookTest is Test { vm.expectRevert("No Axelar Payment Received"); uint256 expectedQuote = 0; bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata - .formatMetadata(expectedQuote, 0, abi.encodePacked()); + .formatMetadata(expectedQuote, abi.encodePacked()); bytes memory testMetadata = StandardHookMetadata.formatMetadata( 100, 100, @@ -80,7 +78,7 @@ contract AxelarHookTest is Test { function test_quoteDispatch_ReturnsSmallQuote() public { uint256 expectedQuote = 1; bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata - .formatMetadata(expectedQuote, 0, abi.encodePacked()); + .formatMetadata(expectedQuote, abi.encodePacked()); bytes memory testMetadata = StandardHookMetadata.formatMetadata( 100, 100, @@ -96,7 +94,7 @@ contract AxelarHookTest is Test { // type(uint256).max = 115792089237316195423570985008687907853269984665640564039457584007913129639935. that's a big quote uint256 expectedQuote = type(uint256).max; bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata - .formatMetadata(expectedQuote, 0, abi.encodePacked()); + .formatMetadata(expectedQuote, abi.encodePacked()); bytes memory testMetadata = StandardHookMetadata.formatMetadata( 100, 100,