Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sync missed commits with develop #437

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: "FOUNDRY_PROFILE=localdev forge build"

- name: "Cache the build so that it can be re-used by the other jobs"
uses: "actions/cache/save@v3"
uses: "actions/cache/save@v4"
with:
key: "foundry-build-${{ github.sha }}"
path: |
Expand All @@ -71,7 +71,7 @@ jobs:
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Restore the cached build"
uses: "actions/cache/restore@v3"
uses: "actions/cache/restore@v4"
with:
fail-on-cache-miss: true
key: "foundry-build-${{ github.sha }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { StandardHookMetadata } from "src/vendor/hyperlane/StandardHookMetadata.
/// @dev Allows state registries to use Hyperlane v3 for crosschain communication
/// @author Zeropoint Labs
contract HyperlaneImplementation is IAmbImplementation, IMessageRecipient {

using DataLib for uint256;

//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -120,6 +119,12 @@ contract HyperlaneImplementation is IAmbImplementation, IMessageRecipient {
);
}

/// @inheritdoc IAmbImplementation
function generateExtraData(uint256 gasLimit) external pure override returns (bytes memory extraData) {
/// @notice encoded dst gas limit
extraData = abi.encode(gasLimit);
}

//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ILayerZeroUserApplicationConfig } from "src/vendor/layerzero/ILayerZero
/// @dev Allows state registries to use Layerzero for crosschain communication
/// @author Zeropoint Labs
contract LayerzeroImplementation is IAmbImplementation, ILayerZeroUserApplicationConfig, ILayerZeroReceiver {

using DataLib for uint256;

//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -189,6 +188,12 @@ contract LayerzeroImplementation is IAmbImplementation, ILayerZeroUserApplicatio
(fees,) = lzEndpoint.estimateFees(chainId, address(this), message_, false, extraData_);
}

/// @inheritdoc IAmbImplementation
function generateExtraData(uint256 gasLimit) external pure override returns (bytes memory extraData) {
/// @notice encoded layerzero adapter params (version 2). Other values are not used atm.
extraData = abi.encodePacked(uint16(2), gasLimit, uint256(0), address(0));
}

//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import "src/vendor/wormhole/Utils.sol";
/// @dev Allows state registries to use Wormhole AR's for crosschain communication
/// @author Zeropoint Labs
contract WormholeARImplementation is IAmbImplementation, IWormholeReceiver {

using DataLib for uint256;

//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -125,6 +124,12 @@ contract WormholeARImplementation is IAmbImplementation, IWormholeReceiver {
(fees,) = relayer.quoteEVMDeliveryPrice(dstChainId, dstNativeAirdrop, dstGasLimit);
}

/// @inheritdoc IAmbImplementation
function generateExtraData(uint256 gasLimit) external pure override returns (bytes memory extraData) {
/// @notice encoded dst gas limit
extraData = abi.encode(0, gasLimit);
}

//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion src/interfaces/IAmbImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity ^0.8.23;
/// @dev Interface for arbitrary message bridge (AMB) implementations
/// @author ZeroPoint Labs
interface IAmbImplementation {

//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
Expand All @@ -32,6 +31,12 @@ interface IAmbImplementation {
view
returns (uint256 fees);

/// @dev returns the extra data for the given gas request
/// @param gasLimit is the amount of gas limit in wei to override
/// @return extraData is the bytes encoded extra data
/// NOTE: this process is unique to the message bridge
function generateExtraData(uint256 gasLimit) external pure returns (bytes memory extraData);

//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
Expand Down
15 changes: 1 addition & 14 deletions src/payments/PaymentHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -713,20 +713,7 @@ contract PaymentHelper is IPaymentHelper {

for (uint256 i; i < len; ++i) {
uint256 gasReq = i != 0 ? totalDstGasReqInWeiForProof : totalDstGasReqInWei;
/// @dev amb id 1: layerzero
/// @dev amb id 2: hyperlane
/// @dev amb id 3: wormhole

/// @notice id 1: encoded layerzero adapter params (version 2). Other values are not used atm.
/// @notice id 2: encoded dst gas limit
/// @notice id 3: encoded dst gas limit
if (ambIds_[i] == 1) {
extraDataPerAMB[i] = abi.encodePacked(uint16(2), gasReq, uint256(0), address(0));
} else if (ambIds_[i] == 2) {
extraDataPerAMB[i] = abi.encode(gasReq);
} else if (ambIds_[i] == 3) {
extraDataPerAMB[i] = abi.encode(0, gasReq);
}
extraDataPerAMB[i] = IAmbImplementation(superRegistry.getAmbAddress(ambIds_[i])).generateExtraData(gasReq);
}
}

Expand Down
25 changes: 0 additions & 25 deletions test/utils/BaseSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1374,31 +1374,6 @@ abstract contract BaseSetup is DSTest, StdInvariant, Test {
GAS ESTIMATION & PAYLOAD HELPERS
//////////////////////////////////////////////////////////////*/

/// @dev Generates the extraData for each amb
/// @dev TODO - Sujith to comment further
function _generateExtraData(uint8[] memory selectedAmbIds) internal pure returns (bytes[] memory) {
bytes[] memory ambParams = new bytes[](selectedAmbIds.length);

for (uint256 i; i < selectedAmbIds.length; ++i) {
/// @dev 1 = Lz
if (selectedAmbIds[i] == 1) {
ambParams[i] = bytes("");
}

/// @dev 2 = Hyperlane
if (selectedAmbIds[i] == 2) {
ambParams[i] = abi.encode(500_000);
}

/// @dev 3 = Wormhole
if (selectedAmbIds[i] == 3) {
ambParams[i] = abi.encode(0, 500_000);
}
}

return ambParams;
}

struct LocalAckVars {
uint256 totalFees;
uint256 ambCount;
Expand Down