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

Add verify command #1306

Merged
merged 33 commits into from
Sep 1, 2023
Merged

Add verify command #1306

merged 33 commits into from
Sep 1, 2023

Conversation

SkymanOne
Copy link
Contributor

@SkymanOne SkymanOne commented Aug 29, 2023

Supersedes #696

Adds a cargo contract verify <path to reference contract bundle> command which allows to verify if the given contract code matches the reference bundle.

In addition to the previous PR, I have added the support to verify "verifiable" contract. If the contract bundle specify image in metadata, then we build the target contract code in the container of the specified image and then verify.

This PR also locks the version of wasm-opt crate which often is the cause of binary mismatch.

@SkymanOne SkymanOne mentioned this pull request Aug 29, 2023
@SkymanOne SkymanOne marked this pull request as ready for review August 29, 2023 22:56
Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

One more thing: a lot of trust will be put into this command, therefore we should have integration tests here for both the positive and negative results of this command.

@SkymanOne
Copy link
Contributor Author

One more thing: a lot of trust will be put into this command, therefore we should have integration tests here for both the positive and negative results of this command.

I doubt we will be able to simulate different OS environments, but minor changes in the code should work.

tracing::debug!("Building contract in {}", project_dir.to_string_lossy());
cargo_contract(&project_dir)
.arg("build")
.arg("--release")
Copy link
Contributor Author

@SkymanOne SkymanOne Aug 30, 2023

Choose a reason for hiding this comment

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

Oddly, without the flag, the cargo contract build produces different wasm binaries even though the crate name and code are identical but places in differnt temp dirs.

Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM.

Might be good as a next step to be able to verify from a contract account id that it is an instance of the verified contract. Should be straightforward just by looking up the code hash and then comparing that.

@SkymanOne SkymanOne merged commit b731f54 into master Sep 1, 2023
10 checks passed
@SkymanOne SkymanOne deleted the gn/verify-command branch September 1, 2023 15:56
@smiasojed smiasojed mentioned this pull request Nov 30, 2023
@smiasojed smiasojed mentioned this pull request Mar 4, 2024
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.

3 participants