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

🔷 [2023-10] Cranelift produces zkasm the right way #9623

Closed
2 tasks
nagisa opened this issue Oct 2, 2023 · 1 comment
Closed
2 tasks

🔷 [2023-10] Cranelift produces zkasm the right way #9623

nagisa opened this issue Oct 2, 2023 · 1 comment
Labels
A-zk C-epic Category: an epic T-contract-runtime Team: issues relevant to the contract runtime team

Comments

@nagisa
Copy link
Collaborator

nagisa commented Oct 2, 2023

This is a monthly initiative tracking issue.

Today our zkasm backend is largely a copy of RISC-V backend still, and it shows. It also frequently causes me have a brain spasm and misremember what and how certain functions of zkasm work. Either way, the primary thing we need to do, I think, before implementing the rest of the backend, is to get fundamentals in order:

  • Clean up register and ABI definitions (in particular type alignments and such);
  • Make sure our use of MachBuffer makes sense, that we apply relocations in the right place, that we add prologues, epilogues and other such fluff in the right places;

Implementing some of the WASM operations in zkasm is going to be troublesome as well, given that we only really have some arithmetic and bitwise op instructions to work with. One thing to keep in mind here is that we don’t need a full WASM instruction set for an MVP test – which makes me think that I should also gather requirements on what the representative benchmark contracts we want to use to evaluate zkasm, and then write down the list of the operations that we want to implement.

@nagisa nagisa added C-epic Category: an epic T-contract-runtime Team: issues relevant to the contract runtime team A-zk labels Oct 2, 2023
@nagisa
Copy link
Collaborator Author

nagisa commented Oct 30, 2023

I have made some headway in cleaning up the backend, but I don’t feel like I made enough progress there to mark off either of the points above as completed, unfortunately. Machine definition cleanup in particular ended up being quite tricky as I kept hitting far reaching uses of certain entities such as the zero register which necessitated rewriting large chunks of non-trivial functionality. As an example is the PR the floating/vector removal which ended up touching about 1000 lines of code, even though I went in intending to remove just the register definitions. Fortunately for floating point, all that code could be removed wholesale – zkASM simply does not support it at this time. Not as easy to do so on the integer side of things.

I have also started looking into the second point, as part of a larger effort to move our testing over to the pre-existing filetests framework. Far away from being complete, but at the very least it is already clear that there’s a non-trivial amount of work here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-zk C-epic Category: an epic T-contract-runtime Team: issues relevant to the contract runtime team
Projects
None yet
Development

No branches or pull requests

1 participant