stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
118 stars 66 forks source link

Fix client code gen to use efficient symbol #1297

Closed leighmcculloch closed 1 month ago

leighmcculloch commented 1 month ago

What

Change the client generated code to use the efficient compile time const Symbol generation for contract invocation function names when the function names are small enough.

Why

The client is intended to be a zero-cost abstraction when compared with invoking a contract with env.invoke_contract(cid, fn, args), but currently it is ~200 bytes more expensive in WASM size. This is because the generated client code is using runtime conversion from a &str to a Symbol for all symbols, even small ones that can be converted to a Symbol at compile time using const expressions.

This change reduces the size of contracts using a single short symbol by ~200 bytes.

Close #1290

leighmcculloch commented 1 month ago

@kalepail this is released in v21.2.0.