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

🚧✨ Store contract abi and source #1124

Closed

Conversation

bal7hazar
Copy link
Contributor

@bal7hazar bal7hazar commented Oct 31, 2023

Closes #1121

The upload method should be updated to upload the serialized abi json and the contract source to ipfs and set the ipfs uri into the WorldMetadata before upload.

I tried to add tests into metadata_tests.rs file, but it seems tests in it are not play at all while running cargo run --bin sozo -- --manifest-path crates/dojo-core/Scarb.toml test (neither in the CI) not sure where does it come from but I guess it was the case before I did anything, so probably expected for some reason.

It should be modified to always create a WorldMetadata with the abi and source fields and merge in the user defined metadata from the manifest.

I decided to override default WorldMetadata (with abi and source) by the user manifest, so I guess both fields could be overridden by a user input, which is more flexible but mb less secure.

We will need to update the compiler to output the flattened source representation too.

About this topic, I understood to add the sierra program code into the manifest file generated after a build, I hope I have git it correctly.

Workload ~ 5h

Contract {
name: WORLD_CONTRACT_NAME.into(),
abi: abi.clone(),
source: source.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the sierra? Is it enough to verify a contract + abi with just sierra? I think we want to store the cairo code itself, so we can compile it down to sierra -> casm to verify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, sierra code must be compiled by the verifier

Copy link
Contributor Author

@bal7hazar bal7hazar Oct 31, 2023

Choose a reason for hiding this comment

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

@tarrencev I am a bit confused, about what we expect:

  • Everything in the manifest
  • Everything in a separate file abi + source per contract
  • Everything in separate files (1 file for abi + 1 file for the source per contract)
  • All the cairo code into a single file (generated by the compiler? I am not aware of that, also it should includes cairo code dependancies to be verifiable) and 1 abi file per contract

Copy link
Contributor

Choose a reason for hiding this comment

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

@bal7hazar I think the 3rd option would be best, with the flattened source code. I'm not sure exactly how to extract that from the compiler but it should be possible. Ideally we could support the file structure as well, but it might be tricky. Perhaps we handle source in a separate commit and start with abi?

Copy link
Contributor Author

@bal7hazar bal7hazar Nov 1, 2023

Choose a reason for hiding this comment

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

Perhaps we handle source in a separate commit and start with abi?

@tarrencev, actually I am not sure the abi is required for a verification purpose. If we can have the cairo sources, we should be able to generate abi from it, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bal7hazar yes that is true but abi can still be useful for interacting with the contracts without verification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have overspent time on it, and it is still confused to me.
I think it will be more efficient if someone else knowing better dojo internal flows and rust could work on it
I can prefer to pause this PR, leaving it for anyone wanting to continue or restart from the beginning.

@glihm
Copy link
Collaborator

glihm commented Feb 7, 2024

Hey @bal7hazar, do appreciate you time and effort on this one.
Will close since dropped and some part of dojo is evolving which could affect how this issue is taclked. :)

Thanks again. πŸ™

@glihm glihm closed this Feb 7, 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.

Store contract abi and source in contract metadata
3 participants