Skip to content

Commit

Permalink
feat: update fuel-core v0.13 (#563)
Browse files Browse the repository at this point in the history
* feat: update fuel-core v0.13

* chore: add skip on test

* revert

* add cs

* use latest

* up v

* remove char

* update tests

* adjust message encoding tests post upgrade

* rm unused step, rm comment

* break cache

* rvt

* change storage type

* adjust

* revert

* adjust sway version

* use std lib

* Update package.json

Co-authored-by: Cameron Manavian <cameron.manavian@fuel.sh>
  • Loading branch information
luizstacio and Cameron Manavian authored Nov 3, 2022
1 parent cf9e017 commit 2a98c1e
Show file tree
Hide file tree
Showing 25 changed files with 202 additions and 101 deletions.
8 changes: 8 additions & 0 deletions .changeset/smooth-garlics-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@fuel-ts/contract": patch
"@fuel-ts/providers": patch
"@fuel-ts/transactions": patch
"@fuel-ts/wallet": patch
---

update fuel version
7 changes: 0 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const config: Config.InitialOptions = {
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
modulePathIgnorePatterns: ['/dist/'],
coveragePathIgnorePatterns: ['/dist/'],
testTimeout: 15000,
};

export default config;
1 change: 0 additions & 1 deletion packages/contract/src/contracts/multicall/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ license = "Apache-2.0"
name = "multicall"

[dependencies]
std = { path = "/Users/luizstacio/fuels/sway/sway-lib-std" }
2 changes: 1 addition & 1 deletion packages/forc-bin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"forc": "./forc.js"
},
"config": {
"forcVersion": "0.28.1"
"forcVersion": "0.30.0"
},
"dependencies": {
"node-fetch": "^2.6.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/fuel-gauge/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/fuel-gauge/src/contract-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
22 changes: 12 additions & 10 deletions packages/fuel-gauge/src/coverage-contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { BN, Message, Contract } from 'fuels';
import {
zeroPad,
arrayify,
NativeAssetId,
bn,
toHex,
Expand Down Expand Up @@ -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),
},
Expand All @@ -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'),
},
Expand All @@ -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 () => {
Expand All @@ -415,23 +417,23 @@ 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),
},
{
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),
},
{
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),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> {
Expand Down
111 changes: 97 additions & 14 deletions packages/providers/fuel-core-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ input BalanceFilterInput {

type Block {
id: BlockId!
height: U64!
header: Header!
transactions: [Transaction!]!
time: DateTime!
producer: Address!
}

type BlockConnection {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -323,7 +373,7 @@ type Message {
sender: Address!
recipient: Address!
nonce: U64!
data: [Int!]!
data: HexString!
daHeight: U64!
fuelBlockSpend: U64
}
Expand Down Expand Up @@ -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!
Expand All @@ -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!
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -603,6 +668,7 @@ type Receipt {
sender: Address
recipient: Address
nonce: Bytes32
contractId: ContractId
}

enum ReceiptType {
Expand Down Expand Up @@ -650,6 +716,8 @@ enum RunState {

scalar Salt

scalar Signature

input SpendQueryElementInput {
"""
Identifier of the asset to spend.
Expand All @@ -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!]
Expand Down
3 changes: 2 additions & 1 deletion packages/providers/src/message.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { BytesLike } from '@ethersproject/bytes';
import type { AbstractAddress } from '@fuel-ts/interfaces';
import type { BN } from '@fuel-ts/math';

Expand All @@ -8,7 +9,7 @@ export type Message = {
amount: BN;
sender: AbstractAddress;
recipient: AbstractAddress;
data: number[];
data: BytesLike;
daHeight: BN;
nonce: BN;
};
7 changes: 4 additions & 3 deletions packages/providers/src/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/providers/src/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Provider', () => {

const version = await provider.getVersion();

expect(version).toEqual('0.11.2');
expect(version).toEqual('0.13.2');
});

it('can call()', async () => {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('Provider', () => {
{
type: ReceiptType.ScriptResult,
result: bn(0),
gasUsed: bn(0x2c),
gasUsed: bn(0x86b),
},
];

Expand Down
Loading

1 comment on commit 2a98c1e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 89.87% 3593/3998
🟡 Branches 71.86% 692/963
🟢 Functions 87.14% 718/824
🟢 Lines 89.87% 3443/3831

Test suite run success

543 tests passing in 49 suites.

Report generated by 🧪jest coverage report action from 2a98c1e

Please sign in to comment.