FuelLabs/sway · error · anyhow::Error
Fetching gas costs from testnet is currently not implemented
Error message
Fetching gas costs from testnet is currently not implemented.
What it means
Identical stub to the Mainnet arm: GasCostsSource::provide_gas_costs() returns a hard-coded anyhow error for Self::Testnet because fetching live gas costs is not implemented (sway#7472). Only the BuiltIn arm returns Ok, by deserializing the packaged gas_costs_values.json.
Source
Thrown at forc-test/src/lib.rs:208
Testnet,
File(String),
}
impl GasCostsSource {
pub fn provide_gas_costs(&self) -> Result<GasCostsValues, anyhow::Error> {
match self {
// Values in the `gas_costs_values.json` are taken from the `chain-configuration` repository:
// chain-configuration/upgradelog/ignition/consensus_parameters/<version>.json
// Update these values when there are changes to the on-chain gas costs.
Self::BuiltIn => Ok(serde_json::from_str(include_str!(
"../gas_costs_values.json"
))?),
// TODO: (GAS-COSTS) Fetch actual gas costs from mainnet/testnet and JSON file.
// See: https://github.com/FuelLabs/sway/issues/7472
Self::Mainnet => Err(anyhow::anyhow!(
"Fetching gas costs from mainnet is currently not implemented."
)),
Self::Testnet => Err(anyhow::anyhow!(
"Fetching gas costs from testnet is currently not implemented."
)),
Self::File(_file_path) => Err(anyhow::anyhow!(
"Loading gas costs from a JSON file is currently not implemented."
)),
}
}
}
impl FromStr for GasCostsSource {
type Err = anyhow::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
"built-in" => Ok(Self::BuiltIn),
"mainnet" => Ok(Self::Mainnet),
"testnet" => Ok(Self::Testnet),
file_path => Ok(Self::File(file_path.to_string())),View on GitHub (pinned to 47e5e902fa)
Solutions
- Run `forc test` with the built-in source (default, or explicitly `--gas-costs built-in`)
- Track/upgrade to a forc version implementing testnet fetching (sway#7472)
- If you maintain the tool, implement the arm by fetching consensus parameters and deserializing into GasCostsValues
Example fix
# before forc test --gas-costs testnet # after forc test --gas-costs built-in
Defensive patterns
Strategy: validation
Validate before calling
let source = GasCostsSource::from_str(value)?;
if matches!(source, GasCostsSource::Testnet | GasCostsSource::Mainnet | GasCostsSource::File(_)) {
anyhow::bail!("only 'built-in' gas costs are supported by this forc version");
} Type guard
fn supported(src: &GasCostsSource) -> bool {
matches!(src, GasCostsSource::BuiltIn)
} Try / catch
if let Err(e) = source.provide_gas_costs() {
if e.to_string().contains("testnet") {
// fall back to built-in values for now
return GasCostsSource::BuiltIn.provide_gas_costs();
}
return Err(e);
} Prevention
- Default to omitting --gas-costs (BuiltIn is the default variant)
- Wrap forc invocations in scripts and validate the supported source list once per forc version
When it happens
Trigger: `forc test --gas-costs testnet`, or GasCostsSource::from_str("testnet") followed by provide_gas_costs(). Parsing "testnet" succeeds; the failure happens at gas-cost provisioning time.
Common situations: Developers targeting testnet who expect cost profiles to mirror the live network, or CI configs pinned to `--gas-costs testnet` copied from templates for a forc version that never supported it.
Related errors
- Fetching gas costs from mainnet is currently not implemented
- Loading gas costs from a JSON file is currently not implemen
- missing dependency name
- invalid version requirement `{v}`
- Invalid salt format: {}
AI-assisted analysis of FuelLabs/sway@47e5e902fa (2026-08-16).
Data as JSON: /api/errors/394891a3c54f94d4.
Report an issue: GitHub.