# ZK WASM Meetup, September 2023 [Index document](https://hackmd.io/IqQMg6I6Qz-AEc8MSEU4eg?view) Timeline - 6-8 September 2023 Goal: Knowledge sharing, supporting ZK WASM work --- ## Agenda ### September 6 * Presentation: (1h) Andrei presents WASM and NEAR Contract Runtime * [Runtime presentation](https://docs.google.com/presentation/d/1Fe6GBQqZ93-M1jM1Al63XqwGX-KQ7XsVB18HUMLne3k/edit#slide=id.p1) * High level flow: https://nomicon.io/RuntimeSpec/Components/ * [Contract preparation](https://nomicon.io/RuntimeSpec/Preparation) * [Host functions](https://nomicon.io/RuntimeSpec/Components/BindingsSpec/) * [WASM Spec](https://webassembly.github.io/spec/core/bikeshed/) and [code examples](https://learnxinyminutes.com/docs/wasm/) * [Cranelift opcodes](https://docs.wasmtime.dev/api/cranelift_codegen/ir/instructions/enum.Opcode.html) and [ZK ASM lowering rules](https://github.com/near/wasmtime/blob/zkasm-hackaton/cranelift/codegen/src/isa/zkasm/lower.isle) * Show [example](https://github.com/near/nearcore/issues/9386#issuecomment-1679070284) for [WASMI](https://github.com/paritytech/wasmi), [generated ops](https://gist.github.com/akashin/cfba7ecc86d8365f0eeab8e5d4bbc672) * [Rust to Cranelift compiler](https://github.com/bjorn3/rustc_codegen_cranelift) * Brainstorming: (2h) Andrei and Bowen: Can we make proving fast enough to be usable in NEAR? * How can we optimize for latency? * How can we aggregate proofs? * What can we do with [“Compiler JIT bombs”](https://docs.google.com/presentation/d/1n75Mo09HmyruV5S7q0cHWuq-UorrvdG1bRAYTNydBcY/edit#slide=id.g672d2eff65ef7faa_0) * Presentation: (1h) Polygon team: Walk through Polygon Hermez architecture * From moment user submits transaction till transaction is included onchain * How long does aggregation take now? * Can we use tree structure vs linear structure? * 14:00 - 15:00 Polygon folks on an internal meeting ### September 7 * Presentation: (1h) Jordi presents PIL2/Future of Proving/Plonky3? * Anything that will change for users of PIL/ZK ASM? * Hector: More recent developments in ZK (e.g. Lasso, Jolt), main ideas in Plonky 3 * E.g. if we want to prove 1000 consecutive blocks or 1000 transactions * Pair-programming: (2h) Andrei + Polygon, Setup development environment together * Go through Polygon Hermez repositories and understand their purpose * Set up tools for benchmarking and profiling proofs * Writing ZK ASM test suite with inputs * [Tech setup](https://hackmd.io/xlfXSX0qQGe2npk4S0Kf3A) from Andrei * WASM toolkit setup * Cranelift -> ZK ASM compiler from Andrei * Run the production prover (Try AWS instance?) * Pair-programming: (2h) Felicia: Modifying the PIL and Processor * CALL and RETURN using the stack * Adding a new circuit for hash function like SHA256 * Switch from 256 bit to 64 bit machine * Adding a new register ### September 8 * Brainstorming: (2h) Bowen facilitates: "How we collaborate going forward?" * The focus of NEAR and Polygon team * Shared goals for a quarter * Code contributions * Other VM types, e.g. Miden: https://github.com/0xPolygonMiden/miden-vm * Is this something we should look at for ZK WASM? ### Notes * Performance of 64 bit processor is 3 times faster, without storage and POSEIDON Proof (2**23 / 4) in 30s 70k instructions per second In a big machine Read hardware 10M instructions per second