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

Support casm serialised output #676

Closed
maciektr opened this issue Sep 14, 2023 · 9 comments
Closed

Support casm serialised output #676

maciektr opened this issue Sep 14, 2023 · 9 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@maciektr
Copy link
Contributor

maciektr commented Sep 14, 2023

Problem

As of now, lib target compilation (as opposed to starknet contract targets) is capable of producing CASM artefacts in a textual, human readable format only (equivalent to sierra-compile compiler cli). In contrast, starknet contract compilation uses serialisable json format instead. It is possible to define a similar serialisable casm format for non-contract projects as well. This alternative should be supported as an artefact of lib target compilation.

Proposed solution

  • Modify lib target properties to allow casm artefact format specification
    • lib target properties are defined here:
      struct Props {
      pub sierra: bool,
      pub casm: bool,
      pub sierra_text: bool,
      }
    • Analogously to sierra artefact, it should allow casm and casm_text boolean inputs.
    • casm should create json serialized artefacts, while casm-text should create textual ones.
    • By default both should be disabled.
    • This properties will be available to users as casm and casm-text keys on [lib] object in Scarb.toml manifest files.
  • Modify lib target compiler to produce new artefacts.
    • This compiler abstraction is implemented in this file:
    • Should read properties from previous point and produce artefacts accordingly to user specification.
    • Artefact for serialised output should be written with .casm.json extension into the target directory with target name as filename.
    • Artefact for textual output should be written with .casm extension into the target directory, with the same name.
  • Ensure new artefact type is produced

Notes

See https://github.com/software-mansion/scarb/pull/637/files for similar change introducing new artefact format.

@maciektr maciektr added this to Scarb Sep 14, 2023
@github-project-automation github-project-automation bot moved this to Triage in Scarb Sep 14, 2023
@maciektr maciektr added the help wanted Extra attention is needed label Sep 14, 2023
@maciektr maciektr moved this from Triage to Todo in Scarb Sep 14, 2023
@maciektr maciektr moved this from Todo to Backlog in Scarb Sep 14, 2023
@rodrigo-pino
Copy link

I am taking this one 🙋

@mkaput mkaput moved this from Backlog to In Progress in Scarb Sep 15, 2023
@mkaput
Copy link
Member

mkaput commented Sep 15, 2023

  • Analogously to sierra artefact, it should allow casm and casm_text boolean inputs.
  • casm should create json serialized artefacts, while casm-text should create textual ones.
  • By default both should be disabled.
  • This properties will be available to users as casm and casm-text keys on [lib] object in Scarb.toml manifest files.

I'm not entirely sure about this ones; perhaps we should consult this with Ori or Ariel. For CASM it kinda makes sense to still output text as the default, isn't it?

@rodrigo-pino
Copy link

rodrigo-pino commented Sep 15, 2023

I'm not entirely sure about this ones; perhaps we should consult this with Ori or Ariel. For CASM it kinda makes sense to still output text as the default, isn't it?

The only I can think of is that it is for Cairo devs to verify the Casm of some high-level Cairo code is as expected. Beyond that, I really don't see much use.

Given the knowledge I have, for casm to make sense it needs to have some metadata that describes it such as Entrypoints, Builtins and Hints that it is using. If it is in something easily parseable format (such as json) it really helps other non-rusty tools.

@mkaput
Copy link
Member

mkaput commented Sep 19, 2023

I've asked Cairo team about this.

@mkaput
Copy link
Member

mkaput commented Sep 20, 2023

OK, discussed privately with @orizi. Let's make JSON the default, and add casm-text option.

@maciektr
Copy link
Contributor Author

Hi @rodrigo-pino !
Are you working on this?

@rodrigo-pino
Copy link

rodrigo-pino commented Oct 31, 2023

Hi @maciektr, sorry just did an initial scope analysis gathering what I needed to implement, I found in that search that I will need Sierra metadata as well since in order to made a Cairo 1 runner you require metadata that exists on both Sierra and Casm (but that can be another separate PR)

I haven't implemented much, but be sure I (or someone from the team) will take on this since we do need it at some point in not the far future. If you want to put it backlog or something, I understand. I'll ping you right here as soon as we are ready to take on this!

@maciektr
Copy link
Contributor Author

maciektr commented Nov 2, 2023

Sure, I understand completely! I will put it back to backlog, but it's still yours!

@maciektr
Copy link
Contributor Author

maciektr commented Jun 3, 2024

Closing as not planned since release of universal-sierra-compiler (software-mansion/universal-sierra-compiler) which should provide support for all different kinds of sierra to casm compilation.

@maciektr maciektr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Scarb Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Archived in project
Development

No branches or pull requests

3 participants