Skip to main content

Module blob_loader

Module blob_loader 

Source
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 for bytecode. The loader blob’s id is the value to use as the proxy’s INITIAL_TARGET; data_blobs are the chunked code pieces it references and must be uploaded first.
upload_loader_blobs
Upload data_blobs then loader_blob. Blobs already on chain are skipped (blob_exists check). Returns the loader blob’s id.