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

feat(script): add dev deploy and config scripts #2

Merged
merged 23 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b53642
feat(script): add dev deploy scripts
PierrickGT Oct 2, 2024
d2c35b5
feat(script): add dev config scripts
PierrickGT Oct 3, 2024
aaa6bc7
chore(github): enable fork tests
PierrickGT Oct 3, 2024
8122a97
fix(Portals): use relative importh paths
PierrickGT Oct 3, 2024
0bd3e56
chore(lib): update dependencies
PierrickGT Oct 8, 2024
d421ecb
fix(DeployBase): fix SpokePortal address
PierrickGT Oct 9, 2024
8418cdd
fix(Makefile): add verify flag to deploy commands
PierrickGT Oct 9, 2024
cc5c79c
feat(script): add transceivers upgrade script
PierrickGT Oct 10, 2024
faa8982
feat(script): add portal uggrade script
PierrickGT Oct 10, 2024
2d36bb9
chore(lib): update dependencies
PierrickGT Oct 10, 2024
f23059e
feat(script): add HubPortal cast commands
PierrickGT Oct 11, 2024
3b6ea4f
Merge branch 'main' into feat/WEB3-1200-add-deploy-scripts
PierrickGT Oct 12, 2024
f8d4238
feat(script): add SmartM token deploy script
PierrickGT Oct 16, 2024
e3bf133
chore(git): add build sizes workflow test
PierrickGT Oct 21, 2024
779c8f9
Merge branch 'main' into feat/WEB3-1200-add-deploy-scripts
PierrickGT Oct 25, 2024
4a02907
chore(lib): remove wrapped-m-token
PierrickGT Oct 25, 2024
ade50f2
feat(Deploy): add SpokeVault to deploy script
PierrickGT Oct 26, 2024
bbc24d0
feat(Governance): add Governor and Configurator contracts (#3)
PierrickGT Oct 30, 2024
346c7f6
fix(SpokeVault): use Migratable from common
PierrickGT Oct 30, 2024
74ba0f9
chore(lib): update common
PierrickGT Oct 30, 2024
4130092
feat(Deploy): add Spoke SmartM Earner Manager
PierrickGT Oct 30, 2024
3dd3dd7
Merge branch 'main' of github.com:m0-foundation/m-portal into feat/WE…
PierrickGT Oct 30, 2024
bfcd720
fix(SpokePortal): fix IndexingMath import path
PierrickGT Oct 30, 2024
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
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
path = lib/example-native-token-transfers
url = [email protected]:wormhole-foundation/example-native-token-transfers.git
branch = main
[submodule "lib/wrapped-m-token"]
path = lib/wrapped-m-token
url = [email protected]:m0-foundation/wrapped-m-token.git
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about this approach. It doesn't scale well since adding a new chain requires to duplicate all those commands and it's easy to make a copy-paste mistake.
Is it possible to just pass a chain name and read all the required information from json config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can refactor later but we should still keep one command per network.

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
1 change: 1 addition & 0 deletions lib/wrapped-m-token
Submodule wrapped-m-token added at 18e10a
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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's should be called Cast. cast is just a command-line tool, and we're not using it to call the script. Since it sends cross-chain transactions Send is more descriptive name

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
Loading