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 Epirus Substrate Explorer Phase 2 Milestone 1 #652

Merged
merged 2 commits into from
Dec 18, 2022
Merged

Conversation

conor10
Copy link
Contributor

@conor10 conor10 commented Dec 8, 2022

Milestone Delivery Checklist

Link to the application pull request: w3f/Grants-Program#1159

@alxs
Copy link
Contributor

alxs commented Dec 12, 2022

Many thanks for the delivery @conor10. We'll look into it as soon as possible.

@randombishop randombishop self-assigned this Dec 12, 2022
@randombishop
Copy link
Contributor

Thanks again for the delivery @conor10. I just started working on this evaluation, and will probably get back to you by the end of this week...

@randombishop
Copy link
Contributor

randombishop commented Dec 16, 2022

Hi @conor10!
Great codebase, very well documented and I managed to install, build and test each repo just fine from first try.

I am now trying to create the example flipper contract and make its verifiable package.
Steps to install:

git clone https://github.com/web3labs/ink-verifier-image.git
cd ink-verifier-image/
docker build . -t ink-verifier:develop
cd cli
cargo install --path .

Steps to try it on flipper contract

cargo install --git https://github.com/paritytech/cargo-contract   --rev e2e804be3bab2a987f0441fb8025a5a82da1c10e
cargo contract new flipper
cd flipper
cargo build --release
build-verifiable-ink -t develop .

But I get the following error:

ERROR: An unexpected import function was found in the contract Wasm: set_storage.
The only allowed import functions are those starting with one of the following prefixes:
seal, memory

(Attached the full log as well)
ink_verifier_error.log

@XY-Wang
Copy link

XY-Wang commented Dec 16, 2022

Hi @randombishop !

It seems that the error happens due to a mismatch between the ink! and cargo-contract versions. Since our verifier image has cargo-contract version pinned to the commit e2e8...c10e it expects the ink! version to be the same. Unfortunately cargo contract new doesn't generate the flipper Cargo.toml with the same pinned version.

To fix:
In your flipper Cargo.toml file, please change the ink dependency to ink = { git="https://github.com/paritytech/ink", rev="c2c0a9ff2c8f161b183c0e3d99c6358c96afaee3", version = "4.0.0-alpha.3", default-features = false }
I'm guessing that right now it says ink = { version = "4.0.0-alpha.3", default-features = false }?
You can check our example flipper contract here to see the Cargo.toml configuration.
Then run build-verifiable-ink -t develop . again and it should work :)

Hope that helps!

P.S. In case you haven't seen, we also have ready-built verifiable packages in this repo. You'll need to use the contracts in ink4.0.0-alpha.3/ for uploading to local testnet and ink4.0.0-beta/ for uploading to Rococo Contracts. The need for different versions is explained here.

@randombishop
Copy link
Contributor

Hi @XY-Wang thanks for your help, the command line tool works now!
So just a general question: is the assumption that only contracts compiled with the tool will be possible to be verified? or is there a path to verify a contract that was built with different versions of ink! without using the packaging tool?
I will move forward with accepting the delivery anyways, just a curiosity question...

@XY-Wang
Copy link

XY-Wang commented Dec 16, 2022

Thank you very much for the evaluation @randombishop!

To answer your question:
The packaging tool is not strictly necessary but the docker image is (which is what the cli uses under the hood) :D This is because the build is non-deterministic across different operating systems and architectures. The ink! team did a pretty good investigation into this and you can read about their findings here. Building the contract using the docker image ensures that the build environment is identical when verifying.

Ink! developers will be able to specify which version of cargo-contract they want to build their contract with; the cargo-contract version should of course be compatible with the ink! version. We support passing these build variables to the image:

BUILD_MODE=Release
CARGO_CONTRACT_VERSION=2.0.0-alpha.4
RUST_TOOLCHAIN=stable-x86_64-unknown-linux-gnu
KEEP_DEBUG_SYMBOLS=false
OPTIMIZATION_PASSES=Z

The caveat is that prior to cargo-contract 2.0.0-alpha.4-e2e804b, the above information was not emitted to the contract metadata (relevant PR here). So only contracts written with ink! from this version onward can be verified. This is also why we decided to add the signed metadata upload feature.

Some possible future developments will be to integrate the verifier image in other ink! tools such as cargo-contract or Swanky to ensure that developers always end up with a verifiable contract bundle :)

Hope this clarifies your doubts!

@randombishop
Copy link
Contributor

Got it, so as long as the version of cargo-contract is above cargo-contract 2.0.0-alpha.4-e2e804b I should be able to configure the docker image to build the exact same bytecode, and should be fine?

@XY-Wang
Copy link

XY-Wang commented Dec 16, 2022

Exactly!

Just note that building with cargo-contract 2.0.0-alpha.5 or above means your contract can only be deployed on a chain that supports Weights V2 (such as Rococo Contracts). On the other hand, contract built with versions lower than 2.0.0-alpha.5 can only be deployed on chains with Weights V1 😄

@randombishop
Copy link
Contributor

Perfect, thanks for the clarifications!
Awaiting a final check by another evaluator before the delivery can be approved and merged.
You can find my temporary evaluation here: https://github.com/w3f/Grant-Milestone-Delivery/blob/81dfe12dda2e6ff9dffab1801952c40fa6110af0/evaluations/epirus_substrate_explorer_1_randombishop.md

@Noc2 Noc2 merged commit d402d78 into w3f:master Dec 18, 2022
@github-actions
Copy link

github-actions bot commented Dec 18, 2022

Congratulations on completing the first milestone of this grant! As part of the Grants Program, we want to help grant recipients acknowledge their grants publicly. To that end, we’ve created a badge for projects that successfully deliver their first milestone. Note that it must only be used within the context of the delivered work, so please do not display it on your team or project's homepage unless accompanied by a short description of the grant.

Furthermore, you're now welcome to announce the grant publicly. Please remember to observe the foundation’s guidelines in doing so. In case you haven't done so yet, you may also reach out to [email protected] for feedback on your announcement and cross-promotion.

Thank you for your contribution and good luck with the remaining milestones, if any! As usual, please let us know if you run into any delays by leaving a comment on the application PR, or directly submitting an amendment.

@randombishop
Copy link
Contributor

@conor10 Happy to inform you that your delivery was accepted.
Evaluation notes here: https://github.com/w3f/Grant-Milestone-Delivery/blob/master/evaluations/epirus_substrate_explorer_1_randombishop.md
I'll forward your invoice to the finance team, please allow for up to two weeks for processing. (maybe 3 with holiday season.)

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.

5 participants