From 5586cbefa5a903855ce6540caf009d6c409e7aff Mon Sep 17 00:00:00 2001 From: Willem Olding Date: Sat, 13 Apr 2024 16:00:10 +1000 Subject: [PATCH] example running indexer in parallel with vm --- Cargo.lock | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 4 ++- justfile | 10 ++++-- src/main.rs | 10 ++++-- 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa02276..6d5598a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,6 +108,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "ascii" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" + [[package]] name = "async-stream" version = "0.3.5" @@ -875,6 +881,19 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "combine" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +dependencies = [ + "ascii", + "byteorder", + "either", + "memchr", + "unreachable", +] + [[package]] name = "console" version = "0.15.8" @@ -1881,6 +1900,64 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "graphql-introspection-query" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2a4732cf5140bd6c082434494f785a19cfb566ab07d1382c3671f5812fed6d" +dependencies = [ + "serde", +] + +[[package]] +name = "graphql-parser" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ebc8013b4426d5b81a4364c419a95ed0b404af2b82e2457de52d9348f0e474" +dependencies = [ + "combine", + "thiserror", +] + +[[package]] +name = "graphql_client" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50cfdc7f34b7f01909d55c2dcb71d4c13cbcbb4a1605d6c8bd760d654c1144b" +dependencies = [ + "graphql_query_derive", + "serde", + "serde_json", +] + +[[package]] +name = "graphql_client_codegen" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e27ed0c2cf0c0cc52c6bcf3b45c907f433015e580879d14005386251842fb0a" +dependencies = [ + "graphql-introspection-query", + "graphql-parser", + "heck", + "lazy_static", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", +] + +[[package]] +name = "graphql_query_derive" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83febfa838f898cfa73dfaa7a8eb69ff3409021ac06ee94cfb3d622f6eeb1a97" +dependencies = [ + "graphql_client_codegen", + "proc-macro2", + "syn 1.0.109", +] + [[package]] name = "group" version = "0.12.1" @@ -2685,6 +2762,7 @@ dependencies = [ "autocfg", "num-integer", "num-traits", + "serde", ] [[package]] @@ -4480,9 +4558,11 @@ version = "0.1.0" dependencies = [ "ethereum-types", "futures-util", + "graphql_client", "hex", "http 1.1.0", "hyper", + "num-bigint", "serde", "serde_json", "thiserror", @@ -4699,6 +4779,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +dependencies = [ + "void", +] + [[package]] name = "untrusted" version = "0.9.0" @@ -4744,6 +4833,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "wagyu-zcash-parameters" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 276b2f5..60d6e09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,9 +36,11 @@ cartezcash-lightwalletd = { path = "cartezcash-lightwalletd", optional = true } tower-cartesi = { path = "tower-cartesi" } [features] -default = [] +default = ["listen-http"] lightwalletd = ["dep:cartezcash-lightwalletd", "dep:tonic", "dep:zebra-state"] preinitialize-halo2 = [] +listen-http = [] +listen-graphql = [] [workspace] members = [ "cartezcash-lightwalletd", "tiny-cash", "tower-cartesi"] diff --git a/justfile b/justfile index 692d738..5a9fa16 100644 --- a/justfile +++ b/justfile @@ -9,19 +9,23 @@ run: run-local: ROLLUP_HTTP_SERVER_URL=http://127.0.0.1:8080/host-runner GRPC_SERVER_URL="[::1]:50051" cargo run --features lightwalletd +run-local-graphql: + ROLLUP_HTTP_SERVER_URL=http://127.0.0.1:8080/graphql GRPC_SERVER_URL="[::1]:50051" cargo run --no-default-features --features listen-graphql,lightwalletd + + sunodo-nobackend: sunodo run --no-backend ##### Interact with dApp via sunodo @deposit address amount: - sunodo send ether --execLayerData=$1 --amount=$2 --rpc-url=http://127.0.0.1:8545 --chain-id=31337 --dapp=0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C + sunodo send ether --execLayerData=$1 --amount=$2 --rpc-url=http://127.0.0.1:8545 --chain-id=31337 --dapp=0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e @send txn_hex: - sunodo send generic --input="0x$2" --rpc-url=http://127.0.0.1:8545 --chain-id=31337 --dapp=0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C + sunodo send generic --input="0x$2" --rpc-url=http://127.0.0.1:8545 --chain-id=31337 --dapp=0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e execute_voucher: - cast send 0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C "executeVoucher(address, bytes, struct Proof _proof)" + cast send 0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e "executeVoucher(address, bytes, struct Proof _proof)" ##### wallet related commands diff --git a/src/main.rs b/src/main.rs index d48ea89..92f36f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tower::{buffer::Buffer, util::BoxService, BoxError, Service, ServiceExt}; -use tower_cartesi::{listen_http, Request as RollAppRequest, Response}; +use tower_cartesi::{Request as RollAppRequest, Response}; use futures_util::future::FutureExt; @@ -79,7 +79,13 @@ async fn main() -> Result<(), anyhow::Error> { tracing::info!("wallet GRPC server listening on {}", addr); } - listen_http(&mut cartezcash_app, &server_addr) + #[cfg(feature = "listen-http")] + tower_cartesi::listen_http(&mut cartezcash_app, &server_addr) + .await + .expect("Failed to start the rollup server"); + + #[cfg(feature = "listen-graphql")] + tower_cartesi::listen_graphql(&mut cartezcash_app, &server_addr, 10) .await .expect("Failed to start the rollup server");