Code Monkey home page Code Monkey logo

cle-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cle-cli's Issues

Yarn Installation Fails for CLE Project Creation

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

unexpected events.length == 0 when event.data too huge

Env

  • zkgraph-lib: 1.0.1
  • zkgraph-cli: 1.0.0-alpha.0

reproduce

  1. npm init zkgraph@latest
  2. Initialize the zkgraph project according to the guidelines.
  3. modify package.json with specific version of zkgraph-lib and zkgraph-cli
  4. modify zkgraph.config.ts with developing compiler server
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;
  1. modify 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!");
}
  1. modify 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"
  1. run command npm run compile && npm run exec -- 18137200
  2. The events.length as 0 in Logs.

image

Fail to retrieve event after 22nd

zkgraph cannot parse event which blocks[0].events.length is greater than 21.

Env

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

reproduce as follow steps:

  1. run command: npm init zkgraph@alpha
  2. follow the instruction and initialize the zkgraph project
  3. save the following code as mapping.ts:
//@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);
}
  1. save the following code as a.ts:
// @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));
  }
}
  1. save the following code as zkgraph.yaml:
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"
  1. run command: 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
image

Optimization of error message

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?

Env

zkgraph-api: v1.0.3
zkgraph-cli: v1.0.0
zkgraph-lib: v1.0.1

reproduce

  1. npm init zkgraph@latest
  2. modify zkgraph.config.ts with a low balance account privateKey.
  3. try npm run prove

and the error log will be like following:
image

When slot.Key is equal to 0, the prove will fail.

When slot.Key is equal to 0, the prove will fail.

Env

  • zkgraph-lib: v1.0.1
  • zkgraph-cli: v1.0.0
  • zkgraph-api: v1.0.3
  • compiler: http://compiler.hyperoracle.io/compile

Reproduce

  1. npm init zkgraph@latest
  2. Follow the instructions to create a project of storage type.
  3. modify zkgraph.yaml as follow:
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"
  1. modify mapping.ts as follow:
//@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");
}
  1. run command npm run compile && npm run setup && npm run prove -- 18882868 01 --prove

And follow error message will be throw.
image

I can't compile CLE Hello template

Error:
image

The whole process:
npm create cle@latest
I selected Hello template and typed other needed info
cd test
npx cle compile

What is the problem at? Thx

state prove failed.

It seems that the state prove has failed.

ENV

  • zkgraph-lib: v1.0.1
  • zkgraph-api: v1.0.3
  • zkgraph-cli: v1.0.0
  • CompilerServerEndpoint: http://compiler.dev.hyperoracle.io/compile

Reproduce

  1. npm init zkgraph@latest
  2. Follow the instructions to initialize the storage demo project.
  3. modify zkgraph.config.ts with a valid privateKey
  4. npm run compile && npm run setup
  5. npm run prove -- 4971020 6370902000000003336530047e5ec3da40c000000000068f1888e6eb7036fffe --prove
  6. zkgraph will have the following error messages.
    image

Optimize the error message of state 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.

Enc

  • zkgraph-lib: v1.0.1
  • zkgraph-cli: v1.0.0
  • zkgraph-api: v1.0.3

reproduce

  1. npm init zkgraph@latest
  2. Follow the guide to create a project of storage type.
  3. run command npm run compile && npm run exec -- 11882969
    error message which be throw as follow:
image

input too large to mock prove

When the input is too large, prove --test cannot simulate the proving process.

Env

  • zkgraph-lib: v1.0.1
  • zkgraph-cli: 1.0.0-alpha.0

Reproduce

  1. git clone https://github.com/LiRiu/zkEthscription.git
  2. cd zkEthscription && npm install
  3. cp zkgraph.config.example.js zkgraph.config.js && vim zkgraph.config.js
  4. npm run prove -- 4940316 00bc614e646174613a696d6167652f6a7065673b6261736536342c2f396a2f34414151536b5a4a5267414241514141415141424141442f327745454541424441454d4151774244414563415177424c41464d415577424c414767416341426b41484141614143614149304167514342414930416d674470414b59417377436d414c4d41706744704157494133414543414e774133414543414e774259674534415873424e4145664154514265774534416a4942755147484159634275514979416f6b43495149454169454369514d534172384376774d534139344472415065425134464467624c4551424441454d4151774244414563415177424c41464d415577424c414767416341426b41484141614143614149304167514342414930416d674470414b59417377436d414c4d41706744704157494133414543414e774133414543414e774259674534415873424e4145664154514265774534416a4942755147484159634275514979416f6b43495149454169454369514d534172384376774d534139344472415065425134464467624c2f384941455167415441424d417745694141495241514d5241662f454143774141414d4241514141414141414141414141414141414141434177454541514542415141414141414141414141414141414141414141514c2f3267414d417745414168414445414141414f414141595575684d594641446373563649374c6b3654584d624c495a754964664c306e5643545339335045796a525452455a62446f353646567a5177463163425642414148514b45775a5141412f2f3851414a424142414149424241494341674d4141414141414141414151414345514d534954455151534169457a42525958482f3267414941514541415438412f625473347a4c61526d4f6e2f444e6a477166414d7a5955715a4a585336566d4531584d72516175586d4e583378784d4c6d574d506d6c556a7061746f4e2b737770626c6a6b7a676c796f55426e396534392b4355666f7831714a4d356638415a587161324a686a564d53353472325266714241446d3833747863645438754f6d4b744730626c7655785a4e336f6c764250554e49745274756a6130577436796732347a784c304b347777357179336b764e307143387543504338356d4a694b48784746676d2b6234326633662f2f454142635241414d4241414141414141414141414141414141414145524d41442f3267414941514942415438416d41736b612f2f454142515241514141414141414141414141414141414141414145442f3267414941514d4241543841542f2f5a00000000000000000000bc614e --test

and the error will seem like below:
image

prove panic by unknown error

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:

  1. npm init zkgraph@latest
  2. Follow the instructions to complete the initialization.
  3. modify zkgraph.config.ts with CompilerServerEndpoint: "http://compiler.dev.hyperoracle.io/compile"
  4. modify mapping.ts and zkgraph.yaml as following code:
    mapping.ts
//@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"
  1. run command npm run compile && npm run setup ( maybe already setup )
  2. run command npm run prove -- 18827736 08cc --prove

At this time, an HTTPS error without catch will cause a panic.
image

unexpected events.length == 0

Description

In certain situations, events.length may unexpectedly become 0.
Please reproduce the following steps:

1. Init zkgraph@alpha

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"

2. code mapping.ts

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);
}

3. compile and execute

 npm run compile && npm run exec -- 18518315
image

The excessively long bytes cannot be toHexString.

When the Bytes are too large, the toHexString function cannot execute.

Env

  • zkgraph-lib: v1.0.1
  • zkgraph-cli: v1.0.0

Reproduce

  1. npm init zkgraph@latest
  2. Follow the guide to initialize a project of type "event"
  3. modify src/mapping.ts as follow:
//@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();
}
  1. modify src/zkgraph.yaml as follow:
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"
  1. npm run compile && npm run exec -- 4940316
    Next, there will be the following error message from execue.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.