Skip to content
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

feat: Add receipts to transaction status #1504

Merged
merged 25 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Description of the upcoming release here.

### Added

- [#1504](https://github.com/FuelLabs/fuel-core/pull/1504): A `Success` or `Failure` variant of `TransactionStatus` returned by a query now contains the associated receipts generated by transaction execution.
- [#1503](https://github.com/FuelLabs/fuel-core/pull/1503): Add `gtf` opcode sanity check
- [#1502](https://github.com/FuelLabs/fuel-core/pull/1502): Added price benchmark for `vm_initialization`.
- [#1492](https://github.com/FuelLabs/fuel-core/pull/1492): Support backward iteration in the RocksDB. It allows backward queries that were not allowed before.
Expand Down
2 changes: 2 additions & 0 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ type FailureStatus {
time: Tai64Timestamp!
reason: String!
programState: ProgramState
receipts: [Receipt!]!
}

type FeeParameters {
Expand Down Expand Up @@ -850,6 +851,7 @@ type SuccessStatus {
block: Block!
time: Tai64Timestamp!
programState: ProgramState
receipts: [Receipt!]!
}

scalar Tai64Timestamp
Expand Down
1 change: 1 addition & 0 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ impl FuelClient {
) -> io::Result<(TransactionStatus, Option<Vec<Receipt>>)> {
let tx_id = self.submit(tx).await?;
let status = self.await_transaction_commit(&tx_id).await?;
// TODO: Remove `receipts` now that receipts are queryable from the `Success` or `Failure` status
let receipts = self.receipts(&tx_id).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove it in this PR=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this query and replaced it with a block to read the receipts from the transaction status retrieved earlier in this function. This introduces an extra clone() because we now duplicate the receipts. This is okay for now - in the future, we can remove this function entirely because it is now redundant, and the submit_and_await_commit endpoint will return receipts for all successful and failed transactions. I have added a TODO inline to highlight this.


Ok((status, receipts))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ query($id: TransactionId!) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
... on SqueezedOutStatus {
reason
Expand All @@ -67,6 +101,40 @@ query($id: TransactionId!) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
... on SqueezedOutStatus {
reason
Expand All @@ -70,6 +104,40 @@ query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ query($after: String, $before: String, $first: Int, $last: Int) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
... on SqueezedOutStatus {
reason
Expand All @@ -70,6 +104,40 @@ query($after: String, $before: String, $first: Int, $last: Int) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ query($id: TransactionId!) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
... on SqueezedOutStatus {
reason
Expand All @@ -123,6 +157,40 @@ query($id: TransactionId!) {
returnType
data
}
receipts {
param1
param2
amount
assetId
gas
digest
contract {
id
}
is
pc
ptr
ra
rb
rc
rd
reason
receiptType
to {
id
}
toAddress
val
len
result
gasUsed
data
sender
recipient
nonce
contractId
subId
}
}
}
witnesses
Expand Down
5 changes: 5 additions & 0 deletions crates/client/src/client/schema/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct TransactionEdge {
#[cynic(graphql_type = "Transaction", schema_path = "./assets/schema.sdl")]
pub struct OpaqueTransaction {
pub raw_payload: HexString,
// TODO: Remove now that Success and Failure status includes receipts
bvrooman marked this conversation as resolved.
Show resolved Hide resolved
pub receipts: Option<Vec<Receipt>>,
pub status: Option<TransactionStatus>,
}
Expand Down Expand Up @@ -174,18 +175,22 @@ pub struct SubmittedStatus {
#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct SuccessStatus {
// pub tx_id: TransactionIdFragment,
pub block: BlockIdFragment,
pub time: Tai64Timestamp,
pub program_state: Option<ProgramState>,
pub receipts: Vec<Receipt>,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct FailureStatus {
// pub tx_id: TransactionIdFragment,
pub block: BlockIdFragment,
pub time: Tai64Timestamp,
pub reason: String,
pub program_state: Option<ProgramState>,
pub receipts: Vec<Receipt>,
}

#[derive(cynic::QueryFragment, Debug)]
Expand Down
Loading
Loading