Description
As @richardpringle and I discussed offline, it may be more effective to serialize all arguments in one tuple instead of serializing each argument individually.
Currently, when calling #[public]
functions from the host
or with call_program
we do the following
- we serialize every individual parameter using borsh and then prepending it with the length of its bytes.
- deserialize each individual parameter in
rust
by grabbing the byte length and then callingborsh
By serializing all arguments into a singular tuple(which borsh
supports), we can reduce serialization and a good amount of memory allocations. Take the transfer
function for example
pub fn transfer(program: Program, sender: Address, recipient: Address, amount: i64) -> bool
Currently we must serialize and then deserialize every argument we want to pass in. Instead on the host
side we could create a tuple like (program, sender, recipient, amount)
and then perform only one serialization as described above. On the receiving end, we adjust the #[public]
proc macro to do the following
- deserialization the entire tuple at once
- split the tuple up and sequentially pass the arguments to the desired function
Metadata
Metadata
Assignees
Type
Projects
Status
Done ✅
Activity