From e74272beddca381918cdfb003e20738cf2a6c270 Mon Sep 17 00:00:00 2001 From: rashad Date: Tue, 24 Oct 2023 06:24:18 -0400 Subject: [PATCH] chore: remove native execution (#1423) * chore: remove native execution * clippy * fix test --- Cargo.lock | 22 --- Cargo.toml | 1 - docs/README.md | 1 - docs/src/SUMMARY.md | 1 - docs/src/forc-index/build.md | 1 - docs/src/forc-index/deploy.md | 1 - docs/src/forc-index/new.md | 1 - docs/src/forc-index/run-native.md | 45 ----- docs/src/project-components/manifest.md | 4 +- examples/greetings-native/Dockerfile | 81 -------- examples/greetings-native/README.md | 60 ------ examples/greetings-native/docker-compose.yaml | 48 ----- .../greetings-native-indexer/Cargo.toml | 13 -- .../greetings_native_indexer.manifest.yaml | 38 ---- .../greetings_native_indexer.schema.graphql | 14 -- .../greetings-native-indexer/src/main.rs | 25 --- packages/fuel-indexer-api-server/src/uses.rs | 10 +- .../database-types/src/lib.rs | 4 - packages/fuel-indexer-graphql/src/graphql.rs | 3 +- packages/fuel-indexer-lib/Cargo.toml | 2 - .../fuel-indexer-lib/src/graphql/parser.rs | 24 +-- packages/fuel-indexer-lib/src/lib.rs | 23 --- packages/fuel-indexer-lib/src/manifest.rs | 25 +-- packages/fuel-indexer-macros/src/decoder.rs | 178 +++-------------- packages/fuel-indexer-macros/src/indexer.rs | 77 ++------ packages/fuel-indexer-macros/src/lib.rs | 1 - packages/fuel-indexer-macros/src/native.rs | 187 ------------------ packages/fuel-indexer-macros/src/schema.rs | 10 +- packages/fuel-indexer-plugin/Cargo.toml | 23 --- packages/fuel-indexer-plugin/src/lib.rs | 2 - packages/fuel-indexer-plugin/src/native.rs | 77 -------- .../fuel-indexer-schema/src/db/manager.rs | 6 +- packages/fuel-indexer-schema/src/db/tables.rs | 28 +-- .../scripts/test-examples.bash | 28 --- packages/fuel-indexer-tests/tests/commands.rs | 9 - packages/fuel-indexer-tests/tests/config.rs | 15 -- packages/fuel-indexer-tests/tests/service.rs | 6 - ...ommands__forc_index_build_help_output.snap | 1 - ...mmands__forc_index_deploy_help_output.snap | 1 - ...sts__commands__forc_index_help_output.snap | 26 ++- ..._commands__forc_index_new_help_output.snap | 1 - packages/fuel-indexer-utils/Cargo.toml | 3 - packages/fuel-indexer/src/executor.rs | 103 ---------- packages/fuel-indexer/src/lib.rs | 7 +- packages/fuel-indexer/src/service.rs | 58 +----- plugins/forc-index/src/cli.rs | 6 +- plugins/forc-index/src/commands/build.rs | 17 -- plugins/forc-index/src/commands/deploy.rs | 21 -- plugins/forc-index/src/commands/mod.rs | 1 - plugins/forc-index/src/commands/new.rs | 4 - plugins/forc-index/src/commands/run_native.rs | 54 ----- plugins/forc-index/src/defaults.rs | 77 +------- .../forc-index/src/ops/forc_index_build.rs | 88 ++++----- .../forc-index/src/ops/forc_index_deploy.rs | 2 - plugins/forc-index/src/ops/forc_index_new.rs | 57 ++---- .../src/ops/forc_index_run_native.rs | 111 ----------- plugins/forc-index/src/ops/mod.rs | 1 - plugins/forc-index/src/utils.rs | 7 +- scripts/utils/build_modules.bash | 5 - 59 files changed, 142 insertions(+), 1603 deletions(-) delete mode 100644 docs/src/forc-index/run-native.md delete mode 100644 examples/greetings-native/Dockerfile delete mode 100644 examples/greetings-native/README.md delete mode 100644 examples/greetings-native/docker-compose.yaml delete mode 100644 examples/greetings-native/greetings-native-indexer/Cargo.toml delete mode 100644 examples/greetings-native/greetings-native-indexer/greetings_native_indexer.manifest.yaml delete mode 100644 examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql delete mode 100644 examples/greetings-native/greetings-native-indexer/src/main.rs delete mode 100644 packages/fuel-indexer-macros/src/native.rs delete mode 100644 packages/fuel-indexer-plugin/src/native.rs delete mode 100644 plugins/forc-index/src/commands/run_native.rs delete mode 100644 plugins/forc-index/src/ops/forc_index_run_native.rs diff --git a/Cargo.lock b/Cargo.lock index 596985d5f..786fc75fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3354,8 +3354,6 @@ dependencies = [ "fuel-indexer-types", "http", "lazy_static", - "proc-macro2", - "quote", "serde", "serde_json", "serde_yaml", @@ -3414,24 +3412,15 @@ dependencies = [ name = "fuel-indexer-plugin" version = "0.21.2" dependencies = [ - "anyhow", - "async-trait", "bincode", - "fuel-indexer", - "fuel-indexer-api-server", - "fuel-indexer-database", "fuel-indexer-lib", "fuel-indexer-schema", "fuel-indexer-types", - "futures", "getrandom", "hex", "serde", "serde_json", "sha2 0.10.7", - "tokio", - "tracing", - "tracing-subscriber 0.2.25", ] [[package]] @@ -4124,17 +4113,6 @@ dependencies = [ "serde", ] -[[package]] -name = "greetings_native_indexer" -version = "0.0.0" -dependencies = [ - "async-trait", - "fuel-indexer", - "fuel-indexer-utils", - "fuels", - "serde", -] - [[package]] name = "group" version = "0.12.1" diff --git a/Cargo.toml b/Cargo.toml index 95dc75ea9..089d73292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ "examples/fuel-explorer/fuel-explorer", - "examples/greetings-native/greetings-native-indexer", "examples/greetings/greetings-data", "examples/greetings/greetings-fuel-client", "examples/greetings/greetings-indexer", diff --git a/docs/README.md b/docs/README.md index 3a5ac7549..818c0f0ff 100644 --- a/docs/README.md +++ b/docs/README.md @@ -79,7 +79,6 @@ SUBCOMMANDS: new Create a new indexer project in a new directory postgres Fuel Postgres Orchestrator remove Stop and remove a running indexer - run-native Run a native indexer start Standalone binary for the Fuel indexer service status Check the status of a registered indexer ``` diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 26cd29c76..970c27264 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -44,7 +44,6 @@ - [remove](./forc-index/remove.md) - [start](./forc-index/start.md) - [status](./forc-index/status.md) - - [run-native](./forc-index/run-native.md) - [forc postgres](./forc-postgres/index.md) - [create](./forc-postgres/create.md) - [drop](./forc-postgres/drop.md) diff --git a/docs/src/forc-index/build.md b/docs/src/forc-index/build.md index cc472432e..4892ba9bd 100644 --- a/docs/src/forc-index/build.md +++ b/docs/src/forc-index/build.md @@ -17,7 +17,6 @@ OPTIONS: -h, --help Print help information --locked Ensure that the Cargo.lock file is up-to-date. -m, --manifest Manifest file name of indexer being built. - --native Building for native execution. -p, --path Path to the indexer project. -v, --verbose Enable verbose output. diff --git a/docs/src/forc-index/deploy.md b/docs/src/forc-index/deploy.md index 319a5696e..3971e5693 100644 --- a/docs/src/forc-index/deploy.md +++ b/docs/src/forc-index/deploy.md @@ -18,7 +18,6 @@ OPTIONS: -h, --help Print help information --locked Ensure that the Cargo.lock file is up-to-date. -m, --manifest Path to the manifest of indexer project being deployed. - --native Building for native execution. -p, --path Path to the indexer project. --remove-data Remove all indexed data when replacing an existing indexer. --replace-indexer If an indexer with the same UID exists, remove it. diff --git a/docs/src/forc-index/new.md b/docs/src/forc-index/new.md index 914df7753..22f481e8d 100644 --- a/docs/src/forc-index/new.md +++ b/docs/src/forc-index/new.md @@ -20,6 +20,5 @@ OPTIONS: -h, --help Print help information --name Name of indexer. --namespace Namespace to which indexer belongs. - --native Initialize an indexer with native execution enabled. -v, --verbose Enable verbose output. ``` diff --git a/docs/src/forc-index/run-native.md b/docs/src/forc-index/run-native.md deleted file mode 100644 index 8a303c86b..000000000 --- a/docs/src/forc-index/run-native.md +++ /dev/null @@ -1,45 +0,0 @@ -# `forc index run-native` - -Run a native indexer. - -```bash -forc index run-native --path . -- --run-migrations --postgres-host localhost -``` - -```text -Run a native indexer - -USAGE: - forc-index run-native [OPTIONS] [-- ...] - -ARGS: - ... - Extra passed to `fuel-indexer run` - - Example usage: `forc-index run-native --path . -- --run-migrations --stop-idle-indexers` - -OPTIONS: - --bin - Path to native indexer binary (if not using default location). - - -d, --debug - Build artifacts with the debug profile. - - -h, --help - Print help information - - --locked - Ensure that the Cargo.lock file is up-to-date. - - -m, --manifest - Manifest file name of indexer being built. - - -p, --path - Path to the indexer project. - - --skip-build - Do not build before deploying. - - -v, --verbose - Enable verbose output. -``` diff --git a/docs/src/project-components/manifest.md b/docs/src/project-components/manifest.md index e64041184..96ed9c883 100644 --- a/docs/src/project-components/manifest.md +++ b/docs/src/project-components/manifest.md @@ -76,9 +76,7 @@ The `end_block` field indicates the block height after which the indexer should _Required._ -The `module` field contains a file path that points to code that will be run as an _executor_ inside of the indexer. There are two available options for modules/execution: `wasm` and `native`. Note that when specifying a `wasm` module, the provided path must lead to a compiled WASM binary. - -> Important: At this time, `wasm` is the preferred method of execution. +The `module` field contains a file path that points to code that will be run as an _executor_ inside of the indexer. ## `resumable` diff --git a/examples/greetings-native/Dockerfile b/examples/greetings-native/Dockerfile deleted file mode 100644 index 59dc94e9c..000000000 --- a/examples/greetings-native/Dockerfile +++ /dev/null @@ -1,81 +0,0 @@ -# Stage 1: Build -FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx -FROM --platform=$BUILDPLATFORM rust:1.72.1 AS chef - -ARG TARGETPLATFORM -RUN cargo install cargo-chef -WORKDIR /build/ - -COPY --from=xx / / - -# hadolint ignore=DL3008 -RUN apt-get update -y && \ - apt-get install -y --no-install-recommends \ - build-essential \ - clang \ - cmake \ - gcc \ - git \ - libclang-dev \ - lld \ - llvm \ - pkg-config - -RUN xx-apt-get update && \ - xx-apt-get install -y binutils g++ libc6-dev && \ - apt-get clean - -FROM chef AS planner -ENV CARGO_NET_GIT_FETCH_WITH_CLI=true -COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -# Stage 2: build binaries -FROM chef AS builder -ENV CARGO_NET_GIT_FETCH_WITH_CLI=true -COPY --from=planner /build/recipe.json recipe.json - -ENV SQLX_OFFLINE=true - -RUN xx-cargo chef cook --release -p greetings_native_indexer --recipe-path recipe.json -COPY . . -RUN xx-cargo build --release -p greetings_native_indexer \ - && xx-verify ./target/$(xx-cargo --print-target-triple)/release/greetings_native_indexer \ - && mv ./target/$(xx-cargo --print-target-triple)/release/greetings_native_indexer ./target/release/greetings_native_indexer \ - && mv ./target/$(xx-cargo --print-target-triple)/release/greetings_native_indexer.d ./target/release/greetings_native_indexer.d - -# Stage 3: Run -FROM ubuntu:22.04 AS run - -WORKDIR /root/ - -RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \ - && apt-get install -y --no-install-recommends \ - tzdata \ - ca-certificates \ - libpq-dev \ - wget \ - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y - -COPY --from=builder /build/target/release/greetings_native_indexer . -COPY --from=builder /build/target/release/greetings_native_indexer.d . -COPY --from=builder /build/examples/greetings-native/greetings-native-indexer . -COPY --from=builder /build/examples/greetings/contracts/greeting/out/debug/greeting-abi.json . - -# Since unlike WASM indexers, native indexers can't be deployed, we need to -# write the specific asset paths to the manifest, as well as the manifest itself. -# -# We only have to do this because the example is contained within the project worksapce (and it's -# manifest asset paths are relative to that workspace root). You wouldn't need to do this otherwise. -RUN echo "namespace: fuellabs\n\ -fuel_client: ~\n\ -graphql_schema: schema/greetings_native_indexer.schema.graphql\n\ -abi: greetings-abi.son\n\ -start_block: ~\n\ -end_block: ~\n\ -contract_id: fuel1q6sj2srt0u40jdqg2lvvnspyuhse9rs2s2fv9nmv0hqjcrdc7sqsfpwv9x\n\ -identifier: greetings_native\n\ -module: native\n\ -resumable: true" > greetings_native_indexer.manifest.yaml \ No newline at end of file diff --git a/examples/greetings-native/README.md b/examples/greetings-native/README.md deleted file mode 100644 index 13ec524d4..000000000 --- a/examples/greetings-native/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# greetings-native - -A simple program that demonstrates the full Fuel indexer experience. - -## Usage - -> NOTE: Commands are run from `fuel-indexer/examples/greetings-native` - -### Spin up containers - -Build image locally - -```bash -docker compose up -``` - -Spin up containers for the Postgres database server and the indexer service. - -> IMPORTANT: Ensure that any local Postgres instance on port 5432 is stopped. - -```bash -docker compose up -``` - -### Deploy the indexer - -> Note that since this example uses native execution (as opposed to WASM execution), there is no need to -> "deploy" the indexer. You'll notice that your indexer is already running inside your Docker container. - -### Interact - -Trigger some test data by simulating a contract call. - -```bash -cargo run -p greetings-data --bin greetings-data -- --host 0.0.0.0:4000 -``` - -### Validate - -Ensure that test data was indexed via a GraphQL query: - 1. Open this GraphQL playground link http://192.168.1.34:29987/api/playground/fuellabs/greetings-native_indexer - 2. Submit the following query - -```graphql -query { - transaction { - hash - block { - hash - height - } - } -} -``` - -> IMPORTANT: Since this example uses a dockerized indexer service, with the GraphQL -> web server being bound at interface `0.0.0.0` your LAN IP might differ from the -> `192.168.1.34` mentioned above. -> -> On *nix platforms you can typically find your LAN IP via `ifconfig | grep inet` diff --git a/examples/greetings-native/docker-compose.yaml b/examples/greetings-native/docker-compose.yaml deleted file mode 100644 index c799f920d..000000000 --- a/examples/greetings-native/docker-compose.yaml +++ /dev/null @@ -1,48 +0,0 @@ -version: "3.9" -services: - postgres: - image: postgres:latest - ports: - - "5432:5432" - volumes: - - .:/usr/local/postgres - environment: - - POSTGRES_PASSWORD=postgres - - PGUSER=postgres - healthcheck: - test: - [ - "CMD-SHELL", - "pg_isready", - "-U", - "postgres", - "-d", - "postgres" - ] - interval: 30s - timeout: 60s - retries: 5 - start_period: 80s - fuel-node: - build: - context: ./../../ - dockerfile: ./ci/Dockerfile.fuel-node - image: fuel-indexer/local:fuel-node - command: bash -c "./fuel-node --host 0.0.0.0:4000 --contract-bin greeting.bin --chain-config test-chain-config.json" - ports: - - "4000:4000" - volumes: - - .:/usr/local/fuel-node - depends_on: - - postgres - greetings-native: - build: - context: ./../../ - dockerfile: ./examples/greetings-native/Dockerfile - command: bash -c "sleep 2 && ./greetings_native_indexer --fuel-node-host fuel-node --postgres-host postgres --postgres-password postgres --web-api-host 0.0.0.0 --run-migrations --manifest ./greetings_native_indexer.manifest.yaml" - ports: - - "29987:29987" - volumes: - - .:/usr/local/greetings-native - depends_on: - - fuel-node \ No newline at end of file diff --git a/examples/greetings-native/greetings-native-indexer/Cargo.toml b/examples/greetings-native/greetings-native-indexer/Cargo.toml deleted file mode 100644 index fe6d33ea0..000000000 --- a/examples/greetings-native/greetings-native-indexer/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "greetings_native_indexer" -version = "0.0.0" -edition = "2021" -publish = false -rust-version = "1.73.0" - -[dependencies] -async-trait = { version = "0.1" } -fuel-indexer = { workspace = true } -fuel-indexer-utils = { workspace = true, features = ["native-execution"] } -fuels = { workspace = true, features = ["std"] } -serde = { workspace = true } diff --git a/examples/greetings-native/greetings-native-indexer/greetings_native_indexer.manifest.yaml b/examples/greetings-native/greetings-native-indexer/greetings_native_indexer.manifest.yaml deleted file mode 100644 index 664e3601e..000000000 --- a/examples/greetings-native/greetings-native-indexer/greetings_native_indexer.manifest.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# A namespace is a logical grouping of declared names. Think of the namespace -# as an organization identifier -namespace: fuellabs - -# The identifier field is used to identify the given index. -identifier: greetings_native - -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: examples/greetings/contracts/greeting/out/debug/greeting-abi.json - -# The particular start block after which you'd like your indexer to start indexing events. -start_block: ~ - -# The particular end block after which you'd like your indexer to stop indexing events. -end_block: ~ - -# The `fuel_client` denotes the address (host, port combination) of the running Fuel client -# that you would like your indexer to index events from. In order to use this per-indexer -# `fuel_client` option, the indexer service at which your indexer is deployed will have to run -# with the `--indexer_net_config` option. -fuel_client: ~ - -# The contract_id specifies which particular contract you would like your index to subscribe to. -contract_id: fuel1q6sj2srt0u40jdqg2lvvnspyuhse9rs2s2fv9nmv0hqjcrdc7sqsfpwv9x - -# The graphql_schema field contains the file path that points to the GraphQL schema for the -# given index. -graphql_schema: examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql - -# The module field contains a file path that points to code that will be run as an executor inside -# of the indexer. -# Important: At this time, wasm is the preferred method of execution. -module: native - -# The resumable field contains a boolean that specifies whether or not the indexer should, synchronise -# with the latest block if it has fallen out of sync. -resumable: true diff --git a/examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql b/examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql deleted file mode 100644 index 7c2f35d16..000000000 --- a/examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql +++ /dev/null @@ -1,14 +0,0 @@ -# Calling this `Greeter` so as to not clash with `Person` in the contract -type Greeter @entity { - id: ID! - name: String! - last_seen: U32! -} - -# Calling this `Salutation` so as to not clash with `Greeting` in the contract -type Salutation @entity { - id: ID! - message: String! - greeter: Greeter! - last_seen: U32! -} diff --git a/examples/greetings-native/greetings-native-indexer/src/main.rs b/examples/greetings-native/greetings-native-indexer/src/main.rs deleted file mode 100644 index b5a6c127e..000000000 --- a/examples/greetings-native/greetings-native-indexer/src/main.rs +++ /dev/null @@ -1,25 +0,0 @@ -extern crate alloc; -use fuel_indexer_utils::prelude::*; - -#[indexer( - manifest = "examples/greetings-native/greetings-native-indexer/greetings_native_indexer.manifest.yaml" -)] -mod greetings_native_indexer { - - async fn greetings_indexer_handler(event: Greeting, block_data: BlockData) { - info!("Handling new Greeting event."); - let height = std::cmp::min(0, block_data.header.height - 1); - let name = event.person.name.to_right_trimmed_str().to_string(); - let greeting = event.greeting.to_right_trimmed_str().to_string(); - let message = format!("{greeting} šŸ‘‹, my name is {name}"); - - let greeter = Greeter::new(name, height).get_or_create().await; - - let salutation = Salutation::new(message, greeter.id.clone(), height) - .get_or_create() - .await; - - greeter.save().await; - salutation.save().await; - } -} diff --git a/packages/fuel-indexer-api-server/src/uses.rs b/packages/fuel-indexer-api-server/src/uses.rs index bbbde0c5c..747b36f3b 100644 --- a/packages/fuel-indexer-api-server/src/uses.rs +++ b/packages/fuel-indexer-api-server/src/uses.rs @@ -27,7 +27,6 @@ use fuel_indexer_lib::{ FuelClientHealthResponse, ReloadRequest, ServiceRequest, ServiceStatus, StopRequest, }, - ExecutionSource, }; use fuel_indexer_schema::db::manager::SchemaManager; use hyper::Client; @@ -376,14 +375,7 @@ async fn register_indexer_assets_transaction( schema_manager .write() .await - .new_schema( - namespace, - identifier, - schema, - // Only WASM can be sent over the web. - ExecutionSource::Wasm, - conn, - ) + .new_schema(namespace, identifier, schema, conn) .await?; assets.push(asset); diff --git a/packages/fuel-indexer-database/database-types/src/lib.rs b/packages/fuel-indexer-database/database-types/src/lib.rs index 2e1369ff6..bb97bff11 100644 --- a/packages/fuel-indexer-database/database-types/src/lib.rs +++ b/packages/fuel-indexer-database/database-types/src/lib.rs @@ -1253,7 +1253,6 @@ mod tests { use async_graphql_parser::types::ObjectType; use async_graphql_parser::types::Type; use fuel_indexer_lib::graphql::GraphQLSchema; - use fuel_indexer_lib::ExecutionSource; #[test] fn test_can_create_well_formed_table_and_table_components_when_passed_typedef() { @@ -1323,7 +1322,6 @@ type Person @entity { let schema = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1345,7 +1343,6 @@ type Person @entity { let schema = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1402,7 +1399,6 @@ type Wallet @entity { let schema = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); diff --git a/packages/fuel-indexer-graphql/src/graphql.rs b/packages/fuel-indexer-graphql/src/graphql.rs index ab7465d7c..c1c5bbe8a 100644 --- a/packages/fuel-indexer-graphql/src/graphql.rs +++ b/packages/fuel-indexer-graphql/src/graphql.rs @@ -679,7 +679,7 @@ impl<'a> GraphqlQueryBuilder<'a> { mod tests { use super::*; - use fuel_indexer_lib::{graphql::GraphQLSchema, ExecutionSource}; + use fuel_indexer_lib::graphql::GraphQLSchema; #[test] fn test_operation_parse_into_user_query() { @@ -773,7 +773,6 @@ type Tx @entity { "test_index", &GraphQLSchema::new(schema.to_string()), DbType::Postgres, - ExecutionSource::Wasm, ) .unwrap(); diff --git a/packages/fuel-indexer-lib/Cargo.toml b/packages/fuel-indexer-lib/Cargo.toml index 87b02a60e..b58276d79 100644 --- a/packages/fuel-indexer-lib/Cargo.toml +++ b/packages/fuel-indexer-lib/Cargo.toml @@ -18,8 +18,6 @@ clap = { features = ["cargo", "derive", "env"], workspace = true } fuel-indexer-types = { workspace = true } http = { version = "0.2", default-features = false } lazy_static = { version = "1.4" } -proc-macro2 = "1.0" -quote = "1.0" serde = { workspace = true } serde_json = { workspace = true } serde_yaml = "0.8" diff --git a/packages/fuel-indexer-lib/src/graphql/parser.rs b/packages/fuel-indexer-lib/src/graphql/parser.rs index 4c1af66cd..d7e866eb1 100644 --- a/packages/fuel-indexer-lib/src/graphql/parser.rs +++ b/packages/fuel-indexer-lib/src/graphql/parser.rs @@ -10,7 +10,7 @@ use crate::{ inject_internal_types_into_document, is_list_type, list_field_type_name, GraphQLSchema, GraphQLSchemaValidator, IdCol, BASE_SCHEMA, }, - join_table_name, ExecutionSource, + join_table_name, }; use async_graphql_parser::{ parse_schema, @@ -190,9 +190,6 @@ pub struct ParsedGraphQLSchema { /// Identifier of the indexer. identifier: String, - /// Indexer method of execution. - exec_source: ExecutionSource, - /// All unique names of types in the schema (whether objects, enums, or scalars). type_names: HashSet, @@ -276,7 +273,6 @@ impl Default for ParsedGraphQLSchema { Self { namespace: "".to_string(), identifier: "".to_string(), - exec_source: ExecutionSource::Wasm, type_names: HashSet::new(), typedef_names_to_types: HashMap::new(), enum_names: HashSet::new(), @@ -307,7 +303,6 @@ impl ParsedGraphQLSchema { pub fn new( namespace: &str, identifier: &str, - exec_source: ExecutionSource, schema: Option<&GraphQLSchema>, ) -> ParsedResult { let base_type_names = { @@ -329,7 +324,6 @@ impl ParsedGraphQLSchema { decoder.parsed_graphql_schema.namespace = namespace.to_string(); decoder.parsed_graphql_schema.identifier = identifier.to_string(); - decoder.parsed_graphql_schema.exec_source = exec_source.clone(); decoder.parsed_graphql_schema.version = schema.version.clone(); }; @@ -351,11 +345,6 @@ impl ParsedGraphQLSchema { &self.identifier } - /// Indexer method of execution. - pub fn exec_source(&self) -> &ExecutionSource { - &self.exec_source - } - /// Mapping of object names to objects. pub fn objects(&self) -> &HashMap { &self.objects @@ -1033,7 +1022,6 @@ union Storage = Safe | Vault let parsed = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ); @@ -1099,7 +1087,6 @@ type Bar @entity { let parsed = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ); @@ -1130,7 +1117,6 @@ type TransactionData @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1162,7 +1148,6 @@ union Baz = Foo | Bar | Zoo let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1195,7 +1180,6 @@ union Baz = Foo | Bar | Zoo let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1221,7 +1205,6 @@ type Zoo @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1241,7 +1224,6 @@ type Foo @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1261,7 +1243,6 @@ type Foo @entity(virtual: true) { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1287,7 +1268,6 @@ type Bar @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1373,7 +1353,6 @@ type Bar @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1399,7 +1378,6 @@ type Bar @entity { let _ = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); diff --git a/packages/fuel-indexer-lib/src/lib.rs b/packages/fuel-indexer-lib/src/lib.rs index 69bebe5c0..0b6c58e4b 100644 --- a/packages/fuel-indexer-lib/src/lib.rs +++ b/packages/fuel-indexer-lib/src/lib.rs @@ -10,32 +10,9 @@ pub mod graphql; pub mod manifest; pub mod utils; -use proc_macro2::TokenStream; -use quote::quote; - /// Max size of Postgres array types. pub const MAX_ARRAY_LENGTH: usize = 2500; -/// The source of execution for the indexer. -#[derive(Default, Clone, Debug)] -pub enum ExecutionSource { - /// The indexer is being executed as a standalone binary. - Native, - - /// The indexer is being executed in a WASM runtime. - #[default] - Wasm, -} - -impl ExecutionSource { - pub fn async_awaitness(&self) -> (TokenStream, TokenStream) { - match self { - Self::Native => (quote! {async}, quote! {.await}), - Self::Wasm => (quote! {}, quote! {}), - } - } -} - #[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)] pub enum WasmIndexerError { DeserializationError = 0, diff --git a/packages/fuel-indexer-lib/src/manifest.rs b/packages/fuel-indexer-lib/src/manifest.rs index 20e8dcbd4..24d954282 100644 --- a/packages/fuel-indexer-lib/src/manifest.rs +++ b/packages/fuel-indexer-lib/src/manifest.rs @@ -1,4 +1,4 @@ -use crate::{graphql::GraphQLSchema, ExecutionSource}; +use crate::graphql::GraphQLSchema; use anyhow::Result; use serde::{Deserialize, Serialize}; use std::{ @@ -27,14 +27,10 @@ pub enum ManifestError { /// /// When using a `Wasm` module, the WASM binary at the given path /// is read and those bytes are registered into a `WasmIndexerExecutor`. -/// `Native` modules on the other hand do not require a path, because -/// native indexers compile to binaries that can be executed without having -/// to read the bytes of some compiled module. #[derive(Debug, Deserialize, Serialize, Clone)] #[serde(rename_all = "snake_case")] pub enum Module { Wasm(String), - Native, } impl From for Module { @@ -47,7 +43,6 @@ impl ToString for Module { fn to_string(&self) -> String { match self { Self::Wasm(o) => o.to_string(), - Self::Native => "native".to_string(), } } } @@ -56,9 +51,6 @@ impl AsRef for Module { fn as_ref(&self) -> &Path { match self { Self::Wasm(o) => Path::new(o), - Self::Native => { - unimplemented!("Only WASM execution supports module path access.") - } } } } @@ -140,19 +132,7 @@ impl Manifest { format!("{}.{}", &self.namespace, &self.identifier) } - /// Determine what type of execution source this indexer is using. - pub fn execution_source(&self) -> ExecutionSource { - match &self.module { - Module::Native => ExecutionSource::Native, - Module::Wasm(_o) => ExecutionSource::Wasm, - } - } - /// Return the bytes of the compiled indexer WASM module. - /// - /// Note that as mentioned, because native execution does not compile - /// to a module that can be uploaded (as WASM execution does), there is - /// no way to read module bytes if native execution is specified. pub fn module_bytes(&self) -> ManifestResult> { match &self.module { Module::Wasm(p) => { @@ -164,9 +144,6 @@ impl Manifest { Ok(bytes) } - Module::Native => { - unimplemented!("Native execution does not support this method.") - } } } diff --git a/packages/fuel-indexer-macros/src/decoder.rs b/packages/fuel-indexer-macros/src/decoder.rs index 6a1582b4f..b756d0add 100644 --- a/packages/fuel-indexer-macros/src/decoder.rs +++ b/packages/fuel-indexer-macros/src/decoder.rs @@ -4,12 +4,9 @@ use async_graphql_parser::types::{ }; use async_graphql_parser::{Pos, Positioned}; use async_graphql_value::Name; -use fuel_indexer_lib::{ - graphql::{ - check_for_directive, field_id, types::IdCol, ParsedGraphQLSchema, - MAX_FOREIGN_KEY_LIST_FIELDS, - }, - ExecutionSource, +use fuel_indexer_lib::graphql::{ + check_for_directive, field_id, types::IdCol, ParsedGraphQLSchema, + MAX_FOREIGN_KEY_LIST_FIELDS, }; use fuel_indexer_types::type_id; use proc_macro2::TokenStream; @@ -37,9 +34,6 @@ pub struct ImplementationDecoder { /// Token stream of struct fields. struct_fields: TokenStream, - /// Execution source of indexer. - exec_source: ExecutionSource, - /// `TypeDefinition`. typdef: TypeDefinition, @@ -56,7 +50,6 @@ impl Default for ImplementationDecoder { parameters: quote! {}, hasher: quote! {}, struct_fields: quote! {}, - exec_source: ExecutionSource::Wasm, typdef: TypeDefinition { description: None, extend: false, @@ -154,7 +147,6 @@ impl Decoder for ImplementationDecoder { parameters, hasher, struct_fields, - exec_source: parsed.exec_source().clone(), typdef: typ.clone(), parsed: parsed.clone(), } @@ -246,7 +238,6 @@ impl From for TokenStream { parameters, hasher, struct_fields, - exec_source, typdef, parsed, } = decoder; @@ -266,31 +257,14 @@ impl From for TokenStream { // `TypeDefinition::Union`. let typdef = parsed.get_union(&typdef_name).unwrap_or(&typdef); - let impl_get_or_create = match exec_source { - ExecutionSource::Native => { - quote! { - pub async fn get_or_create(self) -> Self { - match Self::load(self.id.clone()).await { - Some(instance) => instance, - None => { - self.save().await; - self - }, - } - } - } - } - ExecutionSource::Wasm => { - quote! { - pub fn get_or_create(self) -> Self { - match Self::load(self.id.clone()) { - Some(instance) => instance, - None => { - self.save(); - self - }, - } - } + let impl_get_or_create = quote! { + pub fn get_or_create(self) -> Self { + match Self::load(self.id.clone()) { + Some(instance) => instance, + None => { + self.save(); + self + }, } } }; @@ -501,9 +475,6 @@ pub struct ObjectDecoder { /// Tokens for the parameters of the `Entity::new` function. impl_decoder: ImplementationDecoder, - /// The source of the GraphQL schema. - exec_source: ExecutionSource, - /// The unique ID of this GraphQL type. type_id: i64, } @@ -516,7 +487,6 @@ impl Default for ObjectDecoder { field_extractors: quote! {}, from_row: quote! {}, to_row: quote! {}, - exec_source: ExecutionSource::Wasm, impl_decoder: ImplementationDecoder::default(), type_id: std::i64::MAX, } @@ -600,7 +570,6 @@ impl Decoder for ObjectDecoder { field_extractors, from_row, to_row, - exec_source: parsed.exec_source().clone(), impl_decoder: ImplementationDecoder::from_typedef(typ, parsed), type_id, } @@ -760,7 +729,6 @@ impl From for TokenStream { from_row, to_row, impl_decoder, - exec_source, type_id, .. } = decoder; @@ -820,116 +788,30 @@ impl From for TokenStream { quote! { None } }; - let impl_entity = match exec_source { - ExecutionSource::Native => quote! { - #[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] - pub struct #ident { - #struct_fields - } - - #[async_trait::async_trait] - impl<'a> Entity<'a> for #ident { - const TYPE_ID: i64 = #type_id; - const JOIN_METADATA: Option<[Option>; MAX_FOREIGN_KEY_LIST_FIELDS]> = #join_metadata; - - fn from_row(mut vec: Vec) -> Self { - #field_extractors - Self { - #from_row - } - } - - fn to_row(&self) -> Vec { - vec![ - #to_row - ] - } - - async fn save_many_to_many(&self) { - unsafe { - match &db { - Some(d) => { - if let Some(meta) = Self::JOIN_METADATA { - let items = meta.iter().filter_map(|x| x.clone()).collect::>(); - let row = self.to_row(); - let queries = items - .iter() - .map(|item| RawQuery::from_metadata(item, &row)) - .filter(|query| !query.is_empty()) - .map(|query| query.to_string()) - .collect::>(); - - d.lock().await.put_many_to_many_record(queries).await.expect(&format!("Entity::save_many_to_many for {} failed.", stringify!(#ident))); - } - } - None => {} - } - } - } + let impl_entity = quote! { + #[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] + pub struct #ident { + #struct_fields + } - async fn load(id: UID) -> Option { - unsafe { - match &db { - Some(d) => { - match d.lock().await.get_object(Self::TYPE_ID, id.to_string()).await { - Ok(Some(bytes)) => { - let columns: Vec = bincode::deserialize(&bytes).expect("Failed to deserialize Vec for Entity::load."); - let obj = Self::from_row(columns); - Some(obj) - }, - Ok(None) => None, - Err(e) => { - panic!("Entity::load for {} failed.", stringify!(#ident)) - } - } - } - None => None, - } - } - } + impl<'a> Entity<'a> for #ident { + const TYPE_ID: i64 = #type_id; + const JOIN_METADATA: Option<[Option>; MAX_FOREIGN_KEY_LIST_FIELDS]> = #join_metadata; - async fn save(&self) { - unsafe { - match &db { - Some(d) => { - self.save_many_to_many().await; - d.lock().await.put_object( - Self::TYPE_ID, - self.to_row(), - serialize(&self.to_row()) - ).await.expect(&format!("Entity::save for {} failed.", stringify!(#ident))); - } - None => {}, - } - } + fn from_row(mut vec: Vec) -> Self { + #field_extractors + Self { + #from_row } } - }, - ExecutionSource::Wasm => quote! { - #[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] - pub struct #ident { - #struct_fields - } - - impl<'a> Entity<'a> for #ident { - const TYPE_ID: i64 = #type_id; - const JOIN_METADATA: Option<[Option>; MAX_FOREIGN_KEY_LIST_FIELDS]> = #join_metadata; - - fn from_row(mut vec: Vec) -> Self { - #field_extractors - Self { - #from_row - } - } - - fn to_row(&self) -> Vec { - vec![ - #to_row - ] - } + fn to_row(&self) -> Vec { + vec![ + #to_row + ] } - }, + + } }; let impl_new = TokenStream::from(impl_decoder); @@ -1045,7 +927,6 @@ type Person @entity { let schema = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); @@ -1149,7 +1030,6 @@ type Wallet @entity { let schema = ParsedGraphQLSchema::new( "test", "test", - ExecutionSource::Wasm, Some(&GraphQLSchema::new(schema.to_string())), ) .unwrap(); diff --git a/packages/fuel-indexer-macros/src/indexer.rs b/packages/fuel-indexer-macros/src/indexer.rs index ef3182e3d..4758dbbea 100644 --- a/packages/fuel-indexer-macros/src/indexer.rs +++ b/packages/fuel-indexer-macros/src/indexer.rs @@ -1,14 +1,11 @@ use crate::{ - helpers::*, - native::{handler_block_native, native_main}, - parse::IndexerConfig, - schema::process_graphql_schema, + helpers::*, parse::IndexerConfig, schema::process_graphql_schema, wasm::handler_block_wasm, }; use fuel_abi_types::abi::program::TypeDeclaration; use fuel_indexer_lib::{ constants::*, manifest::ContractIds, manifest::Manifest, - utils::workspace_manifest_prefix, ExecutionSource, + utils::workspace_manifest_prefix, }; use fuel_indexer_types::{type_id, FUEL_TYPES_NAMESPACE}; use fuels::{core::codec::resolve_fn_selector, types::param_types::ParamType}; @@ -497,8 +494,6 @@ fn process_fn_items( } }; - let (asyncness, awaitness) = manifest.execution_source().async_awaitness(); - for item in contents { match item { Item::Fn(fn_item) => { @@ -571,7 +566,7 @@ fn process_fn_items( abi_dispatchers.push(quote! { if ( #(#input_checks)&&* ) { - #fn_name(#(#arg_list),*)#awaitness; + #fn_name(#(#arg_list),*); } }); @@ -666,7 +661,7 @@ fn process_fn_items( } } - pub #asyncness fn dispatch(&self) { + pub fn dispatch(&self) { #(#abi_dispatchers)* } } @@ -881,10 +876,10 @@ fn process_fn_items( } } } - decoder.dispatch()#awaitness; + decoder.dispatch(); let metadata = IndexMetadataEntity::new(block.time as u64, block.header.height, block.id); - metadata.save()#awaitness; + metadata.save(); } }, quote! { @@ -926,23 +921,14 @@ pub fn prefix_abi_and_schema_paths( (None, schema.to_string()) } -pub fn get_abi_tokens( - namespace: &str, - abi: &str, - exec_source: ExecutionSource, -) -> proc_macro2::TokenStream { - let no_std = match exec_source { - ExecutionSource::Native => false, - ExecutionSource::Wasm => true, - }; - +pub fn get_abi_tokens(namespace: &str, abi: &str) -> proc_macro2::TokenStream { match Abigen::generate( vec![AbigenTarget { name: namespace.to_string(), abi: abi.to_owned(), program_type: ProgramType::Contract, }], - no_std, + true, ) { Ok(tokens) => tokens, Err(e) => { @@ -971,9 +957,7 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr prefix_abi_and_schema_paths(manifest.abi(), manifest.graphql_schema()); let abi_tokens = match abi { - Some(ref abi_path) => { - get_abi_tokens(manifest.namespace(), abi_path, manifest.execution_source()) - } + Some(ref abi_path) => get_abi_tokens(manifest.namespace(), abi_path), None => proc_macro2::TokenStream::new(), }; @@ -982,50 +966,23 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr manifest.namespace(), manifest.identifier(), &schema_string, - manifest.execution_source(), ); let decl_tokens = additional_declarations(); - let output = match manifest.execution_source() { - ExecutionSource::Native => { - let (handler_block, fn_items) = - process_fn_items(&manifest, abi, indexer_module); - let handler_block = handler_block_native(handler_block); - let naitve_main_tokens = native_main(); + let (handler_block, fn_items) = process_fn_items(&manifest, abi, indexer_module); + let handler_block = handler_block_wasm(handler_block); + let output = quote! { - quote! { + #decl_tokens - #decl_tokens + #abi_tokens - #abi_tokens + #graphql_tokens - #graphql_tokens + #handler_block - #handler_block - - #fn_items - - #naitve_main_tokens - } - } - ExecutionSource::Wasm => { - let (handler_block, fn_items) = - process_fn_items(&manifest, abi, indexer_module); - let handler_block = handler_block_wasm(handler_block); - quote! { - - #decl_tokens - - #abi_tokens - - #graphql_tokens - - #handler_block - - #fn_items - } - } + #fn_items }; proc_macro::TokenStream::from(output) diff --git a/packages/fuel-indexer-macros/src/lib.rs b/packages/fuel-indexer-macros/src/lib.rs index ad6d2282c..d7f941b3e 100644 --- a/packages/fuel-indexer-macros/src/lib.rs +++ b/packages/fuel-indexer-macros/src/lib.rs @@ -4,7 +4,6 @@ extern crate proc_macro; pub(crate) mod decoder; pub(crate) mod helpers; pub(crate) mod indexer; -pub(crate) mod native; pub(crate) mod parse; pub(crate) mod schema; pub(crate) mod wasm; diff --git a/packages/fuel-indexer-macros/src/native.rs b/packages/fuel-indexer-macros/src/native.rs deleted file mode 100644 index c9efedd92..000000000 --- a/packages/fuel-indexer-macros/src/native.rs +++ /dev/null @@ -1,187 +0,0 @@ -use quote::quote; - -/// Generate the handler block for the native execution environment. -pub fn handler_block_native( - handler_block: proc_macro2::TokenStream, -) -> proc_macro2::TokenStream { - let native_prelude = native_prelude(); - - quote! { - - #native_prelude - - async fn handle_events(blocks: Vec, db_conn: Arc>) -> IndexerResult<()> { - - unsafe { - if db.is_none() { - db = Some(db_conn); - } - } - - #handler_block - - Ok(()) - - } - } -} - -/// Prelude imports for the `indexer` module. -/// -/// These imports are placed below the top-level lib imports, so any -/// dependencies imported here will only be within the scope of the -/// indexer module, not within the scope of the entire lib module. -fn native_prelude() -> proc_macro2::TokenStream { - quote! { - static mut db: Option>> = None; - - use fuel_indexer_utils::plugin::types::*; - use fuel_indexer_utils::plugin::native::*; - use fuel_indexer_utils::plugin::{serde_json, serialize, deserialize, bincode}; - use fuel_indexer_utils::plugin::serde::{Deserialize, Serialize}; - use fuels::{ - core::{codec::ABIDecoder, Configurables, traits::{Parameterize, Tokenizable}}, - types::{StringToken}, - }; - - } -} - -/// Generate the `main` function for the native execution module. -/// -/// This should be an exact reference to `fuel_indexer::main` with a few exceptions: -/// - No references to an embedded database -/// - `--manifest` is a required option. -/// - Handlers are registered via `register_native_indexer` instead of `register_indexer_from_manifest`. -pub fn native_main() -> proc_macro2::TokenStream { - quote! { - // Returns a future which completes when a shutdown signal has been received. - fn shutdown_signal_handler() -> std::io::Result> { - let mut sighup: Signal = signal(SignalKind::hangup())?; - let mut sigterm: Signal = signal(SignalKind::terminate())?; - let mut sigint: Signal = signal(SignalKind::interrupt())?; - - let future = async move { - #[cfg(unix)] - { - tokio::select! { - _ = sighup.recv() => { - info!("Received SIGHUP. Stopping services."); - } - _ = sigterm.recv() => { - info!("Received SIGTERM. Stopping services."); - } - _ = sigint.recv() => { - info!("Received SIGINT. Stopping services."); - } - } - } - - #[cfg(not(unix))] - { - signal::ctrl_c().await?; - info!("Received CTRL+C. Stopping services."); - } - }; - - Ok(future) - } - - #[tokio::main] - async fn main() -> anyhow::Result<()> { - - let args = IndexerArgs::parse(); - - let IndexerArgs { manifest, .. } = args.clone(); - - let mut subsystems: tokio::task::JoinSet<()> = tokio::task::JoinSet::new(); - - subsystems.spawn(shutdown_signal_handler()?); - - let config = args - .config - .clone() - .map(IndexerConfig::from_file) - .unwrap_or(Ok(IndexerConfig::from(args)))?; - - init_logging(&config).await?; - - info!("Configuration: {:?}", config); - - #[allow(unused)] - let (tx, rx) = channel::(defaults::SERVICE_REQUEST_CHANNEL_SIZE); - - let pool = IndexerConnectionPool::connect(&config.database.to_string()).await?; - - if config.run_migrations { - let mut c = pool.acquire().await?; - queries::run_migration(&mut c).await?; - } - - let mut service = IndexerService::new(config.clone(), pool.clone(), rx).await?; - - if manifest.is_none() { - panic!("Manifest required to use native execution."); - } - - let p = manifest.unwrap(); - if config.verbose { - info!("Using manifest file located at '{}'", p.display()); - } - let manifest = Manifest::from_file(&p)?; - service.register_native_indexer(manifest, handle_events).await?; - - subsystems.spawn(async { - let result = service.run().await; - if let Err(e) = result { - tracing::error!("Indexer Service failed: {e}"); - } - }); - - // Fuel indexer API web server always on due to feature-flagging - // - // TODO: https://github.com/FuelLabs/fuel-indexer/issues/1393 - // - // #[cfg(feature = "api-server")] - subsystems.spawn({ - let config = config.clone(); - async { - if let Err(e) = WebApi::build_and_run(config, pool, tx).await { - tracing::error!("Api Server failed: {e}"); - } - } - }); - - // Fuel core components removed due to feature-flagging - // - // TODO: https://github.com/FuelLabs/fuel-indexer/issues/1393 - // - // #[cfg(feature = "fuel-core-lib")] - // { - // use fuel_core::service::{Config, FuelService}; - // use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - - // if config.local_fuel_node { - // let config = Config { - // addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 4000), - // ..Config::local_node() - // }; - // subsystems.spawn(async move { - // if let Err(e) = FuelService::new_node(config).await { - // tracing::error!("Fuel Node failed: {e}"); - // }; - // }); - // } - // }; - - // Each subsystem runs its own loop, and we require all subsystems for the - // Indexer service to operate correctly. If any of the subsystems stops - // running, the entire Indexer Service exits. - if subsystems.join_next().await.is_some() { - subsystems.shutdown().await; - } - - Ok(()) - } - } -} diff --git a/packages/fuel-indexer-macros/src/schema.rs b/packages/fuel-indexer-macros/src/schema.rs index a50b752ae..f964546f0 100644 --- a/packages/fuel-indexer-macros/src/schema.rs +++ b/packages/fuel-indexer-macros/src/schema.rs @@ -2,9 +2,7 @@ use crate::{decoder::*, helpers::*}; use async_graphql_parser::types::{TypeDefinition, TypeKind}; use fuel_indexer_lib::graphql::GraphQLSchema; -use fuel_indexer_lib::{ - graphql::ParsedGraphQLSchema, utils::workspace_manifest_prefix, ExecutionSource, -}; +use fuel_indexer_lib::{graphql::ParsedGraphQLSchema, utils::workspace_manifest_prefix}; use quote::quote; use std::fs::File; use std::io::Read; @@ -37,7 +35,6 @@ pub(crate) fn process_graphql_schema( namespace: &str, identifier: &str, schema_path: &str, - exec_source: ExecutionSource, ) -> proc_macro2::TokenStream { let namespace_tokens = const_item("NAMESPACE", namespace); let identifer_tokens = const_item("IDENTIFIER", identifier); @@ -73,9 +70,8 @@ pub(crate) fn process_graphql_schema( #toolchain_version_tokens }; - let schema = - ParsedGraphQLSchema::new(namespace, identifier, exec_source, Some(&schema)) - .expect("Failed to parse GraphQL schema."); + let schema = ParsedGraphQLSchema::new(namespace, identifier, Some(&schema)) + .expect("Failed to parse GraphQL schema."); for (_, type_def) in schema.type_defs().iter() { if let Some(def) = process_type_def(&schema, type_def) { diff --git a/packages/fuel-indexer-plugin/Cargo.toml b/packages/fuel-indexer-plugin/Cargo.toml index 35d62d5f8..e4eac34cb 100644 --- a/packages/fuel-indexer-plugin/Cargo.toml +++ b/packages/fuel-indexer-plugin/Cargo.toml @@ -13,35 +13,12 @@ description = "Fuel Indexer Plugin" crate-type = ['rlib'] [dependencies] -anyhow = { version = "1.0", default-features = false, optional = true } -async-trait = { version = "0.1", optional = true } bincode = { workspace = true } -fuel-indexer = { workspace = true, features = ["api-server"], optional = true } -fuel-indexer-api-server = { workspace = true, optional = true } -fuel-indexer-database = { workspace = true, optional = true } fuel-indexer-lib = { workspace = true } fuel-indexer-schema = { workspace = true, default-features = false } fuel-indexer-types = { workspace = true } -futures = { version = "0.3", optional = true } getrandom = { version = "0.2", features = ["js"] } hex = "0.4" serde = { workspace = true } serde_json = { workspace = true } sha2 = { version = "0.10" } -tokio = { features = ["macros", "rt-multi-thread", "sync", "process"], optional = true, workspace = true } -tracing = { optional = true, workspace = true } -tracing-subscriber = { version = "0.2", features = ["env-filter"], optional = true } - -[features] -default = [] -native-execution = [ - "anyhow", - "async-trait", - "fuel-indexer-api-server", - "fuel-indexer-database", - "fuel-indexer", - "futures", - "tokio", - "tracing-subscriber", - "tracing", -] diff --git a/packages/fuel-indexer-plugin/src/lib.rs b/packages/fuel-indexer-plugin/src/lib.rs index 35650c192..94f3c6725 100644 --- a/packages/fuel-indexer-plugin/src/lib.rs +++ b/packages/fuel-indexer-plugin/src/lib.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "native-execution")] -pub mod native; pub mod wasm; pub mod types { diff --git a/packages/fuel-indexer-plugin/src/native.rs b/packages/fuel-indexer-plugin/src/native.rs deleted file mode 100644 index b275a0541..000000000 --- a/packages/fuel-indexer-plugin/src/native.rs +++ /dev/null @@ -1,77 +0,0 @@ -extern crate alloc; - -use alloc::vec::Vec; -use async_trait; -use fuel_indexer_schema::{join::JoinMetadata, FtColumn}; - -pub use anyhow; -pub use fuel_indexer::prelude::{ - Arc, Database, IndexerError, IndexerResult, IndexerService, Mutex, - NativeIndexExecutor, -}; -pub use fuel_indexer_api_server::api::WebApi; -pub use fuel_indexer_database::{queries, IndexerConnectionPool}; -pub use fuel_indexer_lib::{ - config::{cli::Parser, IndexerArgs, IndexerConfig}, - defaults, - graphql::MAX_FOREIGN_KEY_LIST_FIELDS, - manifest::Manifest, - utils::{init_logging, ServiceRequest}, -}; -use fuel_indexer_types::scalar::UID; -pub use futures; -pub use sha2::{Digest, Sha256}; -pub use std::{ - collections::{HashMap, HashSet}, - str::FromStr, -}; -pub use tokio; -pub use tokio::signal::unix::{signal, Signal, SignalKind}; -pub use tokio::sync::mpsc::channel; -pub use tracing; -pub use tracing_subscriber; -pub use tracing_subscriber::filter::EnvFilter; - -pub struct Logger; - -impl Logger { - pub fn error(log: &str) { - tracing::error!(log); - } - - pub fn warn(log: &str) { - tracing::warn!(log); - } - - pub fn info(log: &str) { - tracing::info!(log); - } - - pub fn debug(log: &str) { - tracing::debug!(log); - } - - pub fn trace(log: &str) { - tracing::trace!(log); - } -} - -#[async_trait::async_trait] -pub trait Entity<'a>: Sized + PartialEq + Eq + std::fmt::Debug { - const TYPE_ID: i64; - const JOIN_METADATA: Option<[Option>; MAX_FOREIGN_KEY_LIST_FIELDS]>; - - async fn save_many_to_many(&self); - - fn from_row(vec: Vec) -> Self; - - fn to_row(&self) -> Vec; - - fn type_id(&self) -> i64 { - Self::TYPE_ID - } - - async fn load(id: UID) -> Option; - - async fn save(&self); -} diff --git a/packages/fuel-indexer-schema/src/db/manager.rs b/packages/fuel-indexer-schema/src/db/manager.rs index afae3e701..79315f157 100644 --- a/packages/fuel-indexer-schema/src/db/manager.rs +++ b/packages/fuel-indexer-schema/src/db/manager.rs @@ -5,7 +5,7 @@ use crate::db::{tables::IndexerSchema, IndexerSchemaDbResult}; use fuel_indexer_database::{queries, IndexerConnection, IndexerConnectionPool}; -use fuel_indexer_lib::{graphql::GraphQLSchema, ExecutionSource}; +use fuel_indexer_lib::graphql::GraphQLSchema; use tracing::info; /// `SchemaManager` is a wrapper for `IndexerSchema` that also provides @@ -26,7 +26,6 @@ impl SchemaManager { namespace: &str, identifier: &str, schema: GraphQLSchema, - exec_source: ExecutionSource, conn: &mut IndexerConnection, ) -> IndexerSchemaDbResult<()> { let version = schema.version(); @@ -38,9 +37,8 @@ impl SchemaManager { identifier, &schema, self.pool.database_type(), - exec_source.clone(), )? - .commit(&schema, exec_source, conn) + .commit(&schema, conn) .await?; } Ok(()) diff --git a/packages/fuel-indexer-schema/src/db/tables.rs b/packages/fuel-indexer-schema/src/db/tables.rs index bc569a363..2f1bdaf29 100644 --- a/packages/fuel-indexer-schema/src/db/tables.rs +++ b/packages/fuel-indexer-schema/src/db/tables.rs @@ -10,7 +10,7 @@ use fuel_indexer_database::{ queries, types::*, DbType, IndexerConnection, IndexerConnectionPool, }; use fuel_indexer_lib::graphql::{GraphQLSchema, ParsedGraphQLSchema}; -use fuel_indexer_lib::{manifest::Manifest, ExecutionSource}; +use fuel_indexer_lib::manifest::Manifest; use itertools::Itertools; /// `IndexerSchema` is used to encapsulate most of the logic related to parsing @@ -44,19 +44,13 @@ impl IndexerSchema { identifier: &str, schema: &GraphQLSchema, db_type: DbType, - exec_source: ExecutionSource, ) -> IndexerSchemaDbResult { Ok(IndexerSchema { db_type, namespace: namespace.to_string(), identifier: identifier.to_string(), schema: schema.to_owned(), - parsed: ParsedGraphQLSchema::new( - namespace, - identifier, - exec_source, - Some(schema), - )?, + parsed: ParsedGraphQLSchema::new(namespace, identifier, Some(schema))?, tables: Vec::new(), }) } @@ -75,15 +69,10 @@ impl IndexerSchema { pub async fn commit( mut self, schema: &GraphQLSchema, - exec_source: ExecutionSource, conn: &mut IndexerConnection, ) -> IndexerSchemaDbResult { - let parsed_schema = ParsedGraphQLSchema::new( - &self.namespace, - &self.identifier, - exec_source, - Some(schema), - )?; + let parsed_schema = + ParsedGraphQLSchema::new(&self.namespace, &self.identifier, Some(schema))?; let mut statements = Vec::new(); self.schema = schema.to_owned(); @@ -206,15 +195,10 @@ impl IndexerSchema { let IndexerAsset { bytes, .. } = queries::indexer_asset(&mut conn, &indexer_id, IndexerAssetType::Manifest) .await?; - let manifest = Manifest::try_from(&bytes)?; + let _manifest = Manifest::try_from(&bytes)?; let schema = GraphQLSchema::new(root.schema.clone()); - let parsed = ParsedGraphQLSchema::new( - namespace, - identifier, - manifest.execution_source(), - Some(&schema), - )?; + let parsed = ParsedGraphQLSchema::new(namespace, identifier, Some(&schema))?; let tables = parsed .storage_backed_typedefs() diff --git a/packages/fuel-indexer-tests/scripts/test-examples.bash b/packages/fuel-indexer-tests/scripts/test-examples.bash index 1e60efb18..e8fba8c38 100644 --- a/packages/fuel-indexer-tests/scripts/test-examples.bash +++ b/packages/fuel-indexer-tests/scripts/test-examples.bash @@ -58,34 +58,6 @@ sleep 2 forc_index_kill -# ******************************** -# examples/greetings-native -# ******************************** - -# cd ../greetings-native - -# forc-index build --path ./greetings-native-indexer --native - -# # Update manifest with paths relative to the example due to cargo workspace -# sed -i \ -# "s|^graphql_schema: examples/greetings-native/greetings-native-indexer/schema/greetings_native_indexer\.schema\.graphql|graphql_schema: $PWD/greetings-native-indexer/schema/greetings_native_indexer.schema.graphql|" \ -# ./greetings-native-indexer/greetings_native_indexer.manifest.yaml - -# Start indexer in the background -# forc-index run-native --path ./greetings-native-indexer -- --run-migrations --postgres-password my-secret -# sleep 60 - -# check_service_status - -# cargo run -p greetings-data --bin greetings-data -# sleep 5 - -# # Check data is indexed -# echo "SELECT COUNT(*) FROM fuellabs_greetings_native.salutation;" | psql -h localhost -p 5432 -U postgres -# sleep 2 - -# forc_index_kill - # ******************************** # examples/fuel-explorer # ******************************** diff --git a/packages/fuel-indexer-tests/tests/commands.rs b/packages/fuel-indexer-tests/tests/commands.rs index c19b3e684..d04c5b1aa 100644 --- a/packages/fuel-indexer-tests/tests/commands.rs +++ b/packages/fuel-indexer-tests/tests/commands.rs @@ -127,12 +127,3 @@ fn test_forc_index_start_help_output() { .unwrap(); insta::assert_snapshot!(output); } - -#[test] -fn test_forc_index_run_native_help_output() { - let output = cmd!(FORC_INDEX, "run-native", "--help") - .pipe(cmd!("tail", "-n", "+2")) - .read() - .unwrap(); - insta::assert_snapshot!(output); -} diff --git a/packages/fuel-indexer-tests/tests/config.rs b/packages/fuel-indexer-tests/tests/config.rs index 71effa389..abcbaf9f7 100644 --- a/packages/fuel-indexer-tests/tests/config.rs +++ b/packages/fuel-indexer-tests/tests/config.rs @@ -27,19 +27,4 @@ fn test_rustc_version_in_default_indexer_cargo_manifest_matches_project_rustc_ve let cargo_toml: Config = toml::from_str(&cargo_toml).unwrap(); assert_eq!(cargo_toml.package.rust_version, rustc_version.to_string()); fs::remove_dir_all("./indexer-test").unwrap(); - - let _ = Command::new("forc-index") - .arg("new") - .arg("indexer-test") - .arg("--namespace") - .arg("fuellabs") - .arg("--native") - .spawn() - .unwrap() - .wait() - .unwrap(); - let cargo_toml = fs::read_to_string("./indexer-test/Cargo.toml").unwrap(); - let cargo_toml: Config = toml::from_str(&cargo_toml).unwrap(); - assert_eq!(cargo_toml.package.rust_version, rustc_version.to_string()); - fs::remove_dir_all("./indexer-test").unwrap(); } diff --git a/packages/fuel-indexer-tests/tests/service.rs b/packages/fuel-indexer-tests/tests/service.rs index 814dba91b..866ab78fb 100644 --- a/packages/fuel-indexer-tests/tests/service.rs +++ b/packages/fuel-indexer-tests/tests/service.rs @@ -83,9 +83,6 @@ async fn test_wasm_executor_can_meter_execution() { } } } - _ => panic!( - "Expected a WASM module in the manifest but got a Native module instead." - ), } } @@ -205,8 +202,5 @@ async fn test_wasm_executor_error_codes() { } } } - _ => panic!( - "Expected a WASM module in the manifest but got a Native module instead." - ), } } diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_build_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_build_help_output.snap index 5bf7d8868..b15a2eb3d 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_build_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_build_help_output.snap @@ -12,6 +12,5 @@ OPTIONS: -h, --help Print help information --locked Ensure that the Cargo.lock file is up-to-date. -m, --manifest Manifest file name of indexer being built. - --native Building for native execution. -p, --path Path to the indexer project. -v, --verbose Enable verbose output. diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_deploy_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_deploy_help_output.snap index e96b2108d..fcfb4ac82 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_deploy_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_deploy_help_output.snap @@ -13,7 +13,6 @@ OPTIONS: -h, --help Print help information --locked Ensure that the Cargo.lock file is up-to-date. -m, --manifest Path to the manifest of indexer project being deployed. - --native Building for native execution. -p, --path Path to the indexer project. --remove-data Remove all indexed data when replacing an existing indexer. --replace-indexer If an indexer with the same UID exists, remove it. diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_help_output.snap index bccc48fe5..ee6f118d8 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_help_output.snap @@ -12,17 +12,15 @@ OPTIONS: -V, --version Print version information SUBCOMMANDS: - auth Authenticate against an indexer service - build Build an indexer - check Check for Fuel indexer components - deploy Deploy an indexer to an indexer service - help Print this message or the help of the given subcommand(s) - kill Kill the indexer process. Note that this command will kill any process - listening on the default indexer port or the port specified by the `--port` - flag - new Create a new indexer project in a new directory - postgres Fuel Postgres Orchestrator - remove Stop and remove a running indexer - run-native Run a native indexer - start Standalone binary for the Fuel indexer service - status Check the status of a registered indexer + auth Authenticate against an indexer service + build Build an indexer + check Check for Fuel indexer components + deploy Deploy an indexer to an indexer service + help Print this message or the help of the given subcommand(s) + kill Kill the indexer process. Note that this command will kill any process listening + on the default indexer port or the port specified by the `--port` flag + new Create a new indexer project in a new directory + postgres Fuel Postgres Orchestrator + remove Stop and remove a running indexer + start Standalone binary for the Fuel indexer service + status Check the status of a registered indexer diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_new_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_new_help_output.snap index e87962b75..66f5c039a 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_new_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_new_help_output.snap @@ -15,5 +15,4 @@ OPTIONS: -h, --help Print help information --name Name of indexer. --namespace Namespace to which indexer belongs. - --native Initialize an indexer with native execution enabled. -v, --verbose Enable verbose output. diff --git a/packages/fuel-indexer-utils/Cargo.toml b/packages/fuel-indexer-utils/Cargo.toml index 48831f9fb..2b1e77944 100644 --- a/packages/fuel-indexer-utils/Cargo.toml +++ b/packages/fuel-indexer-utils/Cargo.toml @@ -13,6 +13,3 @@ description = "Utilities for use in an indexer to be deployed on the Fuel indexe fuel-indexer-macros = { default-features = false, workspace = true } fuel-indexer-plugin = { workspace = true } serde = { workspace = true, features = ["derive"] } - -[features] -native-execution = ["fuel-indexer-plugin/native-execution"] diff --git a/packages/fuel-indexer/src/executor.rs b/packages/fuel-indexer/src/executor.rs index 00fbe7fa3..53034a6f2 100644 --- a/packages/fuel-indexer/src/executor.rs +++ b/packages/fuel-indexer/src/executor.rs @@ -565,8 +565,6 @@ pub async fn retrieve_blocks_from_node( } /// Executors are responsible for the actual indexing of data. -/// -/// Executors can either be WASM modules or native Rust functions. #[async_trait] pub trait Executor where @@ -620,107 +618,6 @@ impl IndexEnv { } } -/// Native executors differ from WASM executors in that they are not sandboxed; they are merely a -/// set of native Rust functions that (run/execute/are spawned) directly from the indexer service -/// process. -pub struct NativeIndexExecutor -where - F: Future> + Send, -{ - /// Reference to the connected database. - db: Arc>, - - /// Manifest of the indexer. - manifest: Manifest, - - /// Function that handles events. - handle_events_fn: fn(Vec, Arc>) -> F, - - /// Kill switch. When set to true, the indexer must stop execution. - kill_switch: Arc, -} - -impl NativeIndexExecutor -where - F: Future> + Send, -{ - /// Create a new `NativeIndexExecutor`. - pub async fn new( - manifest: &Manifest, - pool: IndexerConnectionPool, - config: &IndexerConfig, - handle_events_fn: fn(Vec, Arc>) -> F, - ) -> IndexerResult { - let mut db = Database::new(pool.clone(), manifest, config).await; - let mut conn = pool.acquire().await?; - let version = fuel_indexer_database::queries::type_id_latest( - &mut conn, - manifest.namespace(), - manifest.identifier(), - ) - .await?; - db.load_schema(version).await?; - let kill_switch = Arc::new(AtomicBool::new(false)); - Ok(Self { - db: Arc::new(Mutex::new(db)), - manifest: manifest.to_owned(), - handle_events_fn, - kill_switch, - }) - } - - /// Create a new `NativeIndexExecutor`. - pub async fn create( - config: &IndexerConfig, - manifest: &Manifest, - pool: IndexerConnectionPool, - handle_events: fn(Vec, Arc>) -> F, - ) -> IndexerResult { - NativeIndexExecutor::new(manifest, pool.clone(), config, handle_events).await - } -} - -#[async_trait] -impl Executor for NativeIndexExecutor -where - F: Future> + Send, -{ - /// Handle events for native executor. - async fn handle_events(&mut self, blocks: Vec) -> IndexerResult<()> { - self.db.lock().await.start_transaction().await?; - let res = (self.handle_events_fn)(blocks, self.db.clone()).await; - let uid = self.manifest.uid(); - if let Err(e) = res { - error!("NativeIndexExecutor({uid}) handle_events failed: {e:?}."); - self.db.lock().await.revert_transaction().await?; - return Err(IndexerError::NativeExecutionRuntimeError); - } else { - // Do not commit if kill switch has been triggered. - if self.kill_switch.load(Ordering::SeqCst) { - self.db.lock().await.revert_transaction().await?; - } else { - self.db.lock().await.commit_transaction().await?; - } - } - Ok(()) - } - - fn kill_switch(&self) -> &Arc { - &self.kill_switch - } - - fn manifest(&self) -> &Manifest { - &self.manifest - } - - async fn get_panic_message(&self) -> IndexerResult { - return Err(anyhow::anyhow!( - "get_panic_message() not supported in native exetutor." - ) - .into()); - } -} - /// WASM executors are the primary means of execution. /// /// WASM executors contain a WASM module that is instantiated and executed by the indexer service on a diff --git a/packages/fuel-indexer/src/lib.rs b/packages/fuel-indexer/src/lib.rs index 27d70924f..8bd262928 100644 --- a/packages/fuel-indexer/src/lib.rs +++ b/packages/fuel-indexer/src/lib.rs @@ -8,7 +8,7 @@ pub(crate) mod queries; mod service; pub use database::Database; -pub use executor::{Executor, IndexEnv, NativeIndexExecutor, WasmIndexExecutor}; +pub use executor::{Executor, IndexEnv, WasmIndexExecutor}; pub use fuel_indexer_database::IndexerDatabaseError; pub use fuel_indexer_lib::{ config::IndexerConfig, @@ -26,8 +26,7 @@ use openssl as _; pub mod prelude { pub use super::{ Database, Executor, FtColumn, IndexEnv, IndexerConfig, IndexerError, - IndexerResult, IndexerService, Manifest, Module, NativeIndexExecutor, - WasmIndexExecutor, + IndexerResult, IndexerService, Manifest, Module, WasmIndexExecutor, }; pub use async_std::sync::{Arc, Mutex}; pub use fuel_indexer_lib::config::{DatabaseConfig, FuelClientConfig, WebApiConfig}; @@ -76,8 +75,6 @@ pub enum IndexerError { ManifestError(#[from] ManifestError), #[error("Error creating wasm executor.")] WasmExecutionInstantiationError, - #[error("Error creating native executor.")] - NativeExecutionInstantiationError, #[error("Native execution runtime error.")] NativeExecutionRuntimeError, #[error("Tokio time error: {0:?}")] diff --git a/packages/fuel-indexer/src/service.rs b/packages/fuel-indexer/src/service.rs index f58c14eaf..a05569e27 100644 --- a/packages/fuel-indexer/src/service.rs +++ b/packages/fuel-indexer/src/service.rs @@ -1,9 +1,9 @@ use crate::{ - executor::{NativeIndexExecutor, WasmIndexExecutor}, - Database, Executor, IndexerConfig, IndexerError, IndexerResult, Manifest, + executor::WasmIndexExecutor, Executor, IndexerConfig, IndexerError, IndexerResult, + Manifest, }; use anyhow::Context; -use async_std::sync::{Arc, Mutex}; +use async_std::sync::Arc; use async_std::{fs::File, io::ReadExt}; use fuel_indexer_database::{ queries, @@ -12,8 +12,6 @@ use fuel_indexer_database::{ }; use fuel_indexer_lib::utils::ServiceRequest; use fuel_indexer_schema::db::manager::SchemaManager; -use fuel_indexer_types::fuel::BlockData; -use futures::Future; use std::collections::HashMap; use std::marker::Send; use std::sync::atomic::{AtomicBool, Ordering}; @@ -122,7 +120,6 @@ impl IndexerService { manifest.namespace(), manifest.identifier(), schema, - manifest.execution_source(), &mut conn, ) .await?; @@ -137,9 +134,6 @@ impl IndexerService { file.read_to_end(&mut bytes).await?; bytes } - crate::Module::Native => { - return Err(IndexerError::NativeExecutionInstantiationError) - } }; let executor = WasmIndexExecutor::create( @@ -220,52 +214,6 @@ impl IndexerService { Ok(()) } - /// Register a native indexer to the `IndexerService`, from a `Manifest`. - pub async fn register_native_indexer< - T: Future> + Send + 'static, - >( - &mut self, - mut manifest: Manifest, - handle_events: fn(Vec, Arc>) -> T, - ) -> IndexerResult<()> { - let mut conn = self.pool.acquire().await?; - let _index = queries::register_indexer( - &mut conn, - manifest.namespace(), - manifest.identifier(), - None, - ) - .await?; - - self.manager - .new_schema( - manifest.namespace(), - manifest.identifier(), - manifest.graphql_schema_content()?, - manifest.execution_source(), - &mut conn, - ) - .await?; - - let start_block = get_start_block(&mut conn, &manifest).await.unwrap_or(1); - manifest.set_start_block(start_block); - - let uid = manifest.uid(); - let executor = NativeIndexExecutor::::create( - &self.config, - &manifest, - self.pool.clone(), - handle_events, - ) - .await?; - - info!("Registered NativeIndex({})", uid); - - self.start_executor(executor).await?; - - Ok(()) - } - /// Kick it off! Run the indexer service loop, listening to service messages primarily coming from the web server. pub async fn run(mut self) -> IndexerResult<()> { loop { diff --git a/plugins/forc-index/src/cli.rs b/plugins/forc-index/src/cli.rs index f9ca11039..38113ec7b 100644 --- a/plugins/forc-index/src/cli.rs +++ b/plugins/forc-index/src/cli.rs @@ -3,8 +3,8 @@ pub(crate) use crate::commands::{ auth::Command as AuthCommand, build::Command as BuildCommand, check::Command as CheckCommand, deploy::Command as DeployCommand, kill::Command as KillCommand, new::Command as NewCommand, - remove::Command as RemoveCommand, run_native::Command as RunNativeCommand, - start::Command as StartCommand, status::Command as StatusCommand, + remove::Command as RemoveCommand, start::Command as StartCommand, + status::Command as StatusCommand, }; use clap::{Parser, Subcommand}; use forc_postgres::{ @@ -31,7 +31,6 @@ pub enum ForcIndex { New(NewCommand), Postgres(ForcPostgresOpt), Remove(RemoveCommand), - RunNative(RunNativeCommand), Start(Box), Status(StatusCommand), } @@ -59,6 +58,5 @@ pub async fn run_cli() -> Result<(), anyhow::Error> { }, ForcIndex::Kill(command) => crate::commands::kill::exec(command), ForcIndex::Status(command) => crate::commands::status::exec(command).await, - ForcIndex::RunNative(command) => crate::commands::run_native::exec(command).await, } } diff --git a/plugins/forc-index/src/commands/build.rs b/plugins/forc-index/src/commands/build.rs index 89e882ce2..ec2ea75d6 100644 --- a/plugins/forc-index/src/commands/build.rs +++ b/plugins/forc-index/src/commands/build.rs @@ -22,28 +22,11 @@ pub struct Command { #[clap(long, help = "Ensure that the Cargo.lock file is up-to-date.")] pub locked: bool, - /// Building for native execution. - #[clap(long, help = "Building for native execution.")] - pub native: bool, - /// Enable verbose output. #[clap(short, long, help = "Enable verbose output.")] pub verbose: bool, } -impl Default for Command { - fn default() -> Self { - Command { - manifest: Some(String::new()), - path: None, - debug: false, - verbose: false, - locked: false, - native: false, - } - } -} - pub fn exec(command: Command) -> Result<()> { forc_index_build::init(command)?; Ok(()) diff --git a/plugins/forc-index/src/commands/deploy.rs b/plugins/forc-index/src/commands/deploy.rs index ba9abaa2f..06c0053b2 100644 --- a/plugins/forc-index/src/commands/deploy.rs +++ b/plugins/forc-index/src/commands/deploy.rs @@ -38,10 +38,6 @@ pub struct Command { #[clap(long, help = "Ensure that the Cargo.lock file is up-to-date.")] pub locked: bool, - /// Building for native execution. - #[clap(long, help = "Building for native execution.")] - pub native: bool, - /// Enable verbose logging. #[clap(short, long, help = "Enable verbose logging.")] pub verbose: bool, @@ -62,23 +58,6 @@ pub struct Command { pub remove_data: bool, } -impl Default for Command { - fn default() -> Self { - Command { - url: "http://127.0.0.1:29987".to_string(), - manifest: Some(String::new()), - path: None, - auth: Some("".to_string()), - debug: false, - verbose: false, - locked: false, - native: false, - skip_build: false, - replace_indexer: false, - remove_data: false, - } - } -} pub async fn exec(command: Command) -> Result<()> { forc_index_deploy::init(command).await?; Ok(()) diff --git a/plugins/forc-index/src/commands/mod.rs b/plugins/forc-index/src/commands/mod.rs index 8d20177c0..091d8a1a4 100644 --- a/plugins/forc-index/src/commands/mod.rs +++ b/plugins/forc-index/src/commands/mod.rs @@ -5,6 +5,5 @@ pub mod deploy; pub mod kill; pub mod new; pub mod remove; -pub mod run_native; pub mod start; pub mod status; diff --git a/plugins/forc-index/src/commands/new.rs b/plugins/forc-index/src/commands/new.rs index 1a23b3063..1120153d5 100644 --- a/plugins/forc-index/src/commands/new.rs +++ b/plugins/forc-index/src/commands/new.rs @@ -17,10 +17,6 @@ pub struct Command { #[clap(long, help = "Namespace to which indexer belongs.")] pub namespace: Option, - /// Initialize an indexer with native execution enabled. - #[clap(long, help = "Initialize an indexer with native execution enabled.")] - pub native: bool, - /// Resolve indexer asset filepaths using absolute paths. #[clap(long, help = "Resolve indexer asset filepaths using absolute paths.")] pub absolute_paths: bool, diff --git a/plugins/forc-index/src/commands/run_native.rs b/plugins/forc-index/src/commands/run_native.rs deleted file mode 100644 index 52eedf51f..000000000 --- a/plugins/forc-index/src/commands/run_native.rs +++ /dev/null @@ -1,54 +0,0 @@ -use crate::ops::forc_index_run_native; -use anyhow::Result; -use clap::Parser; -use std::path::PathBuf; - -/// Run a native indexer. -#[derive(Debug, Parser)] -pub struct Command { - /// Manifest file name of indexer being built. - #[clap(short, long, help = "Manifest file name of indexer being built.")] - pub manifest: Option, - - /// Path of indexer project. - #[clap(short, long, help = "Path to the indexer project.")] - pub path: Option, - - /// Build optimized artifacts with the debug profile. - #[clap(short, long, help = "Build artifacts with the debug profile.")] - pub debug: bool, - - /// Ensure that the Cargo.lock file is up-to-date. - #[clap(long, help = "Ensure that the Cargo.lock file is up-to-date.")] - pub locked: bool, - - /// Do not build before deploying. - #[clap(long, help = "Do not build before deploying.")] - pub skip_build: bool, - - /// Enable verbose output. - #[clap(short, long, help = "Enable verbose output.")] - pub verbose: bool, - - /// Path to native indexer binary (if not using default location). - #[clap( - long, - help = "Path to native indexer binary (if not using default location)." - )] - pub bin: Option, - - /// Extra passed to `fuel-indexer run` - /// - /// Example usage: `forc-index run-native --path . -- --run-migrations --stop-idle-indexers` - #[clap( - multiple = true, - last = true, - help = "Extra passed to `fuel-indexer run`" - )] - pub args: Vec, -} - -pub async fn exec(command: Command) -> Result<()> { - forc_index_run_native::init(command).await?; - Ok(()) -} diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 8cc2ad4e3..87bdb4d3d 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -4,7 +4,6 @@ use std::path::PathBuf; pub const CARGO_MANIFEST_FILE_NAME: &str = "Cargo.toml"; pub const INDEXER_LIB_FILENAME: &str = "lib.rs"; -pub const INDEXER_BINARY_FILENAME: &str = "main.rs"; pub const CARGO_CONFIG_DIR_NAME: &str = ".cargo"; pub const CARGO_CONFIG_FILENAME: &str = "config"; pub const INDEXER_SERVICE_HOST: &str = "http://127.0.0.1:29987"; @@ -15,31 +14,6 @@ pub const SUCCESS_EMOJI_PADDING: usize = 3; pub const FAIL_EMOJI_PADDING: usize = 6; pub const HEADER_PADDING: usize = 20; -/// Generate default cargo manifest for native indexer. -pub fn default_native_indexer_cargo_toml(indexer_name: &str) -> String { - format!( - r#"[package] -name = "{indexer_name}" -version = "0.0.0" -edition = "2021" -publish = false -rust-version = "1.73.0" - -[[bin]] -name = "{indexer_name}" -path = "src/main.rs" - -[dependencies] -async-trait = {{ version = "0.1" }} -fuel-indexer = {{ version = "0.21", default-features = false }} -fuel-indexer-utils = {{ version = "0.21", features = ["native-execution"] }} -fuels = {{ version = "0.46", default-features = false, features = ["std"] }} -getrandom = {{ version = "0.2", features = ["js"] }} -serde = {{ version = "1.0", default-features = false, features = ["derive"] }} -"# - ) -} - /// Generate default cargo manifest for wasm indexer. pub fn default_indexer_cargo_toml(indexer_name: &str) -> String { format!( @@ -68,7 +42,6 @@ pub fn default_indexer_manifest( schema_filename: &str, indexer_name: &str, project_path: Option<&PathBuf>, - is_native: bool, ) -> String { let schema_path = match project_path { Some(p) => p.join("schema").join(schema_filename), @@ -78,14 +51,6 @@ pub fn default_indexer_manifest( } }; - let module = if is_native { - r#" - native: ~"# - } else { - r#" - wasm: ~"# - }; - let schema_path = schema_path.display(); format!( @@ -121,8 +86,8 @@ graphql_schema: {schema_path} # The module field contains a file path that points to code that will be run as an executor inside # of the indexer. -# Important: At this time, wasm is the preferred method of execution. -module: {module} +module: + wasm: ~ # The resumable field contains a boolean that specifies whether or not the indexer should, synchronise # with the latest block if it has fallen out of sync. @@ -169,44 +134,6 @@ pub mod {indexer_name}_index_mod {{ ) } -/// Generate default binary module for native indexer. -pub fn default_indexer_binary( - indexer_name: &str, - manifest_filename: &str, - project_path: Option<&PathBuf>, -) -> String { - let manifest_path = match project_path { - Some(p) => p.join(manifest_filename), - None => PathBuf::from(manifest_filename), - }; - - let manifest_path = manifest_path.display(); - - format!( - r#"extern crate alloc; -use fuel_indexer_utils::prelude::*; - -#[indexer(manifest = "{manifest_path}")] -pub mod {indexer_name}_index_mod {{ - - async fn {indexer_name}_handler(block_data: BlockData) {{ - if block_data.header.height % 1000 == 0 {{ - info!("Processing Block#{{}}. (>'.')>", block_data.header.height); - }} - - let block = Block::new(block_data.header.height.into(), block_data.id); - block.save().await; - - for transaction in block_data.transactions.iter() {{ - let tx = Transaction::new(block_data.id, Bytes32::from(<[u8; 32]>::from(transaction.id))); - tx.save().await; - }} - }} -}} -"# - ) -} - /// Generate default schema for indexer. pub fn default_indexer_schema() -> String { r#"type Block @entity { diff --git a/plugins/forc-index/src/ops/forc_index_build.rs b/plugins/forc-index/src/ops/forc_index_build.rs index a83800f63..6c83b72ba 100644 --- a/plugins/forc-index/src/ops/forc_index_build.rs +++ b/plugins/forc-index/src/ops/forc_index_build.rs @@ -17,7 +17,6 @@ use tracing::info; pub fn init(command: BuildCommand) -> anyhow::Result<()> { let BuildCommand { - native, path, debug, locked, @@ -68,7 +67,6 @@ pub fn init(command: BuildCommand) -> anyhow::Result<()> { root_dir.as_path(), Path::new(manifest_schema_file.as_path()), indexer_manifest_path.as_path(), - manifest.execution_source(), )?; // Construct our build command @@ -77,11 +75,9 @@ pub fn init(command: BuildCommand) -> anyhow::Result<()> { let mut cmd = Command::new("cargo"); cmd.arg("build") .arg("--manifest-path") - .arg(&cargo_manifest_path); - - if !native { - cmd.arg("--target").arg(defaults::WASM_TARGET); - } + .arg(&cargo_manifest_path) + .arg("--target") + .arg(defaults::WASM_TARGET); let bool_opts = [ (release, "--release"), @@ -165,48 +161,46 @@ pub fn init(command: BuildCommand) -> anyhow::Result<()> { } // Write the build artifacts to the indexer manifest - if !native { - let binary = format!("{}.wasm", config.package.name); - let profile = if release { "release" } else { "debug" }; - - let target_dir: std::path::PathBuf = - crate::utils::cargo_target_dir(path.as_path()).unwrap(); - - let abs_artifact_path = target_dir - .join(defaults::WASM_TARGET) - .join(profile) - .join(&binary); - - let rel_artifact_path = Path::new("target") - .join(defaults::WASM_TARGET) - .join(profile) - .join(&binary); - - let abs_wasm = abs_artifact_path.as_path().display().to_string(); - let relative_wasm = rel_artifact_path.as_path().display().to_string(); - - manifest.set_module(Module::Wasm(relative_wasm)); - - let status = Command::new("wasm-snip") - .arg(&abs_wasm) - .arg("-o") - .arg(&abs_wasm) - .arg("-p") - .arg("__wbindgen") - .spawn() - .unwrap_or_else(|e| panic!("āŒ Failed to spawn wasm-snip process: {e}",)) - .wait() - .unwrap_or_else(|e| panic!("āŒ Failed to finish wasm-snip process: {e}",)); - - if !status.success() { - let code = status.code(); - anyhow::bail!("āŒ Failed to execute wasm-snip: (Code: {code:?})",) - } - - // FIXME: This should include whatever comments were in the original doc - manifest.write(&indexer_manifest_path)?; + let binary = format!("{}.wasm", config.package.name); + let profile = if release { "release" } else { "debug" }; + + let target_dir: std::path::PathBuf = + crate::utils::cargo_target_dir(path.as_path()).unwrap(); + + let abs_artifact_path = target_dir + .join(defaults::WASM_TARGET) + .join(profile) + .join(&binary); + + let rel_artifact_path = Path::new("target") + .join(defaults::WASM_TARGET) + .join(profile) + .join(&binary); + + let abs_wasm = abs_artifact_path.as_path().display().to_string(); + let relative_wasm = rel_artifact_path.as_path().display().to_string(); + + manifest.set_module(Module::Wasm(relative_wasm)); + + let status = Command::new("wasm-snip") + .arg(&abs_wasm) + .arg("-o") + .arg(&abs_wasm) + .arg("-p") + .arg("__wbindgen") + .spawn() + .unwrap_or_else(|e| panic!("āŒ Failed to spawn wasm-snip process: {e}",)) + .wait() + .unwrap_or_else(|e| panic!("āŒ Failed to finish wasm-snip process: {e}",)); + + if !status.success() { + let code = status.code(); + anyhow::bail!("āŒ Failed to execute wasm-snip: (Code: {code:?})",) } + // FIXME: This should include whatever comments were in the original doc + manifest.write(&indexer_manifest_path)?; + Ok(()) } diff --git a/plugins/forc-index/src/ops/forc_index_deploy.rs b/plugins/forc-index/src/ops/forc_index_deploy.rs index 9fa9bbbe3..5a5f476db 100644 --- a/plugins/forc-index/src/ops/forc_index_deploy.rs +++ b/plugins/forc-index/src/ops/forc_index_deploy.rs @@ -25,7 +25,6 @@ pub async fn init(command: DeployCommand) -> anyhow::Result<()> { auth, debug, locked, - native, verbose, replace_indexer, remove_data, @@ -39,7 +38,6 @@ pub async fn init(command: DeployCommand) -> anyhow::Result<()> { debug, verbose, locked, - native, })?; } diff --git a/plugins/forc-index/src/ops/forc_index_new.rs b/plugins/forc-index/src/ops/forc_index_new.rs index 98ea8dd56..3a72ab632 100644 --- a/plugins/forc-index/src/ops/forc_index_new.rs +++ b/plugins/forc-index/src/ops/forc_index_new.rs @@ -44,9 +44,7 @@ fn print_welcome_message() { `forc index start` Start a local indexer service. `forc index status` - Check the status of an indexer. -`forc index run-native` - Run a native indexer."#; + Check the status of an indexer."#; let ascii_tag = r#" ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ā–ˆā–ˆā€ ā–ˆā–ˆā€ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ā–ˆā–ˆā€ ā–ˆā–ˆā€ā–ˆā–ˆā–ˆā€ ā–ˆā–ˆā€ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ā–ˆā–ˆā€ ā–ˆā–ˆā€ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā€ @@ -70,7 +68,6 @@ pub fn create_indexer(command: NewCommand) -> anyhow::Result<()> { name, path: project_dir, namespace, - native, absolute_paths, verbose, } = command; @@ -111,11 +108,7 @@ pub fn create_indexer(command: NewCommand) -> anyhow::Result<()> { // Make a new directory for the project fs::create_dir_all(Path::new(&project_dir).join("src"))?; - let default_toml = if native { - defaults::default_native_indexer_cargo_toml(&project_name) - } else { - defaults::default_indexer_cargo_toml(&project_name) - }; + let default_toml = defaults::default_indexer_cargo_toml(&project_name); // Write index Cargo manifest fs::write( @@ -147,7 +140,6 @@ pub fn create_indexer(command: NewCommand) -> anyhow::Result<()> { &schema_filename, &project_name, proj_abspath.as_ref(), - native, ), )?; @@ -159,41 +151,26 @@ pub fn create_indexer(command: NewCommand) -> anyhow::Result<()> { )?; // What content are we writing? - let (filename, content) = if native { - ( - defaults::INDEXER_BINARY_FILENAME, - defaults::default_indexer_binary( - &project_name, - &manifest_filename, - proj_abspath.as_ref(), - ), - ) - } else { - ( - defaults::INDEXER_LIB_FILENAME, - defaults::default_indexer_lib( - &project_name, - &manifest_filename, - proj_abspath.as_ref(), - ), - ) - }; + let (filename, content) = ( + defaults::INDEXER_LIB_FILENAME, + defaults::default_indexer_lib( + &project_name, + &manifest_filename, + proj_abspath.as_ref(), + ), + ); // Write indexer file fs::write(Path::new(&project_dir).join("src").join(filename), content)?; // Write cargo config with WASM target - if !native { - fs::create_dir_all( - Path::new(&project_dir).join(defaults::CARGO_CONFIG_DIR_NAME), - )?; - let _ = fs::write( - Path::new(&project_dir) - .join(defaults::CARGO_CONFIG_DIR_NAME) - .join(defaults::CARGO_CONFIG_FILENAME), - defaults::default_cargo_config(), - ); - } + fs::create_dir_all(Path::new(&project_dir).join(defaults::CARGO_CONFIG_DIR_NAME))?; + let _ = fs::write( + Path::new(&project_dir) + .join(defaults::CARGO_CONFIG_DIR_NAME) + .join(defaults::CARGO_CONFIG_FILENAME), + defaults::default_cargo_config(), + ); if verbose { info!("\nāœ… Successfully created indexer {project_name}"); diff --git a/plugins/forc-index/src/ops/forc_index_run_native.rs b/plugins/forc-index/src/ops/forc_index_run_native.rs deleted file mode 100644 index 51245374c..000000000 --- a/plugins/forc-index/src/ops/forc_index_run_native.rs +++ /dev/null @@ -1,111 +0,0 @@ -use crate::{ - cli::{BuildCommand, RunNativeCommand}, - commands::build, - defaults, - utils::*, -}; -use fuel_indexer_lib::manifest::Manifest; -use std::{ - fs::File, - io::Read, - path::{Path, PathBuf}, - process::Command, -}; -use tracing::info; - -pub async fn init(command: RunNativeCommand) -> anyhow::Result<()> { - let RunNativeCommand { - path, - debug, - locked, - manifest: mani_path, - verbose, - skip_build, - bin, - args, - .. - } = command; - - if !skip_build { - build::exec(BuildCommand { - manifest: mani_path.clone(), - path: path.clone(), - debug, - verbose, - locked, - native: true, - })?; - } - - let release = !debug; - - let (root_dir, manifest, indexer_name) = - project_dir_info(path.as_ref(), mani_path.as_ref())?; - - // Must be in the directory of the indexer being built - let cargo_manifest_path = root_dir.join(defaults::CARGO_MANIFEST_FILE_NAME); - if !cargo_manifest_path.exists() { - let cargo_manifest_dir = { - let mut path = cargo_manifest_path; - path.pop(); - path - }; - anyhow::bail!( - "could not find `Cargo.toml` in `{}`", - cargo_manifest_dir.display() - ); - } - - let current_dir = std::env::current_dir()?; - - let path = path.unwrap_or(current_dir); - - let mut file = File::open(&cargo_manifest_path)?; - let mut content = String::new(); - file.read_to_string(&mut content)?; - - let indexer_manifest_path = root_dir.join(manifest); - let manifest = Manifest::from_file(&indexer_manifest_path)?; - - let workspace_root: PathBuf = cargo_workspace_root_dir(path.as_path()).unwrap(); - - let manifest_schema_file = Path::new(&workspace_root).join(manifest.graphql_schema()); - - let binpath = bin - .unwrap_or_else(|| { - let dir = if release { "release" } else { "debug" }; - let name = dasherize_to_underscore(&indexer_name); - workspace_root.join("target").join(dir).join(name) - }) - .display() - .to_string(); - - // Rebuild the WASM module even if only the schema has changed. - ensure_rebuild_if_schema_or_manifest_changed( - root_dir.as_path(), - Path::new(manifest_schema_file.as_path()), - indexer_manifest_path.as_path(), - manifest.execution_source(), - )?; - - let mut cmd = Command::new(binpath); - cmd.arg("--manifest").arg(&indexer_manifest_path); - - for arg in args { - cmd.arg(arg); - } - - if verbose { - info!("{cmd:?}") - } - - match cmd.spawn() { - Ok(child) => { - let pid = child.id(); - info!("āœ… Successfully started the indexer service at PID {pid}"); - } - Err(e) => panic!("āŒ Failed to spawn fuel-indexer child process: {e:?}."), - } - - Ok(()) -} diff --git a/plugins/forc-index/src/ops/mod.rs b/plugins/forc-index/src/ops/mod.rs index 9807f456f..512edfa0f 100644 --- a/plugins/forc-index/src/ops/mod.rs +++ b/plugins/forc-index/src/ops/mod.rs @@ -5,6 +5,5 @@ pub mod forc_index_deploy; pub mod forc_index_kill; pub mod forc_index_new; pub mod forc_index_remove; -pub mod forc_index_run_native; pub mod forc_index_start; pub mod forc_index_status; diff --git a/plugins/forc-index/src/utils.rs b/plugins/forc-index/src/utils.rs index 3a0652907..0de57c9aa 100644 --- a/plugins/forc-index/src/utils.rs +++ b/plugins/forc-index/src/utils.rs @@ -1,5 +1,4 @@ use crate::{defaults, defaults::manifest_name}; -use fuel_indexer_lib::ExecutionSource; use reqwest::{multipart::Part, Body}; use std::{ fs::canonicalize, @@ -154,7 +153,6 @@ pub fn ensure_rebuild_if_schema_or_manifest_changed( project_dir: &Path, schema: &Path, manifest: &Path, - exec_source: ExecutionSource, ) -> std::io::Result<()> { let schema_mtime = { let metadata = std::fs::metadata(schema).unwrap_or_else(|e| { @@ -173,10 +171,7 @@ pub fn ensure_rebuild_if_schema_or_manifest_changed( }; let entrypoint_rs = { - let sourcefile = match exec_source { - ExecutionSource::Native => "main.rs", - ExecutionSource::Wasm => "lib.rs", - }; + let sourcefile = "lib.rs"; let mut path = project_dir.to_owned(); path.push("src"); path.push(sourcefile); diff --git a/scripts/utils/build_modules.bash b/scripts/utils/build_modules.bash index 41b246232..472a4a43b 100644 --- a/scripts/utils/build_modules.bash +++ b/scripts/utils/build_modules.bash @@ -33,9 +33,4 @@ bash scripts/stripper.bash greetings_indexer.wasm cp greetings_indexer.wasm target/wasm32-unknown-unknown/release/ rm -fv greetings_indexer.wasm - -cargo build -p greetings_native_indexer --locked --release - - - set +ex