Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ethereum-mainnet-rpc.allthatnode.com
URL_ANKR_JSON_RPC_GOERLI=ethereum-goerli-rpc.allthatnode.com
PRIVATE_KEY_GOERLI=
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,31 @@ gh repo create zkgraph-new --public --template="https://github.com/hyperoracle/z

### Configuration

After clone your project, you need to create `config.js` file at root folder based on `config-example.js`
After cloning your project, you need to create `config.js` file at root folder based on `config-example.js`

Generate an environment file by running `cp .env-example .env`.

If you wish to use ANKR to create JSON RPC requests to the Ethereum Goerli Testnet then go to https://www.ankr.com/rpc/ and click "Base Goerli Testnet" and then copy the "HTTPS Endpoint" value and paste it as the value of `URL_ANKR_JSON_RPC_GOERLI` in the .env file.

Lastly paste the private key of an Ethereum address that has Goerli Testnet Eth as the value of `PRIVATE_KEY_GOERLI` in the .env file. To obtain Goerli Testnet Eth refer to [this article](https://www.coingecko.com/learn/goerli-eth).

```js
// ./config.js
export const config = {
// Update your Etherum JSON RPC provider URL here.
// Update your Ethereum JSON RPC provider URL here.
// Please note that the provider must support debug_getRawReceipts RPC method.
// Recommended provider: ANKR.
JsonRpcProviderUrl: "https://{URL}",
UserPrivateKey: "0x{PRIVATE_KEY}",
JsonRpcProviderUrl: "https://{URL_ANKR_JSON_RPC_GOERLI}",
UserPrivateKey: "0x{PRIVATE_KEY_GOERLI}",
// ...and other configs.
};
```

> To check if the provider supports the [`debug_getRawReceipts`](https://github.com/ethereum/go-ethereum/pull/24773) JSON RPC method, check if the following returns a response `{"jsonrpc":"2.0","id":42,"result":["...}`. In the example below the argument is the block hash (i.e. 0x3bb580f7645e2bdeb34b226f1b559d22a4a1ba5e2474504e294088389923ebd0) of a block number (i.e. 9438739) on the Goerli Testnet where the provider JSON RPC endpoint was obtained from https://www.allthatnode.com/ethereum.dsrv
```bash
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_getRawReceipts","params":["0x3bb580f7645e2bdeb34b226f1b559d22a4a1ba5e2474504e294088389923ebd0"],"id":42}' https://ethereum-goerli-rpc.allthatnode.com
```

Then run:

```bash
Expand Down Expand Up @@ -64,6 +75,10 @@ npm run compile-local
npm run exec-local -- {block_id}
```

Note: If using Ethereum Mainnet endpoint then its block 17633573 emits the event `Sync(uint112,uint112)` as specified in src/zkgraph.yaml so when you run `npm run exec-local -- 17633573` it outputs that 1 event matched. The same block number on another network like Goerli may not have emitted that event, so it may be necessary to find a block where it did (if at all) or deploy your own smart contract to a network that emits an event and then add that event to src/zkgraph.yaml with it configured to use that network.

Note: If using Ethereum Goerli Testnet then replace the `block_id` above with a block from https://goerli.etherscan.io/blocks

### Set Up Local Image

```bash
Expand Down
2 changes: 1 addition & 1 deletion api/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (currentNpmScriptName() === "compile-local") {
// Compile Locally
localCompile(config.LocalWasmBinPath, watPath);
} else if (currentNpmScriptName() === "compile") {
// Test Compile Erro with Local Compile
// Test Compile Error with Local Compile
localCompile("build/tmp.wasm", "build/tmp.wat");

// Only Call Compile Server When No Local Compile Errors
Expand Down
3 changes: 3 additions & 0 deletions api/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const [filteredRawReceiptList, filteredEventList] = rlpDecodeAndEventFilter(
fromHexString(source_address),
source_esigs.map((esig) => fromHexString(esig)),
);
console.log('filteredRawReceiptList', filteredRawReceiptList)
console.log('filteredEventList', filteredEventList)

// Gen Offsets
let [rawReceipts, matchedEventOffsets] = genStreamAndMatchedEventOffsets(
Expand All @@ -67,6 +69,7 @@ let wasmPath;

let asmain_exported;
if (currentNpmScriptName() === "exec-local") {
// e.g. build/zkgraph_local.wasm
wasmPath = config.LocalWasmBinPath;
const { asmain } = await instantiateWasm(wasmPath);
asmain_exported = asmain;
Expand Down
12 changes: 7 additions & 5 deletions config-example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'dotenv/config'

export const config = {
// Update your Etherum JSON RPC provider URL here.
// Update your Ethereum JSON RPC provider URL here.
// Please note that the provider must support debug_getRawReceipts RPC method.
JsonRpcProviderUrl: "https://{URL}",
// Update your private key here to sign zkwasm messages.
// Please note that (during testnet phrase) your address balance (in zkwasm server) should > 0;
UserPrivateKey: "0x{PRIVATE_KEY}",
JsonRpcProviderUrl: `https://${process.env.URL_ANKR_JSON_RPC_GOERLI}`,
// Update your private key here to sign zkWasm messages.
// Please note that (during testnet phrase) your address balance (in zkWasm server) should > 0;
UserPrivateKey: `0x${process.env.PRIVATE_KEY_GOERLI}`,

ZkwasmProviderUrl: "https://zkwasm-explorer.delphinuslab.com:8090",
CompilerServerEndpoint: "https://compiler.hyperoracle.io/compile",
Expand Down
2 changes: 1 addition & 1 deletion lib/common/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export function zkmain(): void {
matched_event_offset.length / 7,
matched_event_offset.dataStart,
) as Bytes;

require(state == expected_state ? 1 : 0);
}
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"axios": "^1.4.0",
"commander": "^11.0.0",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"form-data": "^4.0.0",
"js-yaml": "^4.1.0",
Expand Down