Skip to content

Commit

Permalink
Merge branch 'v3' into trevor/add-neutron
Browse files Browse the repository at this point in the history
  • Loading branch information
nambrot committed Nov 13, 2023
2 parents 66233f7 + b14f997 commit 19e6e11
Show file tree
Hide file tree
Showing 154 changed files with 8,654 additions and 12,854 deletions.
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
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": ["prettier-plugin-solidity", "@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
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM node:16-alpine
FROM node:18-alpine

WORKDIR /hyperlane-monorepo

RUN apk add --update --no-cache git g++ make py3-pip

RUN yarn set version 3.2.0
RUN yarn plugin import workspace-tools
RUN yarn set version 4.0.1

# Copy package.json and friends
COPY package.json yarn.lock .yarnrc.yml ./
Expand Down
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": "^2.8.8"
},
"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
2 changes: 2 additions & 0 deletions rust/agents/relayer/src/msg/gas_payment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct GasPaymentEnforcer {
}

impl GasPaymentEnforcer {
/// Note that `policy_configs` should not be empty. In the settings,
/// a default of vec![GasPaymentEnforcementConf::default()] is used.
pub fn new(
policy_configs: impl IntoIterator<Item = GasPaymentEnforcementConf>,
db: HyperlaneRocksDB,
Expand Down
2 changes: 1 addition & 1 deletion rust/agents/relayer/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl FromRawConf<RawRelayerSettings> for RelayerSettings {
matching_list,
})
}).collect_vec()
}).unwrap_or_default();
}).unwrap_or_else(|_| vec![GasPaymentEnforcementConf::default()]);

let whitelist = p
.chain(&mut err)
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,11 +191,10 @@ contract Mailbox is IMailbox, Indexed, Versioned, OwnableUpgradeable {
* @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.
Expand Down Expand Up @@ -391,11 +390,9 @@ contract Mailbox is IMailbox, Indexed, Versioned, OwnableUpgradeable {
* @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
) 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,22 +59,20 @@ contract OPStackHook is AbstractMessageIdAuthHook {
}

// ============ 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)}(
Expand Down
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;
}
}
Loading

0 comments on commit 19e6e11

Please sign in to comment.