feat(contracts): deploy each Honk library once per distinct bytecode - #42
Merged
Merged
Conversation
bb writes RelationsLib and ZKTranscriptLib into every verifier it generates and forge links each verifier only against its own file's copy, so the two circuits paid for two identical deployments. Libraries groups link references by the hash of the library's creation code and deploys each distinct hash once, through the CREATE2 deployer at an address derived from that hash, so a library already on the chain is found and linked rather than deployed again. deploy_honk_verifiers takes a set; deploy_honk_verifier still works alone. Both circuits: four transactions, was six. Assisted-by: Claude Fable 5.1 Signed-off-by: xgreenx <xgreenx9999@gmail.com>
The vendored verifiers' libraries are identical today, so they can only show the sharing half of the rule. LinkFixture.sol links libraries under the same two names compiled from other code; the anvil test reads it from forge's out/ and shows its pair deployed beside the circuits' pair, not shared. Assisted-by: Claude Fable 5.1 Signed-off-by: xgreenx <xgreenx9999@gmail.com>
Assisted-by: Claude Fable 5.1 Signed-off-by: xgreenx <xgreenx9999@gmail.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RelationsLibandZKTranscriptLibcompile to identical bytecode in both verifier files, yet each circuit deployed its own copy: ~15.8 KB paid twice.Changes
deploy::Librariesgroups link references by the hash of the library's creation code and deploys each distinct hash once; every file whose copy has that hash links the one address. No version, no list.library_address(creation_code); a re-run finds code there and sends nothing.circuits::deploy_honk_verifiers(provider, artifacts, &Circuit::ALL, sender)deploys a set and returnsHonkVerifiers { verifiers, libraries }.deploy_honk_verifierstill works alone.Libraries::linkreturns linked creation code without deploying (factory deploys).circuits.rsdoc no longer claims the libraries are unshared.Initializerhash equalskeccak256(code),logNdiffers.LinkFixture.sollinks same-named libraries compiled from other code; read from forgeout/, its pair deploys beside the circuits' pair.Verified
forge test482 passed; lint and fmt clean.cargo test --allwith anvil: 14 unit + 7 anvil pass;cargo docclean.Not verified / known issues
link_creation_codewithLibraries::deploy+link.