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: add assemblycreate for warning suppression for zksolc 1.5.10 #840

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dutterbutter
Copy link
Collaborator

What πŸ’»

  • Adds assemblycreate error suppression

Why βœ‹

  • Breaking change in 1.5.9 of zksolc

Evidence πŸ“·

Include screenshots, screen recordings, or console output here demonstrating that your changes work as intended

Documentation πŸ“š

Please ensure the following before submitting your PR:

  • Check if these changes affect any documented features or workflows.
  • Update the book if these changes affect any documented features or workflows.

@dutterbutter dutterbutter requested a review from a team as a code owner January 14, 2025 18:26
Copy link
Contributor

@elfedy elfedy left a comment

Choose a reason for hiding this comment

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

Looks good. Maybe we should wait until linking is merged to add this change and then formally bump zksolc to version 1.5.9 along with it though.

@Karrq
Copy link
Contributor

Karrq commented Jan 14, 2025

I think it's ok as long as we don't change the default version here. But we should add this flag by default for >= 1.5.9 I believe since the affected contract is part of forge-std

@elfedy
Copy link
Contributor

elfedy commented Jan 14, 2025

I think it's ok as long as we don't change the default version here. But we should add this flag by default for >= 1.5.9 I believe since the affected contract is part of forge-std

It's fine in terms of functionality. It's just tidier history wise to have an isolated PR bumping the compiler version and include the changes related to the version bump in that same PR.

@dutterbutter dutterbutter added the do not merge πŸ›‘ Do not merge this PR until label is removed label Jan 14, 2025
Cargo.toml Outdated Show resolved Hide resolved
@Karrq
Copy link
Contributor

Karrq commented Jan 15, 2025

Hey @dutterbutter I need 1.5.9 for the linking due to the unlinked factory deps, I think it's best if we merge your PR first, bumping to 1.5.9 with it, and then my linking PR would be based on top of 1.5.9, wdyt?
/cc @elfedy

@dutterbutter dutterbutter removed the do not merge πŸ›‘ Do not merge this PR until label is removed label Jan 16, 2025
@dutterbutter dutterbutter changed the title feat: add assemblycreate for error suppression for zksolc 1.5.9 feat: add assemblycreate for warning suppression for zksolc 1.5.10 Jan 17, 2025
@dutterbutter
Copy link
Collaborator Author

@elfedy bumped this to 1.5.10 and made it default. One question I have, when I log out the compiler output from the tests I see the following difference between TxOrigin warning and AssemblyCreate warning:

AssemblyCreate

compiled: ProjectCompileOutput {
    compiler_output: AggregatedCompilerOutput {
        errors: [
            Error {
                component: "general",
                error_code: None,
                formatted_message: Some(
                    "Warning: `suppressedWarnings` at the root of standard JSON input is deprecated. Please move them to `settings`.\n",
                ),
                message: "`suppressedWarnings` at the root of standard JSON input is deprecated. Please move them to `settings`.",
                severity: Warning,
                source_location: None,
                type: "Warning",
            },
        ],

TxOrigin:

compiled: ProjectCompileOutput {
    compiler_output: AggregatedCompilerOutput {
        errors: [],

I would expect the error field to be similar? I dont think it has any effect on this PR as the test passes but wanted to flag nonetheless.

@dutterbutter
Copy link
Collaborator Author

Is it correct the test failures related to:

failed compiling zksync project: Missing libraries detected:

Would be resolved with #800 ?

@elfedy
Copy link
Contributor

elfedy commented Jan 17, 2025

Is it correct the test failures related to:

failed compiling zksync project: Missing libraries detected:

Would be resolved with #800 ?

@dutterbutter I don't think those failures are expected. @Karrq can confirm though, maybe something changed on 1.5.10 about the missing libs/linking output?

@elfedy
Copy link
Contributor

elfedy commented Jan 17, 2025

when I log out the compiler output from the tests I see the following difference between TxOrigin warning and AssemblyCreate warning

@dutterbutter will investigate this, it is strange as it should not change at all and should always have the warning. We are just deserializing the error json so not sure how this can happen by just changing the suppressedWarnings field value.

@Karrq
Copy link
Contributor

Karrq commented Jan 20, 2025

Hmm I suspect it could be because in a recent compiler release (I think 1.5.8) the detect-missing-libraries flag has been changed a bit, and instead of being exclusive with the bytecode it's now included in the output.
I think the presence of the field (and/or) values triggers our check and we end compilation by showing this message to the user.
I don't particularly think we should get rid of it entirely (for backwards compatiblity), but we could reduce this to a "warning" for 1.5.8, and with #800 I can get rid of the warning for >= 1.5.9

@elfedy
Copy link
Contributor

elfedy commented Jan 20, 2025

I don't particularly think we should get rid of it entirely (for backwards compatiblity), but we could reduce this to a "warning" for 1.5.8, and with #800 I can get rid of the warning for >= 1.5.9

Since we removed the detect-missing-libraries flag in #822, we can probably remove that missing-libraries error flow here instead of #800, if this is in fact the cause of the failing tests. Not sure it's worth keeping just for the 1.5.8 use case

@dutterbutter
Copy link
Collaborator Author

@elfedy @Karrq do I understand correctly that we want to remove this condition entirely in this PR?

@Karrq
Copy link
Contributor

Karrq commented Jan 20, 2025

I'm in favor of retaining it wrt backwards compatibility & compiler versioning, but if that's not a concern then I'm in favor of removing it as well

@elfedy
Copy link
Contributor

elfedy commented Jan 20, 2025

@dutterbutter yes we would remove all missing libs checks from handle_output, they were just there to print a pretty warning about missing libs with the old flow. I think right know that text would only be relevant for 1.5.8 and it's just not worth it to keep that warning and flow to support a warning for that version alone (And they can get missing libs in that version by using --json flag anyways)

@dutterbutter
Copy link
Collaborator Author

dutterbutter commented Jan 20, 2025

@elfedy updated to remove the logic for processing missing libraries in zksync_handle_output here. This has fixed the Missing libraries detected test failures previously mentioned.

Are tests, zksolc_can_compile_with_remapped_links and zksolc_can_compile_with_remapped_links here, still relevant with this change? They are currently failing from the mentioned change?

@elfedy
Copy link
Contributor

elfedy commented Jan 20, 2025

Are tests, zksolc_can_compile_with_remapped_links and zksolc_can_compile_with_remapped_links here, still relevant with this change? They are currently failing from the mentioned change?

I think we should keep the tests. As far as I understand they should pass as the libraries are being specified in the input and bytecode should be linked, right @Karrq ?

@elfedy
Copy link
Contributor

elfedy commented Jan 20, 2025

@dutterbutter @Karrq seems we will need to update our is_unlinked() method. we currently check for empty hash or missing_libraries having some entry. Testing some compilations with 1.5.10, it seems that when you pass libraries, the contract will be linked and compiled but still output its libraries on the missing_libraries field (@hedgar2017 is this correct? Is it expected?). So we will need to distinguish it in some other way. Maybe checking for empty hash is enough or we could make use of the objectFormat field ("raw" = linked, "elf" = unlinked) ?

Copy link

@hedgar2017 hedgar2017 left a comment

Choose a reason for hiding this comment

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

LGtM!

@dutterbutter
Copy link
Collaborator Author

@hedgar2017 any insight on @elfedy question:

Testing some compilations with 1.5.10, it seems that when you pass libraries, the contract will be linked and compiled but still output its libraries on the missing_libraries field (@hedgar2017 is this correct? Is it expected?

@hedgar2017
Copy link

@dutterbutter @Karrq seems we will need to update our is_unlinked() method. we currently check for empty hash or missing_libraries having some entry. Testing some compilations with 1.5.10, it seems that when you pass libraries, the contract will be linked and compiled but still output its libraries on the missing_libraries field (@hedgar2017 is this correct? Is it expected?). So we will need to distinguish it in some other way. Maybe checking for empty hash is enough or we could make use of the objectFormat field ("raw" = linked, "elf" = unlinked) ?

Must be a bug. I can fix it in v1.5.11.
For checking the bytecode status, using objectFormat as you said is the cleanest way. I added it exactly for this purpose.

@Karrq
Copy link
Contributor

Karrq commented Jan 21, 2025

I actually had a different false positive where interfaces (that didn't have a hash) would be detected as unlinked - so I removed that and added if the number of unlinked factory deps (which afaik contains all factory deps) is higher than the list of linked factory deps, in addition to the missing libraries, but if we have another field to determine that then that's even better

@Karrq
Copy link
Contributor

Karrq commented Jan 21, 2025

For checking the bytecode status, using objectFormat as you said is the cleanest way. I added it exactly for this purpose.

Sounds like we should switch is_unlinked to that then - I originally made it from my understanding of the documentation

@hedgar2017
Copy link

For checking the bytecode status, using objectFormat as you said is the cleanest way. I added it exactly for this purpose.

Sounds like we should switch is_unlinked to that then - I originally made it from my understanding of the documentation

Sure, but please provide a bug report for the issue above. Is it very important to fix anyway.

@Karrq
Copy link
Contributor

Karrq commented Jan 21, 2025

Sure, but please provide a bug report for the issue above.

So @dutterbutter if I understand correctly you are observing a populated missing_libraries field in a fully linked contract?

Copy link
Contributor

@Karrq Karrq left a comment

Choose a reason for hiding this comment

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

Other than the discussion above this looks good

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