Skip to content

Commit

Permalink
Merge pull request #115 from XLabs/update-sdk
Browse files Browse the repository at this point in the history
Bump wormhole sdk version
  • Loading branch information
scnale authored Jan 22, 2025
2 parents e42ad48 + ed1f5e1 commit 96304d6
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 985 deletions.
12 changes: 3 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
[submodule "evm/lib/forge-std"]
path = evm/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "evm/lib/openzeppelin-contracts"]
path = evm/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "evm/lib/relayer-infra-contracts"]
path = lib/relayer-infra-contracts
url = https://github.com/XLabs/relayer-infra-contracts
[submodule "evm/lib/permit2"]
path = evm/lib/permit2
url = https://github.com/Uniswap/permit2
[submodule "evm/lib/wormhole-solidity-sdk"]
path = evm/lib/wormhole-solidity-sdk
url = https://github.com/wormhole-foundation/wormhole-solidity-sdk
[submodule "wormhole-foundation-solidity-sdk"]
path = evm/lib/wormhole-solidity-sdk
url = https://github.com/wormhole-foundation/wormhole-solidity-sdk
[submodule "lib/relayer-infra-contracts"]
path = lib/relayer-infra-contracts
url = https://github.com/XLabs/relayer-infra-contracts
1 change: 0 additions & 1 deletion evm/lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from dc44c9
2 changes: 1 addition & 1 deletion evm/lib/wormhole-solidity-sdk
Submodule wormhole-solidity-sdk updated 34 files
+2 −2 README.md
+41 −4 docs/Optimization.md
+280 −0 docs/bytecode_analysis/calldata_slice_to_memory.md
+74 −0 docs/bytecode_analysis/soliditiy_calldata_bytes.md
+1 −0 foundry.toml
+45 −17 src/Utils.sol
+298 −0 src/components/dispatcher/AccessControl.sol
+37 −0 src/components/dispatcher/Ids.sol
+41 −0 src/components/dispatcher/SweepTokens.sol
+71 −0 src/components/dispatcher/Upgrade.sol
+10 −4 src/constants/Common.sol
+12 −0 src/interfaces/token/IERC20Metadata.sol
+20 −0 src/interfaces/token/IERC20Permit.sol
+32 −59 src/libraries/BytesParsing.sol
+67 −0 src/libraries/SafeERC20.sol
+2 −1 src/libraries/WormholeCctpMessages.sol
+4 −0 src/proxy/ProxyBase.sol
+3 −2 src/testing/CctpMessages.sol
+26 −0 src/testing/UpgradeTester.sol
+44 −3 src/testing/WormholeRelayer/DeliveryInstructionSerde.sol
+15 −12 src/testing/WormholeRelayer/MockOffchainRelayer.sol
+1 −1 src/testing/WormholeRelayerTest.sol
+11 −0 src/utils/Revert.sol
+23 −0 src/utils/Transfer.sol
+17 −0 src/utils/UniversalAddress.sol
+66 −0 test/Keccak.t.sol
+15 −2 test/Proxy.t.sol
+920 −0 test/components/dispatcher/AccessControl.t.sol
+51 −0 test/components/dispatcher/SweepTokens.t.sol
+135 −0 test/components/dispatcher/Upgrade.t.sol
+71 −0 test/components/dispatcher/utils/Dispatcher.sol
+66 −0 test/components/dispatcher/utils/DispatcherTestBase.sol
+19 −0 test/components/dispatcher/utils/utils.sol
+14 −18 test/generated/BytesParsingTestWrapper.sol
2 changes: 1 addition & 1 deletion evm/src/Tbr.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract Tbr is TbrDispatcher {
(admins[i], offset) = args.asAddressCdUnchecked(offset);
}

args.checkLengthCd(offset);
BytesParsing.checkLength(offset, args.length);

_accessControlConstruction(owner, admins);
_configConstruction(payable(feeRecipient));
Expand Down
7 changes: 0 additions & 7 deletions evm/src/assets/TbrBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,4 @@ abstract contract TbrBase is PriceOracleIntegration {
}
state.paused = paused;
}

function _transferEth(address to, uint256 amount) internal {
if (amount == 0) return;

(bool success, ) = to.call{value: amount}(new bytes(0));
if (!success) revert PaymentFailure(to);
}
}
8 changes: 4 additions & 4 deletions evm/src/assets/TbrConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
accessControlState,
Role,
NotAuthorized,
senderHasAuth
} from "./sharedComponents/AccessControl.sol";
senderAtLeastAdmin
} from "wormhole-sdk/components/dispatcher/AccessControl.sol";
import { BytesParsing } from "wormhole-sdk/libraries/BytesParsing.sol";
import { ProxyBase } from "wormhole-sdk/proxy/ProxyBase.sol";
import { TbrBase } from "./TbrBase.sol";
Expand Down Expand Up @@ -50,7 +50,7 @@ abstract contract TbrConfig is TbrBase, AccessControl {
// ---- externals ----

function _batchConfigCommands(bytes calldata commands, uint offset) internal returns (uint) {
bool isOwner = senderHasAuth() == Role.Owner;
bool isOwner = senderAtLeastAdmin() == Role.Owner;

uint commandCount;
(commandCount, offset) = commands.asUint8CdUnchecked(offset);
Expand Down Expand Up @@ -168,7 +168,7 @@ abstract contract TbrConfig is TbrBase, AccessControl {
// ---- private ----

function _setFeeRecipient(address newFeeRecipient) internal {
senderHasAuth();
senderAtLeastAdmin();

ConfigState storage state = configState();
address oldFeeRecipient = state.feeRecipient;
Expand Down
15 changes: 8 additions & 7 deletions evm/src/assets/TbrDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
pragma solidity ^0.8.25;

import { BytesParsing } from "wormhole-sdk/libraries/BytesParsing.sol";
import { SweepTokens } from "./sharedComponents/SweepTokens.sol";
import { SweepTokens } from "wormhole-sdk/components/dispatcher/SweepTokens.sol";
import { tokenOrNativeTransfer } from "wormhole-sdk/utils/Transfer.sol";
import { RawDispatcher } from "wormhole-sdk/RawDispatcher.sol";
import { Upgrade } from "./sharedComponents/Upgrade.sol";
import { Upgrade } from "wormhole-sdk/components/dispatcher/Upgrade.sol";
import { InvalidCommand } from "./TbrBase.sol";
import { TbrConfig } from "./TbrConfig.sol";
import { TbrUser } from "./TbrUser.sol";
import "./sharedComponents/ids.sol";
import "wormhole-sdk/components/dispatcher/Ids.sol";
import "./TbrIds.sol";

/**
Expand Down Expand Up @@ -71,10 +72,10 @@ abstract contract TbrDispatcher is RawDispatcher, TbrConfig, TbrUser, SweepToken
++commandIndex;
}

data.checkLengthCd(offset);
BytesParsing.checkLength(offset, data.length);

_transferEth(_getFeeRecipient(), fees);
_transferEth(msg.sender, senderRefund);
tokenOrNativeTransfer(address(0), _getFeeRecipient(), fees);
tokenOrNativeTransfer(address(0), msg.sender, senderRefund);
return new bytes(0);
}}

Expand Down Expand Up @@ -113,7 +114,7 @@ abstract contract TbrDispatcher is RawDispatcher, TbrConfig, TbrUser, SweepToken
ret = abi.encodePacked(ret, result);
++queryIndex;
}
data.checkLengthCd(offset);
BytesParsing.checkLength(offset, data.length);
return ret;
}}
}
6 changes: 3 additions & 3 deletions evm/src/assets/TbrUser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {PermitParsing} from "wormhole-sdk/libraries/PermitParsing.sol";
import {fromUniversalAddress, reRevert} from "wormhole-sdk/Utils.sol";
import {FREE_MEMORY_PTR} from "wormhole-sdk/constants/Common.sol";
import {IWETH} from "wormhole-sdk/interfaces/token/IWETH.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IERC20Permit} from "@openzeppelin/token/ERC20/extensions/IERC20Permit.sol";
import {IERC20Metadata} from "wormhole-sdk/interfaces/token/IERC20Metadata.sol";
import {IERC20Permit} from "wormhole-sdk/interfaces/token/IERC20Permit.sol";
import {SafeERC20} from "wormhole-sdk/libraries/SafeERC20.sol";
import {ISignatureTransfer, IAllowanceTransfer} from "permit2/IPermit2.sol";
import {TRANSFER_TOKEN_WITH_RELAY_ID, TRANSFER_GAS_TOKEN_WITH_RELAY_ID, COMPLETE_TRANSFER_ID, RELAY_FEE_ID, BASE_RELAYING_CONFIG_ID, APPROVE_TOKEN_ID} from "./TbrIds.sol";
import {TbrBase, InvalidCommand} from "./TbrBase.sol";
Expand Down
250 changes: 0 additions & 250 deletions evm/src/assets/sharedComponents/AccessControl.sol

This file was deleted.

Loading

0 comments on commit 96304d6

Please sign in to comment.