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

Graduate to yarn 4 🧶 #2899

Merged
merged 22 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
3 changes: 0 additions & 3 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ jobs:
with:
node-version: 18

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1

- name: yarn-cache
uses: actions/cache@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"*.js": "prettier --write",
"*.ts": "prettier --write",
"*.md": "prettier --write",
"*.sol": "prettier --write"
"*.md": "prettier --write"
}
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
"bracketSpacing": false
}
}
],
"importOrder": ["^@hyperlane-xyz/(.*)$", "^../(.*)$", "^./(.*)$"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
compressionLevel: mixed

enableGlobalCache: false

enableScripts: false

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v3"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-3.2.0.cjs
yarnPath: .yarn/releases/yarn-4.0.1.cjs
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
"description": "A yarn workspace of core Hyperlane packages",
"version": "0.0.0",
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^8.0.0",
"lint-staged": "^12.4.3",
"prettier": "^2.4.1"
"prettier": "^3.0.3"
},
"packageManager": "yarn@3.2.0",
"packageManager": "yarn@4.0.1",
"private": true,
"scripts": {
"build": "yarn workspaces foreach --verbose --parallel --topological run build",
"clean": "yarn workspaces foreach --verbose --parallel run clean",
"build": "yarn workspaces foreach --all --parallel --topological run build",
"clean": "yarn workspaces foreach --all --parallel run clean",
"prettier": "yarn workspaces foreach --all --parallel run prettier",
"lint": "yarn workspaces foreach --all --parallel run lint",
"test": "yarn workspaces foreach --all --parallel run test",
"coverage": "yarn workspaces foreach --all --parallel run coverage",
"version:prepare": "yarn workspaces foreach --all --no-private --topological version --immediate",
"publish:all": "yarn workspaces foreach --all --no-private --topological npm publish --access public",
"postinstall": "husky install",
"prettier": "yarn workspaces foreach --verbose --parallel run prettier",
"lint": "yarn workspaces foreach --verbose --parallel run lint",
"test": "yarn workspaces foreach --verbose --parallel run test",
"coverage": "yarn workspaces foreach --verbose --parallel run coverage",
"version:check": "yarn version check --interactive",
"version:prepare": "yarn workspaces foreach --no-private --verbose --topological version --immediate",
"publish:all": "yarn workspaces foreach --no-private --verbose --topological npm publish --access public"
"version:check": "yarn version check --interactive"
},
"workspaces": [
"solidity",
Expand Down
17 changes: 7 additions & 10 deletions solidity/contracts/Mailbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -191,52 +191,51 @@
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
payable
override
{
function process(
bytes calldata _metadata,
bytes calldata _message
) external payable override {
/// CHECKS ///

// Check that the message was intended for this mailbox.
require(_message.version() == VERSION, "Mailbox: bad version");
require(
_message.destination() == localDomain,
"Mailbox: unexpected destination"
);

// Check that the message hasn't already been delivered.
bytes32 _id = _message.id();
require(delivered(_id) == false, "Mailbox: already delivered");

// Get the recipient's ISM.
address recipient = _message.recipientAddress();
IInterchainSecurityModule ism = recipientIsm(recipient);

/// EFFECTS ///

deliveries[_id] = Delivery({
processor: msg.sender,
blockNumber: uint48(block.number)
});
emit Process(_message.origin(), _message.sender(), recipient);
emit ProcessId(_id);

/// INTERACTIONS ///

// Verify the message via the interchain security module.
require(
ism.verify(_metadata, _message),
"Mailbox: ISM verification failed"
);

// Deliver the message to the recipient.
IMessageRecipient(recipient).handle{value: msg.value}(
_message.origin(),
_message.sender(),
_message.body()
);
}

Check warning

Code scanning / Slither

Dangerous strict equalities Medium


/**
* @notice Returns the account that processed the message.
Expand Down Expand Up @@ -391,11 +390,9 @@
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
function recipientIsm(
address _recipient

Check notice

Code scanning / Slither

Missing zero address validation

Mailbox.recipientIsm(address)._recipient (contracts/Mailbox.sol#394) lacks a zero-check on : - (success,returnData) = _recipient.staticcall(abi.encodeCall(ISpecifiesInterchainSecurityModule.interchainSecurityModule,())) (contracts/Mailbox.sol#397-402)
) public view returns (IInterchainSecurityModule) {
// use low-level staticcall in case of revert or empty return data
(bool success, bytes memory returnData) = _recipient.staticcall(
abi.encodeCall(
Expand Down
25 changes: 9 additions & 16 deletions solidity/contracts/client/GasRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ abstract contract GasRouter is Router {
* @notice Sets the gas amount dispatched for each configured domain.
* @param gasConfigs The array of GasRouterConfig structs
*/
function setDestinationGas(GasRouterConfig[] calldata gasConfigs)
external
onlyOwner
{
function setDestinationGas(
GasRouterConfig[] calldata gasConfigs
) external onlyOwner {
for (uint256 i = 0; i < gasConfigs.length; i += 1) {
_setDestinationGas(gasConfigs[i].domain, gasConfigs[i].gas);
}
Expand All @@ -42,25 +41,19 @@ abstract contract GasRouter is Router {
* @param _destinationDomain The domain of the router.
* @return _gasPayment Payment computed by the registered InterchainGasPaymaster.
*/
function quoteGasPayment(uint32 _destinationDomain)
external
view
returns (uint256 _gasPayment)
{
function quoteGasPayment(
uint32 _destinationDomain
) external view returns (uint256 _gasPayment) {
return _quoteDispatch(_destinationDomain, "");
}

function _refundAddress(uint32) internal view virtual returns (address) {
return msg.sender;
}

function _metadata(uint32 _destination)
internal
view
virtual
override
returns (bytes memory)
{
function _metadata(
uint32 _destination
) internal view virtual override returns (bytes memory) {
return
StandardHookMetadata.formatMetadata(
destinationGas[_destination],
Expand Down
8 changes: 3 additions & 5 deletions solidity/contracts/client/MailboxClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ abstract contract MailboxClient is OwnableUpgradeable {
* @notice Sets the address of the application's custom interchain security module.
* @param _module The address of the interchain security module contract.
*/
function setInterchainSecurityModule(address _module)
public
onlyContractOrNull(_module)
onlyOwner
{
function setInterchainSecurityModule(
address _module
) public onlyContractOrNull(_module) onlyOwner {
interchainSecurityModule = IInterchainSecurityModule(_module);
}

Expand Down
59 changes: 25 additions & 34 deletions solidity/contracts/client/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ abstract contract Router is MailboxClient, IMessageRecipient {
* @param _domain The domain of the remote Application Router
* @param _router The address of the remote Application Router
*/
function enrollRemoteRouter(uint32 _domain, bytes32 _router)
external
virtual
onlyOwner
{
function enrollRemoteRouter(
uint32 _domain,
bytes32 _router
) external virtual onlyOwner {
_enrollRemoteRouter(_domain, _router);
}

Expand All @@ -80,11 +79,9 @@ abstract contract Router is MailboxClient, IMessageRecipient {
* @notice Batch version of `unenrollRemoteRouter`
* @param _domains The domains of the remote Application Routers
*/
function unenrollRemoteRouters(uint32[] calldata _domains)
external
virtual
onlyOwner
{
function unenrollRemoteRouters(
uint32[] calldata _domains
) external virtual onlyOwner {
uint256 length = _domains.length;
for (uint256 i = 0; i < length; i += 1) {
_unenrollRemoteRouter(_domains[i]);
Expand Down Expand Up @@ -121,10 +118,10 @@ abstract contract Router is MailboxClient, IMessageRecipient {
* @param _domain The domain
* @param _address The new router
*/
function _enrollRemoteRouter(uint32 _domain, bytes32 _address)
internal
virtual
{
function _enrollRemoteRouter(
uint32 _domain,
bytes32 _address
) internal virtual {
_routers.set(_domain, _address);
}

Expand All @@ -141,11 +138,10 @@ abstract contract Router is MailboxClient, IMessageRecipient {
* @param _domain The domain of the potential remote Application Router
* @param _address The address of the potential remote Application Router
*/
function _isRemoteRouter(uint32 _domain, bytes32 _address)
internal
view
returns (bool)
{
function _isRemoteRouter(
uint32 _domain,
bytes32 _address
) internal view returns (bool) {
return routers(_domain) == _address;
}

Expand All @@ -154,33 +150,28 @@ abstract contract Router is MailboxClient, IMessageRecipient {
* @param _domain The domain of the chain for which to get the Application Router
* @return _router The address of the remote Application Router on _domain
*/
function _mustHaveRemoteRouter(uint32 _domain)
internal
view
returns (bytes32)
{
function _mustHaveRemoteRouter(
uint32 _domain
) internal view returns (bytes32) {
(bool contained, bytes32 _router) = _routers.tryGet(_domain);
require(contained, _domainNotFoundError(_domain));
return _router;
}

function _domainNotFoundError(uint32 _domain)
internal
pure
returns (string memory)
{
function _domainNotFoundError(
uint32 _domain
) internal pure returns (string memory) {
return
string.concat(
"No router enrolled for domain: ",
_domain.toString()
);
}

function _dispatch(uint32 _destinationDomain, bytes memory _messageBody)
internal
virtual
returns (bytes32)
{
function _dispatch(
uint32 _destinationDomain,
bytes memory _messageBody
) internal virtual returns (bytes32) {
return _dispatch(_destinationDomain, msg.value, _messageBody);
}

Expand Down
20 changes: 9 additions & 11 deletions solidity/contracts/hooks/OPStackHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,26 @@
}

// ============ Internal functions ============
function _quoteDispatch(bytes calldata, bytes calldata)
internal
pure
override
returns (uint256)
{
function _quoteDispatch(
bytes calldata,
bytes calldata
) internal pure override returns (uint256) {
return 0; // gas subsidized by the L2
}

/// @inheritdoc AbstractMessageIdAuthHook
function _sendMessageId(bytes calldata metadata, bytes memory payload)
internal
override
{
function _sendMessageId(
bytes calldata metadata,
bytes memory payload
) internal override {
require(
metadata.msgValue(0) < 2**255,
metadata.msgValue(0) < 2 ** 255,
"OPStackHook: msgValue must be less than 2 ** 255"
);
l1Messenger.sendMessage{value: metadata.msgValue(0)}(
TypeCasts.bytes32ToAddress(ism),
payload,
GAS_LIMIT
);
}

Check failure

Code scanning / Slither

Functions that send Ether to arbitrary destinations High

}
19 changes: 8 additions & 11 deletions solidity/contracts/hooks/PausableHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,16 @@ contract PausableHook is AbstractPostDispatchHook, Ownable, Pausable {
// ============ Internal functions ============

/// @inheritdoc AbstractPostDispatchHook
function _postDispatch(bytes calldata metadata, bytes calldata message)
internal
override
whenNotPaused
{}
function _postDispatch(
bytes calldata metadata,
bytes calldata message
) internal override whenNotPaused {}

/// @inheritdoc AbstractPostDispatchHook
function _quoteDispatch(bytes calldata, bytes calldata)
internal
pure
override
returns (uint256)
{
function _quoteDispatch(
bytes calldata,
bytes calldata
) internal pure override returns (uint256) {
return 0;
}
}
18 changes: 8 additions & 10 deletions solidity/contracts/hooks/StaticProtocolFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ contract StaticProtocolFee is AbstractPostDispatchHook, Ownable {
// ============ Internal Functions ============

/// @inheritdoc AbstractPostDispatchHook
function _postDispatch(bytes calldata metadata, bytes calldata message)
internal
override
{
function _postDispatch(
bytes calldata metadata,
bytes calldata message
) internal override {
require(
msg.value >= protocolFee,
"StaticProtocolFee: insufficient protocol fee"
Expand All @@ -109,12 +109,10 @@ contract StaticProtocolFee is AbstractPostDispatchHook, Ownable {
}

/// @inheritdoc AbstractPostDispatchHook
function _quoteDispatch(bytes calldata, bytes calldata)
internal
view
override
returns (uint256)
{
function _quoteDispatch(
bytes calldata,
bytes calldata
) internal view override returns (uint256) {
return protocolFee;
}

Expand Down
Loading
Loading