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

Bugfix: Can't generate proof for transactions on the last signed block number #1795

Merged
merged 9 commits into from
Jul 4, 2024

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Jul 3, 2024

Content

This PR includes a fix for #1785, there was several problems:

  • The computed block number to be signed was not taking in account the fact that block range ends is exclusive, meaning that it overflowed over the next block range, a block range which end after the block number that we want to sign.
    To solve this we simply subtract one to the computation.
  • The request that retrieved block range when computing merkle roots excluded the last block range.

Not directly related to the bug:

  • The prover would add leaf to it's merkle tree in some condition, corrupting it as this changed its merkle root so it no longer matcher the one in the certificate.
    This was worrisome since this corrupted merkle tree is returned to a resource pool after use, meaning that a subsequent requests would also yield invalid proofs.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

Comments

I'm unsure this totally fix the problem as when investing the logs I could see that, in the transaction importer, they were a gap of minus one between the block number of the transaction we asked it to import and the really imported transactions.
We should oversee the testing preview network after merge to ensure that its fixed or if there's still more work needed.

Issue(s)

Relates to #1785

@Alenar Alenar requested review from sfauvel, jpraynaud and dlachaume July 3, 2024 10:29
Copy link

github-actions bot commented Jul 3, 2024

Test Results

    4 files  ±0     52 suites  +1   8m 45s ⏱️ +5s
1 123 tests +9  1 123 ✅ +9  0 💤 ±0  0 ❌ ±0 
1 271 runs  +9  1 271 ✅ +9  0 💤 ±0  0 ❌ ±0 

Results for commit 10e2a20. ± Comparison against base commit f10e4eb.

♻️ This comment has been updated with latest results.

@Alenar Alenar force-pushed the djo/1785/last_tx_not_proved branch from 9b71577 to a1ee335 Compare July 3, 2024 10:54
@Alenar Alenar temporarily deployed to testing-preview July 3, 2024 11:01 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet July 3, 2024 11:01 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/1785/last_tx_not_proved branch from a1ee335 to afef448 Compare July 3, 2024 11:03
@Alenar Alenar temporarily deployed to testing-preview July 3, 2024 11:12 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet July 3, 2024 11:12 — with GitHub Actions Inactive
Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

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

LGTM

mithril-common/src/crypto_helper/merkle_map.rs Outdated Show resolved Hide resolved
Alenar and others added 4 commits July 4, 2024 15:25
The previous, private, `replace` is renamed to `replace_unchecked`.
The new replace call `replace_unchecked` but it check that the replaced
key exist and that the value is the same.

Co-authored-by: Sébastien Fauvel <sfauvel@users.noreply.github.com>
By using shared methods to construct boilerplate.
Before it allowed to add new keys to the merkle tree, making it create
proofs based on a different merkle root than the one signed in the last
certificate.

Even more worrisome this merkle tree would be then returned modified
to its mkpool, making this corruption persist until the pool is refreshed.
@Alenar Alenar force-pushed the djo/1785/last_tx_not_proved branch from 404449d to 7b1564b Compare July 4, 2024 13:25
Alenar added 5 commits July 4, 2024 16:14
It was missing one block range when retrieving data.

With the given block ranges in DB (end is exclusive):
[ (15..30),
  (30..45),
  (45..60) ]

Before the fix it would return when asked block number:
 - `44`: [ (15..30) ] -> WRONG, should also include (30..45)
 - `45`: [ (15..30) ]  -> WRONG, should also include (30..45)
 - `46`: [ (15..30), (30..45) ] -> WRONG, should also include (45..60)
Substacting `1` to the result to account for the fact that a block range
end is exclusive.
* Mithril-aggregator from `0.5.34` to `0.5.35`
* Mithril-signer from `0.2.157` to `0.2.158`
* Mithril-common from `0.4.25` to `0.4.26`
* Mithril-persistence from `0.2.14` to `0.2.15`
@Alenar Alenar force-pushed the djo/1785/last_tx_not_proved branch from 7b1564b to 10e2a20 Compare July 4, 2024 14:14
@Alenar Alenar temporarily deployed to testing-preview July 4, 2024 14:21 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet July 4, 2024 14:21 — with GitHub Actions Inactive
@Alenar Alenar merged commit f04a629 into main Jul 4, 2024
40 of 42 checks passed
@Alenar Alenar deleted the djo/1785/last_tx_not_proved branch July 4, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants