From 9a7515c7f90c3299f120a79656baccd3b6ac89b7 Mon Sep 17 00:00:00 2001 From: rashad Date: Mon, 25 Sep 2023 11:35:25 -0400 Subject: [PATCH 1/5] Revert "chore: remove alloc references" (#1375) Revert "chore: remove alloc references (#1367)" This reverts commit 2424dd7935942ae3cd9ad94668ff4ab73c646d6e. --- docs/src/designing-a-schema/types.md | 4 +- docs/src/indexing-fuel-types/blocks.md | 1 + docs/src/indexing-fuel-types/receipts.md | 14 ++- docs/src/indexing-fuel-types/transactions.md | 2 + .../fuel-explorer/fuel-explorer/src/lib.rs | 1 + .../hello-indexer-native/src/main.rs | 1 + examples/hello-world/hello-indexer/src/lib.rs | 1 + packages/fuel-indexer-macros/src/native.rs | 2 - packages/fuel-indexer-macros/src/wasm.rs | 2 - packages/fuel-indexer-plugin/src/wasm.rs | 1 + packages/fuel-indexer-schema/src/join.rs | 2 + packages/fuel-indexer-schema/src/lib.rs | 2 + .../indexers/fuel-indexer-test/src/lib.rs | 2 + .../simple-wasm/simple-wasm/src/lib.rs | 1 + packages/fuel-indexer-tests/tests/service.rs | 1 + ...fail_if_abi_contains_reserved_fuel_type.rs | 1 + ...l_if_arg_not_passed_to_handler_function.rs | 1 + ...attribute_abi_arg_includes_invalid_type.rs | 1 + ...ibute_abi_arg_includes_invalid_type.stderr | 96 +++++++++---------- ...ttribute_manifest_schema_arg_is_invalid.rs | 1 + ...bute_manifest_schema_arg_is_invalid.stderr | 18 ++-- .../fail_if_ident_not_defined_in_abi.rs | 1 + .../fail_if_ident_not_defined_in_abi.stderr | 2 +- .../fail_if_indexer_module_is_empty.rs | 1 + ...on_function_patterns_included_in_module.rs | 1 + ...unction_patterns_included_in_module.stderr | 2 +- ...f_unsupported_type_used_in_handler_args.rs | 1 + ...supported_type_used_in_handler_args.stderr | 2 +- .../pass_if_indexer_is_valid_multi_type.rs | 1 + .../pass_if_indexer_is_valid_single_type.rs | 1 + .../pass_if_unsupported_types_are_used.rs | 1 + plugins/forc-index/src/defaults.rs | 6 +- 32 files changed, 104 insertions(+), 70 deletions(-) diff --git a/docs/src/designing-a-schema/types.md b/docs/src/designing-a-schema/types.md index 91c11371e..11ed5561c 100644 --- a/docs/src/designing-a-schema/types.md +++ b/docs/src/designing-a-schema/types.md @@ -15,6 +15,7 @@ type Account @entity { This `Account` object type from the GraphQL schema, might be used in an indexer module like so: ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -43,6 +44,7 @@ enum SignatureLabel { This `SignatureLabel` object type from the GraphQL schema, might be used in an indexer module like so: ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -106,10 +108,10 @@ type Transaction @entity { This `Transaction` union type from the GraphQL schema, might be used in an indexer module like so: ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] - mod indexer_mod { fn handle_event(event: Event) { let bytecode_length = 1024; diff --git a/docs/src/indexing-fuel-types/blocks.md b/docs/src/indexing-fuel-types/blocks.md index bca9c442a..df89e8f23 100644 --- a/docs/src/indexing-fuel-types/blocks.md +++ b/docs/src/indexing-fuel-types/blocks.md @@ -19,6 +19,7 @@ pub struct BlockData { ## Usage ```rust,ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] diff --git a/docs/src/indexing-fuel-types/receipts.md b/docs/src/indexing-fuel-types/receipts.md index 0e68fd3cb..a000df9dd 100644 --- a/docs/src/indexing-fuel-types/receipts.md +++ b/docs/src/indexing-fuel-types/receipts.md @@ -34,9 +34,6 @@ pub struct Burn { ``` ```rust, ignore -use fuel_indexer_utils::prelude::*; - -#[indexer(manifest = "indexer.manifest.yaml")] mod indexer_mod { fn handle_burn_receipt(block_data: BlockData) { let height = block_data.header.height; @@ -71,6 +68,7 @@ pub struct Call { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -105,6 +103,7 @@ pub struct Log { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -144,6 +143,7 @@ pub struct LogData { > Note: the example below will run both when the type `MyEvent` is logged as well as when `MyEvent` is returned from a function. ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -173,6 +173,7 @@ pub struct MessageOut { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -199,6 +200,7 @@ pub struct Mint { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -232,6 +234,7 @@ pub struct Panic { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -269,6 +272,7 @@ pub struct Return { You can handle functions that produce a `Return` receipt type by adding a parameter with the type `Return`. ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -336,6 +340,7 @@ pub struct Revert { | FailedAssert | 4 | ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -368,6 +373,7 @@ pub struct ScriptResult { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -405,6 +411,7 @@ pub struct Transfer { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -442,6 +449,7 @@ pub struct TransferOut { ``` ```rust, ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] diff --git a/docs/src/indexing-fuel-types/transactions.md b/docs/src/indexing-fuel-types/transactions.md index 83b507fd7..435ab54c5 100644 --- a/docs/src/indexing-fuel-types/transactions.md +++ b/docs/src/indexing-fuel-types/transactions.md @@ -19,6 +19,7 @@ pub struct TransactionData { ### Usage ```rust,ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] @@ -67,6 +68,7 @@ pub enum TransactionStatus { ### Usage ```rust,ignore +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "indexer.manifest.yaml")] diff --git a/examples/fuel-explorer/fuel-explorer/src/lib.rs b/examples/fuel-explorer/fuel-explorer/src/lib.rs index effb67338..c23b18ddb 100644 --- a/examples/fuel-explorer/fuel-explorer/src/lib.rs +++ b/examples/fuel-explorer/fuel-explorer/src/lib.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; // TODO: We use a lot of manual type conversion below due to https://github.com/FuelLabs/fuel-indexer/issues/286 diff --git a/examples/hello-world-native/hello-indexer-native/src/main.rs b/examples/hello-world-native/hello-indexer-native/src/main.rs index 0fc0e7e13..9b1d4d9d7 100644 --- a/examples/hello-world-native/hello-indexer-native/src/main.rs +++ b/examples/hello-world-native/hello-indexer-native/src/main.rs @@ -20,6 +20,7 @@ //! ```bash //! cargo run -p hello-world-data --bin hello-world-data //! ``` +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer( diff --git a/examples/hello-world/hello-indexer/src/lib.rs b/examples/hello-world/hello-indexer/src/lib.rs index c7719d0d0..f6a77c2c6 100644 --- a/examples/hello-world/hello-indexer/src/lib.rs +++ b/examples/hello-world/hello-indexer/src/lib.rs @@ -26,6 +26,7 @@ //! cargo run -p hello-world-data --bin hello-world-data //! ``` +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "examples/hello-world/hello-indexer/hello_indexer.manifest.yaml")] diff --git a/packages/fuel-indexer-macros/src/native.rs b/packages/fuel-indexer-macros/src/native.rs index 4cded672d..544dd066c 100644 --- a/packages/fuel-indexer-macros/src/native.rs +++ b/packages/fuel-indexer-macros/src/native.rs @@ -33,8 +33,6 @@ pub fn handler_block_native( /// indexer module, not within the scope of the entire lib module. fn native_prelude() -> proc_macro2::TokenStream { quote! { - extern crate alloc; - type B256 = [u8; 32]; static mut db: Option>> = None; diff --git a/packages/fuel-indexer-macros/src/wasm.rs b/packages/fuel-indexer-macros/src/wasm.rs index fd4bcdea0..95838c13b 100644 --- a/packages/fuel-indexer-macros/src/wasm.rs +++ b/packages/fuel-indexer-macros/src/wasm.rs @@ -36,8 +36,6 @@ pub fn handler_block_wasm( /// indexer module, not within the scope of the entire lib module. fn wasm_prelude() -> proc_macro2::TokenStream { quote! { - extern crate alloc; - use alloc::{format, vec, vec::Vec}; use std::str::FromStr; diff --git a/packages/fuel-indexer-plugin/src/wasm.rs b/packages/fuel-indexer-plugin/src/wasm.rs index b49b34093..e8af8578e 100644 --- a/packages/fuel-indexer-plugin/src/wasm.rs +++ b/packages/fuel-indexer-plugin/src/wasm.rs @@ -1,4 +1,5 @@ extern crate alloc; + use alloc::vec::Vec; use fuel_indexer_lib::{ graphql::MAX_FOREIGN_KEY_LIST_FIELDS, diff --git a/packages/fuel-indexer-schema/src/join.rs b/packages/fuel-indexer-schema/src/join.rs index 98cc20661..167cd0daa 100644 --- a/packages/fuel-indexer-schema/src/join.rs +++ b/packages/fuel-indexer-schema/src/join.rs @@ -2,6 +2,8 @@ use crate::FtColumn; use fuel_indexer_lib::join_table_typedefs_name; use serde::{Deserialize, Serialize}; +extern crate alloc; + /// Details for the many-to-many relationship. /// /// This is essentially the same as `fuel_indexer_lib::graphql::parser::JoinTableRelation`, just diff --git a/packages/fuel-indexer-schema/src/lib.rs b/packages/fuel-indexer-schema/src/lib.rs index d47b6ef78..29f0e9152 100644 --- a/packages/fuel-indexer-schema/src/lib.rs +++ b/packages/fuel-indexer-schema/src/lib.rs @@ -5,6 +5,8 @@ // TODO: Deny `clippy::unused_crate_dependencies` when including feature-flagged dependency `itertools` +extern crate alloc; + use fuel_indexer_lib::MAX_ARRAY_LENGTH; use fuel_indexer_types::{fuel::*, scalar::*, Identity}; use serde::{Deserialize, Serialize}; diff --git a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs index c8f9c04f3..a86761c60 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs @@ -1,3 +1,5 @@ +extern crate alloc; + use fuel_indexer_utils::prelude::*; #[indexer( diff --git a/packages/fuel-indexer-tests/indexers/simple-wasm/simple-wasm/src/lib.rs b/packages/fuel-indexer-tests/indexers/simple-wasm/simple-wasm/src/lib.rs index 9b51c375a..678e972ef 100644 --- a/packages/fuel-indexer-tests/indexers/simple-wasm/simple-wasm/src/lib.rs +++ b/packages/fuel-indexer-tests/indexers/simple-wasm/simple-wasm/src/lib.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/tests/service.rs b/packages/fuel-indexer-tests/tests/service.rs index 8d1e6ed00..814dba91b 100644 --- a/packages/fuel-indexer-tests/tests/service.rs +++ b/packages/fuel-indexer-tests/tests/service.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer::prelude::fuel::{BlockData, Consensus, Header}; use fuel_indexer::{Executor, IndexerConfig, WasmIndexExecutor}; use fuel_indexer_lib::WasmIndexerError; diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs b/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs index 324f399e1..651fe3004 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_arg_not_passed_to_handler_function.rs b/packages/fuel-indexer-tests/trybuild/fail_if_arg_not_passed_to_handler_function.rs index 52f30834b..211cf47f4 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_arg_not_passed_to_handler_function.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_arg_not_passed_to_handler_function.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.rs b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.rs index 1dce61ae7..e05167111 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::indexer; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.stderr b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.stderr index 867601ed3..bbdbd6f64 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.stderr +++ b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_abi_arg_includes_invalid_type.stderr @@ -1,4 +1,4 @@ -error: Type with ident 'Ident { ident: "BadType", span: #0 bytes(205..212) }' not defined in the ABI. +error: Type with ident 'Ident { ident: "BadType", span: #0 bytes(225..232) }' not defined in the ABI. --> trybuild/fail_if_attribute_abi_arg_includes_invalid_type.rs | | #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] @@ -26,13 +26,13 @@ error[E0412]: cannot find type `BlockData` in this scope | help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::BlockData; +2 + use fuel_indexer::prelude::fuel::BlockData; | -1 + use fuel_indexer_plugin::prelude::BlockData; +2 + use fuel_indexer_plugin::prelude::BlockData; | -1 + use fuel_indexer_types::fuel::BlockData; +2 + use fuel_indexer_types::fuel::BlockData; | -1 + use fuel_indexer_utils::plugin::prelude::BlockData; +2 + use fuel_indexer_utils::plugin::prelude::BlockData; | error[E0422]: cannot find struct, variant or union type `BlockData` in this scope @@ -43,13 +43,13 @@ error[E0422]: cannot find struct, variant or union type `BlockData` in this scop | help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::BlockData; +2 + use fuel_indexer::prelude::fuel::BlockData; | -1 + use fuel_indexer_plugin::prelude::BlockData; +2 + use fuel_indexer_plugin::prelude::BlockData; | -1 + use fuel_indexer_types::fuel::BlockData; +2 + use fuel_indexer_types::fuel::BlockData; | -1 + use fuel_indexer_utils::plugin::prelude::BlockData; +2 + use fuel_indexer_utils::plugin::prelude::BlockData; | error[E0433]: failed to resolve: use of undeclared crate or module `fuel` @@ -60,17 +60,17 @@ error[E0433]: failed to resolve: use of undeclared crate or module `fuel` | help: there is a crate or module with a similar name | -32 | header: fuels::Header { +33 | header: fuels::Header { | ~~~~~ help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel; +2 + use fuel_indexer::prelude::fuel; | -1 + use fuel_indexer_plugin::prelude::fuel; +2 + use fuel_indexer_plugin::prelude::fuel; | -1 + use fuel_indexer_types::fuel; +2 + use fuel_indexer_types::fuel; | -1 + use fuel_indexer_utils::plugin::prelude::fuel; +2 + use fuel_indexer_utils::plugin::prelude::fuel; | error[E0433]: failed to resolve: use of undeclared crate or module `fuel` @@ -81,17 +81,17 @@ error[E0433]: failed to resolve: use of undeclared crate or module `fuel` | help: there is a crate or module with a similar name | -44 | transactions: vec![fuels::TransactionData { +45 | transactions: vec![fuels::TransactionData { | ~~~~~ help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel; +2 + use fuel_indexer::prelude::fuel; | -1 + use fuel_indexer_plugin::prelude::fuel; +2 + use fuel_indexer_plugin::prelude::fuel; | -1 + use fuel_indexer_types::fuel; +2 + use fuel_indexer_types::fuel; | -1 + use fuel_indexer_utils::plugin::prelude::fuel; +2 + use fuel_indexer_utils::plugin::prelude::fuel; | error[E0433]: failed to resolve: use of undeclared crate or module `fuel` @@ -102,23 +102,23 @@ error[E0433]: failed to resolve: use of undeclared crate or module `fuel` | help: there is a crate or module with a similar name | -45 | status: fuels::TransactionStatus::default(), +46 | status: fuels::TransactionStatus::default(), | ~~~~~ help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::TransactionStatus; +2 + use fuel_indexer::prelude::fuel::TransactionStatus; | -1 + use fuel_indexer_plugin::prelude::fuel::TransactionStatus; +2 + use fuel_indexer_plugin::prelude::fuel::TransactionStatus; | -1 + use fuel_indexer_types::fuel::TransactionStatus; +2 + use fuel_indexer_types::fuel::TransactionStatus; | -1 + use fuel_indexer_utils::plugin::prelude::fuel::TransactionStatus; +2 + use fuel_indexer_utils::plugin::prelude::fuel::TransactionStatus; | and 1 other candidate help: if you import `TransactionStatus`, refer to it directly | -45 - status: fuel::TransactionStatus::default(), -45 + status: TransactionStatus::default(), +46 - status: fuel::TransactionStatus::default(), +46 + status: TransactionStatus::default(), | error[E0433]: failed to resolve: use of undeclared crate or module `fuel` @@ -129,23 +129,23 @@ error[E0433]: failed to resolve: use of undeclared crate or module `fuel` | help: there is a crate or module with a similar name | -48 | fuels::Receipt::Call { +49 | fuels::Receipt::Call { | ~~~~~ help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::Receipt; +2 + use fuel_indexer::prelude::fuel::Receipt; | -1 + use fuel_indexer_plugin::prelude::fuel::Receipt; +2 + use fuel_indexer_plugin::prelude::fuel::Receipt; | -1 + use fuel_indexer_types::fuel::Receipt; +2 + use fuel_indexer_types::fuel::Receipt; | -1 + use fuel_indexer_utils::plugin::prelude::fuel::Receipt; +2 + use fuel_indexer_utils::plugin::prelude::fuel::Receipt; | and 2 other candidates help: if you import `Receipt`, refer to it directly | -48 - fuel::Receipt::Call { -48 + Receipt::Call { +49 - fuel::Receipt::Call { +49 + Receipt::Call { | error[E0433]: failed to resolve: use of undeclared crate or module `fuel` @@ -156,23 +156,23 @@ error[E0433]: failed to resolve: use of undeclared crate or module `fuel` | help: there is a crate or module with a similar name | -59 | fuels::Receipt::ReturnData { +60 | fuels::Receipt::ReturnData { | ~~~~~ help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::Receipt; +2 + use fuel_indexer::prelude::fuel::Receipt; | -1 + use fuel_indexer_plugin::prelude::fuel::Receipt; +2 + use fuel_indexer_plugin::prelude::fuel::Receipt; | -1 + use fuel_indexer_types::fuel::Receipt; +2 + use fuel_indexer_types::fuel::Receipt; | -1 + use fuel_indexer_utils::plugin::prelude::fuel::Receipt; +2 + use fuel_indexer_utils::plugin::prelude::fuel::Receipt; | and 2 other candidates help: if you import `Receipt`, refer to it directly | -59 - fuel::Receipt::ReturnData { -59 + Receipt::ReturnData { +60 - fuel::Receipt::ReturnData { +60 + Receipt::ReturnData { | error[E0433]: failed to resolve: use of undeclared type `Transaction` @@ -183,13 +183,13 @@ error[E0433]: failed to resolve: use of undeclared type `Transaction` | help: consider importing one of these items | -1 + use fuel_indexer::prelude::fuel::Transaction; +2 + use fuel_indexer::prelude::fuel::Transaction; | -1 + use fuel_indexer_plugin::prelude::fuel::Transaction; +2 + use fuel_indexer_plugin::prelude::fuel::Transaction; | -1 + use fuel_indexer_types::fuel::Transaction; +2 + use fuel_indexer_types::fuel::Transaction; | -1 + use fuel_indexer_utils::plugin::prelude::fuel::Transaction; +2 + use fuel_indexer_utils::plugin::prelude::fuel::Transaction; | and 3 other candidates @@ -201,13 +201,13 @@ error[E0425]: cannot find function `serialize` in this scope | help: consider importing one of these items | -1 + use chrono::naive::serde::ts_microseconds::serialize; +2 + use chrono::naive::serde::ts_microseconds::serialize; | -1 + use chrono::naive::serde::ts_microseconds_option::serialize; +2 + use chrono::naive::serde::ts_microseconds_option::serialize; | -1 + use chrono::naive::serde::ts_milliseconds::serialize; +2 + use chrono::naive::serde::ts_milliseconds::serialize; | -1 + use chrono::naive::serde::ts_milliseconds_option::serialize; +2 + use chrono::naive::serde::ts_milliseconds_option::serialize; | and 16 other candidates diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.rs b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.rs index e96ae6d69..c9215559d 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.stderr b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.stderr index 0cf8a8d04..c9e426f67 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.stderr +++ b/packages/fuel-indexer-tests/trybuild/fail_if_attribute_manifest_schema_arg_is_invalid.stderr @@ -26,13 +26,13 @@ error[E0433]: failed to resolve: use of undeclared type `Consensus` | help: consider importing one of these items | -1 + use crate::fuel::Consensus; +2 + use crate::fuel::Consensus; | -1 + use fuel_indexer::prelude::fuel::Consensus; +2 + use fuel_indexer::prelude::fuel::Consensus; | -1 + use fuel_indexer_plugin::prelude::fuel::Consensus; +2 + use fuel_indexer_plugin::prelude::fuel::Consensus; | -1 + use fuel_indexer_types::fuel::Consensus; +2 + use fuel_indexer_types::fuel::Consensus; | and 1 other candidate @@ -44,13 +44,13 @@ error[E0433]: failed to resolve: use of undeclared type `Transaction` | help: consider importing one of these items | -1 + use crate::fuel::Transaction; +2 + use crate::fuel::Transaction; | -1 + use fuel_indexer::prelude::fuel::Transaction; +2 + use fuel_indexer::prelude::fuel::Transaction; | -1 + use fuel_indexer_plugin::prelude::fuel::Transaction; +2 + use fuel_indexer_plugin::prelude::fuel::Transaction; | -1 + use fuel_indexer_types::fuel::Transaction; +2 + use fuel_indexer_types::fuel::Transaction; | and 4 other candidates @@ -80,7 +80,7 @@ error[E0308]: mismatched types found struct `Vec<_>` help: try wrapping the expression in `Some` | -64 | data: Some(bytes), +65 | data: Some(bytes), | +++++ + error[E0063]: missing field `producer` in initializer of `fuel_indexer_utils::prelude::BlockData` diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs index c09da16c5..2e0ccd8f2 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.stderr b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.stderr index c4f8e8abc..c68514063 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.stderr +++ b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.stderr @@ -1,4 +1,4 @@ -error: Type with ident 'Ident { ident: "ThisIsNotDefinedInTheABI", span: #0 bytes(157..181) }' not defined in the ABI. +error: Type with ident 'Ident { ident: "ThisIsNotDefinedInTheABI", span: #0 bytes(177..201) }' not defined in the ABI. --> trybuild/fail_if_ident_not_defined_in_abi.rs | | #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_indexer_module_is_empty.rs b/packages/fuel-indexer-tests/trybuild/fail_if_indexer_module_is_empty.rs index f024c3d23..404f326dd 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_indexer_module_is_empty.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_indexer_module_is_empty.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.rs b/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.rs index a8609762b..22b7f745d 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.stderr b/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.stderr index bda560adb..c11ec9e15 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.stderr +++ b/packages/fuel-indexer-tests/trybuild/fail_if_non_function_patterns_included_in_module.stderr @@ -1,4 +1,4 @@ -error: Unsupported item in indexer module 'Item::Mod { attrs: [], vis: Visibility::Inherited, unsafety: None, mod_token: Mod, ident: Ident { ident: "some_disallowed_module", span: #0 bytes(139..161) }, content: Some((Brace, [])), semi: None }'. +error: Unsupported item in indexer module 'Item::Mod { attrs: [], vis: Visibility::Inherited, unsafety: None, mod_token: Mod, ident: Ident { ident: "some_disallowed_module", span: #0 bytes(159..181) }, content: Some((Brace, [])), semi: None }'. --> trybuild/fail_if_non_function_patterns_included_in_module.rs | | #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.rs b/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.rs index 1c29e307c..d97caf827 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.stderr b/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.stderr index 87a2b3d3a..96515ff14 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.stderr +++ b/packages/fuel-indexer-tests/trybuild/fail_if_unsupported_type_used_in_handler_args.stderr @@ -1,4 +1,4 @@ -error: Type with ident 'Ident { ident: "Vec", span: #0 bytes(157..160) }' is not currently supported. +error: Type with ident 'Ident { ident: "Vec", span: #0 bytes(177..180) }' is not currently supported. --> trybuild/fail_if_unsupported_type_used_in_handler_args.rs | | #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs index 49fcc6f6d..7a6196747 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs index d9ce24181..c097f1e24 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs b/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs index 44a6a037d..bcc01f01b 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs @@ -1,3 +1,4 @@ +extern crate alloc; use fuel_indexer_utils::prelude::*; #[no_mangle] diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index dc89f364f..0a3f058c6 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -148,7 +148,8 @@ pub fn default_indexer_lib( let manifest_path = manifest_path.display(); format!( - r#"use fuel_indexer_utils::prelude::*; + r#"extern crate alloc; +use fuel_indexer_utils::prelude::*; #[indexer(manifest = "{manifest_path}")] pub mod {indexer_name}_index_mod {{ @@ -185,7 +186,8 @@ pub fn default_indexer_binary( let manifest_path = manifest_path.display(); format!( - r#"use fuel_indexer_utils::prelude::*; + r#"extern crate alloc; +use fuel_indexer_utils::prelude::*; #[indexer(manifest = "{manifest_path}")] pub mod {indexer_name}_index_mod {{ From 093c5530a372346360df59d5e2a8d13ee6eb0887 Mon Sep 17 00:00:00 2001 From: rashad Date: Mon, 25 Sep 2023 11:39:45 -0400 Subject: [PATCH 2/5] v0.20.11 (#1376) Co-authored-by: Rashad Alston --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 34 +++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 170fce916..1e03e8cc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2672,7 +2672,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "forc-index" -version = "0.20.10" +version = "0.20.11" dependencies = [ "actix-web", "anyhow", @@ -2705,7 +2705,7 @@ dependencies = [ [[package]] name = "forc-postgres" -version = "0.20.10" +version = "0.20.11" dependencies = [ "anyhow", "clap 3.2.25", @@ -3203,7 +3203,7 @@ dependencies = [ [[package]] name = "fuel-indexer" -version = "0.20.10" +version = "0.20.11" dependencies = [ "anyhow", "async-std", @@ -3235,7 +3235,7 @@ dependencies = [ [[package]] name = "fuel-indexer-api-server" -version = "0.20.10" +version = "0.20.11" dependencies = [ "anyhow", "async-graphql 5.0.10", @@ -3293,7 +3293,7 @@ dependencies = [ [[package]] name = "fuel-indexer-database" -version = "0.20.10" +version = "0.20.11" dependencies = [ "fuel-indexer-database-types", "fuel-indexer-lib", @@ -3305,7 +3305,7 @@ dependencies = [ [[package]] name = "fuel-indexer-database-types" -version = "0.20.10" +version = "0.20.11" dependencies = [ "async-graphql-parser 5.0.10", "async-graphql-value 5.0.10", @@ -3318,7 +3318,7 @@ dependencies = [ [[package]] name = "fuel-indexer-graphql" -version = "0.20.10" +version = "0.20.11" dependencies = [ "async-graphql 5.0.10", "async-graphql-parser 5.0.10", @@ -3336,7 +3336,7 @@ dependencies = [ [[package]] name = "fuel-indexer-lib" -version = "0.20.10" +version = "0.20.11" dependencies = [ "anyhow", "async-graphql-parser 5.0.10", @@ -3361,7 +3361,7 @@ dependencies = [ [[package]] name = "fuel-indexer-macro-utils" -version = "0.20.10" +version = "0.20.11" dependencies = [ "proc-macro-error", "proc-macro2", @@ -3371,7 +3371,7 @@ dependencies = [ [[package]] name = "fuel-indexer-macros" -version = "0.20.10" +version = "0.20.11" dependencies = [ "async-graphql-parser 5.0.10", "async-graphql-value 5.0.10", @@ -3393,7 +3393,7 @@ dependencies = [ [[package]] name = "fuel-indexer-metrics" -version = "0.20.10" +version = "0.20.11" dependencies = [ "axum 0.6.20", "lazy_static", @@ -3403,7 +3403,7 @@ dependencies = [ [[package]] name = "fuel-indexer-plugin" -version = "0.20.10" +version = "0.20.11" dependencies = [ "anyhow", "async-trait", @@ -3426,7 +3426,7 @@ dependencies = [ [[package]] name = "fuel-indexer-postgres" -version = "0.20.10" +version = "0.20.11" dependencies = [ "bigdecimal", "chrono", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "fuel-indexer-schema" -version = "0.20.10" +version = "0.20.11" dependencies = [ "async-graphql-parser 5.0.10", "fuel-indexer-database", @@ -3516,7 +3516,7 @@ dependencies = [ [[package]] name = "fuel-indexer-types" -version = "0.20.10" +version = "0.20.11" dependencies = [ "bincode", "bytes", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "fuel-indexer-utils" -version = "0.20.10" +version = "0.20.11" dependencies = [ "fuel-indexer-macros", "fuel-indexer-plugin", diff --git a/Cargo.toml b/Cargo.toml index 37ea39b86..3efae8640 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,29 +61,29 @@ homepage = "https://fuel.network/" license = "Apache-2.0" repository = "https://github.com/FuelLabs/fuel-indexer" rust-version = "1.72.0" -version = "0.20.10" +version = "0.20.11" [workspace.dependencies] async-graphql-parser = "5.0" async-graphql-value = "5.0" bincode = "1.3" clap = "3.1" -forc-index = { version = "0.20.10", path = "./plugins/forc-index" } -forc-postgres = { version = "0.20.10", path = "./plugins/forc-postgres" } -fuel-indexer = { version = "0.20.10", path = "./packages/fuel-indexer" } -fuel-indexer-api-server = { version = "0.20.10", path = "./packages/fuel-indexer-api-server" } -fuel-indexer-database = { version = "0.20.10", path = "./packages/fuel-indexer-database" } -fuel-indexer-database-types = { version = "0.20.10", path = "./packages/fuel-indexer-database/database-types" } -fuel-indexer-graphql = { version = "0.20.10", path = "./packages/fuel-indexer-graphql" } -fuel-indexer-lib = { version = "0.20.10", path = "./packages/fuel-indexer-lib" } -fuel-indexer-macro-utils = { version = "0.20.10", path = "./packages/fuel-indexer-macros/macro-utils" } -fuel-indexer-macros = { version = "0.20.10", path = "./packages/fuel-indexer-macros", default-features = false } -fuel-indexer-metrics = { version = "0.20.10", path = "./packages/fuel-indexer-metrics" } -fuel-indexer-plugin = { version = "0.20.10", path = "./packages/fuel-indexer-plugin", default-features = false } -fuel-indexer-postgres = { version = "0.20.10", path = "./packages/fuel-indexer-database/postgres" } -fuel-indexer-schema = { version = "0.20.10", path = "./packages/fuel-indexer-schema", default-features = false } -fuel-indexer-types = { version = "0.20.10", path = "./packages/fuel-indexer-types" } -fuel-indexer-utils = { version = "0.20.10", path = "./packages/fuel-indexer-utils" } +forc-index = { version = "0.20.11", path = "./plugins/forc-index" } +forc-postgres = { version = "0.20.11", path = "./plugins/forc-postgres" } +fuel-indexer = { version = "0.20.11", path = "./packages/fuel-indexer" } +fuel-indexer-api-server = { version = "0.20.11", path = "./packages/fuel-indexer-api-server" } +fuel-indexer-database = { version = "0.20.11", path = "./packages/fuel-indexer-database" } +fuel-indexer-database-types = { version = "0.20.11", path = "./packages/fuel-indexer-database/database-types" } +fuel-indexer-graphql = { version = "0.20.11", path = "./packages/fuel-indexer-graphql" } +fuel-indexer-lib = { version = "0.20.11", path = "./packages/fuel-indexer-lib" } +fuel-indexer-macro-utils = { version = "0.20.11", path = "./packages/fuel-indexer-macros/macro-utils" } +fuel-indexer-macros = { version = "0.20.11", path = "./packages/fuel-indexer-macros", default-features = false } +fuel-indexer-metrics = { version = "0.20.11", path = "./packages/fuel-indexer-metrics" } +fuel-indexer-plugin = { version = "0.20.11", path = "./packages/fuel-indexer-plugin", default-features = false } +fuel-indexer-postgres = { version = "0.20.11", path = "./packages/fuel-indexer-database/postgres" } +fuel-indexer-schema = { version = "0.20.11", path = "./packages/fuel-indexer-schema", default-features = false } +fuel-indexer-types = { version = "0.20.11", path = "./packages/fuel-indexer-types" } +fuel-indexer-utils = { version = "0.20.11", path = "./packages/fuel-indexer-utils" } fuel-tx = { version = "=0.35.3", default-features = false } fuel-types = { version = "=0.35.3", default-features = false, features = ["serde"] } fuel-vm = { version = "=0.35.3", default-features = false } From 2b834b6159b333e7d6f50eeee773a1cf004267c9 Mon Sep 17 00:00:00 2001 From: dadepo Date: Tue, 26 Sep 2023 17:53:56 +0400 Subject: [PATCH 3/5] enhancement: Removed report_metrics from indexer manifest (#1372) --- docs/src/project-components/manifest.md | 7 ------- .../fuel-explorer/fuel_explorer.manifest.yaml | 4 ---- .../hello_indexer_native.manifest.yaml | 4 ---- .../hello-world/hello-indexer/hello_indexer.manifest.yaml | 4 ---- .../indexers/fuel-indexer-test/fuel_indexer_test.yaml | 1 - plugins/forc-index/src/defaults.rs | 4 ---- 6 files changed, 24 deletions(-) diff --git a/docs/src/project-components/manifest.md b/docs/src/project-components/manifest.md index fe8475b65..e64041184 100644 --- a/docs/src/project-components/manifest.md +++ b/docs/src/project-components/manifest.md @@ -15,7 +15,6 @@ start_block: 1564 end_block: 310000 module: wasm: path/to/my/wasm_module.wasm -report_metrics: true ``` ## `namespace` @@ -81,12 +80,6 @@ The `module` field contains a file path that points to code that will be run as > Important: At this time, `wasm` is the preferred method of execution. -## `report_metrics` - -_Optional._ - -The `report_metrics` field indicates whether to report Prometheus metrics to the Fuel backend. - ## `resumable` _Optional._ diff --git a/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml b/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml index 3902b2f56..21d61ce07 100644 --- a/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml +++ b/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml @@ -34,10 +34,6 @@ graphql_schema: examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schem module: wasm: target/wasm32-unknown-unknown/release/fuel_explorer.wasm -# The report_metrics field contains boolean whether or not to report Prometheus metrics to the -# Fuel backend -report_metrics: true - # 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/hello-world-native/hello-indexer-native/hello_indexer_native.manifest.yaml b/examples/hello-world-native/hello-indexer-native/hello_indexer_native.manifest.yaml index b2fd05a98..e3e2729d8 100644 --- a/examples/hello-world-native/hello-indexer-native/hello_indexer_native.manifest.yaml +++ b/examples/hello-world-native/hello-indexer-native/hello_indexer_native.manifest.yaml @@ -33,10 +33,6 @@ graphql_schema: examples/hello-world-native/hello-indexer-native/schema/hello_i # Important: At this time, wasm is the preferred method of execution. module: native -# The report_metrics field contains boolean whether or not to report Prometheus metrics to the -# Fuel backend -report_metrics: true - # 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/hello-world/hello-indexer/hello_indexer.manifest.yaml b/examples/hello-world/hello-indexer/hello_indexer.manifest.yaml index 07fee8fee..951a93ed6 100644 --- a/examples/hello-world/hello-indexer/hello_indexer.manifest.yaml +++ b/examples/hello-world/hello-indexer/hello_indexer.manifest.yaml @@ -34,10 +34,6 @@ graphql_schema: examples/hello-world/hello-indexer/schema/hello_indexer.schema.g module: wasm: target/wasm32-unknown-unknown/release/hello_indexer.wasm -# The report_metrics field contains boolean whether or not to report Prometheus metrics to the -# Fuel backend -report_metrics: true - # 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/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml index 03ef1f48d..828dd71df 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml @@ -8,5 +8,4 @@ contract_id: fuel1h97g4w7wrwv78ad5xquxs3ecl30xstuqgzsw4uvpakg7yyh8d86spsken2 identifier: index1 module: wasm: target/wasm32-unknown-unknown/release/fuel_indexer_test.wasm -report_metrics: true resumable: true \ No newline at end of file diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 0a3f058c6..56e221cf2 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -123,10 +123,6 @@ graphql_schema: {schema_path} # Important: At this time, wasm is the preferred method of execution. module: {module} -# The report_metrics field contains boolean whether or not to report Prometheus metrics to the -# Fuel backend -report_metrics: true - # 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 From 60038969f65c216ef2ea37214502c87a3e2665b0 Mon Sep 17 00:00:00 2001 From: rashad Date: Tue, 26 Sep 2023 13:05:56 -0400 Subject: [PATCH 4/5] docs: update README (#1379) * docs: update readme * remove forc index pg from forc index check * updates * updates * updates * updates --------- Co-authored-by: Rashad Alston --- config.yaml | 4 +- docs/README.md | 162 ++---------------- docs/src/getting-started/quickstart.md | 4 +- docs/src/project-components/index.md | 2 +- packages/fuel-indexer-utils/src/lib.rs | 3 - .../forc-index/src/ops/forc_index_check.rs | 5 - plugins/forc-index/src/ops/forc_index_new.rs | 4 +- 7 files changed, 24 insertions(+), 160 deletions(-) diff --git a/config.yaml b/config.yaml index 85bf4dc3b..bfc96ec0e 100644 --- a/config.yaml +++ b/config.yaml @@ -3,8 +3,8 @@ # This configuration spec is intended to be used for a single instance # of a Fuel indexer node or service. # -# For more info on how the Fuel indexer works, read the book: https://fuellabs.github.io/fuel-indexer/master/ -# or specifically read up on these configuration options: https://fuellabs.github.io/fuel-indexer/master/getting-started/configuration.html +# For more info on how the Fuel indexer works, read the docs: https://docs.fuel.network/docs/indexer/ +# or specifically read up on these configuration options: https://docs.fuel.network/docs/indexer/getting-started/indexer-service-infrastructure/ # Whether to allow replacing an indexer. # diff --git a/docs/README.md b/docs/README.md index 71724ccbc..882129166 100644 --- a/docs/README.md +++ b/docs/README.md @@ -26,66 +26,38 @@

-The Fuel indexer is a standalone service that can be used to index various components of the blockchain. These indexable components include blocks, transactions, receipts, and state within the Fuel network, allowing for high-performance read-only access to the blockchain for advanced dApp use-cases. - -Want to get started right away? Check out our [Quickstart](https://fuellabs.github.io/fuel-indexer/master/getting-started/quickstart.html)! - -- [For Users](#for-users) - - [Dependencies](#dependencies) - - [`forc-index` Plugin](#forc-index-plugin) - - [WebAssembly (WASM) modules](#webassembly-wasm-modules) -- [For Contributors](#for-contributors) - - [Dev Dependencies](#dev-dependencies) - - [Building from Source](#building-from-source) - - [Testing](#testing) - - [Contributing](#contributing) -- [Read the book](#read-the-book) - -# For Users - -Users of the Fuel indexer project include dApp developers looking to write flexible data-based backends for their dApp frontends, as well as index operators who are interested in managing one or many indexer projects for dApp developers. +### [➡️ Read the Quickstart! ➡️](https://docs.fuel.network/docs/indexer/getting-started/quickstart/) -## Dependencies +## What is the Fuel indexer? -### `fuelup` - -- We use fuelup in order to get the binaries produced by services in the Fuel ecosystem. Fuelup will install binaries related to the Fuel node, the Fuel indexer, the Fuel orchestrator (forc), and other components. -- fuelup can be downloaded [here](https://github.com/FuelLabs/fuelup). +The Fuel indexer is a standalone service that can be used to index various components of the blockchain. These indexable components include blocks, transactions, receipts, and state within the Fuel network, allowing for high-performance read-only access to the blockchain for advanced dApp use-cases. -### `WebAssembly` +> TLDR: It's Infrastructure as a service (IaaS) for Web3 dApp backends. -Two additonal cargo components will be required to build your indexers: `wasm-snip` and the `wasm32-unknown-unknown` target. +## Install -- To install `wasm-snip`: +Fuel's indexer supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon). -```bash -cargo install wasm-snip -``` +> If you don't want to deal with dependency issues we recommend just using Fuel's indexer with Docker, [via the included docker-compose file](https://github.com/FuelLabs/fuel-indexer/blob/develop/scripts/docker-compose.yaml). -To install the `wasm32-unknown-unknown` target via `rustup`: +Install Fuel's toolchain manager - fuelup. ```bash -rustup target add wasm32-unknown-unknown +curl --proto '=https' --tlsv1.2 -sSf https://install.fuel.network/fuelup-init.sh | sh ``` -> IMPORTANT: Users on Apple Silicon macOS systems may experience trouble when trying to build WASM modules due to its `clang` binary not supporting WASM targets. If encountered, you can install a binary with better support from Homebrew (`brew install llvm`) and instruct `rustc` to leverage it by setting the following environment variables: -> -> - `AR=/opt/homebrew/opt/llvm/bin/llvm-ar` -> - `CC=/opt/homebrew/opt/llvm/bin/clang` +> The `fuel-indexer` and `forc-index` binaries should now be available in your `$PATH` -## `forc-index` Plugin +## Usage -The primary way of developing Fuel indexers for end users is via the `forc-index` plugin. The `forc-index` plugin, is a CLI tool that is bundled with Fuel's primary CLI tooling interface, [`forc`](https://github.com/FuelLabs/sway/tree/master/forc) ("Fuel Orchestrator"). +For development, users will primarily use the `forc index` command line utility made available after installing fuelup. -As mentioned in the [dependencies](#dependencies) section, the `forc-index` plugin is made available once you download [`fuelup`](#fuelup). - -If you've successfully gone through the [Quickstart](#quickstart), you should already have `forc-index` installed and available in your `PATH`. - -```text +```bash forc index --help ``` -``` +```text +forc index 0.0.0 Fuel Indexer Orchestrator USAGE: @@ -108,111 +80,11 @@ SUBCOMMANDS: remove Stop and remove a running indexer start Standalone binary for the Fuel indexer service status Check the status of a registered indexer -``` - -## WebAssembly (WASM) modules - -Within the context of the Fuel indexer, WebAssembly (WASM) modules are binaries that are compiled to a `wasm32-unknown-unknown` target, which can then be deployed to a running indexer service, and run as isolated runtime environments. - -There are a few points that Fuel indexer users should know when using WASM: - -1. WASM modules are only used if the execution mode specified in your manifest file is `wasm`. - -2. Developers should be aware of what things may not work off-the-shelf in a module: file I/O, thread spawning, and anything that depends on system libraries. This is due to the technological limitations of WASM as a whole; more information can be found [here](https://rustwasm.github.io/docs/book/reference/which-crates-work-with-wasm.html). - -3. As of this writing, there is a small bug in newly built Fuel indexer WASM modules that produces a WASM runtime error due to an errant upstream dependency. For now, a quick workaround requires the use of `wasm-snip` to remove the errant symbols from the WASM module. More info can be found in the related script [here](https://github.com/FuelLabs/fuel-indexer/blob/develop/scripts/stripper.bash). - -> IMPORTANT: Users on Apple Silicon macOS systems may experience trouble when trying to build WASM modules due to its `clang` binary not supporting WASM targets. If encountered, you can install a binary with better support from Homebrew (`brew install llvm`) and instruct `rustc` to leverage it by setting the following environment variables: -> -> - `export AR=/opt/homebrew/opt/llvm/bin/llvm-ar` -> - `export CC=/opt/homebrew/opt/llvm/bin/clang` - -# For Contributors - -Contributors of the Fuel indexer project are devs looking to help backends for their dApps. - -## Dev Dependencies - -### `docker` - -> IMPORTANT: Docker is not required to run the Fuel indexer. - -- We use Docker to produce reproducible environments for users that may be concerned with installing components with large sets of dependencies (e.g. PostgreSQL). -- Docker can be downloaded [here](https://docs.docker.com/engine/install/). - -### Database - -At this time, the Fuel indexer requires the use of a database. We currently support a single database option: PostgreSQL. PostgreSQL is a database solution with a complex feature set and requires a database server. - -#### PostgreSQL - -> Note: The following explanation is for demonstration purposes only. A production setup should use secure users, permissions, and passwords. -On macOS systems, you can install PostgreSQL through Homebrew. If it isn't present on your system, you can install it according to the [instructions](https://brew.sh/). Once installed, you can add PostgreSQL to your system by running `brew install postgresql`. You can then start the service through `brew services start postgresql`. You'll need to create a database for your indexed data, which you can do by running `createdb [DATABASE_NAME]`. You may also need to create the `postgres` role; you can do so by running `createuser -s postgres`. - -For Linux-based systems, the installation process is similar. First, you should install PostgreSQL according to your distribution's instructions. Once installed, there should be a new `postgres` user account; you can switch to that account by running `sudo -i -u postgres`. After you have switched accounts, you may need to create a `postgres` database role by running `createuser --interactive`. You will be asked a few questions; the name of the role should be `postgres` and you should elect for the new role to be a superuser. Finally, you can create a database by running `createdb [DATABASE_NAME]`. - -In either case, your PostgreSQL database should now be accessible at `postgres://postgres@localhost:5432/[DATABASE_NAME]`. - -### SQLx - -- After setting up your database, you should install `sqlx-cli` in order to run migrations for your indexer service. -- You can do so by running `cargo install sqlx-cli --features postgres`. -- Once installed, you can run the migrations by running the following command after changing `DATABASE_URL` to match your setup. - -## Building from Source - -### Clone repository - -```bash -git clone git@github.com:FuelLabs/fuel-indexer.git && cd fuel-indexer/ ``` -### Run migrations - -#### PostgreSQL migrations - -```sh -cd packages/fuel-indexer-database/postgres -DATABASE_URL=postgres://postgres@localhost sqlx migrate run -``` - -### Start the service - -```bash -cargo run --bin fuel-indexer -``` - -> If no configuration file or other options are passed, the service will default to a `postgres://postgres@localhost` database connection. - -## Testing - -Fuel indexer tests are currently broken out by a database feature flag. In order to run tests with a PostgreSQL backend, use `--features postgres`. - -### Default tests - -```bash -cargo test --locked --workspace --all-targets -``` - -### End-to-end tests - -```bash -cargo test --locked --workspace --all-targets --features postgres -``` - -### `trybuild` tests - -For tests related to the meta-programming used in the Fuel indexer, we use `trybuild`. - -```bash -RUSTFLAGS='-D warnings' cargo test -p fuel-indexer-tests --features trybuild --locked -``` +#### [➡️ For more details on how to build Fuel indexers, read the docs! ➡️](https://docs.fuel.network/docs/indexer/) ## Contributing -If you're interested in contributing PRs to make the Fuel indexer a better project, feel free to read [our contributors document](./CONTRIBUTING.md). - -# Read the book - -Whether you're a user or a contributor, for more detailed info on how the Fuel indexer service works, make sure you [**read the book**](https://fuellabs.github.io/fuel-indexer/master/). +If you're interested in contributing PRs to make the Fuel indexer a better project, feel free to read [our contributors document](./CONTRIBUTING.md). \ No newline at end of file diff --git a/docs/src/getting-started/quickstart.md b/docs/src/getting-started/quickstart.md index 6d8d2367b..8a00ee8a2 100644 --- a/docs/src/getting-started/quickstart.md +++ b/docs/src/getting-started/quickstart.md @@ -156,8 +156,8 @@ An easy-to-use, flexible indexing service built to go fast. 🚗💨 Read the Docs: - Fuel Indexer: https://github.com/FuelLabs/fuel-indexer -- Fuel Indexer Book: https://fuellabs.github.io/fuel-indexer/latest -- Sway Book: https://fuellabs.github.io/sway/latest +- Fuel Indexer Book: https://docs.fuel.network/docs/indexer/ +- Sway Book: https://docs.fuel.network/docs/sway/ - Rust SDK Book: https://rust.fuel.network diff --git a/docs/src/project-components/index.md b/docs/src/project-components/index.md index 2f3f8c057..331045f72 100644 --- a/docs/src/project-components/index.md +++ b/docs/src/project-components/index.md @@ -7,7 +7,7 @@ The Fuel indexer project can currently be used in a number of different ways: - as tooling to interact with indexers - as a standalone service -- as a part of a larger Fuel project, alongside other components of the Fuel ecosystem (e.g. [Sway smart contracts](https://fuellabs.github.io/sway)) +- as a part of a larger Fuel project, alongside other components of the Fuel ecosystem (e.g. [Sway smart contracts](https://docs.fuel.network/docs/sway/)) We'll describe these three different use cases below. diff --git a/packages/fuel-indexer-utils/src/lib.rs b/packages/fuel-indexer-utils/src/lib.rs index 0095a9ce1..e71bab145 100644 --- a/packages/fuel-indexer-utils/src/lib.rs +++ b/packages/fuel-indexer-utils/src/lib.rs @@ -8,9 +8,6 @@ //! # #[allow(unused)] //! use fuel_indexer_utils::prelude::*; //! ``` -//! -//! Examples on how you can use the prelude can be found in -//! the Hello World indexer example(https://fuellabs.github.io/fuel-indexer/master/examples/hello-world.html). /// Utility functions for Fuel indexers. mod utilities; diff --git a/plugins/forc-index/src/ops/forc_index_check.rs b/plugins/forc-index/src/ops/forc_index_check.rs index 1e83d008a..31d8ce970 100644 --- a/plugins/forc-index/src/ops/forc_index_check.rs +++ b/plugins/forc-index/src/ops/forc_index_check.rs @@ -8,7 +8,6 @@ pub async fn init() -> anyhow::Result<()> { let docker = "docker"; let fuelup = "fuelup"; let wasm_snip = "wasm-snip"; - let forc_pg = "forc-postgres"; let rustc = "rustc"; let forc_wallet = "forc-wallet"; @@ -19,7 +18,6 @@ pub async fn init() -> anyhow::Result<()> { find_executable_with_msg(fuel_core); let (docker_emoji, _docker_path, docker_msg) = find_executable_with_msg(docker); let (fuelup_emoji, _fuelup_path, fuelup_msg) = find_executable_with_msg(fuelup); - let (forc_pg_emoji, _forc_pg_path, forc_pg_msg) = find_executable_with_msg(forc_pg); let (wasm_snip_emoji, _wasm_snip_path, wasm_snip_msg) = find_executable_with_msg(wasm_snip); let (rustc_emoji, _rustc_path, rustc_msg) = find_executable_with_msg(rustc); @@ -38,7 +36,6 @@ pub async fn init() -> anyhow::Result<()> { let docker_header = rightpad_whitespace(docker, defaults::HEADER_PADDING); let fuelup_header = rightpad_whitespace(fuelup, defaults::HEADER_PADDING); let wasm_snip_header = rightpad_whitespace(wasm_snip, defaults::HEADER_PADDING); - let forc_pg_header = rightpad_whitespace(forc_pg, defaults::HEADER_PADDING); let rustc_header = rightpad_whitespace(rustc, defaults::HEADER_PADDING); let forc_wallet_header = rightpad_whitespace(forc_wallet, defaults::HEADER_PADDING); @@ -59,8 +56,6 @@ pub async fn init() -> anyhow::Result<()> { +--------+------------------------+---------------------------------------------------------+ | {wasm_snip_emoji} | {wasm_snip_header} | {wasm_snip_msg}| +--------+------------------------+---------------------------------------------------------+ -| {forc_pg_emoji} | {forc_pg_header} | {forc_pg_msg}| -+--------+------------------------+---------------------------------------------------------+ | {rustc_emoji} | {rustc_header} | {rustc_msg}| +--------+------------------------+---------------------------------------------------------+ | {forc_wallet_emoji} | {forc_wallet_header} | {forc_wallet_msg}| diff --git a/plugins/forc-index/src/ops/forc_index_new.rs b/plugins/forc-index/src/ops/forc_index_new.rs index 7e540b04f..65376f6bf 100644 --- a/plugins/forc-index/src/ops/forc_index_new.rs +++ b/plugins/forc-index/src/ops/forc_index_new.rs @@ -8,8 +8,8 @@ fn print_welcome_message() { let read_the_docs = format!( "Read the Docs:\n- {}\n- {}\n- {}\n- {}\n", "Fuel Indexer: https://github.com/FuelLabs/fuel-indexer", - "Fuel Indexer Book: https://fuellabs.github.io/fuel-indexer/latest", - "Sway Book: https://fuellabs.github.io/sway/latest", + "Fuel Indexer Book: https://docs.fuel.network/docs/indexer/", + "Sway Book: https://docs.fuel.network/docs/sway/", "Rust SDK Book: https://rust.fuel.network", ); From 3052b23826cde9528a1e4b77eef9a180ed169302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=9B?= Date: Tue, 26 Sep 2023 19:23:38 +0200 Subject: [PATCH 5/5] enhancement: make sequential blocks trigger configurable (#1378) * make sequential blocks trigger configurable * add --allow-non-sequential-blocks to QA script --- .../fuel-indexer-benchmarks/src/bin/qa.rs | 1 + .../fuel-indexer-database/postgres/src/lib.rs | 33 ++++++++++++++++--- packages/fuel-indexer-database/src/queries.rs | 15 +++++++++ packages/fuel-indexer-lib/src/config/cli.rs | 7 ++++ packages/fuel-indexer-lib/src/config/mod.rs | 5 +++ packages/fuel-indexer-lib/src/defaults.rs | 3 ++ packages/fuel-indexer-schema/src/db/tables.rs | 7 ---- ...sts__commands__default_indexer_config.snap | 1 + ...ommands__forc_index_start_help_output.snap | 3 ++ ...ommands__fuel_indexer_run_help_output.snap | 3 ++ packages/fuel-indexer/src/executor.rs | 27 ++++++++++++++- packages/fuel-indexer/src/service.rs | 7 ++-- .../forc-index/src/ops/forc_index_start.rs | 2 ++ 13 files changed, 100 insertions(+), 14 deletions(-) diff --git a/packages/fuel-indexer-benchmarks/src/bin/qa.rs b/packages/fuel-indexer-benchmarks/src/bin/qa.rs index 336db2e2a..a8f5333b3 100644 --- a/packages/fuel-indexer-benchmarks/src/bin/qa.rs +++ b/packages/fuel-indexer-benchmarks/src/bin/qa.rs @@ -498,6 +498,7 @@ async fn main() { .arg("--fuel-node-port") .arg("80") .arg("--replace-indexer") + .arg("--allow-non-sequential-blocks") .spawn() .unwrap(); diff --git a/packages/fuel-indexer-database/postgres/src/lib.rs b/packages/fuel-indexer-database/postgres/src/lib.rs index 1fafd6b0b..e837d3d1b 100644 --- a/packages/fuel-indexer-database/postgres/src/lib.rs +++ b/packages/fuel-indexer-database/postgres/src/lib.rs @@ -936,10 +936,35 @@ pub async fn create_ensure_block_height_consecutive_trigger( execute_query(conn, trigger_function).await.unwrap(); let trigger = format!( - "CREATE TRIGGER trigger_ensure_block_height_consecutive - BEFORE INSERT OR UPDATE ON {namespace}_{identifier}.indexmetadataentity - FOR EACH ROW - EXECUTE FUNCTION ensure_block_height_consecutive();" + "DO + $$ + BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM pg_trigger + WHERE tgname = 'trigger_ensure_block_height_consecutive' + ) THEN + CREATE TRIGGER trigger_ensure_block_height_consecutive + BEFORE INSERT OR UPDATE ON {namespace}_{identifier}.indexmetadataentity + FOR EACH ROW + EXECUTE FUNCTION ensure_block_height_consecutive(); + END IF; + END; + $$;" + ); + + execute_query(conn, trigger).await?; + + Ok(()) +} + +pub async fn remove_ensure_block_height_consecutive_trigger( + conn: &mut PoolConnection, + namespace: &str, + identifier: &str, +) -> sqlx::Result<()> { + let trigger = format!( + "DROP TRIGGER IF EXISTS trigger_ensure_block_height_consecutive ON {namespace}_{identifier}.indexmetadataentity;" ); execute_query(conn, trigger).await?; diff --git a/packages/fuel-indexer-database/src/queries.rs b/packages/fuel-indexer-database/src/queries.rs index dbbd38d47..590c15fb0 100644 --- a/packages/fuel-indexer-database/src/queries.rs +++ b/packages/fuel-indexer-database/src/queries.rs @@ -424,3 +424,18 @@ pub async fn create_ensure_block_height_consecutive_trigger( } } } + +pub async fn remove_ensure_block_height_consecutive_trigger( + conn: &mut IndexerConnection, + namespace: &str, + identifier: &str, +) -> sqlx::Result<()> { + match conn { + IndexerConnection::Postgres(ref mut c) => { + postgres::remove_ensure_block_height_consecutive_trigger( + c, namespace, identifier, + ) + .await + } + } +} diff --git a/packages/fuel-indexer-lib/src/config/cli.rs b/packages/fuel-indexer-lib/src/config/cli.rs index 798c9e570..731e6488f 100644 --- a/packages/fuel-indexer-lib/src/config/cli.rs +++ b/packages/fuel-indexer-lib/src/config/cli.rs @@ -191,6 +191,13 @@ pub struct IndexerArgs { /// Amount of blocks to return in a request to a Fuel node. #[clap(long, help = "Amount of blocks to return in a request to a Fuel node.", default_value_t = defaults::NODE_BLOCK_PAGE_SIZE)] pub block_page_size: usize, + + /// Allow missing blocks or non-sequential block processing. + #[clap( + long, + help = "Allow missing blocks or non-sequential block processing." + )] + pub allow_non_sequential_blocks: bool, } #[derive(Debug, Parser, Clone)] diff --git a/packages/fuel-indexer-lib/src/config/mod.rs b/packages/fuel-indexer-lib/src/config/mod.rs index 0c06d678b..fb3cf3874 100644 --- a/packages/fuel-indexer-lib/src/config/mod.rs +++ b/packages/fuel-indexer-lib/src/config/mod.rs @@ -107,6 +107,7 @@ impl Default for IndexerArgs { remove_data: defaults::REMOVE_DATA, accept_sql_queries: defaults::ACCEPT_SQL, block_page_size: defaults::NODE_BLOCK_PAGE_SIZE, + allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS, } } } @@ -136,6 +137,7 @@ pub struct IndexerConfig { pub replace_indexer: bool, pub accept_sql_queries: bool, pub block_page_size: usize, + pub allow_non_sequential_blocks: bool, } impl Default for IndexerConfig { @@ -157,6 +159,7 @@ impl Default for IndexerConfig { replace_indexer: defaults::REPLACE_INDEXER, accept_sql_queries: defaults::ACCEPT_SQL, block_page_size: defaults::NODE_BLOCK_PAGE_SIZE, + allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS, } } } @@ -238,6 +241,7 @@ impl From for IndexerConfig { replace_indexer: args.replace_indexer, accept_sql_queries: args.accept_sql_queries, block_page_size: args.block_page_size, + allow_non_sequential_blocks: args.allow_non_sequential_blocks, }; config @@ -325,6 +329,7 @@ impl From for IndexerConfig { replace_indexer: defaults::REPLACE_INDEXER, accept_sql_queries: args.accept_sql_queries, block_page_size: defaults::NODE_BLOCK_PAGE_SIZE, + allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS, }; config diff --git a/packages/fuel-indexer-lib/src/defaults.rs b/packages/fuel-indexer-lib/src/defaults.rs index 14d5c4e2d..fa14ebef0 100644 --- a/packages/fuel-indexer-lib/src/defaults.rs +++ b/packages/fuel-indexer-lib/src/defaults.rs @@ -134,3 +134,6 @@ pub const REMOVE_DATA: bool = false; /// Allow the web server to accept raw SQL queries. pub const ACCEPT_SQL: bool = false; + +/// Allow missing blocks or non-sequential block processing. +pub const ALLOW_NON_SEQUENTIAL_BLOCKS: bool = false; diff --git a/packages/fuel-indexer-schema/src/db/tables.rs b/packages/fuel-indexer-schema/src/db/tables.rs index 0417e069e..b43cbe186 100644 --- a/packages/fuel-indexer-schema/src/db/tables.rs +++ b/packages/fuel-indexer-schema/src/db/tables.rs @@ -187,13 +187,6 @@ impl IndexerSchema { queries::execute_query(conn, stmnt.to_owned()).await?; } - queries::create_ensure_block_height_consecutive_trigger( - conn, - &self.namespace, - &self.identifier, - ) - .await?; - self.tables = tables; Ok(self) diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__default_indexer_config.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__default_indexer_config.snap index e1fb6240d..83519cde3 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__default_indexer_config.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__default_indexer_config.snap @@ -39,4 +39,5 @@ rate_limit: replace_indexer: false accept_sql_queries: false block_page_size: 20 +allow_non_sequential_blocks: false diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_start_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_start_help_output.snap index d7fac7506..da18a60e1 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_start_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__forc_index_start_help_output.snap @@ -11,6 +11,9 @@ OPTIONS: --accept-sql-queries Allow the web server to accept raw SQL queries. + --allow-non-sequential-blocks + Allow missing blocks or non-sequential block processing. + --auth-enabled Require users to authenticate for some operations. diff --git a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__fuel_indexer_run_help_output.snap b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__fuel_indexer_run_help_output.snap index 46f9952af..80255a0ec 100644 --- a/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__fuel_indexer_run_help_output.snap +++ b/packages/fuel-indexer-tests/tests/snapshots/integration_tests__commands__fuel_indexer_run_help_output.snap @@ -11,6 +11,9 @@ OPTIONS: --accept-sql-queries Allow the web server to accept raw SQL queries. + --allow-non-sequential-blocks + Allow missing blocks or non-sequential block processing. + --auth-enabled Require users to authenticate for some operations. diff --git a/packages/fuel-indexer/src/executor.rs b/packages/fuel-indexer/src/executor.rs index 428ea3541..031a23ee6 100644 --- a/packages/fuel-indexer/src/executor.rs +++ b/packages/fuel-indexer/src/executor.rs @@ -11,7 +11,7 @@ use fuel_core_client::client::{ types::TransactionStatus as ClientTransactionStatus, FuelClient, }; -use fuel_indexer_database::IndexerConnectionPool; +use fuel_indexer_database::{queries, IndexerConnectionPool}; use fuel_indexer_lib::{ defaults::*, manifest::Manifest, utils::serialize, WasmIndexerError, }; @@ -76,6 +76,7 @@ impl From for Vec { // types in `fuel_core_client` don't compile to WASM. pub fn run_executor( config: &IndexerConfig, + pool: IndexerConnectionPool, mut executor: T, ) -> impl Future { // TODO: https://github.com/FuelLabs/fuel-indexer/issues/286 @@ -113,7 +114,31 @@ pub fn run_executor( warn!("No end_block specified in the manifest. Indexer({indexer_uid}) will run forever."); } + let allow_non_sequential_blocks = config.allow_non_sequential_blocks; + async move { + let mut conn = pool.acquire().await.unwrap_or_else(|_| { + panic!("Indexer({indexer_uid}) was unable to acquire a database connection.") + }); + + if allow_non_sequential_blocks { + queries::remove_ensure_block_height_consecutive_trigger( + &mut conn, + executor.manifest().namespace(), + executor.manifest().identifier(), + ) + .await + .unwrap_or_else(|_| panic!("Unable to remove the sequential blocks trigger for Indexer({indexer_uid})")); + } else { + queries::create_ensure_block_height_consecutive_trigger( + &mut conn, + executor.manifest().namespace(), + executor.manifest().identifier(), + ) + .await + .unwrap_or_else(|_| panic!("Unable to create the sequential blocks trigger for Indexer({indexer_uid})")); + } + // If we reach an issue that continues to fail, we'll retry a few times before giving up, as // we don't want to quit on the first error. But also don't want to waste CPU. // diff --git a/packages/fuel-indexer/src/service.rs b/packages/fuel-indexer/src/service.rs index 248b9a10c..16891fafd 100644 --- a/packages/fuel-indexer/src/service.rs +++ b/packages/fuel-indexer/src/service.rs @@ -356,8 +356,11 @@ impl IndexerService { self.killers .insert(uid.clone(), executor.kill_switch().clone()); - self.tasks - .spawn(crate::executor::run_executor(&self.config, executor)); + self.tasks.spawn(crate::executor::run_executor( + &self.config, + self.pool.clone(), + executor, + )); } } diff --git a/plugins/forc-index/src/ops/forc_index_start.rs b/plugins/forc-index/src/ops/forc_index_start.rs index 88396bcf6..a94371b92 100644 --- a/plugins/forc-index/src/ops/forc_index_start.rs +++ b/plugins/forc-index/src/ops/forc_index_start.rs @@ -39,6 +39,7 @@ pub async fn init(command: StartCommand) -> anyhow::Result<()> { remove_data, accept_sql_queries, block_page_size, + allow_non_sequential_blocks, } = command; let mut cmd = Command::new("fuel-indexer"); @@ -91,6 +92,7 @@ pub async fn init(command: StartCommand) -> anyhow::Result<()> { ("--auth-enabled", auth_enabled), ("--verbose", verbose), ("--local-fuel-node", local_fuel_node), + ("--allow-non-sequential-blocks", allow_non_sequential_blocks), ]; for (opt, value) in options.iter() { if *value {