Skip to content

Commit

Permalink
Merge branch 'v3' into v3-agents-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tkporter authored Oct 6, 2023
2 parents 0321fc5 + 35c176f commit 606b874
Show file tree
Hide file tree
Showing 82 changed files with 1,056 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
# needs: [yarn-build]
# strategy:
# matrix:
# environment: [testnet3, mainnet2]
# environment: [testnet4, mainnet2]
# module: [ism, core, igp, ica, helloworld]

# steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,6 @@ const DOMAINS: &[RawDomain] = &[
is_test_net: true,
is_deprecated: false,
},
RawDomain {
name: "zksync2testnet",
token: "ETH",
domain: 280,
chain_id: 280,
is_test_net: true,
is_deprecated: false,
},
];

#[derive(DeriveMigrationName)]
Expand Down
16 changes: 10 additions & 6 deletions rust/hyperlane-core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub enum KnownHyperlaneDomain {

Polygon = 137,
Mumbai = 80001,
PolygonZkEvmTestnet = 1442,

Avalanche = 43114,
Fuji = 43113,
Expand All @@ -76,8 +77,7 @@ pub enum KnownHyperlaneDomain {
MoonbaseAlpha = 1287,

Gnosis = 100,

Zksync2Testnet = 280,
Chiado = 10200,

// -- Local test chains --
/// Test1 local chain
Expand All @@ -94,6 +94,11 @@ pub enum KnownHyperlaneDomain {
SealevelTest1 = 13375,
/// Sealevel local chain 1
SealevelTest2 = 13376,

// -- v3 testnets --
LineaGoerli = 59140,
BaseGoerli = 84531,
ScrollSepolia = 534351,
}

#[derive(Clone)]
Expand Down Expand Up @@ -182,12 +187,11 @@ impl KnownHyperlaneDomain {
many_to_one!(match self {
Mainnet: [
Ethereum, Avalanche, Arbitrum, Polygon, Optimism, BinanceSmartChain, Celo,
Moonbeam,
Gnosis
Moonbeam, Gnosis
],
Testnet: [
Goerli, Mumbai, Fuji, ArbitrumGoerli, OptimismGoerli, BinanceSmartChainTestnet,
Alfajores, MoonbaseAlpha, Zksync2Testnet, Sepolia
Alfajores, MoonbaseAlpha, Sepolia, PolygonZkEvmTestnet, LineaGoerli, BaseGoerli, ScrollSepolia, Chiado
],
LocalTestChain: [Test1, Test2, Test3, FuelTest1, SealevelTest1, SealevelTest2],
})
Expand All @@ -200,7 +204,7 @@ impl KnownHyperlaneDomain {
HyperlaneDomainProtocol::Ethereum: [
Ethereum, Goerli, Sepolia, Polygon, Mumbai, Avalanche, Fuji, Arbitrum, ArbitrumGoerli,
Optimism, OptimismGoerli, BinanceSmartChain, BinanceSmartChainTestnet, Celo, Gnosis,
Alfajores, Moonbeam, MoonbaseAlpha, Zksync2Testnet, Test1, Test2, Test3
Alfajores, Moonbeam, MoonbaseAlpha, PolygonZkEvmTestnet, LineaGoerli, BaseGoerli, ScrollSepolia, Chiado, Test1, Test2, Test3
],
HyperlaneDomainProtocol::Fuel: [FuelTest1],
HyperlaneDomainProtocol::Sealevel: [SealevelTest1, SealevelTest2],
Expand Down
4 changes: 4 additions & 0 deletions solidity/contracts/Mailbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ contract Mailbox is IMailbox, Indexed, Versioned, OwnableUpgradeable {

/// INTERACTIONS ///
uint256 requiredValue = requiredHook.quoteDispatch(metadata, message);
// if underpaying, defer to required hook's reverting behavior
if (msg.value < requiredValue) {
requiredValue = msg.value;
}
requiredHook.postDispatch{value: requiredValue}(metadata, message);
hook.postDispatch{value: msg.value - requiredValue}(metadata, message);

Expand Down
2 changes: 1 addition & 1 deletion solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
typechain: {
outDir: './types',
target: 'ethers-v5',
alwaysGenerateOverloads: false,
alwaysGenerateOverloads: true,
},
mocha: {
bail: true,
Expand Down
2 changes: 1 addition & 1 deletion typescript/helloworld/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ module.exports = {
typechain: {
outDir: './src/types',
target: 'ethers-v5',
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
alwaysGenerateOverloads: true,
},
};
4 changes: 2 additions & 2 deletions typescript/helloworld/src/test/helloworld.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ describe('HelloWorld', async () => {
const body = 'Hello';
await expect(
local.sendHelloWorld(remoteDomain, body, {
value: (await quoteGasPayment(body)).sub(1),
value: 0,
}),
).to.be.revertedWith('insufficient interchain gas payment');
).to.be.revertedWith('StaticProtocolFee: insufficient protocol fee');
});

it('handles a message', async () => {
Expand Down
4 changes: 2 additions & 2 deletions typescript/infra/config/aggregationIsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { DeployEnvironment } from '../src/config';
import { Contexts } from './contexts';
import { owners as mainnet2Owners } from './environments/mainnet2/owners';
import { owners as testOwners } from './environments/test/owners';
import { owners as testnet3Owners } from './environments/testnet3/owners';
import { owners as testnet4Owners } from './environments/testnet4/owners';
import { multisigIsms } from './multisigIsm';

const owners = {
testnet3: testnet3Owners,
testnet4: testnet4Owners,
mainnet2: mainnet2Owners,
test: testOwners,
};
Expand Down
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { environment as mainnet2 } from './mainnet2';
import { environment as test } from './test';
import { environment as testnet3 } from './testnet3';
import { environment as testnet4 } from './testnet4';

export const environments = {
test,
testnet3,
testnet4,
mainnet2,
};
44 changes: 36 additions & 8 deletions typescript/infra/config/environments/mainnet2/core.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { ChainMap, CoreConfig, HookType } from '@hyperlane-xyz/sdk';
import { BigNumber, ethers } from 'ethers';

import {
AggregationHookConfig,
ChainMap,
CoreConfig,
HookType,
IgpHookConfig,
MerkleTreeHookConfig,
ProtocolFeeHookConfig,
} from '@hyperlane-xyz/sdk';
import { objMap } from '@hyperlane-xyz/utils';

import { aggregationIsm } from '../../aggregationIsm';
import { Contexts } from '../../contexts';

import { igp } from './igp';
import { owners } from './owners';

export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
Expand All @@ -23,15 +34,32 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
};
}

const merkleHook: MerkleTreeHookConfig = {
type: HookType.MERKLE_TREE,
};

const igpHook: IgpHookConfig = {
type: HookType.INTERCHAIN_GAS_PAYMASTER,
...igp[local],
};

const defaultHook: AggregationHookConfig = {
type: HookType.AGGREGATION,
hooks: [merkleHook, igpHook],
};

const requiredHook: ProtocolFeeHookConfig = {
type: HookType.PROTOCOL_FEE,
maxProtocolFee: ethers.utils.parseUnits('1', 'gwei'), // 1 gwei of native token
protocolFee: BigNumber.from(1), // 1 wei
beneficiary: owner,
owner,
};

return {
owner,
upgrade,
defaultIsm,
defaultHook: {
type: HookType.INTERCHAIN_GAS_PAYMASTER,
},
requiredHook: {
type: HookType.MERKLE_TREE,
},
defaultHook,
requiredHook,
};
});
22 changes: 11 additions & 11 deletions typescript/infra/config/environments/mainnet2/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { exclude, objMap } from '@hyperlane-xyz/utils';

import { MainnetChains, supportedChainNames } from './chains';
import { core } from './core';
import { owners } from './owners';

// TODO: make this generic
Expand All @@ -25,20 +24,21 @@ function getGasOracles(local: MainnetChains) {
}

export const igp: ChainMap<IgpConfig> = objMap(owners, (chain, owner) => {
const overhead = Object.fromEntries(
exclude(chain, supportedChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
defaultMultisigIsmConfigs[remote].threshold,
defaultMultisigIsmConfigs[remote].validators.length,
),
]),
);

return {
owner,
oracleKey: DEPLOYER_ADDRESS,
beneficiary: KEY_FUNDER_ADDRESS,
gasOracleType: getGasOracles(chain),
overhead: Object.fromEntries(
exclude(chain, supportedChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
defaultMultisigIsmConfigs[remote].threshold,
defaultMultisigIsmConfigs[remote].validators.length,
),
]),
),
upgrade: core[chain].upgrade,
overhead,
};
});
37 changes: 31 additions & 6 deletions typescript/infra/config/environments/test/core.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { BigNumber, ethers } from 'ethers';

import {
AggregationHookConfig,
ChainMap,
CoreConfig,
HookType,
IgpHookConfig,
MerkleTreeHookConfig,
ModuleType,
RoutingIsmConfig,
} from '@hyperlane-xyz/sdk';
import { ProtocolFeeHookConfig } from '@hyperlane-xyz/sdk/src/hook/types';
import { objMap } from '@hyperlane-xyz/utils';

import { aggregationIsm } from './aggregationIsm';
import { igp } from './igp';
import { chainToValidator } from './multisigIsm';
import { owners } from './owners';

Expand All @@ -22,14 +29,32 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
),
};

const merkleHook: MerkleTreeHookConfig = {
type: HookType.MERKLE_TREE,
};

const igpHook: IgpHookConfig = {
type: HookType.INTERCHAIN_GAS_PAYMASTER,
...igp[local],
};

const defaultHook: AggregationHookConfig = {
type: HookType.AGGREGATION,
hooks: [merkleHook, igpHook],
};

const requiredHook: ProtocolFeeHookConfig = {
type: HookType.PROTOCOL_FEE,
maxProtocolFee: ethers.utils.parseUnits('1', 'gwei'), // 1 gwei of native token
protocolFee: BigNumber.from(1), // 1 wei
beneficiary: owner,
owner,
};

return {
owner,
defaultIsm,
defaultHook: {
type: HookType.INTERCHAIN_GAS_PAYMASTER,
},
requiredHook: {
type: HookType.MERKLE_TREE,
},
defaultHook,
requiredHook,
};
});
16 changes: 0 additions & 16 deletions typescript/infra/config/environments/test/hooks.ts

This file was deleted.

19 changes: 10 additions & 9 deletions typescript/infra/config/environments/test/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ function getGasOracles(local: TestChains) {
}

export const igp: ChainMap<IgpConfig> = objMap(owners, (chain, owner) => {
const overhead = Object.fromEntries(
exclude(chain, chainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
multisigIsm[remote].threshold,
multisigIsm[remote].validators.length,
),
]),
);
return {
owner,
oracleKey: owner,
beneficiary: owner,
gasOracleType: getGasOracles(chain),
overhead: Object.fromEntries(
exclude(chain, chainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
multisigIsm[remote].threshold,
multisigIsm[remote].validators.length,
),
]),
),
overhead,
};
});
2 changes: 0 additions & 2 deletions typescript/infra/config/environments/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { agents } from './agent';
import { testConfigs } from './chains';
import { core } from './core';
import { storageGasOracleConfig } from './gas-oracle';
import { merkleTree } from './hooks';
import { igp } from './igp';
import { infra } from './infra';
import { owners } from './owners';
Expand All @@ -18,7 +17,6 @@ export const environment: EnvironmentConfig = {
chainMetadataConfigs: testConfigs,
agents,
core,
hook: merkleTree,
igp,
owners,
infra,
Expand Down
21 changes: 0 additions & 21 deletions typescript/infra/config/environments/testnet3/core.ts

This file was deleted.

Loading

0 comments on commit 606b874

Please sign in to comment.