-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat!: [email protected] and large contract deployments
#2827
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
Merged
Merged
Changes from all commits
Commits
Show all changes
159 commits
Select commit
Hold shift + click to select a range
8f9f28d
feat: intitial support for deploying large contract via blob tx
danielbate 853a442
fix: blob import
danielbate 3173287
feat: remove instanceof checks
danielbate 740745c
feat: blob tx spec and validity fixes
danielbate 2f013fc
feat: correctly get blobIds
danielbate 1e1fbb6
feat: add loader instructions
danielbate 0bbcfdc
feat: append blob ids to loader
danielbate a0e761e
feat: lots of cleanup
danielbate 584cd22
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 3baba23
feat: fix wait for result in blob tx
danielbate 57e8410
chore: linting
danielbate e04d773
test: test mods
danielbate 6829095
chore: add demo package build filter
danielbate cfe4029
test: add max size test for initial deploy method
danielbate 1a04238
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 7d93486
feat: upgrade asm package
danielbate 1b98257
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate b14c753
feat: fix blob cost estimation, funding and blob id handling
danielbate f683923
feat: dynamic blob sizing
danielbate fd95a20
chore: lint
danielbate a7608f7
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 60e7db7
feat: fuel-core with ed19
danielbate 2335817
feat: v4 gas costs, loader fixes and better blob id handling
danielbate b725b29
feat: simplify funding
danielbate e60ef9b
feat: loader contract fixes
danielbate 22864f3
chore: remove redundant code
danielbate adb4548
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 7d3b0fb
feat: isTransactionType helper
danielbate 3bafa2b
chore: doc blocks and pr refactors
danielbate 7c63591
chore: remove math from contract
danielbate 0a97c56
feat: use fuel-core release
danielbate ebd92fc
chore: isTransactionType cleanups
danielbate 7ecfc8c
feat: use regex for response id check
danielbate bb24c41
chore: cleanups
danielbate 96b6e0d
feat: chunk size tolerance
danielbate 0ce01e2
test: deploy test cases
danielbate 57adf3d
feat: add ed19 dependent cost to chain
danielbate d2ebf94
feat: getBytecodeSize
danielbate dda9dc9
docs: documentation for deploy methods
danielbate aac2745
chore: use tolerance const
danielbate 36358fa
chore: update docs
danielbate 4194751
chore: update docs
danielbate bf7ba3b
feat: use [email protected]
danielbate 2aa7735
chore: add test groups
danielbate 82e08fb
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 0ca3c42
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate cf5832c
docs: add chunk tolerance documentation
danielbate 3f76a9a
chore: fix doc
danielbate 90e557e
chore: remove redundant method
danielbate eac868b
chore: deployContractOptions -> deployOptions
danielbate 60322d6
feat: isTransactionTypeBlob
danielbate 16f9189
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate e6e736c
feat: fail blob deploys for invalid funds
danielbate 563a702
chore: fix casing in gas config
danielbate 29d4aa6
chore: linting
danielbate 648999b
test: add e2e
danielbate 350ca5c
chore: enable e2e
danielbate e85c688
chore: update e2e timeout
danielbate 1d534ee
chore: add networkUrl to e2e log
danielbate e1690de
ajust fuel core version
Torres-ssf 5f74186
update fuel core schema
Torres-ssf dbddb32
fixing test case
Torres-ssf 7cefdb6
fix maxFee tests
Torres-ssf 8dd8d53
simplify some tests
Torres-ssf a881d65
ajust some tests
Torres-ssf 2e8a396
chore: add missing test groups
danielbate 389d917
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 5000b71
chore: enable devnet test
danielbate a1d47e9
chore: enable only devnet
danielbate 0ec2b48
add group test
Torres-ssf 75a0606
fix test
Torres-ssf effa5b7
feat: optimise cost estimation
danielbate 2a1d070
add missing import from suggestion
Torres-ssf 097f4ae
make linter happy
Torres-ssf 6fbbc0a
increate test timeout
Torres-ssf da27f7d
increase blob tx tests timeout
Torres-ssf 9e966ce
remove .only
Torres-ssf 71cd33e
feat: pass deploy options to size estimation
danielbate 3417fff
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 65b4bae
chore: disable testnet
danielbate cf1a3c6
test: update isTypeBlob test
danielbate 5208c09
test: use typegend factories in some factory tests
danielbate a5a4aa8
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 0641c7d
test: add missing properties to test chain config
danielbate 55d0739
chore: lint
danielbate a321b81
docs: add loader script rference
danielbate 7905c38
chore: improve chunk fuc
danielbate d4b2f27
chore: remove redundant cast
danielbate 8339d10
docs: update deploying contracts intro
danielbate 6f1d2e1
feat: update max size error message
danielbate 6a9fb26
chore: small refactor for factoryt
danielbate 0d7c34f
chore: refactor
danielbate 339ec6c
chore: nit
danielbate 51901f6
docs: update errors docs
danielbate f08abe5
test: transactionRequestify tests
danielbate 5091527
test: add another devnet test
danielbate fd23a7c
doc: add further info around chunk size tolerance
danielbate 13f6dec
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate a86a6ac
chore: return e2e to defualts
danielbate 83bc54b
chore: add spell check words
danielbate a71e4ba
chore: remove breaking change
danielbate fda0c11
chore: changeset
danielbate f9879c8
fix: arrayify bytecode
danielbate efdc3ed
fix: use workspace version
danielbate 581d662
chore: lock file
danielbate 12ffc55
fix: changeset
danielbate ab792e9
chore: depsync
danielbate 9dff6c0
chore: update lock
danielbate 7117181
Merge branch 'master' into db/feat/blob-contract-deploys
danielbate 4a3f1c5
docs: fix links
danielbate a9cbbce
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 09d809c
feat: BytesLike in contract factory
danielbate 63f13f1
chore: disable testnet
danielbate 080df58
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 586a0da
test: fix docs assertion
danielbate 853bf35
feat: account for max tx size consensus param
danielbate 369576b
test: blob configurable test
danielbate 65d6c7c
test: fix assertion
danielbate 469f8d3
test: deploy via blobs with storage
danielbate 15e8510
feat: chunkSizeTolerance -> chunkSizeOverride
danielbate 41da418
feat: manually use v4 gas types
danielbate 83bc39f
chore: update snippet
danielbate 1312fe3
feat: user patch fuel-core, fixes for devnet, blob ID already uploade…
danielbate 434aa92
chore: chunkSizeTolerance ->chunkSizeOverride
danielbate a405449
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 84a876d
test: e2e updates
danielbate 38db5a5
chore: merge conflict
danielbate 27ee501
chore: restore fuel-core version
danielbate b592cf9
chore: fix built in version
danielbate 9bf6c1c
chore: 0.32.1 upgrade
danielbate 7d0ecad
chore: changeset
danielbate 9ecb1dc
choer: e2e
danielbate 4d685ef
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 3eb9e1e
chore: lint
danielbate 22013c2
chore: enable testnet
danielbate c84c76a
chore: lint
danielbate 226455c
chore: update changeset
danielbate faa4c86
docs: add typegen to snippet
danielbate da41c8b
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 9a12071
chore: dont export chunk size constant
danielbate a0991d7
undo test modification after fuel-core patch
Torres-ssf 71dceae
docs: update doc
danielbate 041bbaf
feat: override -> multiplier
danielbate d2f0987
Merge branch 'db/feat/blob-contract-deploys' of https://github.com/Fu…
danielbate 5223798
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 4cb5ff6
test: add bytecode size check
danielbate 1b17536
test: fix assertion
danielbate f7737a8
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 05bd455
Merge branch 'master' into db/feat/blob-contract-deploys
danielbate 1ebb3db
increase funding attempts to 5
Torres-ssf 85e98eb
create error code
Torres-ssf 0a5dfb4
throw error if funding attempts are exceed
Torres-ssf 2eb233d
add gasPrice to fund method params to avoid re-fetch
Torres-ssf 4b931ee
chore: remove blob e2e
danielbate a6d3daf
Merge branch 'db/feat/blob-contract-deploys' of github.com:FuelLabs/f…
Torres-ssf 373dbb1
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate 6a4931f
chore: update nomenclature
danielbate 29eafac
chore: note around blob deploys
danielbate 55636bc
doc: typo
danielbate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| "@fuel-ts/account": minor | ||
| "@fuel-ts/contract": minor | ||
| "@fuel-ts/errors": minor | ||
| "@fuel-ts/program": minor | ||
| "@fuel-ts/transactions": minor | ||
| "@fuel-ts/utils": minor | ||
| "@fuel-ts/versions": minor | ||
| "@internal/fuel-core": minor | ||
| --- | ||
|
|
||
| feat!: `[email protected]` and large contract deployments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -469,6 +469,7 @@ | |
| } | ||
| ], | ||
| "contracts": [], | ||
| "blobs": [], | ||
| "block_height": 0, | ||
| "da_block_height": 0 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 95 additions & 50 deletions
145
apps/docs-snippets/src/guide/contracts/deploying-contracts.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,110 @@ | ||
| import { readFileSync } from 'fs'; | ||
| import { Provider, FUEL_NETWORK_URL, Wallet, ContractFactory } from 'fuels'; | ||
| import { join } from 'path'; | ||
| /* eslint-disable @typescript-eslint/no-shadow */ | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| import { Provider, TESTNET_NETWORK_URL, Wallet, ContractFactory, hexlify } from 'fuels'; | ||
| import { launchTestNode } from 'fuels/test-utils'; | ||
|
|
||
| import { DocSnippetProjectsEnum } from '../../../test/fixtures/forc-projects'; | ||
| import { getTestWallet } from '../../utils'; | ||
| import { EchoValuesFactory as TypegenFactory, EchoValues } from '../../../test/typegen'; | ||
|
|
||
| /** | ||
| * @group node | ||
| * @group browser | ||
| */ | ||
| describe(__filename, () => { | ||
| let PRIVATE_KEY: string; | ||
| let projectsPath: string; | ||
| let contractName: string; | ||
| describe('Deploying Contracts', () => { | ||
| it('gets the max contract size for the chain', async () => { | ||
| using launched = await launchTestNode(); | ||
|
|
||
| beforeAll(async () => { | ||
| const wallet = await getTestWallet(); | ||
| PRIVATE_KEY = wallet.privateKey; | ||
| projectsPath = join(__dirname, '../../../test/fixtures/forc-projects'); | ||
| const { provider: testProvider } = launched; | ||
| const TESTNET_NETWORK_URL = testProvider.url; | ||
|
|
||
| contractName = DocSnippetProjectsEnum.ECHO_VALUES; | ||
| }); | ||
|
|
||
| it('should successfully deploy and execute contract function', async () => { | ||
| // #region contract-setup-1 | ||
| // #context const PRIVATE_KEY = "..." | ||
|
|
||
| const provider = await Provider.create(FUEL_NETWORK_URL); | ||
|
|
||
| const wallet = Wallet.fromPrivateKey(PRIVATE_KEY, provider); | ||
| // #endregion contract-setup-1 | ||
|
|
||
| // #region contract-setup-2 | ||
| // #context const contractsDir = join(__dirname, '../path/to/contracts/dir') | ||
| // #context const contractName = "contract-name" | ||
|
|
||
| const byteCodePath = join(projectsPath, `${contractName}/out/release/${contractName}.bin`); | ||
| const byteCode = readFileSync(byteCodePath); | ||
|
|
||
| const abiJsonPath = join(projectsPath, `${contractName}/out/release/${contractName}-abi.json`); | ||
| const abi = JSON.parse(readFileSync(abiJsonPath, 'utf8')); | ||
| // #endregion contract-setup-2 | ||
| // #region get-contract-max-size | ||
| // #import { Provider, TESTNET_NETWORK_URL }; | ||
|
|
||
| // #region contract-setup-3 | ||
| const factory = new ContractFactory(byteCode, abi, wallet); | ||
|
|
||
| const { contractId, transactionId, waitForResult } = await factory.deploy(); | ||
| // #endregion contract-setup-3 | ||
| const provider = await Provider.create(TESTNET_NETWORK_URL); | ||
| const { consensusParameters } = provider.getChain(); | ||
| const contractSizeLimit = consensusParameters.contractParameters.contractMaxSize; | ||
| // #endregion get-contract-max-size | ||
| expect(contractSizeLimit).toBeDefined(); | ||
| }); | ||
|
|
||
| // #region contract-setup-4 | ||
| it('deploys a contract', async () => { | ||
| using launched = await launchTestNode(); | ||
|
|
||
| const { | ||
| provider: testProvider, | ||
| wallets: [testWallet], | ||
| } = launched; | ||
| const TESTNET_NETWORK_URL = testProvider.url; | ||
| const WALLET_PVT_KEY = testWallet.privateKey; | ||
| const bytecode = TypegenFactory.bytecode; | ||
|
|
||
| // #region setup | ||
| // #import { Provider, TESTNET_NETWORK_URL, Wallet }; | ||
| // #context import { WALLET_PVT_KEY } from 'path/to/my/env/file'; | ||
| // #context import { TypegenFactory } from 'path/to/typegen/outputs'; | ||
|
|
||
| const provider = await Provider.create(TESTNET_NETWORK_URL); | ||
| const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); | ||
| const factory = new TypegenFactory(wallet); | ||
| // #endregion setup | ||
| expect(hexlify(factory.bytecode)).toBe(hexlify(bytecode)); | ||
|
|
||
| // #region deploy | ||
| // Deploy the contract | ||
| const { waitForResult, contractId, transactionId } = await factory.deploy(); | ||
| // Await it's deployment | ||
| const { contract, transactionResult } = await waitForResult(); | ||
| // #endregion contract-setup-4 | ||
|
|
||
| // #region contract-setup-5 | ||
| const call = await contract.functions.echo_u8(15).call(); | ||
| // #endregion deploy | ||
| expect(contract).toBeDefined(); | ||
| expect(transactionId).toBeDefined(); | ||
| expect(transactionResult.status).toBeTruthy(); | ||
| expect(contractId).toBe(contract.id.toB256()); | ||
|
|
||
| // #region call | ||
| // Call the contract | ||
| const { waitForResult: waitForCallResult } = await contract.functions.echo_u8(10).call(); | ||
| // Await the result of the call | ||
| const { value } = await waitForCallResult(); | ||
| // #endregion call | ||
| expect(value).toBe(10); | ||
| }); | ||
|
|
||
| const { value } = await call.waitForResult(); | ||
| // #endregion contract-setup-5 | ||
| it('deploys a large contract as blobs', async () => { | ||
| using launched = await launchTestNode(); | ||
|
|
||
| const { | ||
| provider: testProvider, | ||
| wallets: [testWallet], | ||
| } = launched; | ||
| const TESTNET_NETWORK_URL = testProvider.url; | ||
| const WALLET_PVT_KEY = testWallet.privateKey; | ||
| const abi = EchoValues.abi; | ||
| const bytecode = TypegenFactory.bytecode; | ||
|
|
||
| // #region blobs | ||
| // #import { Provider, TESTNET_NETWORK_URL, Wallet, ContractFactory }; | ||
| // #context import { WALLET_PVT_KEY } from 'path/to/my/env/file'; | ||
| // #context import { bytecode, abi } from 'path/to/typegen/outputs'; | ||
|
|
||
| const provider = await Provider.create(TESTNET_NETWORK_URL); | ||
| const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); | ||
| const factory = new ContractFactory(bytecode, abi, wallet); | ||
danielbate marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Deploy the contract as blobs | ||
| const { waitForResult, contractId, transactionId } = await factory.deployAsBlobTx({ | ||
| // Increasing chunk size multiplier to be 90% of the max chunk size | ||
| chunkSizeMultiplier: 0.9, | ||
| }); | ||
| // Await it's deployment | ||
| const { contract, transactionResult } = await waitForResult(); | ||
| // #endregion blobs | ||
|
|
||
| expect(contract).toBeDefined(); | ||
| expect(transactionId).toBeDefined(); | ||
| expect(contractId).toBeDefined(); | ||
| expect(transactionResult.isStatusSuccess).toBeTruthy(); | ||
| expect(value).toBe(15); | ||
| expect(transactionResult.status).toBeTruthy(); | ||
| expect(contractId).toBe(contract.id.toB256()); | ||
|
|
||
| const { waitForResult: waitForCallResult } = await contract.functions.echo_u8(10).call(); | ||
| const { value } = await waitForCallResult(); | ||
| expect(value).toBe(10); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -329,3 +329,4 @@ Vitest | |
| CODEOWNERS | ||
| incentivise | ||
| URI | ||
| reuploaded | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.