-
Notifications
You must be signed in to change notification settings - Fork 41
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: Block range computation ignored last block range & last block range if it finished with empty blocks #1820
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Results 4 files ±0 52 suites ±0 8m 51s ⏱️ +6s Results for commit 73f7be8. ± Comparison against base commit 702e519. This pull request removes 7 and adds 8 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
jpraynaud
approved these changes
Jul 15, 2024
Alenar
force-pushed
the
djo/1785/last_tx_not_proved
branch
from
July 15, 2024 14:03
344382f
to
684fde6
Compare
dlachaume
approved these changes
Jul 15, 2024
Instead of computing it from the database. The problem with using bounds entirely computed from database is that it can't accound for blocks with empty transactions, something rare but not impossible in the mainnet. Ie: * There's some Transactions for each blocks in interval (15..=29): a block range root is computed for the interval (15..=29) * There's some Transactions for each blocks in interval (15..=28), no transaction for block 29: today no block range root are computed but we should compute one since the absence of tx for that block is the actual chain state. An alternative would be to store the blocks in the db so we could compute the upper bound based on blocks not on transactions.
That check import up to a last block included in a block range (ie: `29` for blockrange 15..30).
Since all callers will now ask for an inclusive range instead of an exclusive one like before. This allow the TransactionImporter to be called with a block number that's the strict end of a block range (ie: 44 for block range 30..45) without the need to do a `+ 1` when calling `BlockRange::all_block_ranges_in`.
Instead of also fetching the upper bound (that was the highest stored transaction block number). Now the upper bound is given as a parameter from the importer caller, so the previous request can be simplified.
It will yied an empty iterator, else it would crash with an overflow when calling `is_empty` since it subtract start to end.
As it's supersed by `get_highest_block_range`, this means that we can also remove the whole query behind it.
* Mithril-aggregator from `0.5.40` to `0.5.41` * Mithril-signer from `0.2.162` to `0.2.163` * Mithril-common from `0.4.29` to `0.4.30` * Mithril-persistence from `0.2.16` to `0.2.17`
Alenar
force-pushed
the
djo/1785/last_tx_not_proved
branch
from
July 16, 2024 08:01
a5c0cbb
to
73f7be8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Content
This PR fixes two problems:
1. The last advertised block range isn't imported
Following #1795 merge we still could not compute proof for transaction on the last certified block number, even more the whole last block range was not provable (reverting to the state before #1762).
Contrary to the last two fix attempts this time the problem was not in the prover nor the merkle root computation, instead it came from the block range root computation.
This is because in #1795 we change the way the higher bound to certify is computed by subtracting one to the previous computed number so it would fit to the end of a block range (instead of trying to certify
15
,30
or45
it now certify14
,29
or44
).This
-1
echo to the block range sequence computation (seeBlockRange::all_block_ranges_in
) which was excluding in its upper bound.To illustrate, with a start of
30
and an end of75
(now74
):BlockRange::all_block_ranges_in(30..75)
=[(30..45), (45..60), (60..75)]
BlockRange::all_block_ranges_in(30..74)
=[(30..45), (45..60)]
a block range disappearedThe fix is simply to be inclusive for the upper bound:
BlockRange::all_block_ranges_in(30..=74)
=[(30..45), (45..60), (60..75)]
2. The last block range isn't imported if it finish with one or more block without transaction
A block without transactions is rare on the mainnet, but not impossible, and is frequent in testing networks.
This is not correctly handled by the importer since it use the highest stored block number in the
cardano_tx
table as the upper bound in the computation of the block range sequence to compute (same as explained in the previous problem).In order to fix that this PR change the upper bound used: it use the one passed to the transaction importer instead.
We can do that since this block number passer to the importer is computed by the state machine based on the chain current state and the cardano transaction signing configuration, meaning that this block exist.
Note: Another way of doing that would be by also storing the blocks in database so we could use the highest stored block number based on 'real' blocks instead of blocks associated to transactions .
Pre-submit checklist
Comments
Since
get_block_interval_without_block_range_root
is supersed by a new method that only retrieve the highest stored block range interval, its code and the query associated have been removed.Issue(s)
Relates to #1785