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
As part of this test we've realized that the function can be called with an input array which is less than length of 10 (e.g. [42, 42])
^ which seems to return: [42, 42, 0, 4718592, 65536, 65536, 0, 0, 0, 0]
firstly id expect a failure here; i.e. revert or something since function should not be callable with lower-length input
secondly; i'd expect the remaining values returned to be zeroed out - e.g. [42, 42, 0, 0, 0, 0, 0, 0, 0, 0]
Steps
Manually construct ContractCall struct with encoded args - which represent smaller length array than what the sway function requires
Build tx and call contract using this struct
Analyse the return value (using logdecoder and receiptparser)
Possible Solution(s)
The ideal solution would be to revert; as the input array length must match the sway function input arg
If we dont want to do the above; then i'd expect the returned array to have default values for the remaining list of items
Notes
This may not be replicable with the SDK when using abigen! macro on contracts since the compiler requires strict typing of input params.
The bug above was identified when calling contract functions with manually encoded input params - using the ContractCall struct directly.
Installed components
latest - Update available (8 updates)nightly - Update available (9 updates)fuelup - Up to date
The text was updated successfully, but these errors were encountered:
zees-dev
added
bug
Something isn't working
triage
This issue was opened with a template and needs to be triaged by code owners.
labels
Feb 5, 2025
This is a case of garbage-in-garbage-out; i.e. if you provide input lower than the desired length of the input function; the decoder will continue to read memory input (in this case) until the specified output length (of the return param) is reached.
Related Component
compiler
Problem
As part of a PR review - have encountered a weird edge case for sway functions which take in list of elements - e.g.:
As part of this test we've realized that the function can be called with an input array which is less than length of 10 (e.g.
[42, 42]
)^ which seems to return:
[42, 42, 0, 4718592, 65536, 65536, 0, 0, 0, 0]
[42, 42, 0, 0, 0, 0, 0, 0, 0, 0]
Steps
ContractCall
struct with encoded args - which represent smaller length array than what the sway function requiresPossible Solution(s)
Notes
This may not be replicable with the SDK when using
abigen!
macro on contracts since the compiler requires strict typing of input params.ContractCall
struct directly.Installed components
The text was updated successfully, but these errors were encountered: