@corpus-core/colibri-stateless 1.1.30 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,30 @@
1
1
 
2
2
 
3
- <img src="c4_logo.png" alt="C4 Logo" width="300"/>
3
+ <img src="c4_logo.png" alt="Colibri Logo" width="300"/>
4
4
 
5
- # Colibri-stateless
5
+ # Colibri Stateless — JavaScript / TypeScript
6
6
 
7
- ![ETH2.0_Spec_Version 1.4.0](https://img.shields.io/badge/ETH2.0_Spec_Version-1.4.0-2e86c1.svg)
7
+ **Verify Ethereum RPC data cryptographically — without running a full node.**
8
8
 
9
- The colibri client is a stateless and trustless ethereum client, which is optimized for the mobile apps or embedded devices, because it does not hold any state, but verifies on demand.
9
+ ![ETH2.0 Spec Version 1.4.0](https://img.shields.io/badge/ETH2.0_Spec_Version-1.4.0-2e86c1.svg)
10
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
11
+ [![npm](https://img.shields.io/npm/v/@corpus-core/colibri-stateless.svg)](https://www.npmjs.com/package/@corpus-core/colibri-stateless)
12
+
13
+ Colibri Stateless is a highly efficient prover/verifier for Ethereum (with upcoming support for Layer-2s such as OP-Stack). This package runs the C core as WebAssembly in Node.js and the browser, and implements the [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider interface — so it drops straight into ethers, web3.js, or viem while cryptographically verifying every response.
14
+
15
+ [**Website**](https://www.corpuscore.tech/colibri) · [**Docs**](https://corpus-core.gitbook.io/specification-colibri-stateless/developer-guide/bindings/javascript-typescript) · [**Whitepaper**](https://corpus-core.gitbook.io/whitepaper-colibri-stateless) · [**Privacy (PAP)**](https://corpus-core.gitbook.io/pap-colibri-stateless)
16
+
17
+ ## Why Colibri?
18
+
19
+ - **Stateless** — verification needs nothing but the proof and the sync committee it is checked against. The sync committee is cached locally so it does not have to travel with every request, but it works just as well with an empty cache or none at all. No persistent state, no block-by-block header processing, no full node.
20
+ - **Cryptographically verified RPC** — the prover creates proofs for the validity of RPC responses; the verifier checks them against BLS signatures.
21
+ - **Offline verification** — a proof is fully self-contained and can be verified without any network connection, thanks to zk-proofs for the sync committee and signed checkpoints.
22
+ - **On-demand, not always-on** — Colibri only does work when you actually make a request. It does not continuously sync in the background, so it never burns bandwidth, CPU, or battery while your app is idle.
23
+ - **Verifies historical data (older than ~27h / 8192 blocks)** — using `historical_summaries` Merkle proofs from the beacon state, Colibri cleanly verifies old transactions and receipts where other light clients simply fail.
24
+ - **`eth_getLogs` completeness proofs** — cryptographic guarantee that for a requested block range no matching event was omitted (opt-in via `logs_completeness`).
25
+ - **Fully verified local transaction simulation** — simulate a transaction against verified state *before signing*, so users can be shown exactly what a transaction will do.
26
+ - **Tiny & fast** — most requests are barely slower than a plain RPC call — see the [benchmarks](https://corpus-core.gitbook.io/specification-colibri-stateless/specifications/ethereum/benchmark).
27
+ - **Privacy-aware** — Pragmatic Adaptive Privacy (PAP) mode. See the [Privacy Whitepaper](https://corpus-core.gitbook.io/pap-colibri-stateless).
10
28
 
11
29
  ## Installation
12
30
 
@@ -143,7 +161,7 @@ Protect your dApp from NPM supply-chain attacks and transaction manipulation:
143
161
  import { BrowserProvider } from "ethers";
144
162
  import Colibri from "@corpus-core/colibri-stateless";
145
163
 
146
- // 🛡️ Secure transactions with built-in verification
164
+ // Secure transactions with built-in verification
147
165
  const client = new Colibri({
148
166
  fallback_provider: window.ethereum, // MetaMask as Signer
149
167
  verifyTransactions: true // Prevents transaction manipulation
@@ -158,7 +176,7 @@ const tx = await provider.getSigner().sendTransaction({
158
176
  gasLimit: "0x5208"
159
177
  });
160
178
 
161
- console.log("✅ Verified transaction:", tx.hash);
179
+ console.log("Verified transaction:", tx.hash);
162
180
  ```
163
181
 
164
182
  ## Building proofs in you app.
@@ -229,7 +247,7 @@ The constructor of the colibri client accepts a configuration-object, which may
229
247
  Controls how proofs are built and verified. Five modes are available:
230
248
  - `"local"` -- Proofs are built entirely on the client. Requires access to a Beacon API and execution layer RPC. Fully trustless, but slower and needs more infrastructure.
231
249
  - `"remote"` -- Proofs are fetched from a remote Colibri prover server. Fastest option but relies on the prover server for proof generation. The verifier still cryptographically checks every proof.
232
- - `"hybrid"` -- The consensus-layer proof (BlockHeaderProof) comes from the Colibri server, while execution-layer data (account proofs, storage, etc.) is fetched directly from the RPC provider. Best balance of performance and scalability -- the Colibri server only serves lightweight, cacheable header proofs while the heavy RPC load goes to your existing provider.
250
+ - `"hybrid"` -- The consensus-layer proof (BlockHeaderProof) comes from the Colibri server, while execution-layer data (account proofs, storage, etc.) is fetched directly from the RPC provider. Best balance of performance and scalability -- the Colibri server only serves lightweight, cacheable header proofs while the heavy RPC load goes to your existing provider. The delegated `eth_getBlockHeader` / `eth_getBlockByNumber` requests are sent as **cache-friendly GET requests** (`GET /proof/<method>/<block>/<version>/<zk>/<c4>`) with a `Cache-Control` freshness bound, so a CDN in front of the prover can absorb repeated requests for the same head (only ~one new block every 12s).
233
251
  - `"proxy"` -- Like remote, but the client sends its own RPC and Beacon API URLs to the prover server. The server uses these endpoints instead of its own. Useful when the client has access to private or premium RPC providers.
234
252
  - `"light_client"` -- Like hybrid, with additional background polling of block headers to keep the cache warm. Call `startLightClient()` / `stopLightClient()` to control polling. Default interval: 12000ms. By default only the compact `eth_getBlockHeader` is fetched; pass `fullBlock: true` to fetch the full block (useful when many `eth_getTransactionByHash` / `eth_getTransactionReceipt` calls follow).
235
253
  ```js
@@ -306,7 +324,11 @@ The constructor of the colibri client accepts a configuration-object, which may
306
324
  ```js
307
325
  new Colibri({ include_code: true})
308
326
  ```
309
- - `privacy_mode` - **PAP (Pragmatic Adaptive Privacy)** mode: `"none"` (default) or `"basic"`. With `"basic"`, the verifier may use cached storage for optimistic execution and verify afterwards; method type can depend on params.
327
+ - `logs_completeness` - if true, `eth_getLogs` produces (prover) and requires (verifier) a **completeness proof** over the requested block range `[fromBlock, toBlock]`. It proves that no matching log was omitted, not just that the returned logs are valid. This sets the prover flag (`1 << 12`) and the verifier flag (`1 << 9`) and requires a prover that supports it. The range end (`toBlock`) may be a pinned block hash/number or `"latest"`; `"safe"`/`"finalized"` are not supported yet. (default: false, tracks issue #128)
328
+ ```js
329
+ new Colibri({ logs_completeness: true })
330
+ ```
331
+ - `privacy_mode` - **PAP (Pragmatic Adaptive Privacy)** mode: `"none"` (default) or `"basic"`. With `"basic"`, the verifier may use cached storage for optimistic execution and verify afterwards; method type can depend on params. *This feature is still experimental!*
310
332
  ```js
311
333
  new Colibri({ privacy_mode: "basic" })
312
334
  ```
@@ -460,13 +482,12 @@ There is also a VS Code / Cursor launch configuration **"WASM Node Test (inspect
460
482
 
461
483
  ## Concept
462
484
 
463
- The idea behind C4 is to create a ultra light client or better verifier which can be used in Websites, Mobile applications, but especially in embedded systems. The Prover is a library which can used within you mobile app or in the backend to create Proof that the given data is valid. The Verifier is a library which can be used within the embedded system to verify this Proof.
485
+ The idea behind Colibri is to create an ultra-light client — or rather a verifier — that can be used in websites, mobile applications, and especially embedded systems. The prover is a library used within your app or backend to create a proof that the given data is valid. The verifier is a library used on the client (or embedded system) to verify that proof.
464
486
 
465
- The verifier itself is almost stateless and only needs to store the state of the sync committee, which changes every 27h. But with the latest sync committee the verifier is able to verify any proof with the signatures matching the previously verified public keys of the sync committee.
466
- This allows independent Verification and security on any devices without the need to process every blockheader (as light clients usually would do).
487
+ The verifier is stateless: it only needs the current sync committee (which rotates every ~27h), and that committee can be cached, fetched on demand, or delivered with the proof. With it, the verifier can validate any proof whose signatures match the verified public keys of the sync committee — enabling independent verification on any device without processing every block header (as classic light clients do).
467
488
 
468
- More Details can be found on [github](https://github.com/corpus-core/c4)
489
+ More details can be found in the [documentation](https://corpus-core.gitbook.io/specification-colibri-stateless) and on [GitHub](https://github.com/corpus-core/colibri-stateless).
469
490
 
470
491
  ## License
471
492
 
472
- MIT
493
+ MIT — see the main [repository](https://github.com/corpus-core/colibri-stateless) for details.
package/c4w.js CHANGED
@@ -5,7 +5,7 @@ var c4w = (() => {
5
5
  async function(moduleArg = {}) {
6
6
  var moduleRtn;
7
7
 
8
- var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.slice(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["s"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("c4w.wasm")}return new URL("c4w.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["r"];updateMemoryViews();removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{receiveInstance(mod,inst);resolve(mod.exports)})})}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}catch(e){readyPromiseReject(e);return Promise.reject(e)}}var ASM_CONSTS={201420:($0,$1)=>{var keyStr=UTF8ToString($0);var data=Module.storage.get(keyStr);if(data){var bufferPtr=_c4w_buffer_alloc($1,data.length);HEAPU8.set(data,bufferPtr);return 1}return 0},201608:($0,$1,$2)=>{var keyStr=UTF8ToString($0);var array=new Uint8Array($2);array.set(HEAPU8.subarray($1,$1+$2));Module.storage.set(keyStr,array)},201751:$0=>{var keyStr=UTF8ToString($0);Module.storage.del(keyStr)}};class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.unshift(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.unshift(cb);var noExitRuntime=Module["noExitRuntime"]||true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var exceptionLast=0;var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var SYSCALLS={varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;return 0}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs}var __abort_js=()=>abort("");var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var readEmAsmArgsArray=[];var readEmAsmArgs=(sigPtr,buf)=>{readEmAsmArgsArray.length=0;var ch;while(ch=HEAPU8[sigPtr++]){var wide=ch!=105;wide&=ch!=112;buf+=wide&&buf%8?4:0;readEmAsmArgsArray.push(ch==112?HEAPU32[buf>>2]:ch==106?HEAP64[buf>>3]:ch==105?HEAP32[buf>>2]:HEAPF64[buf>>3]);buf+=wide?8:4}return readEmAsmArgsArray};var runEmAsmFunction=(code,sigPtr,argbuf)=>{var args=readEmAsmArgs(sigPtr,argbuf);return ASM_CONSTS[code](...args)};var _emscripten_asm_const_int=(code,sigPtr,argbuf)=>runEmAsmFunction(code,sigPtr,argbuf);var _emscripten_date_now=()=>Date.now();var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToAscii=(str,buffer)=>{for(var i=0;i<str.length;++i){HEAP8[buffer++]=str.charCodeAt(i)}HEAP8[buffer]=0};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;getEnvStrings().forEach((string,i)=>{var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;stringToAscii(string,ptr);bufSize+=string.length+1});return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(string=>bufSize+=string.length+1);HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var _fd_close=fd=>52;var _fd_read=(fd,iov,iovcnt,pnum)=>52;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var wasmImports={a:___assert_fail,b:___cxa_throw,f:___syscall_fcntl64,j:___syscall_ioctl,k:___syscall_openat,m:__abort_js,l:__tzset_js,d:_emscripten_asm_const_int,g:_emscripten_date_now,n:_emscripten_resize_heap,p:_environ_get,q:_environ_sizes_get,c:_exit,h:_fd_close,i:_fd_read,o:_fd_seek,e:_fd_write};var wasmExports=await createWasm();var ___wasm_call_ctors=wasmExports["s"];var _c4w_create_proof_ctx=Module["_c4w_create_proof_ctx"]=wasmExports["t"];var _c4w_free_proof_ctx=Module["_c4w_free_proof_ctx"]=wasmExports["u"];var _c4w_execute_proof_ctx=Module["_c4w_execute_proof_ctx"]=wasmExports["v"];var _c4w_req_set_response=Module["_c4w_req_set_response"]=wasmExports["w"];var _c4w_req_set_error=Module["_c4w_req_set_error"]=wasmExports["x"];var _c4w_create_verify_ctx=Module["_c4w_create_verify_ctx"]=wasmExports["y"];var _c4w_free_verify_ctx=Module["_c4w_free_verify_ctx"]=wasmExports["z"];var _free=Module["_free"]=wasmExports["A"];var _c4w_verify_proof=Module["_c4w_verify_proof"]=wasmExports["B"];var _c4w_get_method_type=Module["_c4w_get_method_type"]=wasmExports["C"];var _c4w_create_rpc_ctx=Module["_c4w_create_rpc_ctx"]=wasmExports["D"];var _c4w_execute_rpc_ctx=Module["_c4w_execute_rpc_ctx"]=wasmExports["E"];var _c4w_free_rpc_ctx=Module["_c4w_free_rpc_ctx"]=wasmExports["F"];var _c4w_set_checkpoint=Module["_c4w_set_checkpoint"]=wasmExports["G"];var _c4w_rpc_ctx_set_witness_keys=Module["_c4w_rpc_ctx_set_witness_keys"]=wasmExports["H"];var _c4w_rpc_ctx_set_proxy_urls=Module["_c4w_rpc_ctx_set_proxy_urls"]=wasmExports["I"];var _c4w_rpc_ctx_set_min_latest_block_ts=Module["_c4w_rpc_ctx_set_min_latest_block_ts"]=wasmExports["J"];var _c4w_decode_proof=Module["_c4w_decode_proof"]=wasmExports["K"];var _c4w_req_free=Module["_c4w_req_free"]=wasmExports["L"];var _c4w_buffer_alloc=Module["_c4w_buffer_alloc"]=wasmExports["M"];var _init_storage=Module["_init_storage"]=wasmExports["N"];var _c4w_get_current_version_number=Module["_c4w_get_current_version_number"]=wasmExports["O"];var _malloc=Module["_malloc"]=wasmExports["Q"];var __emscripten_stack_restore=wasmExports["R"];var __emscripten_stack_alloc=wasmExports["S"];var _emscripten_stack_get_current=wasmExports["T"];Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise;
8
+ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.slice(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["s"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("c4w.wasm")}return new URL("c4w.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["r"];updateMemoryViews();removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(mod,inst)=>{receiveInstance(mod,inst);resolve(mod.exports)})})}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}catch(e){readyPromiseReject(e);return Promise.reject(e)}}var ASM_CONSTS={204348:($0,$1)=>{var keyStr=UTF8ToString($0);var data=Module.storage.get(keyStr);if(data){var bufferPtr=_c4w_buffer_alloc($1,data.length);HEAPU8.set(data,bufferPtr);return 1}return 0},204536:($0,$1,$2)=>{var keyStr=UTF8ToString($0);var array=new Uint8Array($2);array.set(HEAPU8.subarray($1,$1+$2));Module.storage.set(keyStr,array)},204679:$0=>{var keyStr=UTF8ToString($0);Module.storage.del(keyStr)}};class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.unshift(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.unshift(cb);var noExitRuntime=Module["noExitRuntime"]||true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var exceptionLast=0;var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var SYSCALLS={varargs:undefined,getStr(ptr){var ret=UTF8ToString(ptr);return ret}};function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___syscall_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;return 0}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs}var __abort_js=()=>abort("");var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var readEmAsmArgsArray=[];var readEmAsmArgs=(sigPtr,buf)=>{readEmAsmArgsArray.length=0;var ch;while(ch=HEAPU8[sigPtr++]){var wide=ch!=105;wide&=ch!=112;buf+=wide&&buf%8?4:0;readEmAsmArgsArray.push(ch==112?HEAPU32[buf>>2]:ch==106?HEAP64[buf>>3]:ch==105?HEAP32[buf>>2]:HEAPF64[buf>>3]);buf+=wide?8:4}return readEmAsmArgsArray};var runEmAsmFunction=(code,sigPtr,argbuf)=>{var args=readEmAsmArgs(sigPtr,argbuf);return ASM_CONSTS[code](...args)};var _emscripten_asm_const_int=(code,sigPtr,argbuf)=>runEmAsmFunction(code,sigPtr,argbuf);var _emscripten_date_now=()=>Date.now();var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToAscii=(str,buffer)=>{for(var i=0;i<str.length;++i){HEAP8[buffer++]=str.charCodeAt(i)}HEAP8[buffer]=0};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;getEnvStrings().forEach((string,i)=>{var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;stringToAscii(string,ptr);bufSize+=string.length+1});return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(string=>bufSize+=string.length+1);HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var _fd_close=fd=>52;var _fd_read=(fd,iov,iovcnt,pnum)=>52;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var wasmImports={a:___assert_fail,b:___cxa_throw,f:___syscall_fcntl64,j:___syscall_ioctl,k:___syscall_openat,m:__abort_js,l:__tzset_js,d:_emscripten_asm_const_int,g:_emscripten_date_now,n:_emscripten_resize_heap,p:_environ_get,q:_environ_sizes_get,c:_exit,h:_fd_close,i:_fd_read,o:_fd_seek,e:_fd_write};var wasmExports=await createWasm();var ___wasm_call_ctors=wasmExports["s"];var _c4w_create_proof_ctx=Module["_c4w_create_proof_ctx"]=wasmExports["t"];var _c4w_free_proof_ctx=Module["_c4w_free_proof_ctx"]=wasmExports["u"];var _c4w_execute_proof_ctx=Module["_c4w_execute_proof_ctx"]=wasmExports["v"];var _c4w_req_set_response=Module["_c4w_req_set_response"]=wasmExports["w"];var _c4w_req_set_error=Module["_c4w_req_set_error"]=wasmExports["x"];var _c4w_create_verify_ctx=Module["_c4w_create_verify_ctx"]=wasmExports["y"];var _c4w_free_verify_ctx=Module["_c4w_free_verify_ctx"]=wasmExports["z"];var _free=Module["_free"]=wasmExports["A"];var _c4w_verify_proof=Module["_c4w_verify_proof"]=wasmExports["B"];var _c4w_get_method_type=Module["_c4w_get_method_type"]=wasmExports["C"];var _c4w_create_rpc_ctx=Module["_c4w_create_rpc_ctx"]=wasmExports["D"];var _c4w_execute_rpc_ctx=Module["_c4w_execute_rpc_ctx"]=wasmExports["E"];var _c4w_free_rpc_ctx=Module["_c4w_free_rpc_ctx"]=wasmExports["F"];var _c4w_set_checkpoint=Module["_c4w_set_checkpoint"]=wasmExports["G"];var _c4w_rpc_ctx_set_witness_keys=Module["_c4w_rpc_ctx_set_witness_keys"]=wasmExports["H"];var _c4w_rpc_ctx_set_proxy_urls=Module["_c4w_rpc_ctx_set_proxy_urls"]=wasmExports["I"];var _c4w_rpc_ctx_set_min_latest_block_ts=Module["_c4w_rpc_ctx_set_min_latest_block_ts"]=wasmExports["J"];var _c4w_decode_proof=Module["_c4w_decode_proof"]=wasmExports["K"];var _c4w_req_free=Module["_c4w_req_free"]=wasmExports["L"];var _c4w_buffer_alloc=Module["_c4w_buffer_alloc"]=wasmExports["M"];var _init_storage=Module["_init_storage"]=wasmExports["N"];var _c4w_get_current_version_number=Module["_c4w_get_current_version_number"]=wasmExports["O"];var _malloc=Module["_malloc"]=wasmExports["Q"];var __emscripten_stack_restore=wasmExports["R"];var __emscripten_stack_alloc=wasmExports["S"];var _emscripten_stack_get_current=wasmExports["T"];Module["ccall"]=ccall;Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;function run(){if(runDependencies>0){dependenciesFulfilled=run;return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise;
9
9
 
10
10
 
11
11
  return moduleRtn;
package/c4w.wasm CHANGED
Binary file
package/chains.js CHANGED
@@ -23,44 +23,78 @@
23
23
  export const default_config = {
24
24
  '1': {
25
25
  alias: ["mainnet", "eth", "0x1"],
26
- rpcs: ["https://mainnet1.colibri-proof.tech/execution"],
27
- beacon_apis: ["https://mainnet1.colibri-proof.tech/consensus/"],
28
- prover: ["https://mainnet1.colibri-proof.tech"],
26
+ rpcs: [
27
+ "https://mainnet.colibri-proof.tech/execution",
28
+ "https://eth.drpc.org",
29
+ "https://ethereum-rpc.publicnode.com",
30
+ "https://singapore.rpc.blxrbdn.com",
31
+ ],
32
+ beacon_apis: [
33
+ "https://mainnet.colibri-proof.tech/consensus",
34
+ "https://gateway.tenderly.co/public/mainnet",
35
+ "https://ethereum-beacon-api.publicnode.com",
36
+ ],
37
+ prover: ["https://mainnet.colibri-proof.tech", "https://mainnet-prover.incubed.net", "https://mainnet.colimind.com"],
29
38
  checkpointz: [
30
39
  "https://sync-mainnet.beaconcha.in",
31
- "https://beaconstate.info",
32
- "https://sync.invis.tools",
40
+ "https://mainnet.checkpoint.sigp.io",
41
+ "https://mainnet-checkpoint-sync.attestant.io",
42
+ "https://beaconstate-mainnet.chainsafe.io",
43
+ "https://mainnet-checkpoint-sync.stakely.io",
44
+ "https://checkpointz.pietjepuk.net",
33
45
  "https://beaconstate.ethstaker.cc",
34
46
  ],
35
47
  pollingInterval: 12000,
36
48
  },
37
49
  '11155111': {
38
50
  alias: ["sepolia", "0xaa36a7"],
39
- beacon_apis: ["https://ethereum-sepolia-beacon-api.publicnode.com"],
40
- rpcs: ["https://ethereum-sepolia-rpc.publicnode.com"],
41
- prover: ["https://sepolia.colibri-proof.tech"],
51
+ rpcs: [
52
+ "https://sepolia.colibri-proof.tech/execution",
53
+ "https://sepolia.drpc.org",
54
+ "https://ethereum-sepolia-rpc.publicnode.com",
55
+ "https://sepolia.gateway.tenderly.co",
56
+ ],
57
+ beacon_apis: [
58
+ "https://sepolia.colibri-proof.tech/consensus",
59
+ "https://ethereum-sepolia-beacon-api.publicnode.com",
60
+ ],
61
+ prover: ["https://sepolia.colibri-proof.tech", "https://sepolia-prover.incubed.net", "https://sepolia.colimind.com"],
42
62
  checkpointz: [
43
- "https://sepolia.beaconstate.info",
44
63
  "https://checkpoint-sync.sepolia.ethpandaops.io",
64
+ "https://beaconstate-sepolia.chainsafe.io",
45
65
  ],
46
66
  pollingInterval: 12000,
47
67
  },
48
68
  '100': {
49
69
  alias: ["gnosis", "xdai", "0x64"],
50
- beacon_apis: ["https://gnosis.colibri-proof.tech"],
51
- rpcs: ["https://rpc.ankr.com/gnosis"],
52
- prover: ["https://gnosis.colibri-proof.tech"],
70
+ rpcs: [
71
+ "https://gnosis.colibri-proof.tech/execution",
72
+ "https://rpc.gnosischain.com",
73
+ "https://rpc.gnosis.gateway.fm",
74
+ "https://gnosis-rpc.publicnode.com",
75
+ ],
76
+ beacon_apis: [
77
+ "https://gnosis.colibri-proof.tech/consensus",
78
+ "https://rpc-gbc.gnosischain.com",
79
+ "https://gnosis-beacon-api.publicnode.com",
80
+ ],
81
+ prover: ["https://gnosis.colibri-proof.tech", "https://gnosis-prover.incubed.net", "https://gnosis.colimind.com"],
53
82
  checkpointz: ["https://checkpoint.gnosischain.com"],
54
83
  pollingInterval: 5000,
55
84
  },
56
85
  '10200': {
57
86
  alias: ["chiado", "0x27d8"],
58
- beacon_apis: ["https://chiado.colibri-proof.tech/consensus/"],
59
- rpcs: ["https://gnosis-chiado-rpc.publicnode.com"],
87
+ rpcs: [
88
+ "https://rpc.chiado.gnosis.gateway.fm",
89
+ "https://rpc.chiadochain.net",
90
+ "https://gnosis-chiado-rpc.publicnode.com",
91
+ ],
92
+ beacon_apis: [
93
+ "https://rpc-gbc.chiadochain.net",
94
+ ],
60
95
  prover: ["https://chiado.colibri-proof.tech"],
61
96
  checkpointz: [
62
97
  "https://checkpoint.chiadochain.net",
63
- "https://chiado.colibri-proof.tech/consensus/",
64
98
  ],
65
99
  pollingInterval: 5000,
66
100
  },
package/cjs/chains.js CHANGED
@@ -28,44 +28,78 @@ exports.chain_conf = chain_conf;
28
28
  exports.default_config = {
29
29
  '1': {
30
30
  alias: ["mainnet", "eth", "0x1"],
31
- rpcs: ["https://mainnet1.colibri-proof.tech/execution"],
32
- beacon_apis: ["https://mainnet1.colibri-proof.tech/consensus/"],
33
- prover: ["https://mainnet1.colibri-proof.tech"],
31
+ rpcs: [
32
+ "https://mainnet.colibri-proof.tech/execution",
33
+ "https://eth.drpc.org",
34
+ "https://ethereum-rpc.publicnode.com",
35
+ "https://singapore.rpc.blxrbdn.com",
36
+ ],
37
+ beacon_apis: [
38
+ "https://mainnet.colibri-proof.tech/consensus",
39
+ "https://gateway.tenderly.co/public/mainnet",
40
+ "https://ethereum-beacon-api.publicnode.com",
41
+ ],
42
+ prover: ["https://mainnet.colibri-proof.tech", "https://mainnet-prover.incubed.net", "https://mainnet.colimind.com"],
34
43
  checkpointz: [
35
44
  "https://sync-mainnet.beaconcha.in",
36
- "https://beaconstate.info",
37
- "https://sync.invis.tools",
45
+ "https://mainnet.checkpoint.sigp.io",
46
+ "https://mainnet-checkpoint-sync.attestant.io",
47
+ "https://beaconstate-mainnet.chainsafe.io",
48
+ "https://mainnet-checkpoint-sync.stakely.io",
49
+ "https://checkpointz.pietjepuk.net",
38
50
  "https://beaconstate.ethstaker.cc",
39
51
  ],
40
52
  pollingInterval: 12000,
41
53
  },
42
54
  '11155111': {
43
55
  alias: ["sepolia", "0xaa36a7"],
44
- beacon_apis: ["https://ethereum-sepolia-beacon-api.publicnode.com"],
45
- rpcs: ["https://ethereum-sepolia-rpc.publicnode.com"],
46
- prover: ["https://sepolia.colibri-proof.tech"],
56
+ rpcs: [
57
+ "https://sepolia.colibri-proof.tech/execution",
58
+ "https://sepolia.drpc.org",
59
+ "https://ethereum-sepolia-rpc.publicnode.com",
60
+ "https://sepolia.gateway.tenderly.co",
61
+ ],
62
+ beacon_apis: [
63
+ "https://sepolia.colibri-proof.tech/consensus",
64
+ "https://ethereum-sepolia-beacon-api.publicnode.com",
65
+ ],
66
+ prover: ["https://sepolia.colibri-proof.tech", "https://sepolia-prover.incubed.net", "https://sepolia.colimind.com"],
47
67
  checkpointz: [
48
- "https://sepolia.beaconstate.info",
49
68
  "https://checkpoint-sync.sepolia.ethpandaops.io",
69
+ "https://beaconstate-sepolia.chainsafe.io",
50
70
  ],
51
71
  pollingInterval: 12000,
52
72
  },
53
73
  '100': {
54
74
  alias: ["gnosis", "xdai", "0x64"],
55
- beacon_apis: ["https://gnosis.colibri-proof.tech"],
56
- rpcs: ["https://rpc.ankr.com/gnosis"],
57
- prover: ["https://gnosis.colibri-proof.tech"],
75
+ rpcs: [
76
+ "https://gnosis.colibri-proof.tech/execution",
77
+ "https://rpc.gnosischain.com",
78
+ "https://rpc.gnosis.gateway.fm",
79
+ "https://gnosis-rpc.publicnode.com",
80
+ ],
81
+ beacon_apis: [
82
+ "https://gnosis.colibri-proof.tech/consensus",
83
+ "https://rpc-gbc.gnosischain.com",
84
+ "https://gnosis-beacon-api.publicnode.com",
85
+ ],
86
+ prover: ["https://gnosis.colibri-proof.tech", "https://gnosis-prover.incubed.net", "https://gnosis.colimind.com"],
58
87
  checkpointz: ["https://checkpoint.gnosischain.com"],
59
88
  pollingInterval: 5000,
60
89
  },
61
90
  '10200': {
62
91
  alias: ["chiado", "0x27d8"],
63
- beacon_apis: ["https://chiado.colibri-proof.tech/consensus/"],
64
- rpcs: ["https://gnosis-chiado-rpc.publicnode.com"],
92
+ rpcs: [
93
+ "https://rpc.chiado.gnosis.gateway.fm",
94
+ "https://rpc.chiadochain.net",
95
+ "https://gnosis-chiado-rpc.publicnode.com",
96
+ ],
97
+ beacon_apis: [
98
+ "https://rpc-gbc.chiadochain.net",
99
+ ],
65
100
  prover: ["https://chiado.colibri-proof.tech"],
66
101
  checkpointz: [
67
102
  "https://checkpoint.chiadochain.net",
68
- "https://chiado.colibri-proof.tech/consensus/",
69
103
  ],
70
104
  pollingInterval: 5000,
71
105
  },
package/cjs/http.js CHANGED
@@ -44,9 +44,23 @@ function joinPath(base, path) {
44
44
  * @param excludeMask Bitmask to skip servers by index
45
45
  * @return Uint8Array of response bytes and nodeIndex used
46
46
  */
47
- async function fetch_from_servers(servers, path, method, payload, accept = 'json', excludeMask = 0, fetchFn = globalThis.fetch) {
47
+ async function fetch_from_servers(servers, path, method, payload, accept = 'json', excludeMask = 0, fetchFn = globalThis.fetch, maxAge) {
48
48
  let lastError = 'All nodes failed';
49
49
  let nodeIndex = 0;
50
+ // Normalize the method: the C layer emits lowercase ("get"/"post"); fetch expects an
51
+ // uppercase token for standard methods.
52
+ const httpMethod = String(method).toUpperCase();
53
+ const headers = {
54
+ 'Accept': accept === 'json' ? 'application/json' : 'application/octet-stream',
55
+ };
56
+ // Content-Type only describes the request body, so it is only relevant when we actually send a
57
+ // payload (POST). Cache-friendly GET requests (e.g. hybrid block proofs) carry no body.
58
+ if (payload)
59
+ headers['Content-Type'] = 'application/json';
60
+ // Freshness bound for shared caches/CDNs: never accept a response older than `maxAge` seconds
61
+ // (used for `latest` block proofs so a CDN cannot serve a stale head).
62
+ if (maxAge && maxAge > 0)
63
+ headers['Cache-Control'] = `max-age=${Math.floor(maxAge)}`;
50
64
  for (const server of servers) {
51
65
  if (excludeMask & (1 << nodeIndex)) {
52
66
  nodeIndex++;
@@ -54,12 +68,9 @@ async function fetch_from_servers(servers, path, method, payload, accept = 'json
54
68
  }
55
69
  try {
56
70
  const response = await fetchFn(joinPath(server, path), {
57
- method,
71
+ method: httpMethod,
58
72
  body: payload ? JSON.stringify(payload) : undefined,
59
- headers: {
60
- 'Content-Type': 'application/json',
61
- 'Accept': accept === 'json' ? 'application/json' : 'application/octet-stream',
62
- },
73
+ headers,
63
74
  });
64
75
  if (!response.ok) {
65
76
  lastError = `HTTP error! Status: ${response.status}, Details: ${await response.text()}`;
@@ -198,7 +209,7 @@ async function handle_request(req, conf) {
198
209
  try {
199
210
  const accept = req.encoding == 'json' ? 'json' : 'octet';
200
211
  const fetchFn = conf.fetch || globalThis.fetch;
201
- const { data, nodeIndex } = await fetch_from_servers(servers, req.url || '', req.method, req.payload, accept, req.exclude_mask, fetchFn);
212
+ const { data, nodeIndex } = await fetch_from_servers(servers, req.url || '', req.method, req.payload, accept, req.exclude_mask, fetchFn, req.ttl);
202
213
  c4w._c4w_req_set_response(req.req_ptr, (0, wasm_js_1.copy_to_c)(data, c4w), data.length, nodeIndex);
203
214
  if (conf.onTransfer)
204
215
  conf.onTransfer(data.length, req);
package/cjs/index.js CHANGED
@@ -94,6 +94,10 @@ class C4Client {
94
94
  this.verify_flags |= (1 << 6);
95
95
  if (this.config.skip_wsp_check)
96
96
  this.verify_flags |= (1 << 7);
97
+ if (this.config.logs_completeness) {
98
+ this.flags |= (1 << 12);
99
+ this.verify_flags |= (1 << 9);
100
+ }
97
101
  if (!this.config.warningHandler)
98
102
  this.config.warningHandler = async (req, message) => console.warn(message);
99
103
  if (!this.config.proofStrategy)
@@ -258,6 +262,11 @@ class C4Client {
258
262
  case "revert":
259
263
  throwRevert(state.data);
260
264
  case "error":
265
+ if (state.error.includes("zk sync proof") && this.config.zk_proof) {
266
+ // try without zk proof
267
+ this.config.zk_proof = false;
268
+ return await this.rpc(method, args, method_type);
269
+ }
261
270
  throw new Error(state.error);
262
271
  case "pending":
263
272
  await Promise.all(state.requests.map((req) => (0, http_js_1.handle_request)(req, this.config)));
package/http.d.ts CHANGED
@@ -9,7 +9,7 @@ export type AcceptKind = 'json' | 'octet';
9
9
  * @param excludeMask Bitmask to skip servers by index
10
10
  * @return Uint8Array of response bytes and nodeIndex used
11
11
  */
12
- export declare function fetch_from_servers(servers: string[], path: string, method: 'GET' | 'POST', payload?: any, accept?: AcceptKind, excludeMask?: number, fetchFn?: typeof globalThis.fetch): Promise<{
12
+ export declare function fetch_from_servers(servers: string[], path: string, method: 'GET' | 'POST', payload?: any, accept?: AcceptKind, excludeMask?: number, fetchFn?: typeof globalThis.fetch, maxAge?: number): Promise<{
13
13
  data: Uint8Array;
14
14
  nodeIndex: number;
15
15
  }>;
package/http.js CHANGED
@@ -39,9 +39,23 @@ function joinPath(base, path) {
39
39
  * @param excludeMask Bitmask to skip servers by index
40
40
  * @return Uint8Array of response bytes and nodeIndex used
41
41
  */
42
- export async function fetch_from_servers(servers, path, method, payload, accept = 'json', excludeMask = 0, fetchFn = globalThis.fetch) {
42
+ export async function fetch_from_servers(servers, path, method, payload, accept = 'json', excludeMask = 0, fetchFn = globalThis.fetch, maxAge) {
43
43
  let lastError = 'All nodes failed';
44
44
  let nodeIndex = 0;
45
+ // Normalize the method: the C layer emits lowercase ("get"/"post"); fetch expects an
46
+ // uppercase token for standard methods.
47
+ const httpMethod = String(method).toUpperCase();
48
+ const headers = {
49
+ 'Accept': accept === 'json' ? 'application/json' : 'application/octet-stream',
50
+ };
51
+ // Content-Type only describes the request body, so it is only relevant when we actually send a
52
+ // payload (POST). Cache-friendly GET requests (e.g. hybrid block proofs) carry no body.
53
+ if (payload)
54
+ headers['Content-Type'] = 'application/json';
55
+ // Freshness bound for shared caches/CDNs: never accept a response older than `maxAge` seconds
56
+ // (used for `latest` block proofs so a CDN cannot serve a stale head).
57
+ if (maxAge && maxAge > 0)
58
+ headers['Cache-Control'] = `max-age=${Math.floor(maxAge)}`;
45
59
  for (const server of servers) {
46
60
  if (excludeMask & (1 << nodeIndex)) {
47
61
  nodeIndex++;
@@ -49,12 +63,9 @@ export async function fetch_from_servers(servers, path, method, payload, accept
49
63
  }
50
64
  try {
51
65
  const response = await fetchFn(joinPath(server, path), {
52
- method,
66
+ method: httpMethod,
53
67
  body: payload ? JSON.stringify(payload) : undefined,
54
- headers: {
55
- 'Content-Type': 'application/json',
56
- 'Accept': accept === 'json' ? 'application/json' : 'application/octet-stream',
57
- },
68
+ headers,
58
69
  });
59
70
  if (!response.ok) {
60
71
  lastError = `HTTP error! Status: ${response.status}, Details: ${await response.text()}`;
@@ -193,7 +204,7 @@ export async function handle_request(req, conf) {
193
204
  try {
194
205
  const accept = req.encoding == 'json' ? 'json' : 'octet';
195
206
  const fetchFn = conf.fetch || globalThis.fetch;
196
- const { data, nodeIndex } = await fetch_from_servers(servers, req.url || '', req.method, req.payload, accept, req.exclude_mask, fetchFn);
207
+ const { data, nodeIndex } = await fetch_from_servers(servers, req.url || '', req.method, req.payload, accept, req.exclude_mask, fetchFn, req.ttl);
197
208
  c4w._c4w_req_set_response(req.req_ptr, copy_to_c(data, c4w), data.length, nodeIndex);
198
209
  if (conf.onTransfer)
199
210
  conf.onTransfer(data.length, req);
package/index.js CHANGED
@@ -87,6 +87,10 @@ class C4Client {
87
87
  this.verify_flags |= (1 << 6);
88
88
  if (this.config.skip_wsp_check)
89
89
  this.verify_flags |= (1 << 7);
90
+ if (this.config.logs_completeness) {
91
+ this.flags |= (1 << 12);
92
+ this.verify_flags |= (1 << 9);
93
+ }
90
94
  if (!this.config.warningHandler)
91
95
  this.config.warningHandler = async (req, message) => console.warn(message);
92
96
  if (!this.config.proofStrategy)
@@ -251,6 +255,11 @@ class C4Client {
251
255
  case "revert":
252
256
  throwRevert(state.data);
253
257
  case "error":
258
+ if (state.error.includes("zk sync proof") && this.config.zk_proof) {
259
+ // try without zk proof
260
+ this.config.zk_proof = false;
261
+ return await this.rpc(method, args, method_type);
262
+ }
254
263
  throw new Error(state.error);
255
264
  case "pending":
256
265
  await Promise.all(state.requests.map((req) => handle_request(req, this.config)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corpus-core/colibri-stateless",
3
- "version": "1.1.30",
3
+ "version": "2.0.1",
4
4
  "description": "Colibri is a stateless and trustless ethereum client, which is optimized for the mobile apps or embedded devices, because it does not hols the state, but verifies on demand.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/types.d.ts CHANGED
@@ -81,6 +81,12 @@ export interface Config extends ChainConfig {
81
81
  /** Pragmatic Adaptive Privacy mode. Default "none". "basic" sets verify flag for PAP. */
82
82
  privacy_mode?: PrivacyMode;
83
83
  zk_proof?: boolean;
84
+ /**
85
+ * If true, `eth_getLogs` requests produce and require a completeness proof over the
86
+ * requested block range: the proof guarantees that no matching log was omitted.
87
+ * Sets the prover flag (`1 << 12`) and the verify flag (`1 << 9`). Default: false.
88
+ */
89
+ logs_completeness?: boolean;
84
90
  /** Proof generation mode. Default: "remote" if prover URLs configured, otherwise "local". */
85
91
  prover_mode?: ProverMode;
86
92
  /**
@@ -123,6 +129,8 @@ export interface DataRequest {
123
129
  req_ptr: number;
124
130
  /** Milliseconds to wait before (re-)executing this request (e.g. oblivious-node retry backoff). Optional. */
125
131
  delay?: number;
132
+ /** Cache freshness bound in seconds. When set, forwarded as a `Cache-Control: max-age=<ttl>` request header so a shared cache/CDN never returns a response older than this bound (e.g. short bound for `latest` block proofs). Optional. */
133
+ ttl?: number;
126
134
  }
127
135
  export declare enum MethodType {
128
136
  PROOFABLE = 1,