Skip to content

feat: Added foundry deploy script #1044

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

fusmanii
Copy link

@fusmanii fusmanii commented Jun 11, 2025

First attempt at deploy script migration to foundry. Just did one deploy script and looking for feedback.

List of changes:

  • Created DeployHubPool.s.sol and script/DeployEthereumSpokePool.s.sol inside script folder
  • Created DeployConstants.sol inside script folder that works similar to deploy/consts.ts by providing third party smart contract addresses
  • Created DeploymentUtils.sol inside script that works similar to utils/utils.hre.ts
  • Contract can be deployed using forge script script/DeployHubPool.s.sol:DeployHubPool --rpc-url $RPC_URL --broadcast --verify -vvvv which deploys and verifies the contract and adds the deploy info in the broadcast folder
  • Created a script script/extract_foundry_addresses.sh that extracts all the deployed addresses from the broadcast folder and puts it in a json, an md file and a sol file (similar to deployments.json)

Looking for feedback on the proposed flow and how I can make this better and address some of the short comings of the current deployment flow

Fixes https://linear.app/uma/issue/UMA-2906/contracts-migrate-smart-contract-deploy-to-foundry

@fusmanii fusmanii force-pushed the fusmanii/foundry-deploy-scripts branch from 64e7247 to 7ebdaf8 Compare June 11, 2025 19:33

## Mainnet (Chain ID: 1)

### DeployPermissionSplitterProxy.s.sol
Copy link
Member

Choose a reason for hiding this comment

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

Are these just examples or does this .md file also get auto updated?

Copy link
Author

Choose a reason for hiding this comment

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

This file also gets auto updated (which is a bit easier to read than the json file)

from pathlib import Path


def find_broadcast_files(broadcast_dir: Path) -> list:
Copy link
Member

Choose a reason for hiding this comment

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

Can this script run well in the github CI? I think that'd be an ideal end result of this script. Also I know you're probably more familiar with python but does this script require other dependencies? I am wary of adding more dependencies especially since we already have typescript set up..but its not a big deal. This file so far isn't part of the CI/hot path so its fine

Copy link
Author

Choose a reason for hiding this comment

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

changed it to a ts script instead

nicholaspai
nicholaspai previously approved these changes Jun 11, 2025
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

I think this is a great start.

@fusmanii fusmanii changed the title feat: Added foundry deploy script for HubPool WIP: Added foundry deploy script for HubPool Jun 13, 2025
@fusmanii fusmanii marked this pull request as draft June 13, 2025 15:15
@@ -0,0 +1,223 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Why python?

Copy link
Author

Choose a reason for hiding this comment

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

changed it to ts

@grasphoper grasphoper self-requested a review June 20, 2025 15:20

/**
* @title DeployConstants
* @notice Contains constants used in deployment scripts, converted from consts.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we read this in via one or more json configuration files? Two advantages:

  • Config/code split so it's clear (in the future) which changes are configuration and which changes are logical.
  • More flexibility: it will allow us to pull in this info from somewhere else easily. For instance, the json could be generated/updated from an API OR we could import one or more of the config jsons from a common package (like our constants package or something).

Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

Mainly because dealing with json inside a foundry script is not trivial, I also have deployed-addresses.json that is generated regarding your second point

Copy link
Contributor

@mrice32 mrice32 Jun 23, 2025

Choose a reason for hiding this comment

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

Don't they have utilities for that that makes it fairly trivial if the json is well structured? I may be missing some additional complexity (I haven't tried to use these utils before)

https://getfoundry.sh/reference/cheatcodes/parse-json/?highlight=json
https://getfoundry.sh/reference/cheatcodes/parse-json-keys

Copy link
Author

Choose a reason for hiding this comment

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

updated to using perse-json, much cleaner now :)

Copy link
Contributor

@mrice32 mrice32 Jun 25, 2025

Choose a reason for hiding this comment

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

Thoughts on expanding this, s.t. the Constants.sol values are read in from json as well?

Copy link
Author

Choose a reason for hiding this comment

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

Constants are currently in a ts file, but I can create a json for constants that Constants.sol uses

Copy link

socket-security bot commented Jun 22, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​openzeppelin/​foundry-upgrades@​0.4.0501009085100

View full report

fusmanii added 2 commits June 22, 2025 15:43
Signed-off-by: Faisal Usmani <[email protected]>
@fusmanii fusmanii force-pushed the fusmanii/foundry-deploy-scripts branch from 72e2502 to 84ccd43 Compare June 22, 2025 19:43
@fusmanii fusmanii changed the title WIP: Added foundry deploy script for HubPool feat: Added foundry deploy script for HubPool Jun 23, 2025
@fusmanii fusmanii marked this pull request as ready for review June 23, 2025 13:56
@fusmanii fusmanii changed the title feat: Added foundry deploy script for HubPool feat: Added foundry deploy script Jun 23, 2025
Copy link

linear bot commented Jun 23, 2025

WETH9Interface constant WETH_SCROLL = WETH9Interface(0x5300000000000000000000000000000000000004);
WETH9Interface constant WETH_UNICHAIN = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_UNICHAIN_SEPOLIA = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_ALEPH_ZERO = WETH9Interface(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // Assuming bridged WETH
Copy link
Contributor

Choose a reason for hiding this comment

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

This also looks wrong. Maybe we should name this wrapped native token so that it aligns with the var names in the spoke pool constructors (same thing with getWethAddress() below).

Copy link
Author

Choose a reason for hiding this comment

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

Nice catch, updated and renamed to WRAPPED_NATIVE_TOKEN_{CHAINNAME}

WETH9Interface constant WETH_OPTIMISM_SEPOLIA = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_BASE = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_BASE_SEPOLIA = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_LENS = WETH9Interface(0x4200000000000000000000000000000000000006);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WETH9Interface constant WETH_LENS = WETH9Interface(0x4200000000000000000000000000000000000006);
WETH9Interface constant WETH_LENS = WETH9Interface(0xE5ecd226b3032910CEaa43ba92EE8232f8237553);

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

@fusmanii fusmanii force-pushed the fusmanii/foundry-deploy-scripts branch from 1a9787a to 6b82900 Compare June 24, 2025 15:24
@fusmanii fusmanii force-pushed the fusmanii/foundry-deploy-scripts branch from 300516f to 6aec3c4 Compare June 30, 2025 14:55
@fusmanii fusmanii requested review from bmzig and mrice32 June 30, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants