Open dusterbloom opened 2 months ago
Rust Optimizer
, opt
and all available tools to minimize binary sizeserde_json_wasm
instead of serde_json
-> this should reduce the contract sizeIt ensures that a previously stored compiled contract is available and started from in-memory cache rather than from disk.
HowTo:
[Cache::Pin]
/ [Cache::Unpin]
InitializePinnedCodes
MsgPinCodes
/ MsgUnpinCode
which makes pinning / unpinning work by votingCosmWasm contracts store their state in the underlying chain’s storage. Large state usage can increase costs or lead to gas constraints during operations like migrations or upgrades.
While there's no universal "hard" limit on state storage size, larger storage leads to higher gas consumption, especially during migrations or upgrades. Hence, state-heavy contracts should be designed to minimize on-chain storage in favour of off-chain storage (IPFS or other).
The current approach of one contract <-> one enclave binary <-> one websocket listener is an idealization of a much more complex system which we have actually developed.
In order to deploy a quartz
app, the app developer needs:
Current setup for the transfers app includes:
Smart Contracts:
Enclave binaries:
Listener:
cli
Core Components:
Supporting Components:
The current setup is limited in that it forces the developer to work on a single contract / binary / listener paradigm. This might lead to creating contracts whose binary size might exceed the current size limit of 800KB / 1MB.
Currently on neutron the biggest deployed core contract is around 200KB. All other contracts I saw were rarely larger than than. Link to neutron pinned contract list
pinned contracts
, proxy contracts
and factory contracts
work and what impacts would they have on our current setup.Nice writeup @dusterbloom , we have a lot of room to think about architecture now that we've gotten a better look at how Quartz is shaping up.
One note I'd like to add is that the paradigm currently is actually more like 1 contract, 1 enclave, plus 1 websocket listener. The last one is referring to what used to be the listen bash scripts, which are now Rust code implemented in wslistener.rs
in every quartz app.
This websocket listener logic is relatively low level, as it requires indexing into tendermint events and calling the tm-prover library. It would be best if we provided clean abstractions so that users could implement basic/common websocket listener logic seamlessly, but with room for deep customization. Where we want to sit on the simplicity-flexibility spectrum is an open question.. maybe it will depend on what we see users asking for in public. watchexec
seems like a good library to draw inspiration from given the similarity of the problem it solves. They definitely sided with the "flexibility" side of the spectrum, so there isn't too much structure to using their library, but their good documentation makes it easy enough to use.
Also, quartz common just re-exports quartz-{contract, enclave, proto} so technically from the user perspective, its the only lib they have to install :)
@dangush really like the idea of giving devs clean abstractions so that they could implement basic/common websocket listener logic seamlessly, but with room for deep customization. Didn't know about watchexec
will check it out.
Summary
This issue came up as we worked on DCAP and the
tcbinfo
contract. The latter in particular proved difficult to first upload then instantiate due to its inclusion of heavy dependencies with alldefault-features
not turned tofalse
.It follows that we need to figure out if our current approach of having one contract / one enclave in combination can lead to problems with contract - size whether at instantiation or later on at migrations or upgrade.
Open questions:
Acceptance Criteria
cosmwasm