-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: deploying large contracts (loader + blob support) #1472
Conversation
…ct_deploy_w_blobs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing but nits/typos - exceptional work. Still woozy after that asm, but I've never seen an asm block so well commented. LFG!
Found while reviewing FuelLabs/fuels-rs#1472. ### Before requesting review - [x] I have reviewed the code myself
Co-authored-by: Oleksii Filonenko <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I love the new workflow and the typesate pattern makes sense here. Left some nits.
Co-authored-by: hal3e <[email protected]>
Co-authored-by: hal3e <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got some nits. Great work 🚀
3006169
Co-authored-by: MujkicA <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! The API is very clean. Still, I'm nervous to see how people will use it; the documentation is very on point and hopefully it'll help people. In any case, we'll have to keep our eyes here and quickly adjust things as needed.
closes: #1470
A thank you to @hal3e for brainstorming with me.
The
Contract
is now a type-state pattern. Please refer to the below diagram to help you understand the changes:The change was needed so that the following might be achieved:
You basically have three states:
A regular contract
What you're used to seeing. It is either initialized from raw code or loaded from a file:
or
With the notable addition of being able to set
configurables
(previously possible only when usingload_from
):a regular contract can be deployed via
deploy
, which hasn't changed, or viasmart_deploy
that will use blobs/loader if the contract is above what can be deployed in a create tx:Loader contract, blobs pending upload
You can turn a regular contract into a loader contract:
or, if you have the blobs, create it directly:
You can also revert back to the regular contract via
revert_to_regular
.If you now call
deploy
the contract will first deploy the blobs and then the loader itself.You can also split this into two parts by first calling
upload_blobs
and thendeploy
:doing so will have
deploy
only submit the create tx while the uploading will be done inupload_blobs
.Loader, with blobs deployed
You arrive at this contract type by eithers having the blob ids and creating it manually:
or by calling
upload_blobs
as in the previous case:Calling deploy on this contract only deploys the loader.
Estimating max blob size
This is a bit tricky. Blob sizes are limited by two things: max transaction size and max transaction gas (both part of consensus parameters). So a blob can be as big as you want as long as the overall tx respects these two global tx limits.
So that means that properly estimating the max blob the user can send becomes a bit tricky. If you fund the tx with 2 coins instead of 1 the answer changes. If you use a predicate instead of a coin also changes the result. Basically whatever impacts the size or gas usage will impact how big the blob can be.
Say you put a blob of 20kb, and fund the tx. Oh look you have extra size and gas to spare. You increase that a bit but you no longer have 1 coin that can cover that but need to use 2. Ok the new blob size is no longer acceptable since you took up a bit of space adding that coin. Remove it. Ok now you can increase the blob size again. But now you again need 2 coins...
As a start, and until we figure something better and robust, there is a crude estimation available in the form of:
The docs explain the caveats of this estimation.
Breaking changes @digorithm
Contract::new
is removed, replaced withContract::regular
.Contract
now accepts a generic argument denoting the type of contract (regular, loader, etc)Checklist