This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update examples and qa script (#1392)
* chore: update examples and qa script * remove native * rebase origin/develop * fix hello-world manifest
- Loading branch information
Showing
64 changed files
with
1,154 additions
and
414 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# `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>...] | ||
ARGS: | ||
<ARGS>... | ||
Extra passed to `fuel-indexer run` | ||
Example usage: `forc-index run-native --path . -- --run-migrations --stop-idle-indexers` | ||
OPTIONS: | ||
--bin <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> | ||
Manifest file name of indexer being built. | ||
-p, --path <PATH> | ||
Path to the indexer project. | ||
--skip-build | ||
Do not build before deploying. | ||
-v, --verbose | ||
Enable verbose output. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# 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` |
Oops, something went wrong.