Expand description
Shared loader-blob upload primitive.
Sway contract bytecode bigger than one blob-upload transaction
can’t be deployed by uploading a single blob and pointing a proxy
at it: the proxy’s run_external_blob LDCs exactly one blob. The
workaround the SDK gives us is convert_to_loader(max_words),
which splits the bytecode into data_blobs and generates a small
loader stub that LDCs each data blob in order before jumping into
the reconstituted code. We upload the data blobs first, then
upload the loader stub as its own blob, and the proxy points at
the loader blob.
Both OrderBookDeploy / TradeAccountDeploy and the contract
integration tests go through this module so the upload flow stays
in one place. Adding it here, instead of inlining it in each
deployer, avoids the silent-bug class where one site forgets to
upload the data blobs (the loader blob would still upload fine,
the proxy would point at it, and the first call would fail with
TransactionSizeLimitExceeded or a missing-blob LDC trap).
Functions§
- build_
loader_ blobs - Build the
(data_blobs, loader_blob)pair forbytecode. The loader blob’s id is the value to use as the proxy’sINITIAL_TARGET;data_blobsare the chunked code pieces it references and must be uploaded first. - upload_
loader_ blobs - Upload
data_blobsthenloader_blob. Blobs already on chain are skipped (blob_existscheck). Returns the loader blob’s id.