diff --git a/.changeset/thirty-steaks-return.md b/.changeset/thirty-steaks-return.md new file mode 100644 index 00000000000..8e34952091d --- /dev/null +++ b/.changeset/thirty-steaks-return.md @@ -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!: `fuel-core@0.32.1` and large contract deployments diff --git a/.fuel-core/configs/chainConfig.json b/.fuel-core/configs/chainConfig.json index e4ea2be7c8d..13d9a1adc5f 100644 --- a/.fuel-core/configs/chainConfig.json +++ b/.fuel-core/configs/chainConfig.json @@ -40,51 +40,47 @@ }, "chain_id": 0, "gas_costs": { - "V1": { + "V4": { "add": 2, "addi": 2, - "aloc": 2, "and": 2, "andi": 2, - "bal": 86, + "bal": 29, "bhei": 2, "bhsh": 2, - "burn": 25770, + "burn": 19976, "cb": 2, - "cfei": 2, "cfsi": 2, "div": 2, "divi": 2, - "eck1": 3114, - "ecr1": 42270, - "ed19": 2878, + "eck1": 1907, + "ecr1": 26135, "eq": 2, "exp": 2, "expi": 2, - "flag": 1, + "flag": 2, "gm": 2, "gt": 2, - "gtf": 12, + "gtf": 13, "ji": 2, "jmp": 2, "jne": 2, "jnei": 2, "jnzi": 2, - "jmpf": 1, - "jmpb": 1, - "jnzf": 1, - "jnzb": 1, - "jnef": 1, - "jneb": 1, + "jmpf": 2, + "jmpb": 2, + "jnzf": 2, + "jnzb": 2, + "jnef": 2, + "jneb": 2, "lb": 2, - "log": 165, + "log": 102, "lt": 2, "lw": 2, - "mint": 29024, + "mint": 18042, "mlog": 2, - "mod_op": 2, "modi": 2, - "move_op": 2, + "mod_op": 2, "movi": 2, "mroo": 4, "mul": 2, @@ -96,55 +92,68 @@ "ori": 2, "poph": 3, "popl": 3, - "pshh": 4, - "pshl": 4, - "ret": 134, - "rvrt": 153, + "pshh": 5, + "pshl": 5, + "move_op": 2, + "ret": 53, "sb": 2, "sll": 2, "slli": 2, "srl": 2, "srli": 2, - "srw": 209, + "srw": 177, "sub": 2, "subi": 2, "sw": 2, - "sww": 22501, - "time": 50, - "tr": 33912, - "tro": 24294, + "sww": 17302, + "time": 35, + "tr": 27852, + "tro": 19718, "wdcm": 2, - "wqcm": 3, + "wqcm": 2, "wdop": 3, "wqop": 3, "wdml": 3, - "wqml": 4, - "wddv": 5, - "wqdv": 6, - "wdmd": 10, - "wqmd": 17, - "wdam": 9, - "wqam": 11, - "wdmm": 10, - "wqmm": 10, + "wqml": 3, + "wddv": 4, + "wqdv": 5, + "wdmd": 8, + "wqmd": 12, + "wdam": 7, + "wqam": 8, + "wdmm": 8, + "wqmm": 8, "xor": 2, "xori": 2, - "alocDependentCost": { + "rvrt": 2, + "aloc": { "HeavyOperation": { "base": 2, - "gasPerUnit": 0 + "gas_per_unit": 0 + } + }, + "bsiz": { + "LightOperation": { + "base": 17, + "units_per_gas": 790 + } + }, + "bldd": { + "LightOperation": { + "base": 15, + "units_per_gas": 272 } }, "cfe": { "HeavyOperation": { "base": 2, - "gasPerUnit": 0 + "gas_per_unit": 0 } }, - "cfeiDependentCost": { + "cfei": { "HeavyOperation": { "base": 2, - "gasPerUnit": 0 + "gas_per_unit": 0 } }, "call": { @@ -171,6 +180,12 @@ "units_per_gas": 237 } }, + "ed19": { + "LightOperation": { + "base": 45, + "units_per_gas": 237 + } + }, "k256": { "LightOperation": { "base": 37, diff --git a/.fuel-core/configs/stateConfig.json b/.fuel-core/configs/stateConfig.json index b529d526570..47803660257 100644 --- a/.fuel-core/configs/stateConfig.json +++ b/.fuel-core/configs/stateConfig.json @@ -469,6 +469,7 @@ } ], "contracts": [], + "blobs": [], "block_height": 0, "da_block_height": 0 } diff --git a/apps/demo-nextjs/package.json b/apps/demo-nextjs/package.json index 76950d49dc0..541f24fd5fd 100644 --- a/apps/demo-nextjs/package.json +++ b/apps/demo-nextjs/package.json @@ -10,7 +10,7 @@ "pretest": "pnpm original:build" }, "dependencies": { - "@fuels/vm-asm": "0.55.0", + "@fuels/vm-asm": "0.56.0", "@types/node": "^22.2.0", "@types/react-dom": "^18.3", "@types/react": "^18.3.3", diff --git a/apps/demo-react-cra/package.json b/apps/demo-react-cra/package.json index 32a1bc95284..f82853f55fb 100644 --- a/apps/demo-react-cra/package.json +++ b/apps/demo-react-cra/package.json @@ -3,7 +3,7 @@ "version": "0.1.29", "private": true, "dependencies": { - "@fuels/vm-asm": "0.55.0", + "@fuels/vm-asm": "0.56.0", "@testing-library/react": "^16.0.0", "@types/node": "^22.2.0", "@types/react": "^18.3.3", diff --git a/apps/demo-react-vite/package.json b/apps/demo-react-vite/package.json index 8aa86dd4e92..cb7a148c6c1 100644 --- a/apps/demo-react-vite/package.json +++ b/apps/demo-react-vite/package.json @@ -11,7 +11,7 @@ "pretest": "pnpm original:build" }, "dependencies": { - "@fuels/vm-asm": "0.55.0", + "@fuels/vm-asm": "0.56.0", "fuels": "workspace:*", "react-dom": "^18.3.1", "react": "^18.3.1" diff --git a/apps/docs-snippets/src/guide/contracts/deploying-contracts.test.ts b/apps/docs-snippets/src/guide/contracts/deploying-contracts.test.ts index 468ec99fb77..770dac2502b 100644 --- a/apps/docs-snippets/src/guide/contracts/deploying-contracts.test.ts +++ b/apps/docs-snippets/src/guide/contracts/deploying-contracts.test.ts @@ -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); + + // 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); }); }); diff --git a/apps/docs/spell-check-custom-words.txt b/apps/docs/spell-check-custom-words.txt index 364d9d1a4ac..1d35721dce0 100644 --- a/apps/docs/spell-check-custom-words.txt +++ b/apps/docs/spell-check-custom-words.txt @@ -329,3 +329,4 @@ Vitest CODEOWNERS incentivise URI +reuploaded \ No newline at end of file diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index 7c184cf39ba..6706cbd591f 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -1,4 +1,4 @@ -