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

[feat] Custom Cairo runner #118

Open
m-kus opened this issue Aug 30, 2024 · 9 comments
Open

[feat] Custom Cairo runner #118

m-kus opened this issue Aug 30, 2024 · 9 comments
Assignees
Labels
blocked Requires other issues to be resolved first

Comments

@m-kus
Copy link
Collaborator

m-kus commented Aug 30, 2024

Currently we use Scarb cairo-run extension for running the light client program but it has several downsides:

  • Under the hood it uses Sierra runner which does compilation to Casm every time you invoke the runner;
  • It does not expose trace/memory and public input artifacts that are required to generate a proof.

Another option is cairo1-run (from cairo-vm) but it still does not solve (1).

A proposed solution is a custom Cairo runner that:

  • Caches Casm output instead of recompiling every time
  • Uses a reduced execution context (e.g. we don't need Starknet state or hints)
  • Outputs Stone compatible artifacts
  • Pre-processes program arguments (converts JSON to T = Felt | Array<T>)
  • Optionally also queries data from RPC

It should have a convenient CLI so that we can integrate it into the validation pipeline.

@m-kus m-kus self-assigned this Aug 30, 2024
@maciejka
Copy link
Collaborator

I would postpone this one until we gain better understanding how the proving pipeline will look like. Saving Sierra to Casm compilation time does not look like a worthwhile goal.

@maciejka
Copy link
Collaborator

  • Pre-processes program arguments (converts JSON to T = Felt | Array<T>)
  • Optionally also queries data from RPC

Both should be facilitated by a script that will drive the client, rather in Python than in Rust.

@m-kus
Copy link
Collaborator Author

m-kus commented Sep 1, 2024

In general, cairo1-run should suffice, it can work with sierra output and generate all the artifacts necessary for proving. The only problem is that it's not packaged (and you cannot use cargo install either), we'd need to clone, build, and run cairo-vm locally which is not very convenient.

Just to note, custom runner is a very small program, e.g. see https://github.com/HerodotusDev/integrity/blob/main/runner/src/main.rs

@maciejka
Copy link
Collaborator

maciejka commented Sep 2, 2024

I prefer not to go custom route until it is strictly necessary. What would be simplest way to get cairo1-run available via cargo install? Clone the vm repo and publish it under the custom name?

@maciejka maciejka added this to the Milestone 1 milestone Sep 2, 2024
@m-kus
Copy link
Collaborator Author

m-kus commented Sep 2, 2024

Maybe we can ask Lambda to add it to the [bin] section in Cargo.toml (which is probably the easiest option) or build binaries in CI (or ask some OD contributor to do that)

@m-kus
Copy link
Collaborator Author

m-kus commented Sep 2, 2024

Actually it worked without [[bin]] (contrary to https://doc.rust-lang.org/cargo/commands/cargo-install.html#description) cargo install --git https://github.com/lambdaclass/cairo-vm cairo1-run

@m-kus m-kus closed this as completed Sep 2, 2024
@m-kus m-kus reopened this Sep 2, 2024
@m-kus
Copy link
Collaborator Author

m-kus commented Sep 2, 2024

For some reason cairo1-run fails to compile the Sierra file produced by Scarb (and it also fails to compile the project because it does not support crates). I've upgraded cairo-lang-* dependencies but the problem seems to be somewhere else.

I'm moving on with Scarb runner for now, will investigate later.

@m-kus
Copy link
Collaborator Author

m-kus commented Sep 6, 2024

Another thing: we hit "Arguments list too long" in shell when running full client on large blocks (1MB), it seems that the workaround is to read args from file, Scarb does not support that, cairo1-run does.

@m-kus m-kus added the blocked Requires other issues to be resolved first label Sep 9, 2024
@m-kus
Copy link
Collaborator Author

m-kus commented Sep 15, 2024

Additional considerations:

  • with custom runner we can leverage reilabs hints (for ecdsa)
  • run without Starknet context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Requires other issues to be resolved first
Projects
None yet
Development

No branches or pull requests

2 participants