diff --git a/.changeset/thin-beans-act.md b/.changeset/thin-beans-act.md new file mode 100644 index 00000000000..1f59a761870 --- /dev/null +++ b/.changeset/thin-beans-act.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/utils": patch +--- + +chore: made `chainConfig` files match testnet configuration diff --git a/.fuel-core/configs/chainConfig.json b/.fuel-core/configs/chainConfig.json index 13d9a1adc5f..080aa2374e7 100644 --- a/.fuel-core/configs/chainConfig.json +++ b/.fuel-core/configs/chainConfig.json @@ -7,7 +7,7 @@ "max_inputs": 255, "max_outputs": 255, "max_witnesses": 255, - "max_gas_per_tx": 100000000, + "max_gas_per_tx": 30000000, "max_size": 262144, "max_bytecode_subsections": 256 } @@ -17,7 +17,7 @@ "max_predicate_length": 102400, "max_predicate_data_length": 102400, "max_message_data_length": 102400, - "max_gas_per_predicate": 100000000 + "max_gas_per_predicate": 30000000 } }, "script_params": { @@ -34,7 +34,7 @@ }, "fee_params": { "V1": { - "gas_price_factor": 92, + "gas_price_factor": 92000, "gas_per_byte": 63 } }, @@ -79,8 +79,9 @@ "lw": 2, "mint": 18042, "mlog": 2, + "mod": 2, "modi": 2, - "mod_op": 2, + "move": 2, "movi": 2, "mroo": 4, "mul": 2, @@ -94,8 +95,8 @@ "popl": 3, "pshh": 5, "pshl": 5, - "move_op": 2, - "ret": 53, + "ret_contract": 53, + "rvrt_contract": 52, "sb": 2, "sll": 2, "slli": 2, @@ -125,11 +126,10 @@ "wqmm": 8, "xor": 2, "xori": 2, - "rvrt": 2, "aloc": { - "HeavyOperation": { + "LightOperation": { "base": 2, - "gas_per_unit": 0 + "units_per_gas": 15 } }, "bsiz": { @@ -145,154 +145,154 @@ } }, "cfe": { - "HeavyOperation": { - "base": 2, - "gas_per_unit": 0 + "LightOperation": { + "base": 10, + "units_per_gas": 1818181 } }, "cfei": { - "HeavyOperation": { + "LightOperation": { "base": 2, - "gas_per_unit": 0 + "units_per_gas": 1000000 } }, "call": { "LightOperation": { - "base": 18190, - "units_per_gas": 5 + "base": 13513, + "units_per_gas": 7 } }, "ccp": { "LightOperation": { - "base": 48, - "units_per_gas": 22 + "base": 34, + "units_per_gas": 39 } }, "croo": { "LightOperation": { - "base": 131, - "units_per_gas": 2 + "base": 91, + "units_per_gas": 3 } }, "csiz": { "LightOperation": { - "base": 45, - "units_per_gas": 237 + "base": 31, + "units_per_gas": 438 } }, "ed19": { "LightOperation": { - "base": 45, - "units_per_gas": 237 + "base": 3000, + "units_per_gas": 214 } }, "k256": { "LightOperation": { - "base": 37, - "units_per_gas": 3 + "base": 27, + "units_per_gas": 5 } }, "ldc": { "LightOperation": { - "base": 39, - "units_per_gas": 68 + "base": 43, + "units_per_gas": 102 } }, "logd": { "LightOperation": { - "base": 565, - "units_per_gas": 2 + "base": 363, + "units_per_gas": 4 } }, "mcl": { "LightOperation": { - "base": 3, - "units_per_gas": 564 + "base": 2, + "units_per_gas": 1041 } }, "mcli": { "LightOperation": { - "base": 3, - "units_per_gas": 560 + "base": 2, + "units_per_gas": 1025 } }, "mcp": { "LightOperation": { "base": 4, - "units_per_gas": 185 + "units_per_gas": 325 } }, "mcpi": { "LightOperation": { - "base": 9, - "units_per_gas": 455 + "base": 8, + "units_per_gas": 511 } }, "meq": { "LightOperation": { "base": 3, - "units_per_gas": 766 + "units_per_gas": 940 } }, - "retd": { + "retd_contract": { "LightOperation": { - "base": 485, - "units_per_gas": 3 + "base": 305, + "units_per_gas": 4 } }, "s256": { "LightOperation": { - "base": 42, - "units_per_gas": 3 + "base": 31, + "units_per_gas": 4 } }, "scwq": { "HeavyOperation": { - "base": 21672, - "gas_per_unit": 22146 + "base": 16346, + "gas_per_unit": 17163 } }, "smo": { "LightOperation": { - "base": 44437, - "units_per_gas": 1 + "base": 40860, + "units_per_gas": 2 } }, "srwq": { "HeavyOperation": { - "base": 239, - "gas_per_unit": 234 + "base": 187, + "gas_per_unit": 179 } }, "swwq": { "HeavyOperation": { - "base": 22724, - "gas_per_unit": 21231 + "base": 17046, + "gas_per_unit": 16232 } }, "contract_root": { "LightOperation": { - "base": 42, + "base": 31, "units_per_gas": 2 } }, "state_root": { "HeavyOperation": { - "base": 323, - "gas_per_unit": 169 + "base": 236, + "gas_per_unit": 122 } }, "new_storage_per_byte": 63, "vm_initialization": { - "HeavyOperation": { - "base": 5254820, - "gas_per_unit": 0 + "LightOperation": { + "base": 3957, + "units_per_gas": 48 } } } }, "base_asset_id": "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07", - "block_gas_limit": 100000000, + "block_gas_limit": 30000000, "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" } }, diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index cde56a80cea..b36509e5834 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -121,7 +121,7 @@ describe('Provider', () => { { type: ReceiptType.ScriptResult, result: bn(0), - gasUsed: bn(107), + gasUsed: bn(159), }, ]; @@ -407,7 +407,7 @@ describe('Provider', () => { }); it('should cache resources only when TX is successfully submitted', async () => { - const resourceAmount = 50_000; + const resourceAmount = 5_000; const utxosAmount = 2; const testMessage = new TestMessage({ amount: resourceAmount }); @@ -416,6 +416,7 @@ describe('Provider', () => { nodeOptions: { args: ['--poa-instant', 'false', '--poa-interval-period', '1s'], }, + // 3 resources with a total of 15_000 walletsConfig: { coinsPerAsset: utxosAmount, amountPerCoin: resourceAmount, @@ -432,6 +433,7 @@ describe('Provider', () => { expect(coins.length).toBe(utxosAmount); + // Tx will cost 10_000 for the transfer + 1 for fee. All resources will be used const EXPECTED = { utxos: coins.map((coin) => coin.id), messages: [testMessage.nonce], diff --git a/packages/fuel-gauge/src/funding-transaction.test.ts b/packages/fuel-gauge/src/funding-transaction.test.ts index 02c657eea50..82b5fe21801 100644 --- a/packages/fuel-gauge/src/funding-transaction.test.ts +++ b/packages/fuel-gauge/src/funding-transaction.test.ts @@ -223,7 +223,7 @@ describe('Funding Transactions', () => { wallets: [funded], } = launched; - const splitIn = 20; + const splitIn = 204; const sender = Wallet.generate({ provider }); const receiver = Wallet.generate({ provider }); @@ -233,7 +233,7 @@ describe('Funding Transactions', () => { */ await fundingTxWithMultipleUTXOs({ account: sender, - totalAmount: 2400, + totalAmount: 1020, splitIn, baseAssetId: provider.getBaseAssetId(), mainWallet: funded, @@ -271,7 +271,7 @@ describe('Funding Transactions', () => { new FuelError(FuelError.CODES.INVALID_REQUEST, 'not enough coins to fit the target') ); - expect(getResourcesToSpend).toHaveBeenCalledTimes(2); + expect(getResourcesToSpend).toHaveBeenCalled(); }); it('should ensure a partially funded Transaction will require only missing funds', async () => { diff --git a/packages/utils/src/utils/defaultSnapshots/chainConfig.json b/packages/utils/src/utils/defaultSnapshots/chainConfig.json index 13d9a1adc5f..080aa2374e7 100644 --- a/packages/utils/src/utils/defaultSnapshots/chainConfig.json +++ b/packages/utils/src/utils/defaultSnapshots/chainConfig.json @@ -7,7 +7,7 @@ "max_inputs": 255, "max_outputs": 255, "max_witnesses": 255, - "max_gas_per_tx": 100000000, + "max_gas_per_tx": 30000000, "max_size": 262144, "max_bytecode_subsections": 256 } @@ -17,7 +17,7 @@ "max_predicate_length": 102400, "max_predicate_data_length": 102400, "max_message_data_length": 102400, - "max_gas_per_predicate": 100000000 + "max_gas_per_predicate": 30000000 } }, "script_params": { @@ -34,7 +34,7 @@ }, "fee_params": { "V1": { - "gas_price_factor": 92, + "gas_price_factor": 92000, "gas_per_byte": 63 } }, @@ -79,8 +79,9 @@ "lw": 2, "mint": 18042, "mlog": 2, + "mod": 2, "modi": 2, - "mod_op": 2, + "move": 2, "movi": 2, "mroo": 4, "mul": 2, @@ -94,8 +95,8 @@ "popl": 3, "pshh": 5, "pshl": 5, - "move_op": 2, - "ret": 53, + "ret_contract": 53, + "rvrt_contract": 52, "sb": 2, "sll": 2, "slli": 2, @@ -125,11 +126,10 @@ "wqmm": 8, "xor": 2, "xori": 2, - "rvrt": 2, "aloc": { - "HeavyOperation": { + "LightOperation": { "base": 2, - "gas_per_unit": 0 + "units_per_gas": 15 } }, "bsiz": { @@ -145,154 +145,154 @@ } }, "cfe": { - "HeavyOperation": { - "base": 2, - "gas_per_unit": 0 + "LightOperation": { + "base": 10, + "units_per_gas": 1818181 } }, "cfei": { - "HeavyOperation": { + "LightOperation": { "base": 2, - "gas_per_unit": 0 + "units_per_gas": 1000000 } }, "call": { "LightOperation": { - "base": 18190, - "units_per_gas": 5 + "base": 13513, + "units_per_gas": 7 } }, "ccp": { "LightOperation": { - "base": 48, - "units_per_gas": 22 + "base": 34, + "units_per_gas": 39 } }, "croo": { "LightOperation": { - "base": 131, - "units_per_gas": 2 + "base": 91, + "units_per_gas": 3 } }, "csiz": { "LightOperation": { - "base": 45, - "units_per_gas": 237 + "base": 31, + "units_per_gas": 438 } }, "ed19": { "LightOperation": { - "base": 45, - "units_per_gas": 237 + "base": 3000, + "units_per_gas": 214 } }, "k256": { "LightOperation": { - "base": 37, - "units_per_gas": 3 + "base": 27, + "units_per_gas": 5 } }, "ldc": { "LightOperation": { - "base": 39, - "units_per_gas": 68 + "base": 43, + "units_per_gas": 102 } }, "logd": { "LightOperation": { - "base": 565, - "units_per_gas": 2 + "base": 363, + "units_per_gas": 4 } }, "mcl": { "LightOperation": { - "base": 3, - "units_per_gas": 564 + "base": 2, + "units_per_gas": 1041 } }, "mcli": { "LightOperation": { - "base": 3, - "units_per_gas": 560 + "base": 2, + "units_per_gas": 1025 } }, "mcp": { "LightOperation": { "base": 4, - "units_per_gas": 185 + "units_per_gas": 325 } }, "mcpi": { "LightOperation": { - "base": 9, - "units_per_gas": 455 + "base": 8, + "units_per_gas": 511 } }, "meq": { "LightOperation": { "base": 3, - "units_per_gas": 766 + "units_per_gas": 940 } }, - "retd": { + "retd_contract": { "LightOperation": { - "base": 485, - "units_per_gas": 3 + "base": 305, + "units_per_gas": 4 } }, "s256": { "LightOperation": { - "base": 42, - "units_per_gas": 3 + "base": 31, + "units_per_gas": 4 } }, "scwq": { "HeavyOperation": { - "base": 21672, - "gas_per_unit": 22146 + "base": 16346, + "gas_per_unit": 17163 } }, "smo": { "LightOperation": { - "base": 44437, - "units_per_gas": 1 + "base": 40860, + "units_per_gas": 2 } }, "srwq": { "HeavyOperation": { - "base": 239, - "gas_per_unit": 234 + "base": 187, + "gas_per_unit": 179 } }, "swwq": { "HeavyOperation": { - "base": 22724, - "gas_per_unit": 21231 + "base": 17046, + "gas_per_unit": 16232 } }, "contract_root": { "LightOperation": { - "base": 42, + "base": 31, "units_per_gas": 2 } }, "state_root": { "HeavyOperation": { - "base": 323, - "gas_per_unit": 169 + "base": 236, + "gas_per_unit": 122 } }, "new_storage_per_byte": 63, "vm_initialization": { - "HeavyOperation": { - "base": 5254820, - "gas_per_unit": 0 + "LightOperation": { + "base": 3957, + "units_per_gas": 48 } } } }, "base_asset_id": "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07", - "block_gas_limit": 100000000, + "block_gas_limit": 30000000, "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" } }, diff --git a/packages/utils/src/utils/types.ts b/packages/utils/src/utils/types.ts index 8861dbb5461..ca1d41c86f3 100644 --- a/packages/utils/src/utils/types.ts +++ b/packages/utils/src/utils/types.ts @@ -37,35 +37,20 @@ type Operation = }; interface GasCosts { - mod_op: number; - move_op: number; - ret: number; - rvrt: number; - retd: Operation; add: number; addi: number; - aloc: Operation; and: number; andi: number; bal: number; bhei: number; bhsh: number; burn: number; - bldd: Operation; - bsiz: Operation; cb: number; - cfei: Operation; cfsi: number; - croo: Operation; div: number; divi: number; - ecr1: number; eck1: number; - poph: number; - popl: number; - pshh: number; - pshl: number; - ed19: Operation; + ecr1: number; eq: number; exp: number; expi: number; @@ -84,14 +69,15 @@ interface GasCosts { jnzb: number; jnef: number; jneb: number; - k256: Operation; lb: number; log: number; lt: number; lw: number; mint: number; mlog: number; + mod: number; modi: number; + move: number; movi: number; mroo: number; mul: number; @@ -101,9 +87,13 @@ interface GasCosts { not: number; or: number; ori: number; - s256: Operation; + poph: number; + popl: number; + pshh: number; + pshl: number; + ret_contract: number; + rvrt_contract: number; sb: number; - scwq: Operation; sll: number; slli: number; srl: number; @@ -113,7 +103,6 @@ interface GasCosts { subi: number; sw: number; sww: number; - swwq: Operation; time: number; tr: number; tro: number; @@ -134,21 +123,33 @@ interface GasCosts { xor: number; xori: number; new_storage_per_byte: number; - contract_root: Operation; - state_root: Operation; - vm_initialization: Operation; + aloc: Operation; + bsiz: Operation; + bldd: Operation; + cfe: Operation; + cfei: Operation; call: Operation; - mcpi: Operation; ccp: Operation; + croo: Operation; csiz: Operation; + ed19: Operation; + k256: Operation; ldc: Operation; logd: Operation; mcl: Operation; mcli: Operation; mcp: Operation; + mcpi: Operation; meq: Operation; + retd_contract: Operation; + s256: Operation; + scwq: Operation; smo: Operation; srwq: Operation; + swwq: Operation; + contract_root: Operation; + state_root: Operation; + vm_initialization: Operation; } interface Consensus {