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: library deployments though CREATE2 #7711

Merged
merged 13 commits into from
May 14, 2024
Merged

feat: library deployments though CREATE2 #7711

merged 13 commits into from
May 14, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Apr 18, 2024

Motivation

Closes #4810
ref #7027 (comment)

Solution

This PR introduces a new approach to library linking for scripts. If CREATE2 deployer is present on target chain, ibraries are deployed through it, and only if they have not been deployed before. This makes it possible for users to run scripts without ever thinking about library deployment and need to provide addresses in foundry.toml or via --libraries args.

Salt for deployments can be configured through create2_library_salt.

It is not possible to link libraries with cyclic dependencies in such way, so we are still falling back to default linking algo if error occurs.

@klkvr
Copy link
Member Author

klkvr commented Apr 20, 2024

needs foundry-rs/compilers#108 and will be blocked by yansi update

mattsse pushed a commit to foundry-rs/compilers that referenced this pull request Apr 20, 2024
#108)

I'm writing tests for foundry-rs/foundry#7711
which are hardcoding CREATE2 library deployment addreses and they are
currently failing on Windows probably because \r\n line endings which
are causing metadata differences.

This PR tries to fix this by replacing such endings with \n
@klkvr klkvr changed the title [wip] feat: library deployments though CREATE2 feat: library deployments though CREATE2 Apr 22, 2024
@klkvr klkvr marked this pull request as ready for review April 22, 2024 12:20
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

looks fine, please rebase to remove the duplicate commits

crates/evm/evm/src/executors/mod.rs Outdated Show resolved Hide resolved
crates/script/src/runner.rs Outdated Show resolved Hide resolved
crates/script/src/runner.rs Outdated Show resolved Hide resolved
@klkvr klkvr force-pushed the klkvr/library-create2 branch 2 times, most recently from 9b229cd to 08f3c41 Compare April 22, 2024 12:57
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

PTAL @mattsse

crates/config/src/lib.rs Outdated Show resolved Hide resolved
crates/forge/tests/cli/script.rs Show resolved Hide resolved
crates/script/src/build.rs Show resolved Hide resolved
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm,

sorry missed this one...
needs rebase

@klkvr klkvr force-pushed the klkvr/library-create2 branch from 3a0ce36 to e8cc161 Compare May 13, 2024 18:22
@klkvr klkvr force-pushed the klkvr/library-create2 branch from e8cc161 to d9820a1 Compare May 13, 2024 18:54
@klkvr klkvr merged commit 39f155d into master May 14, 2024
19 checks passed
@klkvr klkvr deleted the klkvr/library-create2 branch May 14, 2024 14:36
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.

Create2 deployment by script does not use create2 to deploy libraries
4 participants