Skip to content

Conversation

@d1r1
Copy link
Contributor

@d1r1 d1r1 commented Oct 6, 2025

Summary

Adds fluent-testnet feature flag to maintain backward compatibility with existing testnet deployment while preparing infrastructure for correct FUEL_DENOM_RATE based on benchmarks.

Changes

  • Added fluent-testnet feature flag across entire workspace (all crates, contracts, examples)
  • Implemented conditional compilation for FUEL_DENOM_RATE in crates/types/src/lib.rs:
    • With fluent-testnet feature: 1000 (legacy testnet rate)
    • Without feature: 20 (correct rate based on benchmarks)
  • Updated build.rs to propagate feature flag when compiling contracts
  • Modified e2e tests to use hardcoded 1000 divisor (testnet compatibility mode)
  • Added cfg-if workspace dependency for future conditional logic improvements
  • Reverted revm-rwasm dependency to v82-patched branch

Rationale

Original 1000:1 ratio was a placeholder. Benchmarks show WASM instructions are approximately 20x faster than EVM instructions. However, existing testnet deployment uses rate 1000 and must remain stable. Feature flag enables:

  • Testnet continues using legacy rate 1000 without redeployment
  • Future mainnet/devnet can use correct rate 20
  • Smooth transition without breaking existing deployments

Usage

# For testnet deployment (legacy rate 1000)
cargo build --features fluent-testnet

# For future mainnet/devnet (correct rate 20)
cargo build

Testing

  • All e2e and builtin tests pass with fluent-testnet feature enabled (default in e2e)
  • Feature flag propagates correctly through workspace and contracts
  • Contract compilation respects feature flag via build.rs

Migration Path

  1. Current (testnet): Deploy with --features fluent-testnet
  2. Future (mainnet): Deploy without feature flag to use correct rate
  3. Next steps: Separate PR will update gas calculation to use ceil rounding for costs

Notes

  • This PR only adds feature flag infrastructure - no behavioral changes yet
  • Gas calculation improvements (ceil vs floor) will be in follow-up PR
  • All system fuel constants will be updated in future PR when switching to rate 20

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Criterion results (vs baseline)


running 72 tests


ERC20 Transfer Comparison/1_Original_EVM_ERC20
                        time:   [7.3482 µs 7.3491 µs 7.3501 µs]
Found 32 outliers among 1000 measurements (3.20%)
  16 (1.60%) high mild
  16 (1.60%) high severe
ERC20 Transfer Comparison/2_Emulated_EVM_ERC20
                        time:   [3.0182 ms 3.0190 ms 3.0198 ms]
Found 100 outliers among 1000 measurements (10.00%)
  1 (0.10%) low mild
  58 (5.80%) high mild
  41 (4.10%) high severe
ERC20 Transfer Comparison/3_rWasm_Contract_ERC20
                        time:   [2.4529 ms 2.4560 ms 2.4593 ms]
Found 91 outliers among 1000 measurements (9.10%)
  3 (0.30%) low severe
  4 (0.40%) low mild
  6 (0.60%) high mild
  78 (7.80%) high severe
ERC20 Transfer Comparison/4_Precompiled_UniversalToken
                        time:   [623.46 µs 624.30 µs 625.59 µs]
Found 2 outliers among 1000 measurements (0.20%)
  2 (0.20%) high severe

Greeting Contract Comparison/Original_Greeting
                        time:   [3.6306 µs 3.6322 µs 3.6341 µs]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Greeting Contract Comparison/EVM_Greeting
                        time:   [460.78 µs 460.89 µs 461.00 µs]
Found 10 outliers among 100 measurements (10.00%)
  3 (3.00%) low severe
  4 (4.00%) low mild
  3 (3.00%) high mild
Greeting Contract Comparison/WASM_Greeting
                        time:   [6.9533 µs 6.9553 µs 6.9574 µs]
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe

Heads-up: runner perf is noisy; treat deltas as a smoke check.

@d1r1 d1r1 force-pushed the audit/flu-574 branch 2 times, most recently from e676dc8 to 8a9a0a9 Compare October 7, 2025 12:14
Context: Previous FUEL_DENOM_RATE of 1000 was based on outdated benchmarks. New measurements show WebAssembly instructions are ~20x faster than EVM instructions, not 1000x.

Change: Updated FUEL_DENOM_RATE constant in crates/types/src/lib.rs from 1000 to 20 for production builds. Added 'fluent-testnet' feature flag across workspace to preserve legacy rate (1000) for backward compatibility with existing testnet deployments.

Rationale: Corrects gas cost calculations to match actual performance characteristics. Feature flag prevents breaking existing testnet infrastructure during transition period.

Verification: Benchmarks confirm 20x performance ratio. Feature propagation tested through build system.

Risk: Changes gas consumption calculations for all WASM contract executions
Impact: mainnet (new default), testnet (preserved via feature flag)

BREAKING CHANGE: Production FUEL_DENOM_RATE reduced by 50x affects gas costs for all WASM contracts. Testnet preserves old behavior with fluent-testnet feature.
@d1r1 d1r1 closed this Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants