You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The consensus parameters define the maximum length of vectors such as max_inputs, max_outputs, max_witnesses to be 64-bit values.These values are cast to usize when validating that a transaction’s field does not contain a vector which exceeds these maximums (see figure 23.2). On 32-bit architectures, usize will truncate consensus parameter values larger than 32 bits and reject different transactions than 64-bit platforms.
Figure 23.1: The ConsensusParameters struct definition (fuel-core/crates/client/src/client/schema/chain.rs#11–27)
Short term, define the consensus parameters as 32-bit unsigned integers.
Long term, review platform-dependent behavior such as casts to usize and ensure that code is compatible across architectures.
Either change the data types to be u32, or remove usize casts from the fuel-vm side. Or maybe specify that fuel-vm/core only work on 64bit platforms and add test to that effect.
The text was updated successfully, but these errors were encountered:
xgreenx
changed the title
Consensus parameters are potentially incompatible on 32bit platforms
TOB-FUEL-23: Consensus parameters are potentially incompatible on 32bit platforms
Aug 28, 2023
Description
The consensus parameters define the maximum length of vectors such as max_inputs, max_outputs, max_witnesses to be 64-bit values.These values are cast to usize when validating that a transaction’s field does not contain a vector which exceeds these maximums (see figure 23.2). On 32-bit architectures, usize will truncate consensus parameter values larger than 32 bits and reject different transactions than 64-bit platforms.
Figure 23.1: The ConsensusParameters struct definition (fuel-core/crates/client/src/client/schema/chain.rs#11–27)
Figure 23.2: Validation of transactions against consensus parameters (fuel-vm/fuel-tx/src/transaction/validity.rs#325–335)
Recommendations
Short term, define the consensus parameters as 32-bit unsigned integers.
Long term, review platform-dependent behavior such as casts to usize and ensure that code is compatible across architectures.
Our thoughts
The actual use occurs here:
https://github.com/FuelLabs/fuel-vm/blob/20f1e9b888e359b9d1ac45214673e97277370543/fuel-tx/src/transaction/validity.rs#L325-L335
Either change the data types to be
u32
, or removeusize
casts from the fuel-vm side. Or maybe specify that fuel-vm/core only work on 64bit platforms and add test to that effect.The text was updated successfully, but these errors were encountered: