Skip to content

Commit

Permalink
Return reason of why proof cant be generated (api change) (#2389)
Browse files Browse the repository at this point in the history
## Linked Issues/PRs
Additional changes related to
#1394
Closes: #2367

## Description
Initially we
[wanted](#2258 (review))
these changes, but eventually
[decided](#2258 (comment))
to
[revert](#2258 (comment))
them from the original PR, because even though they are
[not](#2258 (comment))
[considered](#2258 (comment))
strictly breaking, they change the API.



## Checklist
- [X] Breaking changes are clearly marked as such in the PR description
and changelog

### Before requesting review
- [X] I have reviewed the code myself
  • Loading branch information
rafal-ch authored Nov 14, 2024
1 parent ba0fa15 commit 1396b5c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- [2378](https://github.com/FuelLabs/fuel-core/pull/2378): Use cached hash of the topic instead of calculating it on each publishing gossip message.

#### Breaking
- [2389](https://github.com/FuelLabs/fuel-core/pull/2258): Updated the `messageProof` GraphQL schema to return a non-nullable `MessageProof`.

## [Version 0.40.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ type Query {
"""
owner: Address, first: Int, after: String, last: Int, before: String
): MessageConnection!
messageProof(transactionId: TransactionId!, nonce: Nonce!, commitBlockId: BlockId, commitBlockHeight: U32): MessageProof
messageProof(transactionId: TransactionId!, nonce: Nonce!, commitBlockId: BlockId, commitBlockHeight: U32): MessageProof!
messageStatus(nonce: Nonce!): MessageStatus!
relayedTransactionStatus(
"""
Expand Down
11 changes: 2 additions & 9 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ impl FuelClient {
nonce: &Nonce,
commit_block_id: Option<&BlockId>,
commit_block_height: Option<BlockHeight>,
) -> io::Result<Option<types::MessageProof>> {
) -> io::Result<types::MessageProof> {
let transaction_id: TransactionId = (*transaction_id).into();
let nonce: schema::Nonce = (*nonce).into();
let commit_block_id: Option<schema::BlockId> =
Expand All @@ -1153,14 +1153,7 @@ impl FuelClient {
commit_block_id,
commit_block_height,
});

let proof = self
.query(query)
.await?
.message_proof
.map(TryInto::try_into)
.transpose()?;

let proof = self.query(query).await?.message_proof.try_into()?;
Ok(proof)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client/schema/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub struct MessageProofQuery {
commitBlockId: $commit_block_id,
commitBlockHeight: $commit_block_height
)]
pub message_proof: Option<MessageProof>,
pub message_proof: MessageProof,
}

#[derive(cynic::QueryFragment, Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions crates/fuel-core/src/schema/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl MessageQuery {
nonce: Nonce,
commit_block_id: Option<BlockId>,
commit_block_height: Option<U32>,
) -> async_graphql::Result<Option<MessageProof>> {
) -> async_graphql::Result<MessageProof> {
let query = ctx.read_view()?;
let height = match (commit_block_id, commit_block_height) {
(Some(commit_block_id), None) => {
Expand All @@ -157,7 +157,7 @@ impl MessageQuery {
height,
)?;

Ok(Some(MessageProof(proof)))
Ok(MessageProof(proof))
}

#[graphql(complexity = "query_costs().storage_read + child_complexity")]
Expand Down
1 change: 0 additions & 1 deletion tests/tests/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ async fn can_get_message_proof() {
let result = client
.message_proof(&transaction_id, nonce, None, Some(last_height))
.await
.unwrap()
.unwrap();

// 1. Generate the message id (message fields)
Expand Down
6 changes: 2 additions & 4 deletions tests/tests/regenesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ async fn test_regenesis_message_proofs_are_preserved() -> anyhow::Result<()> {
.client
.message_proof(&tx_id, nonce, None, Some((message_block_height + 1).into()))
.await
.expect("Unable to get message proof")
.expect("Message proof not found");
.expect("Unable to get message proof");
let prev_root = proof.commit_block_header.prev_root;
let block_proof_index = proof.block_proof.proof_index;
let block_proof_set: Vec<_> = proof
Expand Down Expand Up @@ -460,8 +459,7 @@ async fn test_regenesis_message_proofs_are_preserved() -> anyhow::Result<()> {
.client
.message_proof(&tx_id, nonce, None, Some(block_height.into()))
.await
.expect("Unable to get message proof")
.expect("Message proof not found");
.expect("Unable to get message proof");
let prev_root = proof.commit_block_header.prev_root;
let block_proof_set: Vec<_> = proof
.block_proof
Expand Down

0 comments on commit 1396b5c

Please sign in to comment.