Skip to content

Add verify command#1306

Merged
SkymanOne merged 33 commits intomasterfrom
gn/verify-command
Sep 1, 2023
Merged

Add verify command#1306
SkymanOne merged 33 commits intomasterfrom
gn/verify-command

Conversation

@SkymanOne
Copy link
Copy Markdown
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
@SkymanOne SkymanOne requested a review from ascjones August 30, 2023 13:06
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@SkymanOne SkymanOne requested a review from ascjones August 30, 2023 15:32
Copy link
Copy Markdown
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
@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