Skip to content

Commit

Permalink
Merge bfcd720 into 7212f88
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT authored Oct 30, 2024
2 parents 7212f88 + bfcd720 commit 806a178
Show file tree
Hide file tree
Showing 52 changed files with 3,024 additions and 272 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Forge build
run: |
forge --version
make sizes
id: build

- name: Install lcov
uses: hrishikesh-kadam/setup-lcov@v1

Expand Down
76 changes: 35 additions & 41 deletions .github/workflows/test-fork.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
# name: Forge Fork Tests
#
# on:
# push:
# branches:
# - main
# pull_request:
#
# permissions: write-all
#
# jobs:
# check:
# name: Fork Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Setup Node
# uses: actions/setup-node@v4
#
# - name: Install NPM dependencies
# run: npm install
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge fork tests
# run: make fork profile=ci
# env:
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
# MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
# BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
# OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
name: Forge Fork Tests

on:
push:
branches:
- main
pull_request:

permissions: write-all

jobs:
check:
name: Fork Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node
uses: actions/setup-node@v4

- name: Install NPM dependencies
run: npm install

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

- name: Run Forge fork tests
run: make fork profile=ci
env:
MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
6 changes: 0 additions & 6 deletions .github/workflows/test-fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge fuzz tests
# run: make fuzz profile=ci
# env:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/test-gas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Forge build
run: |
forge --version
make sizes
id: build

- name: Run Forge tests with gas report
run: make gas-report profile=ci
env:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge integration tests
# run: make integration profile=ci
6 changes: 0 additions & 6 deletions .github/workflows/test-invariant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge invariant tests
# run: make invariant profile=ci
# env:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/test-sizes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Forge Sizes Check

on:
push:
branches:
- main
pull_request:

permissions: write-all

jobs:
check:
name: Sizes Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

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

- name: Run Forge build
run: |
forge --version
make sizes
id: build
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[submodule "lib/common"]
path = lib/common
url = [email protected]:m0-foundation/common.git
branch = main
[submodule "lib/protocol"]
path = lib/protocol
url = [email protected]:m0-foundation/protocol.git
Expand Down
74 changes: 68 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,77 @@
update:; forge update

# Deployment helpers
deploy-local:
FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --rpc-url localhost --broadcast -v
deploy-local-hub:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDevHub.s.sol:DeployDevHub --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

deploy-dev:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDev.s.sol --skip src --skip test --multi --broadcast --slow -v
deploy-local-spoke:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDevSpoke.s.sol:DeployDevSpoke --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --non-interactive --broadcast -v

deploy-dev-sepolia:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDevHub.s.sol:DeployDevHub --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --etherscan-api-key $(ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

deploy-dev-base-sepolia:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDevSpoke.s.sol:DeployDevSpoke --private-key $(DEV_PRIVATE_KEY) --rpc-url $(BASE_SEPOLIA_RPC_URL) --etherscan-api-key $(BASE_ETHERSCAN_API_KEY) --skip test --non-interactive --broadcast --slow -v --verify

deploy-dev-optimism-sepolia:
FOUNDRY_PROFILE=production forge script script/deploy/dev/DeployDevSpoke.s.sol:DeployDevSpoke --private-key $(DEV_PRIVATE_KEY) --rpc-url $(OPTIMISM_SEPOLIA_RPC_URL) --etherscan-api-key $(OPTIMISM_ETHERSCAN_API_KEY) --skip test --non-interactive --broadcast --slow -v --verify

# Configuration helpers
config-dev:
forge script script/deploy/dev/ConfigDev.s.sol --skip src --skip test --multi --broadcast --slow -v
configure-local:
forge script script/configure/dev/configureDev.s.sol:ConfigureDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

configure-dev-sepolia:
forge script script/configure/dev/configureDev.s.sol:ConfigureDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

configure-dev-base-sepolia:
forge script script/configure/dev/configureDev.s.sol:ConfigureDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(BASE_SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

configure-dev-optimism-sepolia:
forge script script/configure/dev/configureDev.s.sol:ConfigureDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(OPTIMISM_SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

# Upgrade helpers
upgrade-transceiver-local:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradeWormholeTransceiverDev.s.sol:UpgradeWormholeTransceiverDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

upgrade-transceiver-dev-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradeWormholeTransceiverDev.s.sol:UpgradeWormholeTransceiverDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --etherscan-api-key $(ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

upgrade-transceiver-dev-base-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradeWormholeTransceiverDev.s.sol:UpgradeWormholeTransceiverDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(BASE_SEPOLIA_RPC_URL) --etherscan-api-key $(BASE_ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

upgrade-transceiver-dev-optimism-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradeWormholeTransceiverDev.s.sol:UpgradeWormholeTransceiverDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(OPTIMISM_SEPOLIA_RPC_URL) --etherscan-api-key $(OPTIMISM_ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

upgrade-portal-local:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradePortalDev.s.sol:UpgradePortalDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

upgrade-portal-dev-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradePortalDev.s.sol:UpgradePortalDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --etherscan-api-key $(ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

upgrade-portal-dev-base-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradePortalDev.s.sol:UpgradePortalDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(BASE_SEPOLIA_RPC_URL) --etherscan-api-key $(BASE_ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

upgrade-portal-dev-optimism-sepolia:
FOUNDRY_PROFILE=production forge script script/upgrade/dev/UpgradePortalDev.s.sol:UpgradePortalDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(OPTIMISM_SEPOLIA_RPC_URL) --etherscan-api-key $(OPTIMISM_ETHERSCAN_API_KEY) --skip test --broadcast --slow -v --verify

# Cast helpers
cast-send-m-token-index-local:
forge script script/cast/dev/CastSendMTokenIndexDev.s.sol:CastSendMTokenIndexDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

cast-send-m-token-index-dev-sepolia:
forge script script/cast/dev/CastSendMTokenIndexDev.s.sol:CastSendMTokenIndexDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

cast-send-registrar-key-local:
forge script script/cast/dev/CastSendRegistrarKeyDev.s.sol:CastSendRegistrarKeyDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

cast-send-registrar-key-dev-sepolia:
forge script script/cast/dev/CastSendRegistrarKeyDev.s.sol:CastSendRegistrarKeyDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

cast-send-registrar-list-status-local:
forge script script/cast/dev/CastSendRegistrarListStatusDev.s.sol:CastSendRegistrarListStatusDev --private-key $(DEV_PRIVATE_KEY) --rpc-url localhost --skip test --broadcast -v

cast-send-registrar-list-status-dev-sepolia:
forge script script/cast/dev/CastSendRegistrarListStatusDev.s.sol:CastSendRegistrarListStatusDev --private-key $(DEV_PRIVATE_KEY) --rpc-url $(SEPOLIA_RPC_URL) --skip test --broadcast --slow -v

# Run slither
slither :; FOUNDRY_PROFILE=production forge build --build-info --skip '*/test/**' --skip '*/script/**' --force && slither --compile-force-framework foundry --ignore-compile --sarif results.sarif --config-file slither.config.json .
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export FOUNDRY_PROFILE=$profile
echo Using profile: $FOUNDRY_PROFILE

if [ "$sizes" = false ]; then
forge build --skip '*/test/**/*.t.sol' --skip '*/script/**' --skip '*/lib/forge-std/**' --extra-output-files abi
forge build --skip '*/test/**' --skip '*/script/**' --skip '*/lib/**' --extra-output-files abi
else
forge build --skip '*/test/**/*.t.sol' --skip '*/script/**' --skip '*/lib/forge-std/**' --extra-output-files abi --sizes
forge build --skip '*/test/**' --skip '*/script/**' --skip '*/lib/**' --extra-output-files abi --sizes
fi
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ verbosity = 3
via_ir = false

[profile.production]
build_info = true
optimizer = true
optimizer_runs = 800
build_info = true
sizes = true
via_ir = true

Expand Down
2 changes: 1 addition & 1 deletion lib/common
Submodule common updated 43 files
+1 −1 .prettierrc.json
+1 −1 .solhint.json
+1 −1 lib/forge-std
+1 −1 src/ERC20Extended.sol
+1 −1 src/ERC3009.sol
+1 −1 src/ERC712Extended.sol
+61 −0 src/Migratable.sol
+48 −0 src/Proxy.sol
+1 −1 src/StatefulERC712.sol
+1 −1 src/interfaces/IERC1271.sol
+1 −1 src/interfaces/IERC20.sol
+3 −3 src/interfaces/IERC20Extended.sol
+1 −1 src/interfaces/IERC3009.sol
+2 −2 src/interfaces/IERC712.sol
+1 −1 src/interfaces/IERC712Extended.sol
+44 −0 src/interfaces/IMigratable.sol
+1 −1 src/interfaces/IStatefulERC712.sol
+11 −11 src/libs/Bytes32String.sol
+110 −0 src/libs/ContinuousIndexingMath.sol
+41 −17 src/libs/ContractHelper.sol
+107 −0 src/libs/IndexingMath.sol
+10 −10 src/libs/SignatureChecker.sol
+49 −55 src/libs/UIntMath.sol
+3 −3 test/Bytes32String.sol
+244 −0 test/ContinuousIndexingMath.t.sol
+1 −1 test/ContractHelper.t.sol
+41 −31 test/ERC20Extended.t.sol
+4 −4 test/ERC3009.t.sol
+5 −5 test/ERC712Extended.t.sol
+167 −0 test/IndexingMath.t.sol
+13 −13 test/SignatureChecker.t.sol
+12 −12 test/UIntMath.t.sol
+8 −8 test/invariant/ERC20ExtendedInvariant.t.sol
+1 −1 test/utils/Bytes32StringHarness.sol
+34 −0 test/utils/ContinuousIndexingMathHarness.sol
+1 −1 test/utils/ContractHelperHarness.sol
+1 −1 test/utils/ERC1271WalletMock.sol
+1 −1 test/utils/ERC20ExtendedHarness.sol
+1 −1 test/utils/ERC712ExtendedHarness.sol
+26 −0 test/utils/IndexingMathHarness.sol
+1 −1 test/utils/SignatureCheckerHarness.sol
+1 −1 test/utils/TestUtils.t.sol
+1 −1 test/utils/UIntMathHarness.sol
2 changes: 1 addition & 1 deletion lib/example-native-token-transfers
2 changes: 1 addition & 1 deletion lib/smart-m-token
64 changes: 64 additions & 0 deletions script/cast/CastBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.26;

import { Script, console2 } from "../../lib/forge-std/src/Script.sol";

import { IManagerBase } from "../../lib/example-native-token-transfers/evm/src/interfaces/IManagerBase.sol";

import { IHubPortal } from "../../src/interfaces/IHubPortal.sol";

import { Utils } from "../helpers/Utils.sol";

contract CastBase is Script, Utils {
function _quoteDeliveryPrice(
address hubPortal_,
uint16 destinationChainId_
) internal view returns (uint256 deliveryPrice_) {
(, deliveryPrice_) = IManagerBase(hubPortal_).quoteDeliveryPrice(destinationChainId_, new bytes(1));
}

function _sendMTokenIndex(
address hubPortal_,
uint16 destinationChainId_,
bytes32 refundAddress_,
uint256 value_
) internal returns (bytes32 messageId_) {
return
IHubPortal(hubPortal_).sendMTokenIndex{ value: value_ }(destinationChainId_, refundAddress_, new bytes(1));
}

function _sendRegistrarKey(
address hubPortal_,
uint16 destinationChainId_,
bytes32 key_,
bytes32 refundAddress_,
uint256 value_
) internal returns (bytes32 messageId_) {
return
IHubPortal(hubPortal_).sendRegistrarKey{ value: value_ }(
destinationChainId_,
key_,
refundAddress_,
new bytes(1)
);
}

function _sendRegistrarListStatus(
address hubPortal_,
uint16 destinationChainId_,
bytes32 listName_,
address account_,
bytes32 refundAddress_,
uint256 value_
) internal returns (bytes32 messageId_) {
return
IHubPortal(hubPortal_).sendRegistrarListStatus{ value: value_ }(
destinationChainId_,
listName_,
account_,
refundAddress_,
new bytes(1)
);
}
}
26 changes: 26 additions & 0 deletions script/cast/dev/CastSendMTokenIndexDev.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.26;

import { console2 } from "../../../lib/forge-std/src/Script.sol";

import { CastBase } from "../CastBase.sol";

contract CastSendMTokenIndexDev is CastBase {
function run() public {
address signer_ = vm.rememberKey(vm.envUint("DEV_PRIVATE_KEY"));

address hubPortal_ = vm.parseAddress(vm.prompt("Enter HubPortal address"));
uint16 destinationChainId_ = _getWormholeChainId(vm.parseUint(vm.prompt("Enter destination chain ID")));

uint256 deliveryPrice_ = _quoteDeliveryPrice(hubPortal_, destinationChainId_);
console2.log("Delivery price: {}", deliveryPrice_);

vm.startBroadcast(signer_);

_sendMTokenIndex(hubPortal_, destinationChainId_, _toUniversalAddress(signer_), deliveryPrice_);
console2.log("M token index sent to Wormhole chain ID {}", destinationChainId_);

vm.stopBroadcast();
}
}
Loading

0 comments on commit 806a178

Please sign in to comment.