fuels-rs icon indicating copy to clipboard operation
fuels-rs copied to clipboard

Minimize the uniqueness of bytecodes

Open xgreenx opened this issue 1 year ago • 2 comments

Overview

One of the techniques for data compression is the registry and re-usage of the same data across many transactions. We need to minimize the uniqueness of any data in the transactions.

Dynamic data

Script's bytecode

One of the most dynamic points is a script's bytecode since SDK constructs(per each contract) a unique script to call a contract. The SDK encodes each argument of the call in the script, so if the contract accepts five arguments, the script will pass each of them.

It means that each unique function signature requires a unique script to call a contract.

Solution

The solution to this problem may be having one general script that can call any contract with any number of arguments. It will allow us not to spawn a unique script per contract's call and reuse the same script many times.

Passing constants to the script

We need to double-check that we don't put constants into the script. If we put them, we must transfer them into the script data - the dynamic part.

xgreenx avatar Feb 04 '24 22:02 xgreenx

Nice; makes a lot of sense. Thanks for the write up @xgreenx

Should we create a mirror issue for the TS SDK as well?

digorithm avatar Feb 04 '24 22:02 digorithm

OK

ak47952 avatar Feb 05 '24 15:02 ak47952