ora-io / cle-cli Goto Github PK
View Code? Open in Web Editor NEWCLI for Building Your CLE.
Home Page: https://docs.ora.io/doc/cle
CLI for Building Your CLE.
Home Page: https://docs.ora.io/doc/cle
I encountered an issue while trying to create a new CLE project using Yarn. Following the instructions provided in the documentation, I attempted to create a project using the following command:
yarn create cle@latest
However, the command failed to complete successfully. I received the following error message:
error An unexpected error occurred: "https://registry.yarnpkg.com/create-ora: Not found".
Interestingly, when I attempted the same process using NPM with the command:
npm create cle@latest
the project creation succeeded without any issues.
unexpected events.length == 0 when event.data too huge
npm init zkgraph@latest
import { UserConfig } from "@hyperoracle/zkgraph-cli";
export default {
UserPrivateKey:
"YOUR_PRIVATE_KEY",
PinataJWT: "",
ZkwasmProviderUrl: "https://rpc.zkwasmhub.com:8090",
CompilerServerEndpoint: "http://compiler.dev.hyperoracle.io/compile",
} as UserConfig;
src/mapping.ts
into below code://@ts-ignore
import { Bytes, Block } from "@hyperoracle/zkgraph-lib";
export function handleBlocks(blocks: Block[]): Bytes {
const events = blocks[0].events;
console.log(events.length.toString());
return Bytes.fromUTF8("Hello zkGraph!");
}
src/zkgraph.yaml
into following code:specVersion: 0.0.2
apiVersion: 0.0.2
name: eg_hello
description: "This demo zkGraph always set a ascii string as the output state. "
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: mainnet
event:
- address: '0xa0e22e94433779c859dddeeaf8c6f15b16b662f4'
events:
- '0x665fba0baf3dc33e9943340197893ac16f56482c2defb8de60f944987fee451c'
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
npm run compile && npm run exec -- 18137200
Some templates need to be updated with the new version and breaking changes of zkgraph-lib 1.0.1
.
More specifically, uniswapprice template needs to be updated because fromBytesBigEndian
is now fromBytes
.
Also need to check if every template works for every new releases. Probably need a github action for that.
zkgraph cannot parse event which blocks[0].events.length is greater than 21.
macos version: Monterey 12.6
zkgraph-lib version: ^0.0.9-alpha.6 ( bug also exist in v1.0.0 )
nodejs version: v20.9.0
reproduce as follow steps:
npm init zkgraph@alpha
//@ts-ignore
import { Bytes, Block, Address } from "@hyperoracle/zkgraph-lib";
import { A } from "./a";
export function handleBlocks(blocks: Block[]): Bytes {
const events = blocks[0].events;
for(let i = 0; i < events.length; i++) {
console.log("try to retrieve topic1 of event " + i.toString() + ": " + events[i].topic1.toHexString());
const transfer = new A(events[i]);
console.log("parse event " + i.toString() + " done. transfer event address: " + transfer.token.toHexString());
}
return Bytes.fromI32(1);
}
// @ts-ignore
import { Event, BigInt, Address } from "@hyperoracle/zkgraph-lib";
export class A {
public token: Address;
constructor(event: Event) {
this.token = Address.fromBytes(event.topic1.slice(12,32));
}
}
specVersion: 0.0.2
apiVersion: 0.0.2
name: zkToken
description: "zkToken"
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: mainnet
event:
- address: '0xc00e94cb662c3520282e6f5717214004a7f26888'
events:
- "Transfer(address,address,uint256)"
- address: '0x0000000000085d4780B73119b644AE5ecd22b376'
events:
- "Transfer(address,address,uint256)"
- address: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9'
events:
- "Transfer(address,address,uint256)"
- address: '0x956F47F50A910163D8BF957Cf5846D573E7f87CA'
events:
- "Transfer(address,address,uint256)"
- address: '0x1985365e9f78359a9B6AD760e32412f4a445E862'
events:
- "Transfer(address,address,uint256)"
- address: '0xE41d2489571d322189246DaFA5ebDe1F4699F498'
events:
- "Transfer(address,address,uint256)"
- address: '0x6B3595068778DD592e39A122f4f5a5cF09C90fE2'
events:
- "Transfer(address,address,uint256)"
- address: '0x8E870D67F660D95d5be530380D0eC0bd388289E1'
events:
- "Transfer(address,address,uint256)"
- address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
events:
- "Transfer(address,address,uint256)"
- address: '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359'
events:
- "Transfer(address,address,uint256)"
- address: '0x514910771AF9Ca656af840dff83E8264EcF986CA'
events:
- "Transfer(address,address,uint256)"
- address: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e'
events:
- "Transfer(address,address,uint256)"
- address: '0x0D8775F648430679A709E98d2b0Cb6250d2887EF'
events:
- "Transfer(address,address,uint256)"
- address: '0x6B175474E89094C44Da98b954EedeAC495271d0F'
events:
- "Transfer(address,address,uint256)"
- address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
events:
- "Transfer(address,address,uint256)"
- address: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
events:
- "Transfer(address,address,uint256)"
- address: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'
events:
- "Transfer(address,address,uint256)"
- address: '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2'
events:
- "Transfer(address,address,uint256)"
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
npm run compile && npm run exec -- 18734585
finally, we will meet a panic like this:
...
parse event 20 done. transfer event address: 0xf89d7b9c864f589bbf53a82105107622b35eaa40
try to retrieve topic1 of event 21: 0x300030003000300030003000300030003000300000000000000000001c000000
parse event 21 done. transfer event address: 0x300030003000300000000000000000001c000000
try to retrieve topic1 of event 22: 0x
wasm://wasm/51eb6a3a:1
RuntimeError: unreachable
at wasm://wasm/51eb6a3a:wasm-function[17]:0x12d7
at wasm://wasm/51eb6a3a:wasm-function[29]:0x26f9
at asmain (/Users/licongfei/Documents/events22/node_modules/@hyperoracle/zkgraph-api/dist/index.cjs:2194:21)
at executeOnInputs (/Users/licongfei/Documents/events22/node_modules/@hyperoracle/zkgraph-api/dist/index.cjs:2324:16)
at async executeOnDataPrep (/Users/licongfei/Documents/events22/node_modules/@hyperoracle/zkgraph-api/dist/index.cjs:2309:10)
at async Object.execute (/Users/licongfei/Documents/events22/node_modules/@hyperoracle/zkgraph-api/dist/index.cjs:2301:10)
at async exec (/Users/licongfei/Documents/events22/node_modules/@hyperoracle/zkgraph-cli/dist/index.cjs:538:17)
Node.js v20.9.0
When the developer does not have enough sepoliaEth to initiate a prove request transaction, the error message is too verbose. Can we catch this error to make it more user-friendly?
zkgraph-api: v1.0.3
zkgraph-cli: v1.0.0
zkgraph-lib: v1.0.1
npm run prove
When slot.Key is equal to 0, the prove will fail.
http://compiler.hyperoracle.io/compile
specVersion: 0.0.2
apiVersion: 0.0.2
name: eg_storage
description: "This demo zkGraph shows 2 ways to access a slot value."
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: mainnet
storage:
- address: '0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8'
slots:
- 1
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
//@ts-ignore
import { Bytes, Account, Block, BigInt } from "@hyperoracle/zkgraph-lib";
let addr = Bytes.fromHexString("0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8");
export function handleBlocks(blocks: Block[]): Bytes {
let acct: Account = blocks[0].account(addr);
return Bytes.fromHexString("1");
}
npm run compile && npm run setup && npm run prove -- 18882868 01 --prove
It seems that the state prove has failed.
http://compiler.dev.hyperoracle.io/compile
npm run compile && npm run setup
npm run prove -- 4971020 6370902000000003336530047e5ec3da40c000000000068f1888e6eb7036fffe --prove
When the state proves that the block is too old, the execution will fail. The error message when it fails can be optimized to be more user-friendly.
npm run compile && npm run exec -- 11882969
When the input is too large, prove --test cannot simulate the proving process.
git clone https://github.com/LiRiu/zkEthscription.git
cd zkEthscription && npm install
cp zkgraph.config.example.js zkgraph.config.js && vim zkgraph.config.js
npm run prove -- 4940316 00bc614e646174613a696d6167652f6a7065673b6261736536342c2f396a2f34414151536b5a4a5267414241514141415141424141442f327745454541424441454d4151774244414563415177424c41464d415577424c414767416341426b41484141614143614149304167514342414930416d674470414b59417377436d414c4d41706744704157494133414543414e774133414543414e774259674534415873424e4145664154514265774534416a4942755147484159634275514979416f6b43495149454169454369514d534172384376774d534139344472415065425134464467624c4551424441454d4151774244414563415177424c41464d415577424c414767416341426b41484141614143614149304167514342414930416d674470414b59417377436d414c4d41706744704157494133414543414e774133414543414e774259674534415873424e4145664154514265774534416a4942755147484159634275514979416f6b43495149454169454369514d534172384376774d534139344472415065425134464467624c2f384941455167415441424d417745694141495241514d5241662f454143774141414d4241514141414141414141414141414141414141434177454541514542415141414141414141414141414141414141414141514c2f3267414d417745414168414445414141414f414141595575684d594641446373563649374c6b3654584d624c495a754964664c306e5643545339335045796a525452455a62446f353646567a5177463163425642414148514b45775a5141412f2f3851414a424142414149424241494341674d4141414141414141414151414345514d534954455151534169457a42525958482f3267414941514541415438412f625473347a4c61526d4f6e2f444e6a477166414d7a5955715a4a585336566d4531584d72516175586d4e583378784d4c6d574d506d6c556a7061746f4e2b737770626c6a6b7a676c796f55426e396534392b4355666f7831714a4d356638415a587161324a686a564d53353472325266714241446d3833747863645438754f6d4b744730626c7655785a4e336f6c764250554e49745274756a6130577436796732347a784c304b347777357179336b764e307143387543504338356d4a694b48784746676d2b6234326633662f2f454142635241414d4241414141414141414141414141414141414145524d41442f3267414941514942415438416d41736b612f2f454142515241514141414141414141414141414141414141414145442f3267414941514d4241543841542f2f5a00000000000000000000bc614e --test
It seems that the prove API is temporarily unable to function properly.
Can be reproduced with any existing zkgraph.
also can be reproduced with following steps:
npm init zkgraph@latest
CompilerServerEndpoint: "http://compiler.dev.hyperoracle.io/compile"
//@ts-ignore
import { Bytes, Account, Block, BigInt } from "@hyperoracle/zkgraph-lib";
let addr = Bytes.fromHexString("0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8");
let key = Bytes.fromHexString(
"0x0000000000000000000000000000000000000000000000000000000000000000"
);
function calculatePrice(sqrtPrice: BigInt): BigInt {
const e12 = BigInt.fromI32(10).pow(12);
const n = sqrtPrice.div(BigInt.fromI32(2).pow(96));
return e12.div(n.pow(2));
}
export function handleBlocks(blocks: Block[]): Bytes {
let acct: Account = blocks[0].account(addr);
let value: Bytes = acct.storage(key);
let priceSqrtBytesX96: Bytes = value.slice(11, 31);
const priceSqrt: BigInt = BigInt.fromBytes(priceSqrtBytesX96);
const price = calculatePrice(priceSqrt);
return Bytes.fromHexString(price.toHex());
}
zkgraph.yaml
specVersion: 0.0.2
apiVersion: 0.0.2
name: eg_storage
description: "calculate uniswap v3 WETH-USDC price with storage interface"
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: mainnet
storage:
- address: '0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8'
slots:
- 0
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
npm run compile && npm run setup
( maybe already setup )npm run prove -- 18827736 08cc --prove
At this time, an HTTPS error without catch will cause a panic.
In certain situations, events.length may unexpectedly become 0.
Please reproduce the following steps:
npm init zkgraph@alpha
zkgraph.yaml which dataSources is mainnet event as below:
specVersion: 0.0.2
apiVersion: 0.0.2
name: eg_event
description: "This demo zkGraph shows 3 ways to access / filter out source events."
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: mainnet
event:
- address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
events:
- "Transfer(address,address,uint256)"
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
console.log the events.length as a string:
//@ts-ignore
import { Bytes, Block, Event } from "@hyperoracle/zkgraph-lib";
export function handleBlocks(blocks: Block[]): Bytes {
// #1 can access all (matched) events of the latest block
let events: Event[] = blocks[0].events;
console.log(events.length.toString());
return Bytes.fromI32(1);
}
npm run compile && npm run exec -- 18518315
When the Bytes are too large, the toHexString function cannot execute.
npm init zkgraph@latest
//@ts-ignore
import { Bytes, Block } from "@hyperoracle/zkgraph-lib";
export function handleBlocks(blocks: Block[]): Bytes {
const event = blocks[0].events[0];
event.data.toHexString();
return Bytes.empty();
}
specVersion: 0.0.2
apiVersion: 0.0.2
name: eg_event
description: "This demo zkGraph shows 3 ways to access / filter out source events."
repository: https://github.com/hyperoracle/zkgraph
dataSources:
- kind: ethereum
network: sepolia
event:
- address: '0xfa002dc692d045afde265d5eac09d012c1af50e8'
events:
- "ethscriptions_protocol_CreateEthscription(address,string)"
mapping:
language: wasm/assemblyscript
file: ./mapping.ts
handler: handleBlocks
dataDestinations:
- kind: ethereum
network: sepolia
address: "0x0000000000000000000000000000000000000001"
npm run compile && npm run exec -- 4940316
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.