Skip to content

Commit

Permalink
add --disable-toolchain-version-check flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Oct 10, 2023
1 parent b78faaf commit abd68d7
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/fuel-indexer-api-server/src/uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ pub(crate) async fn register_indexer_assets(

let fuel_indexer_version = env!("CARGO_PKG_VERSION").to_string();

if toolchain_version != fuel_indexer_version {
if !config.disable_toolchain_version_check
&& toolchain_version != fuel_indexer_version
{
return Err(ApiError::ToolchainVersionMismatch {
toolchain_version,
fuel_indexer_version,
Expand Down
13 changes: 13 additions & 0 deletions packages/fuel-indexer-lib/src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ pub struct IndexerArgs {
help = "Allow missing blocks or non-sequential block processing."
)]
pub allow_non_sequential_blocks: bool,

/// By default, Fuel Indexer will only accept WASM indexer modules compiled with the same toolchain version as the version of Fuel Indexer.
#[clap(
long,
help = "By default, Fuel Indexer will only accept WASM indexer modules compiled with the same toolchain version as the version of Fuel Indexer."
)]
pub disable_toolchain_version_check: bool,
}

#[derive(Debug, Parser, Clone)]
Expand Down Expand Up @@ -323,4 +330,10 @@ pub struct ApiServerArgs {
/// Allow the web server to accept raw SQL queries.
#[clap(long, help = "Allow the web server to accept raw SQL queries.")]
pub accept_sql_queries: bool,
/// By default, Fuel Indexer will only accept WASM indexer modules compiled with the same toolchain version as the version of Fuel Indexer.
#[clap(
long,
help = "By default, Fuel Indexer will only accept WASM indexer modules compiled with the same toolchain version as the version of Fuel Indexer."
)]
pub disable_toolchain_version_check: bool,
}
5 changes: 5 additions & 0 deletions packages/fuel-indexer-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl Default for IndexerArgs {
accept_sql_queries: defaults::ACCEPT_SQL,
block_page_size: defaults::NODE_BLOCK_PAGE_SIZE,
allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS,
disable_toolchain_version_check: defaults::DISABLE_TOOLCHAIN_VERSION_CHECK,
}
}
}
Expand Down Expand Up @@ -138,6 +139,7 @@ pub struct IndexerConfig {
pub accept_sql_queries: bool,
pub block_page_size: usize,
pub allow_non_sequential_blocks: bool,
pub disable_toolchain_version_check: bool,
}

impl Default for IndexerConfig {
Expand All @@ -160,6 +162,7 @@ impl Default for IndexerConfig {
accept_sql_queries: defaults::ACCEPT_SQL,
block_page_size: defaults::NODE_BLOCK_PAGE_SIZE,
allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS,
disable_toolchain_version_check: defaults::DISABLE_TOOLCHAIN_VERSION_CHECK,
}
}
}
Expand Down Expand Up @@ -242,6 +245,7 @@ impl From<IndexerArgs> for IndexerConfig {
accept_sql_queries: args.accept_sql_queries,
block_page_size: args.block_page_size,
allow_non_sequential_blocks: args.allow_non_sequential_blocks,
disable_toolchain_version_check: args.disable_toolchain_version_check,
};

config
Expand Down Expand Up @@ -330,6 +334,7 @@ impl From<ApiServerArgs> for IndexerConfig {
accept_sql_queries: args.accept_sql_queries,
block_page_size: defaults::NODE_BLOCK_PAGE_SIZE,
allow_non_sequential_blocks: defaults::ALLOW_NON_SEQUENTIAL_BLOCKS,
disable_toolchain_version_check: args.disable_toolchain_version_check,
};

config
Expand Down
3 changes: 3 additions & 0 deletions packages/fuel-indexer-lib/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ pub const ACCEPT_SQL: bool = false;

/// Allow missing blocks or non-sequential block processing.
pub const ALLOW_NON_SEQUENTIAL_BLOCKS: bool = false;

/// By default, Fuel Indexer will only accept WASM indexer modules compiled with the same toolchain version as the version of Fuel Indexer.
pub const DISABLE_TOOLCHAIN_VERSION_CHECK: bool = false;
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ replace_indexer: false
accept_sql_queries: false
block_page_size: 20
allow_non_sequential_blocks: false
disable_toolchain_version_check: false

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ OPTIONS:
--database <DATABASE>
Database type. [default: postgres] [possible values: postgres]

--disable-toolchain-version-check
By default, Fuel Indexer will only accept WASM indexer modules compiled with the same
toolchain version as the version of Fuel Indexer.

--embedded-database
Automatically create and start database using provided options or defaults.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ OPTIONS:
--database <DATABASE>
Database type. [default: postgres] [possible values: postgres]

--disable-toolchain-version-check
By default, Fuel Indexer will only accept WASM indexer modules compiled with the same
toolchain version as the version of Fuel Indexer.

--fuel-node-host <FUEL_NODE_HOST>
Host of the running Fuel node. [default: localhost]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ OPTIONS:
--database <DATABASE>
Database type. [default: postgres] [possible values: postgres]

--disable-toolchain-version-check
By default, Fuel Indexer will only accept WASM indexer modules compiled with the same
toolchain version as the version of Fuel Indexer.

--embedded-database
Automatically create and start database using provided options or defaults.

Expand Down
5 changes: 5 additions & 0 deletions plugins/forc-index/src/ops/forc_index_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub async fn init(command: StartCommand) -> anyhow::Result<()> {
accept_sql_queries,
block_page_size,
allow_non_sequential_blocks,
disable_toolchain_version_check,
} = command;

let mut cmd = Command::new("fuel-indexer");
Expand Down Expand Up @@ -93,6 +94,10 @@ pub async fn init(command: StartCommand) -> anyhow::Result<()> {
("--verbose", verbose),
("--local-fuel-node", local_fuel_node),
("--allow-non-sequential-blocks", allow_non_sequential_blocks),
(
"--disable-toolchain-version-check",
disable_toolchain_version_check,
),
];
for (opt, value) in options.iter() {
if *value {
Expand Down

0 comments on commit abd68d7

Please sign in to comment.