From 100ea26b7b329474483ee1430ac97fc26836bc8f Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Sat, 29 Oct 2022 19:26:54 -0300 Subject: [PATCH 01/18] feat: update fuel-core v0.13 --- jest.config.ts | 1 + .../src/contracts/multicall/Forc.toml | 1 - packages/forc-bin/package.json | 4 +- packages/fuel-gauge/scripts/build.sh | 2 +- .../fuel-gauge/src/coverage-contract.test.ts | 22 ++-- .../coverage-contract/src/main.sw | 3 +- packages/providers/fuel-core-schema.graphql | 111 +++++++++++++++--- packages/providers/src/message.ts | 3 +- packages/providers/src/operations.graphql | 7 +- packages/providers/src/provider.test.ts | 6 +- packages/providers/src/provider.ts | 19 ++- packages/providers/src/resource.ts | 2 +- .../src/transaction-request/input.ts | 4 +- .../transaction-response.ts | 20 +++- packages/providers/src/util.ts | 8 ++ .../transactions/src/coders/input.test.ts | 6 +- packages/transactions/src/coders/input.ts | 25 ++-- packages/wallet/src/transfer.test.ts | 8 +- services/fuel-core/Dockerfile | 3 +- services/fuel-core/chainConfig.json | 9 +- 20 files changed, 185 insertions(+), 79 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 9f730b58c21..8327c0c502d 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -7,6 +7,7 @@ const config: Config.InitialOptions = { testPathIgnorePatterns: ['/node_modules/', '/dist/'], modulePathIgnorePatterns: ['/dist/'], coveragePathIgnorePatterns: ['/dist/'], + testTimeout: 15000, }; export default config; diff --git a/packages/contract/src/contracts/multicall/Forc.toml b/packages/contract/src/contracts/multicall/Forc.toml index fdf5a647061..8c7ce4ef2f1 100644 --- a/packages/contract/src/contracts/multicall/Forc.toml +++ b/packages/contract/src/contracts/multicall/Forc.toml @@ -3,4 +3,3 @@ license = "Apache-2.0" name = "multicall" [dependencies] -std = { path = "/Users/luizstacio/fuels/sway/sway-lib-std" } diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 1be80cca26d..f89f2ace0a4 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.26.1", + "version": "0.28.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", @@ -28,7 +28,7 @@ "forc": "./forc.js" }, "config": { - "forcVersion": "0.26.0" + "forcVersion": "0.28.1" }, "dependencies": { "node-fetch": "^2.6.7", diff --git a/packages/fuel-gauge/scripts/build.sh b/packages/fuel-gauge/scripts/build.sh index 2fa639991eb..57c6898c22a 100755 --- a/packages/fuel-gauge/scripts/build.sh +++ b/packages/fuel-gauge/scripts/build.sh @@ -6,7 +6,7 @@ for PROJECT_DIR in ./test-projects/* ; do BIN_DIR="$PROJECT_DIR/out/debug" - forc build -p $PROJECT_DIR --print-finalized-asm + pnpm forc build -p $PROJECT_DIR --print-finalized-asm if [[ $PROJECT_DIR == *"predicate-"* ]]; then pnpm exec ts-node scripts/process-predicate.ts $PROJECT_DIR fi diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 750e38750f0..40b404930f2 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -1,5 +1,7 @@ import type { BN, Message, Contract } from 'fuels'; import { + zeroPad, + arrayify, NativeAssetId, bn, toHex, @@ -353,7 +355,9 @@ describe('Coverage Contract', () => { amount: bn(1), sender: WALLET_B.address, recipient: WALLET_A.address, - data: [8, 7, 6, 5, 4], + data: arrayify( + '0x00000000000000080000000000000007000000000000000600000000000000050000000000000004' + ), nonce: bn(1), daHeight: bn(0), }, @@ -363,7 +367,7 @@ describe('Coverage Contract', () => { amount: bn('12704439083013451934'), sender: WALLET_A.address, recipient: WALLET_B.address, - data: [7], + data: arrayify('0x0000000000000007'), nonce: bn('1017517292834129547'), daHeight: bn('3684546456337077810'), }, @@ -388,19 +392,17 @@ describe('Coverage Contract', () => { amount: bn(900), sender: sender.address, recipient: receiver.address, - data: [12, 13, 14], + data: zeroPad([12, 13, 14], 8), nonce: bn(823), daHeight: bn(0), }, ]; - request.addMessages(messages); const response = await sender.sendTransaction(request); - - await response.wait(); + await response.waitForResult(); const receiverMessages = await receiver.getMessages(); - expect(receiverMessages).toStrictEqual(messages); + expect(receiverMessages).toEqual(messages); }); it('should test sending input messages [3]', async () => { @@ -415,7 +417,7 @@ describe('Coverage Contract', () => { amount: bn(111), sender: sender.address, recipient: receiver.address, - data: [11, 11, 11], + data: zeroPad([11, 11, 11], 8), nonce: bn(100), daHeight: bn(0), }, @@ -423,7 +425,7 @@ describe('Coverage Contract', () => { amount: bn(222), sender: sender.address, recipient: receiver.address, - data: [22, 22, 22], + data: zeroPad([22, 22, 22], 8), nonce: bn(200), daHeight: bn(0), }, @@ -431,7 +433,7 @@ describe('Coverage Contract', () => { amount: bn(333), sender: sender.address, recipient: receiver.address, - data: [33, 33, 33], + data: zeroPad([33, 33, 33], 8), nonce: bn(300), daHeight: bn(0), }, diff --git a/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw b/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw index 8fe31c93502..68255fd1282 100644 --- a/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw +++ b/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw @@ -8,7 +8,6 @@ use std::vec::Vec; use std::option::Option; use std::assert::assert; use std::logging::log; -use std::mem::addr_of; pub struct U8Struct { i: u8, @@ -154,7 +153,7 @@ impl CoverageContract for Contract { log("vector.len"); log(vector.len); log("addr_of vector"); - log(addr_of(vector)); + log(__addr_of(vector)); true }, } diff --git a/packages/providers/fuel-core-schema.graphql b/packages/providers/fuel-core-schema.graphql index f93785ba3f5..eaf01e247c3 100644 --- a/packages/providers/fuel-core-schema.graphql +++ b/packages/providers/fuel-core-schema.graphql @@ -49,10 +49,8 @@ input BalanceFilterInput { type Block { id: BlockId! - height: U64! + header: Header! transactions: [Transaction!]! - time: DateTime! - producer: Address! } type BlockConnection { @@ -281,6 +279,58 @@ type FailureStatus { programState: ProgramState } +type Header { + """ + Hash of the header + """ + id: BlockId! + + """ + The layer 1 height of messages and events to include since the last layer 1 block number. + """ + daHeight: U64! + + """ + Number of transactions in this block. + """ + transactionsCount: U64! + + """ + Number of output messages in this block. + """ + outputMessagesCount: U64! + + """ + Merkle root of transactions. + """ + transactionsRoot: Bytes32! + + """ + Merkle root of messages in this block. + """ + outputMessagesRoot: Bytes32! + + """ + Fuel block height. + """ + height: U64! + + """ + Merkle root of all previous block header hashes. + """ + prevRoot: Bytes32! + + """ + The block producer time. + """ + time: DateTime! + + """ + Hash of the application header. + """ + applicationHash: Bytes32! +} + scalar HexString union Input = InputCoin | InputContract | InputMessage @@ -323,7 +373,7 @@ type Message { sender: Address! recipient: Address! nonce: U64! - data: [Int!]! + data: HexString! daHeight: U64! fuelBlockSpend: U64 } @@ -367,6 +417,18 @@ type MessageOutput { amount: U64! } +type MessageProof { + proofSet: [Bytes32!]! + proofIndex: U64! + sender: Address! + recipient: Address! + nonce: Bytes32! + amount: U64! + data: HexString! + signature: Signature! + header: Header! +} + type Mutation { startSession: ID! endSession(id: ID!): Boolean! @@ -386,12 +448,11 @@ type Mutation { Submits transaction to the txpool """ submit(tx: HexString!): Transaction! - produceBlocks(blocksToProduce: U64!): U64! + produceBlocks(blocksToProduce: U64!, time: TimeParameters): U64! } type NodeInfo { utxoValidation: Boolean! - predicates: Boolean! vmBacktrace: Boolean! minGasPrice: U64! maxTx: U64! @@ -542,6 +603,10 @@ type Query { last: Int before: String ): MessageConnection! + messageProof( + transactionId: TransactionId! + messageId: MessageId! + ): MessageProof """ For each `query_per_asset`, get some spendable resources(of asset specified by the query) owned by @@ -603,6 +668,7 @@ type Receipt { sender: Address recipient: Address nonce: Bytes32 + contractId: ContractId } enum ReceiptType { @@ -650,6 +716,8 @@ enum RunState { scalar Salt +scalar Signature + input SpendQueryElementInput { """ Identifier of the asset to spend. @@ -674,20 +742,35 @@ type SubmittedStatus { type SuccessStatus { block: Block! time: DateTime! - programState: ProgramState! + programState: ProgramState +} + +input TimeParameters { + """ + The time to set on the first block + """ + startTime: U64! + + """ + The time interval between subsequent blocks + """ + blockTimeInterval: U64! } type Transaction { id: TransactionId! - inputAssetIds: [AssetId!]! - inputContracts: [Contract!]! - gasPrice: U64! - gasLimit: U64! - maturity: U64! + inputAssetIds: [AssetId!] + inputContracts: [Contract!] + gasPrice: U64 + gasLimit: U64 + maturity: U64 + txPointer: TxPointer isScript: Boolean! - inputs: [Input!]! + isCreate: Boolean! + isMint: Boolean! + inputs: [Input!] outputs: [Output!]! - witnesses: [HexString!]! + witnesses: [HexString!] receiptsRoot: Bytes32 status: TransactionStatus receipts: [Receipt!] diff --git a/packages/providers/src/message.ts b/packages/providers/src/message.ts index 13861678845..0a439092163 100644 --- a/packages/providers/src/message.ts +++ b/packages/providers/src/message.ts @@ -1,3 +1,4 @@ +import type { BytesLike } from '@ethersproject/bytes'; import type { AbstractAddress } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; @@ -8,7 +9,7 @@ export type Message = { amount: BN; sender: AbstractAddress; recipient: AbstractAddress; - data: number[]; + data: BytesLike; daHeight: BN; nonce: BN; }; diff --git a/packages/providers/src/operations.graphql b/packages/providers/src/operations.graphql index 848e34534ed..6f08f4cf2d1 100644 --- a/packages/providers/src/operations.graphql +++ b/packages/providers/src/operations.graphql @@ -39,12 +39,13 @@ fragment receiptFragment on Receipt { fragment blockFragment on Block { id - height - producer + header { + height + time + } transactions { id } - time } fragment coinFragment on Coin { diff --git a/packages/providers/src/provider.test.ts b/packages/providers/src/provider.test.ts index 761a73047c2..7bccb79373a 100644 --- a/packages/providers/src/provider.test.ts +++ b/packages/providers/src/provider.test.ts @@ -13,7 +13,7 @@ describe('Provider', () => { const version = await provider.getVersion(); - expect(version).toEqual('0.11.2'); + expect(version).toEqual('0.13.0'); }); it('can call()', async () => { @@ -55,7 +55,7 @@ describe('Provider', () => { { type: ReceiptType.ScriptResult, result: bn(0), - gasUsed: bn(0x2c), + gasUsed: bn(0x86b), }, ]; @@ -67,7 +67,7 @@ describe('Provider', () => { // importing and testing it here can generate cycle dependency // as we test this in other modules like call contract its ok to // skip for now - it.skip('can sendTransaction()', async () => { + it('can sendTransaction()', async () => { const provider = new Provider('http://127.0.0.1:4000/graphql'); const response = await provider.sendTransaction({ diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index b4bc9b21c3b..4db4b49d688 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -53,7 +53,6 @@ export type Block = { id: string; height: BN; time: string; - producer: string; transactionIds: string[]; }; @@ -80,7 +79,6 @@ export type ChainInfo = { latestBlock: { id: string; height: BN; - producer: string; time: string; transactions: Array<{ id: string }>; }; @@ -133,9 +131,8 @@ const processGqlChain = (chain: GqlChainInfoFragmentFragment): ChainInfo => ({ }, latestBlock: { id: chain.latestBlock.id, - height: bn(chain.latestBlock.height), - producer: chain.latestBlock.producer, - time: chain.latestBlock.time, + height: bn(chain.latestBlock.header.height), + time: chain.latestBlock.header.time, transactions: chain.latestBlock.transactions.map((i) => ({ id: i.id, })), @@ -212,7 +209,7 @@ export default class Provider { */ async getBlockNumber(): Promise { const { chain } = await this.operations.getChain(); - return bn(chain.latestBlock.height, 10); + return bn(chain.latestBlock.header.height, 10); } /** @@ -428,9 +425,8 @@ export default class Provider { return { id: block.id, - height: bn(block.height), - time: block.time, - producer: block.producer, + height: bn(block.header.height), + time: block.header.time, transactionIds: block.transactions.map((tx) => tx.id), }; } @@ -459,9 +455,8 @@ export default class Provider { return { id: block.id, - height: bn(block.height, 10), - time: block.time, - producer: block.producer, + height: bn(block.header.height, 10), + time: block.header.time, transactionIds: block.transactions.map((tx) => tx.id), transactions: block.transactions.map( (tx) => new TransactionCoder().decode(arrayify(tx.rawPayload), 0)?.[0] diff --git a/packages/providers/src/resource.ts b/packages/providers/src/resource.ts index 69e118e6ca0..da282792720 100644 --- a/packages/providers/src/resource.ts +++ b/packages/providers/src/resource.ts @@ -16,7 +16,7 @@ export type RawMessage = { amount: string; sender: string; recipient: string; - data: Array; + data: string; nonce: string; daHeight: string; }; diff --git a/packages/providers/src/transaction-request/input.ts b/packages/providers/src/transaction-request/input.ts index a73f2051fee..071027227f7 100644 --- a/packages/providers/src/transaction-request/input.ts +++ b/packages/providers/src/transaction-request/input.ts @@ -52,7 +52,7 @@ export type MessageTransactionRequestInput = { witnessIndex: number; /** data of message */ - data: number[]; + data: BytesLike; /** Unique nonce of message */ nonce: BigNumberish; @@ -132,7 +132,7 @@ export const inputify = (value: TransactionRequestInput): Input => { dataLength: value.data.length, predicateLength: predicate.length, predicateDataLength: predicateData.length, - data: value.data, + data: hexlify(value.data), predicate: hexlify(predicate), predicateData: hexlify(predicateData), }; diff --git a/packages/providers/src/transaction-response/transaction-response.ts b/packages/providers/src/transaction-response/transaction-response.ts index 0221a0be71b..ed0e11cd877 100644 --- a/packages/providers/src/transaction-response/transaction-response.ts +++ b/packages/providers/src/transaction-response/transaction-response.ts @@ -24,7 +24,7 @@ import type { } from '../__generated__/operations'; import type Provider from '../provider'; import type { TransactionRequest } from '../transaction-request'; -import { getGasUsedFromReceipts } from '../util'; +import { getGasUsedFromReceipts, sleep } from '../util'; export type TransactionResultCallReceipt = ReceiptCall; export type TransactionResultReturnReceipt = ReceiptReturn; @@ -62,6 +62,9 @@ export type TransactionResult = { time: any; }; +const STATUS_POLLING_INTERVAL_MAX_MS = 5000; +const STATUS_POLLING_INTERVAL_MIN_MS = 500; + const processGqlReceipt = (gqlReceipt: GqlReceiptFragmentFragment): TransactionResultReceipt => { const receipt = new ReceiptCoder().decode(arrayify(gqlReceipt.rawPayload), 0)[0]; @@ -91,6 +94,8 @@ export class TransactionResponse { provider: Provider; /** Gas used on the transaction */ gasUsed: BN = bn(0); + /** Number off attempts to get the committed tx */ + attempts: number = 0; constructor(id: string, request: TransactionRequest, provider: Provider) { this.id = id; @@ -114,8 +119,17 @@ export class TransactionResponse { switch (transaction.status?.type) { case 'SubmittedStatus': { - // TODO: Implement polling or GQL subscription - throw new Error('Not yet implemented'); + // This code implements a similar approach from the fuel-core await_transaction_commit + // https://github.com/FuelLabs/fuel-core/blob/cb37f9ce9a81e033bde0dc43f91494bc3974fb1b/fuel-client/src/client.rs#L356 + // double the interval duration on each attempt until max is reached + // + // This can wait forever, it would be great to implement a max timeout here, but it would require + // improve request handler as response Error not mean that the tx fail. + this.attempts += 1; + await sleep( + Math.min(STATUS_POLLING_INTERVAL_MIN_MS * this.attempts, STATUS_POLLING_INTERVAL_MAX_MS) + ); + return this.waitForResult(); } case 'FailureStatus': { const receipts = transaction.receipts!.map(processGqlReceipt); diff --git a/packages/providers/src/util.ts b/packages/providers/src/util.ts index 65fa74b94fa..1688cb5a096 100644 --- a/packages/providers/src/util.ts +++ b/packages/providers/src/util.ts @@ -95,3 +95,11 @@ export const getGasUsedFromReceipts = (receipts: Array return bn(0); }; + +export function sleep(time: number = 1000) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(true); + }, time); + }); +} diff --git a/packages/transactions/src/coders/input.test.ts b/packages/transactions/src/coders/input.test.ts index 95b7abd5d23..0aa893d9745 100644 --- a/packages/transactions/src/coders/input.test.ts +++ b/packages/transactions/src/coders/input.test.ts @@ -1,4 +1,4 @@ -import { arrayify, hexlify } from '@ethersproject/bytes'; +import { arrayify, hexlify, zeroPad } from '@ethersproject/bytes'; import { bn } from '@fuel-ts/math'; import type { Input, InputMessage } from './input'; @@ -69,7 +69,7 @@ describe('InputCoder', () => { amount: bn(1000), sender: '0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e', recipient: '0xef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a', - data: [12, 13, 14], + data: hexlify(zeroPad([12, 13, 14], 8)), nonce: bn(1234), witnessIndex: 0, dataLength: 3, @@ -91,7 +91,7 @@ describe('InputCoder', () => { amount: bn(1000), sender: '0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e', recipient: '0xef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a', - data: [12, 13, 14], + data: hexlify(zeroPad([12, 13, 14], 8)), nonce: bn(1234), witnessIndex: 0, dataLength: 3, diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index fdeb08f99df..1b8d8ed7344 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -1,7 +1,8 @@ /* eslint-disable max-classes-per-file */ +import type { BytesLike } from '@ethersproject/bytes'; import { arrayify, concat } from '@ethersproject/bytes'; import { sha256 } from '@ethersproject/sha2'; -import { Coder, U64Coder, B256Coder, NumberCoder, ArrayCoder, WORD_SIZE } from '@fuel-ts/abi-coder'; +import { Coder, U64Coder, B256Coder, NumberCoder } from '@fuel-ts/abi-coder'; import type { BN } from '@fuel-ts/math'; import { ByteArrayCoder } from './byte-array'; @@ -205,7 +206,7 @@ export type InputMessage = { recipient: string; /** data of message */ - data: number[]; + data: string; /** Unique nonce of message */ nonce: BN; @@ -241,15 +242,13 @@ export class InputMessageCoder extends Coder { parts.push(new ByteArrayCoder(32).encode(value.recipient)); parts.push(new U64Coder().encode(value.nonce)); parts.push(new U64Coder().encode(value.amount)); - parts.push(new Uint8Array(value.data)); + parts.push(new ByteArrayCoder(value.dataLength).encode(value.data)); return sha256(concat(parts)); } encode(value: InputMessage): Uint8Array { const parts: Uint8Array[] = []; - - const encodedData = new ArrayCoder(new NumberCoder('u8'), value.dataLength).encode(value.data); - + const encodedData = new ByteArrayCoder(value.dataLength).encode(value.data); const mId = InputMessageCoder.getMessageId(value); parts.push(new ByteArrayCoder(32).encode(mId)); parts.push(new ByteArrayCoder(32).encode(value.sender)); @@ -267,14 +266,12 @@ export class InputMessageCoder extends Coder { return concat(parts); } - static decodeData(messageData: number[]): number[] { - const dataLength = messageData.length; - const [data] = new ArrayCoder(new NumberCoder('u8'), dataLength / WORD_SIZE).decode( - arrayify(messageData), - 0 - ); + static decodeData(messageData: BytesLike): Uint8Array { + const bytes = arrayify(messageData); + const dataLength = bytes.length; + const [data] = new ByteArrayCoder(dataLength).decode(bytes, 0); - return data; + return arrayify(data); } decode(data: Uint8Array, offset: number): [InputMessage, number] { @@ -297,7 +294,7 @@ export class InputMessageCoder extends Coder { const predicateLength = decoded; [decoded, o] = new NumberCoder('u16').decode(data, o); const predicateDataLength = decoded; - [decoded, o] = new ArrayCoder(new NumberCoder('u8'), dataLength).decode(data, o); + [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o); const messageData = decoded; [decoded, o] = new ByteArrayCoder(predicateLength).decode(data, o); const predicate = decoded; diff --git a/packages/wallet/src/transfer.test.ts b/packages/wallet/src/transfer.test.ts index 23807812eb9..ff46dcdbb10 100644 --- a/packages/wallet/src/transfer.test.ts +++ b/packages/wallet/src/transfer.test.ts @@ -11,7 +11,8 @@ describe('Wallet', () => { const sender = await generateTestWallet(provider, [[100, NativeAssetId]]); const receiver = await generateTestWallet(provider); - await sender.transfer(receiver.address, 1, NativeAssetId); + const response = await sender.transfer(receiver.address, 1, NativeAssetId); + await response.wait(); const senderBalances = await sender.getBalances(); expect(senderBalances).toEqual([{ assetId: NativeAssetId, amount: bn(99) }]); @@ -32,11 +33,12 @@ describe('Wallet', () => { gasPrice: 1, }); await result.wait(); - }).rejects.toThrowError(`gasLimit(${bn(1)}) is lower than the required (${bn(11)})`); + }).rejects.toThrowError(`gasLimit(${bn(1)}) is lower than the required (${bn(1335)})`); - await sender.transfer(receiver.address, 1, NativeAssetId, { + const response = await sender.transfer(receiver.address, 1, NativeAssetId, { gasLimit: 10000, }); + await response.wait(); const senderBalances = await sender.getBalances(); expect(senderBalances).toEqual([{ assetId: NativeAssetId, amount: bn(99) }]); const receiverBalances = await receiver.getBalances(); diff --git a/services/fuel-core/Dockerfile b/services/fuel-core/Dockerfile index a177667ef3f..180c5179e6e 100644 --- a/services/fuel-core/Dockerfile +++ b/services/fuel-core/Dockerfile @@ -1,5 +1,5 @@ # v0.10.1 +plus -FROM ghcr.io/fuellabs/fuel-core:v0.11.2 +FROM ghcr.io/fuellabs/fuel-core:v0.13.0 ARG IP=0.0.0.0 ARG PORT=4000 @@ -24,7 +24,6 @@ CMD exec ./fuel-core run \ --db-path ${DB_PATH} \ --min-gas-price ${MIN_GAS_PRICE} \ --vm-backtrace \ - --predicates \ --chain ./chainConfig.json EXPOSE ${PORT} diff --git a/services/fuel-core/chainConfig.json b/services/fuel-core/chainConfig.json index 0be11404fef..9c941833c7a 100644 --- a/services/fuel-core/chainConfig.json +++ b/services/fuel-core/chainConfig.json @@ -8,7 +8,7 @@ "parent_network": { "type": "LocalTest" }, - "block_gas_limit": 1000000, + "block_gas_limit": 1000000000, "initial_state": { "coins": [ { @@ -285,7 +285,12 @@ "max_storage_slots": 255, "max_predicate_length": 1048576, "max_predicate_data_length": 1048576, - "gas_price_factor": 1000000, + "gas_price_factor": 1000000000, + "gas_per_byte": 4, "max_message_data_length": 1048576 + }, + "block_producer": { + "utxo_validation": true, + "coinbase_recipient": "0x0000000000000000000000000000000000000000000000000000000000000000" } } From 36ae602a761230603ed93288572f600c0528bc9f Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Sat, 29 Oct 2022 19:33:12 -0300 Subject: [PATCH 02/18] chore: add skip on test --- packages/providers/src/provider.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/providers/src/provider.test.ts b/packages/providers/src/provider.test.ts index 7bccb79373a..e09a2168f8b 100644 --- a/packages/providers/src/provider.test.ts +++ b/packages/providers/src/provider.test.ts @@ -67,7 +67,7 @@ describe('Provider', () => { // importing and testing it here can generate cycle dependency // as we test this in other modules like call contract its ok to // skip for now - it('can sendTransaction()', async () => { + it.skip('can sendTransaction()', async () => { const provider = new Provider('http://127.0.0.1:4000/graphql'); const response = await provider.sendTransaction({ From 8a7a4ec666a4644505ff8af3311aaa00e85fc8da Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 22:28:56 -0700 Subject: [PATCH 03/18] revert --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index f89f2ace0a4..c00ac0db82d 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.28.1", + "version": "0.26.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", From 170694904d68f68747e6af83a5a0d95d7f7f4620 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 22:35:13 -0700 Subject: [PATCH 04/18] add cs --- .changeset/smooth-garlics-poke.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/smooth-garlics-poke.md diff --git a/.changeset/smooth-garlics-poke.md b/.changeset/smooth-garlics-poke.md new file mode 100644 index 00000000000..bf4ceb93b25 --- /dev/null +++ b/.changeset/smooth-garlics-poke.md @@ -0,0 +1,8 @@ +--- +"@fuel-ts/contract": patch +"@fuel-ts/providers": patch +"@fuel-ts/transactions": patch +"@fuel-ts/wallet": patch +--- + +update fuel version From 3340d5d0b5e1bebea0c1ba4149a0c896c9771010 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 22:43:07 -0700 Subject: [PATCH 05/18] use latest --- services/fuel-core/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/fuel-core/Dockerfile b/services/fuel-core/Dockerfile index 180c5179e6e..8a02a2cd484 100644 --- a/services/fuel-core/Dockerfile +++ b/services/fuel-core/Dockerfile @@ -1,5 +1,5 @@ # v0.10.1 +plus -FROM ghcr.io/fuellabs/fuel-core:v0.13.0 +FROM ghcr.io/fuellabs/fuel-core:v0.13.2 ARG IP=0.0.0.0 ARG PORT=4000 From 2c9c7e9efa31b535d2fe5184d70e9149486a8bbe Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:06:27 -0700 Subject: [PATCH 06/18] up v --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index c00ac0db82d..b13edf5fb39 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -28,7 +28,7 @@ "forc": "./forc.js" }, "config": { - "forcVersion": "0.28.1" + "forcVersion": "0.29.0" }, "dependencies": { "node-fetch": "^2.6.7", From 9b4b40420714f6a53329789e6be93625eae4d91b Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:10:38 -0700 Subject: [PATCH 07/18] remove char --- packages/fuel-gauge/test-projects/coverage-contract/src/main.sw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw b/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw index 68255fd1282..0cc27e5ffe7 100644 --- a/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw +++ b/packages/fuel-gauge/test-projects/coverage-contract/src/main.sw @@ -126,7 +126,7 @@ impl CoverageContract for Contract { fn get_contract_id() -> ContractId { let id = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; - ~ContractId::from(id) + ContractId::from(id) } fn get_some_option_u8() -> Option { From 1078e181ebdd1352cae1ef61dc2f4bce5bc4fa2b Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:19:09 -0700 Subject: [PATCH 08/18] update tests --- packages/fuel-gauge/src/contract-factory.test.ts | 3 ++- packages/providers/src/provider.test.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index a86c8077589..1f4a06221fb 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -28,7 +28,8 @@ describe('Contract Factory', () => { expect(contact.interface).toBeInstanceOf(Interface); - await contact.functions.initialize_counter(41).call(); + const { value: valueInitial } = await contact.functions.initialize_counter(41).call(); + expect(valueInitial.toHex()).toEqual(toHex(41)); const { value } = await contact.functions.increment_counter(1).call(); expect(value.toHex()).toEqual(toHex(42)); diff --git a/packages/providers/src/provider.test.ts b/packages/providers/src/provider.test.ts index e09a2168f8b..0553589d8f0 100644 --- a/packages/providers/src/provider.test.ts +++ b/packages/providers/src/provider.test.ts @@ -13,7 +13,7 @@ describe('Provider', () => { const version = await provider.getVersion(); - expect(version).toEqual('0.13.0'); + expect(version).toEqual('0.13.2'); }); it('can call()', async () => { From b8c85dab7708873943511e7d39f60f2a855f0091 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:27:31 -0700 Subject: [PATCH 09/18] adjust message encoding tests post upgrade --- packages/transactions/src/coders/input.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/transactions/src/coders/input.test.ts b/packages/transactions/src/coders/input.test.ts index 0aa893d9745..9d58f1eb338 100644 --- a/packages/transactions/src/coders/input.test.ts +++ b/packages/transactions/src/coders/input.test.ts @@ -79,7 +79,7 @@ describe('InputCoder', () => { predicateData: '0x', }; - const EXPECTED = '0xc2675161a5856e25fe3b526f65461030d2909694582b2c39d2396b409148d6ff'; + const EXPECTED = '0xa2be1e294136b22c8168159892eb26b2503232f1e711e2e6fbb7f8a8b50633b7'; const result = InputMessageCoder.getMessageId(input); expect(result).toEqual(EXPECTED); @@ -104,7 +104,7 @@ describe('InputCoder', () => { const encoded = hexlify(new InputCoder().encode(input)); expect(encoded).toEqual( - '0x0000000000000002c2675161a5856e25fe3b526f65461030d2909694582b2c39d2396b409148d6fff1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6eef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a00000000000003e800000000000004d20000000000000000000000000000001800000000000000000000000000000000000000000000000c000000000000000d000000000000000e' + '0x0000000000000002a2be1e294136b22c8168159892eb26b2503232f1e711e2e6fbb7f8a8b50633b7f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6eef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a00000000000003e800000000000004d20000000000000000000000000000000d0000000000000000000000000000000000000000000c0d0e0000000000' ); }); }); From cd312f4abd9464654a6d266f3772cb0a8d4b812a Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:42:02 -0700 Subject: [PATCH 10/18] rm unused step, rm comment --- .github/workflows/test.yaml | 7 ------- services/fuel-core/Dockerfile | 1 - 2 files changed, 8 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 985cdbc3f8a..93886b63b91 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -31,13 +31,6 @@ jobs: run: | pnpm lint - - name: Setup Docker - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Checking PR Number uses: jwalton/gh-find-current-pr@v1 id: findPr diff --git a/services/fuel-core/Dockerfile b/services/fuel-core/Dockerfile index 8a02a2cd484..c479a745af7 100644 --- a/services/fuel-core/Dockerfile +++ b/services/fuel-core/Dockerfile @@ -1,4 +1,3 @@ -# v0.10.1 +plus FROM ghcr.io/fuellabs/fuel-core:v0.13.2 ARG IP=0.0.0.0 From 21ae5707cb9b4aa8f863954530175f4a278ecce1 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Tue, 1 Nov 2022 23:56:14 -0700 Subject: [PATCH 11/18] break cache --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index b13edf5fb39..8d92d340c12 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.26.1", + "version": "0.29.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", From 03fee37aa84286bcc47865251b65f48a2bd71012 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Wed, 2 Nov 2022 00:03:32 -0700 Subject: [PATCH 12/18] rvt --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 8d92d340c12..b13edf5fb39 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.29.0", + "version": "0.26.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", From 97bda61f0cfef0987654d7c63adb98909474be90 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 00:03:49 -0700 Subject: [PATCH 13/18] change storage type --- .../storage-test-contract/src/main.sw | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw b/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw index c4180810422..dae3f2ed4ce 100644 --- a/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw +++ b/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw @@ -8,6 +8,7 @@ struct StructValidation { } storage { + elll: u64 = 0, var1: u64 = 10, var2: u32 = 20, var3: u16 = 30, @@ -39,26 +40,23 @@ abi StorageTestContract { fn return_var5() -> StructValidation; } -const COUNTER_KEY = 0x0000000000000000000000000000000000000000000000000000000000000000; const VALUE_B256 = 0x0000000000000000000000000000000000000000000000000000000000000001; impl StorageTestContract for Contract { #[storage(write)] fn initialize_counter(value: u64) -> u64 { - store(COUNTER_KEY, value); + storage.elll = value; value } #[storage(read, write)] fn increment_counter(amount: u64) -> u64 { - let value: u64 = get(COUNTER_KEY); - let value = value + amount; - store(COUNTER_KEY, value); - value + let incremented = storage.elll + amount; + storage.elll = incremented; + incremented } #[storage(read)] fn counter() -> u64 { - let value: u64 = get(COUNTER_KEY); - value + storage.elll } // Return values from storage // This is used to test storage initialization, on contract deployment From d07f0f081336a20b4b5083f0e423b331a7dcbff9 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 00:12:02 -0700 Subject: [PATCH 14/18] adjust --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index b13edf5fb39..8d92d340c12 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.26.1", + "version": "0.29.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", From 11c6537b66bfa9a7aa3c4040c0842e1d793bb4d3 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 00:43:45 -0700 Subject: [PATCH 15/18] revert --- .../storage-test-contract/src/main.sw | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw b/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw index dae3f2ed4ce..c4180810422 100644 --- a/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw +++ b/packages/fuel-gauge/test-projects/storage-test-contract/src/main.sw @@ -8,7 +8,6 @@ struct StructValidation { } storage { - elll: u64 = 0, var1: u64 = 10, var2: u32 = 20, var3: u16 = 30, @@ -40,23 +39,26 @@ abi StorageTestContract { fn return_var5() -> StructValidation; } +const COUNTER_KEY = 0x0000000000000000000000000000000000000000000000000000000000000000; const VALUE_B256 = 0x0000000000000000000000000000000000000000000000000000000000000001; impl StorageTestContract for Contract { #[storage(write)] fn initialize_counter(value: u64) -> u64 { - storage.elll = value; + store(COUNTER_KEY, value); value } #[storage(read, write)] fn increment_counter(amount: u64) -> u64 { - let incremented = storage.elll + amount; - storage.elll = incremented; - incremented + let value: u64 = get(COUNTER_KEY); + let value = value + amount; + store(COUNTER_KEY, value); + value } #[storage(read)] fn counter() -> u64 { - storage.elll + let value: u64 = get(COUNTER_KEY); + value } // Return values from storage // This is used to test storage initialization, on contract deployment From 3993680c6e73705b0937fd8bec7d56e4bbeeec80 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 00:54:58 -0700 Subject: [PATCH 16/18] adjust sway version --- packages/forc-bin/package.json | 4 ++-- .../fuel-gauge/test-projects/call-test-contract/src/main.sw | 4 +++- packages/script/src/call-test-script/src/main.sw | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 8d92d340c12..4694e090350 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.29.0", + "version": "0.30.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", @@ -28,7 +28,7 @@ "forc": "./forc.js" }, "config": { - "forcVersion": "0.29.0" + "forcVersion": "0.30.0" }, "dependencies": { "node-fetch": "^2.6.7", diff --git a/packages/fuel-gauge/test-projects/call-test-contract/src/main.sw b/packages/fuel-gauge/test-projects/call-test-contract/src/main.sw index b59f315c497..35d5f21d5fe 100644 --- a/packages/fuel-gauge/test-projects/call-test-contract/src/main.sw +++ b/packages/fuel-gauge/test-projects/call-test-contract/src/main.sw @@ -1,7 +1,9 @@ contract; use std::logging::log; -use std::context::{*, call_frames::*, registers::context_gas}; +use std::context::*; +use std::call_frames::*; +use std::registers::context_gas; use std::contract_id::ContractId; enum TestB256Enum { diff --git a/packages/script/src/call-test-script/src/main.sw b/packages/script/src/call-test-script/src/main.sw index 0c3920ba274..f1d8ce34c90 100644 --- a/packages/script/src/call-test-script/src/main.sw +++ b/packages/script/src/call-test-script/src/main.sw @@ -18,7 +18,7 @@ fn get_script_data() -> T { // Fix weird issue: https://github.com/FuelLabs/sway/issues/1585 let script_length = script_length + script_length % 8; - let is = std::context::registers::instrs_start(); + let is = std::registers::instrs_start(); let script_data_ptr = is + script_length; let script_data = asm(r1: script_data_ptr) { r1: T }; script_data From a32c00bc22f94ee94acfae36688ff7017eb7471e Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 01:16:05 -0700 Subject: [PATCH 17/18] use std lib --- .../script/src/call-test-script/src/main.sw | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/script/src/call-test-script/src/main.sw b/packages/script/src/call-test-script/src/main.sw index f1d8ce34c90..82ef6d5169d 100644 --- a/packages/script/src/call-test-script/src/main.sw +++ b/packages/script/src/call-test-script/src/main.sw @@ -1,5 +1,8 @@ script; +use std::tx::tx_script_data; + + fn log(v: T) { asm(r1: v) { log r1 zero zero zero; @@ -12,25 +15,13 @@ fn logd(v: T) { } } -// TODO: Use std-lib version when it's out: https://github.com/FuelLabs/sway/issues/1062 -fn get_script_data() -> T { - let script_length = std::tx::tx_script_length(); - // Fix weird issue: https://github.com/FuelLabs/sway/issues/1585 - let script_length = script_length + script_length % 8; - - let is = std::registers::instrs_start(); - let script_data_ptr = is + script_length; - let script_data = asm(r1: script_data_ptr) { r1: T }; - script_data -} - struct MyStruct { arg_one: bool, arg_two: u64, } fn main() -> MyStruct { - let my_struct = get_script_data::(); + let my_struct = tx_script_data::(); log(my_struct.arg_one); log(my_struct.arg_two); MyStruct { From 0ffdab945c5c3e42d51519c182ccb99eec0fb656 Mon Sep 17 00:00:00 2001 From: Cameron Manavian Date: Thu, 3 Nov 2022 07:37:16 -0700 Subject: [PATCH 18/18] Update package.json --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 4694e090350..46c5222dbed 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.30.0", + "version": "0.26.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts",