-
Notifications
You must be signed in to change notification settings - Fork 56
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 polkatool jam-service support #176
base: master
Are you sure you want to change the base?
Conversation
Rather than hand assemble https://gist.github.com/sourabhniyogi/5e44600216af117169384a51ab389c8d we would like to demonstrate how a JAM service written in Rust using #[polkavm_import(index = 0)] can be compiled into JAM-ready PVM and include "ecalli {0..22}" calls; By "JAM-ready" we mean the "0/5/10/15" entry points for is_authorized/refine/accumulate/transfer. TODO: (1) Get toolchain instructions sufficient to get above Rust compiled into PVM with (a) ecalli 16/17/3 in place of import/export (refine) + write (accumulate) (b) entrypoints 0/5/10/15 going into is_authorized/refine/accumulate/on_transfer (2) get polkatool to output .pvm byte code with (1b) streamlined
001755e
to
bbf4c11
Compare
@koute Thank you for your super friendly and critically useful hints! Based on your advice, we successfully built a "polkatool jam-service" to take a "cargo build" compiled Rust JAM Service like We added a README showing the steps and the disassembly. We will build a small battery of actually useful services to test this out further, covering many of the other host functions. To make these JAM Services into JAM-ready toplevel service blobs (as defined in equation 241 in A.7 in GP v0.3.8) we will prepend a header in |
bbf4c11
to
57b9bcf
Compare
Sample execution: (after cargo build of jam-service-fib) ./target/release/polkatool jam-service ~/polkavm/guest-programs/jam-service-fib/target/riscv32ema-unknown-none-elf/release/jam-service-fib
57b9bcf
to
706c34a
Compare
This WIP PR sets up:
refine
(entry point 5) imports a 12-byte segment with [n, fib(n), f(n-1)] and exports the next segment in the same way [n+1, fib(n+1), fib(n)].accumulate
(entry point 10) reads a 12-byte segment and writes to service storage key "0"is_authorized
(entry point 0) andon_transfer
(entry point 15) are just stubs right nowpolkatool jam_service [binary]
to run @koute recommended code/approach to be "JAM-ready". By "JAM-ready" we mean having the "0/5/10/15" entry points for is_authorized/refine/accumulate/transfer.Rather than hand assemble PVM byte code like this using @koute's assembler we would much rather use Rust. The sample code includes a first attempt to get at 23 functions from GP Appendix B and teases a few others.