#5727·sway

Stabilize encoding v1

Author: IGI-111Created Mar 13, 2024Updated Sep 11, 2026
Labelscompilerteam:compiler

Now that #4769 has been implemented we should take the necessary steps to turn the experimental encoding into the default:

Actions that needs to be undone after https://github.com/FuelLabs/sway/pull/5915 is merged:

Enable these tests again:

  • should_pass/language/name_resolution_after_monomorphization (https://github.com/FuelLabs/sway/pull/5996)
  • should_pass/language/shadowing/shadowed_glob_imports
  • should_pass/language/name_resolution_inside_intrinsics

These seems to be a bug related with shadows and glob imports. These issues seem to point to similar issues: https://github.com/FuelLabs/sway/issues/5500, https://github.com/FuelLabs/sway/issues/5700

Fix warnings of these tests

  • should_pass/dca/contract/superabi_contract_calls What happens here is that when we implement a trait for Contract, we actually generate two functions: one prefixed __contract_entry that is called by the method selector; and another one normal, that can be called freely. So, if the trait method is never called manually, it is marked as dead.

  • should_pass/dca/unused_fields auto-impl is making all fields being used. so no dead code warnings are being generated. We need to fix this. https://github.com/FuelLabs/sway/pull/6006

Nice to do for future versions:

1 - Contract method selector using match on string slices, ideally desugaring into radix matching; 2 - CEI analysis running normally on "__entry". We need CEI analysis to know about Never or be smart about control flow;

  • Improve the implementation to increase Buffer size dynamically. Done by https://github.com/FuelLabs/sway/pull/6142, because the buffer intrinsic increase buffer correctly now.

  • Buffer used by AbiEncode needs a push_bytes so we can be more efficient when encoding Bytes and others. This should decrease significantly gas usage in some cases. Done https://github.com/FuelLabs/sway/pull/5942, because we can encode slices directly now.

Encoding v1 for Configurables

From https://github.com/FuelLabs/sway/pull/5942

  • Enable sdk-harness tests that were ignore. SDK needs to update configurable encoding.
  • Correctly error when a type with custom impl for AbiEncode is used in configurables
  • abi_encode_size_hint and numeric: Today we decay Numeric into u64. This should be fixed.
  • improve const_eval loops with time-based limit/warnings.
  • https://github.com/FuelLabs/sway/issues/4352