Skip to content

Instantly share code, notes, and snippets.

View sourabhniyogi's full-sized avatar

Sourabh Niyogi sourabhniyogi

View GitHub Profile
#![no_std]
#![no_main]
extern crate alloc;
const SIZE0 : usize = 4*1024*1024; // GP stack
// allocate memory for stack
use polkavm_derive::min_stack_size;
min_stack_size!(SIZE0); // 2^24 - 1 - 4096, should not greater than 2^24 - 1 (16777215)
This file has been truncated, but you can view the full file.
🔍 Testing file: 4_004.json
---------------------------------
DEBUG[04-02|21:24:32.920] SINGLE ACCUMULATE s=1065941251 wrangledResults='{"H":"0x66036e9ff03719152f125a9669f832160d61e3d583385d3e53ffe2735a5f4d14","E":"0x4a01d004095c0328783e60f1a451198d22be1ac2b1de845b88cb1c782ef1b252","A":"0x0b27478648cd19b4f812f897a26976ecf312eac28508b4368d0c63ea949c7cb0","O":"","Y":"0x46090e1520f0664af9bfd333855c91ae7cffd628b1e7a580e93141725da9f4dc","D":"0x000c0a0000005900000037000000"}'
DEBUG[04-02|21:24:32.921] PVM Params OSIZE=4672 WSIZE=24 Z=2 S=40960 O="[140 0 255 255 164 0 255 255 182 0 255 255 200 0 255 255 224 0 255 255 248 0 255 255 14 1 255 255 26 1 255 255 38 1 255 255 56 1 255 255 0 16 0 0 0 0 0 0 252 255 255 255 255 255 255 255 250 255 255 255 255 255 255 255 101 120 112 117 110 103 101 32 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 32 111 117 116 112 117 116 61 247 255 255 255 255 255 255 255 122 61 32 115 61 32 111 95 98 121 116 101 115 95 97 100 100 114 1
🔍 Testing file: 1_005.json
---------------------------------
DEBUG[04-02|20:44:07.639] SINGLE ACCUMULATE s=0 wrangledResults='{"H":"0x3aaf70d3c62f815d100dd6c95185c9c124210ac96115680f0927dc694a367f6a","E":"0x0000000000000000000000000000000000000000000000000000000000000000","A":"0x0b27478648cd19b4f812f897a26976ecf312eac28508b4368d0c63ea949c7cb0","O":"","Y":"0x58895203656b4df71654f43d328d1cb3e10b2f5977f19cb65b84e308b43e8755","D":"0x0024aa125123e0373599cacc94075a0d7d365a6bd81a1e260c4dcabd837fe48ddafdf7050000"}'
DEBUG[04-02|20:44:07.639] PVM Params OSIZE=0 WSIZE=0 Z=2 S=8192 O=[] W=[] "Code and Jump Table size: %d\n"=1074
DEBUG[04-02|20:44:07.639] [N0] bootstrap 1: PC 5 JUMP g=9876 reg="[4294901760 4278059008 0 0 0 0 0 4278124544 176 0 0 0 0]"
DEBUG[04-02|20:44:07.639] [N0] bootstrap 2: PC 179 ADD_IMM_64 g=9876 reg="[4294901760 4278058832 0 0 0 0 0 4278124544 176 0 0 0 0]"
DEBUG[04-02|20:44:07.639] [N0] bootstrap 3: PC 183 STORE_IND_U64 g=987
{
"0": {
"peer_id": 0,
"peer_addr": "jam-0.jamduna.org:9900",
"validator": {
"bandersnatch": "0x5e465beb01dbafe160ce8216047f2155dd0569f058afd52dcea601025a8d161d",
"ed25519": "0x3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29",
"bls": "0xb27150a1f1cd24bccc792ba7ba4220a1e8c36636e35a969d1d14b4c89bce7d1d463474fb186114a89dd70e88506fefc9830756c27a7845bec1cb6ee31e07211afd0dde34f0dc5d89231993cd323973faa23d84d521fd574e840b8617c75d1a1d0102aa3c71999137001a77464ced6bb2885c460be760c709009e26395716a52c8c52e6e23906a455b4264e7d0c75466e",
"metadata": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
go test -run TestStateTransitionSingle
🔍 Testing file: 1_005.json
---------------------------------
DEBUG[03-24|00:20:29.909] SINGLE ACCUMULATE s=0 wrangledResults='{"H":"0x485e30a6fa633b035eb9ee29866443006dbd5e4c1c5b7c84da37b394c2fabe3c","E":"0x0000000000000000000000000000000000000000000000000000000000000000","A":"0x0b27478648cd19b4f812f897a26976ecf312eac28508b4368d0c63ea949c7cb0","O":"","Y":"0xdf10c0d0601a56cd9b9ed0b21bd96b81147bee6b61003fe6e74ea9d302230cd8","D":"0x0024da62d20900f65917b964d44d1c2c3b86be68dd84a8e342a4226c0ba30a01ee242f310000"}'
DEBUG[03-24|00:20:29.909] PVM Params OSIZE=0 WSIZE=0 Z=2 S=8192 O=[] W=[] "Code and Jump Table size: %d\n"=1448
DEBUG[03-24|00:20:29.909] [N0] bootstrap 1: PC 5 JUMP g=1000 pvmHash=aa8b..6411 reg="[4294901760 4278059008 0 0 0 0 0 4278124544 176 0 0 0 0]"
DEBUG[03-24|00:20:29.910] [N0] bootstrap 2: PC 288 ADD_IMM_64 g=1000 pvmHash=2fe3..83e1 reg="[4294901760 4278058816 0 0 0 0 0 4278124544 176 0 0 0
@sourabhniyogi
sourabhniyogi / verifyopsuccinct.js
Created January 9, 2025 00:09
How to verify an OP Succinct proof (groth16) posted to ETH Mainnet by Phala OP Succinct L2
// verifyopsuccinct.js -- shows how to verify an OP Succinct proof (groth16) posted to ETH Mainnet using sample
// https://etherscan.io/tx/0x20cb55cb5c643654cc87bfdcfbb12c73642c6c8199573c25d573b123280038f1
// posted by Phala on Jan-08-2025 11:36:23 AM to ETH Mainnet contract:
// https://etherscan.io/address/0xb45440830bd8d288bb2b5b01be303ae60fc855d8
// You run it (with an infura API key)
// # node verifyphala.js
// SP1 Proof verified!
const ethers = require("ethers"); // v5
@sourabhniyogi
sourabhniyogi / gist:1212d082cf8909d66b0b644f23c00658
Created December 17, 2024 22:43
NEED HELP: how do we write one groth16 proof for the 2 verified Groth16 proofs?
#![no_main]
sp1_zkvm::entrypoint!(main);
use sp1_verifier::Groth16Verifier;
fn prepare_test_data_l2exec1hr() -> (Vec<u8>, Vec<u8>, String) {
// l2exec1hr proof data (formerly fib proof)
let proof: Vec<u8> = vec![
9, 6, 144, 144, 44, 97, 246, 251, 229, 151, 210, 230, 246, 193, 219, 115, 153, 19,
222, 218, 20, 110, 182, 175, 33, 180, 216, 17, 134, 54, 38, 33, 54, 218, 160, 173,
32, 224, 56, 178, 175, 163, 181, 19, 165, 247, 209, 168, 252, 221, 98, 33, 20, 213,
@sourabhniyogi
sourabhniyogi / gist:c054965807711ff7ad62ff251edded9e
Created November 22, 2024 22:53
sp1 eth proofs - compressed
# ls -l | more
total 1917316
-rw-r--r-- 1 root root 5759958 Nov 22 11:15 proof_21242835.bin
-rw-r--r-- 1 root root 4089015 Nov 22 12:56 proof_21243365.bin
-rw-r--r-- 1 root root 6787438 Nov 22 13:14 proof_21243411.bin
-rw-r--r-- 1 root root 9843806 Nov 22 13:42 proof_21243499.bin
-rw-r--r-- 1 root root 5702974 Nov 22 13:57 proof_21243639.bin
-rw-r--r-- 1 root root 6852643 Nov 22 14:32 proof_21243787.bin
-rw-r--r-- 1 root root 6017524 Nov 22 14:33 proof_21243814.bin
-rw-r--r-- 1 root root 6983264 Nov 22 14:45 proof_21243861.bin
pub @main:
jump @is_authorized
fallthrough
fallthrough
fallthrough
jump @refine
fallthrough
fallthrough
fallthrough
jump @accumulate
@sourabhniyogi
sourabhniyogi / jam-test_reconstruct_from_json.rs
Last active July 18, 2024 19:32
JAM test_reconstruct_from_json for Systematic Reed Solomon Finite-Field Erasure Codec, GF(2^16), Cantor basis 2
/*
For JAM Erasure Coding, the first actual test case everyone should use is:
https://gist.github.com/gavofyork/4cde92327cd91eff3e2ab91d316cb83a
The current version GP references Lin, Chung, Han (2016) but this will be removed in favor of:
D. G. Cantor, "On arithmetical algorithms over finite fields", Journal of Combinatorial Theory, Series A, vol. 50, no. 2, pp. 285-300, 1989.
compactly summarized as "Systematic Reed Solomon Finite-Field Erasure Codec, GF(2^16), Cantor basis 2"
The test vectors presently here
https://github.com/w3f/jamtestvectors/pull/4
have 12-byte chunks and break up data into 4096-byte pieces, which is NOT compatible with the GP.