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

Fix an interger overflow in message_proof when looking beyond genesis #1392

Merged
merged 7 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -40,6 +40,7 @@ Description of the upcoming release here.
- [#1342](https://github.com/FuelLabs/fuel-core/pull/1342): Add error handling for P2P requests to return `None` to requester and log error.
- [#1383](https://github.com/FuelLabs/fuel-core/pull/1383): Disallow usage of `log` crate internally in favor of `tracing` crate.
- [#1390](https://github.com/FuelLabs/fuel-core/pull/1390): Up the `ethers` version to `2` to fix an issue with `tungstenite`.
- [#1392](https://github.com/FuelLabs/fuel-core/pull/1392): Fixed an overflow in `message_proof`.
- [#1393](https://github.com/FuelLabs/fuel-core/pull/1393): Increase heartbeat timeout from `2` to `60` seconds, as suggested in [this issue](https://github.com/FuelLabs/fuel-core/issues/1330).

#### Breaking
Expand Down
7 changes: 6 additions & 1 deletion crates/fuel-core/src/query/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ pub fn message_proof<T: MessageProofData + ?Sized>(
None => return Ok(None),
};

let verifiable_commit_block_height = *commit_block_header.height() - 1u32.into();
let block_height = *commit_block_header.height();
if block_height == 0u32.into() {
// Cannot look beyond the genesis block
return Ok(None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it is better to return an error?=)

Copy link
Member Author

Choose a reason for hiding this comment

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

I understood that None means "cannot generate proof" here from the usage above. Is this not the case? It doesn't help that the function docs say this without explaining the meaning:

// TODO: Do we want to return `Option` here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I left this question=D I don't know why we want to return None instead of returning the reason WHY we can't generate the proof.

}
let verifiable_commit_block_height = block_height - 1u32.into();
let block_proof = database.block_history_proof(
message_block_header.height(),
&verifiable_commit_block_height,
Expand Down
Loading