-
Notifications
You must be signed in to change notification settings - Fork 27
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
add class to build a compressed block incrementally #869
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
arvidn
force-pushed
the
block-builder
branch
7 times, most recently
from
January 15, 2025 15:38
c43eb2b
to
f2d7db3
Compare
Pull Request Test Coverage Report for Build 12884465058Details
💛 - Coveralls |
AmineKhaldi
reviewed
Jan 16, 2025
AmineKhaldi
approved these changes
Jan 21, 2025
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.
purpose
This PR instroduces a type called
BlockBuilder
which lets you add spend bundles, one at a time, until the block cost reaches the limit. As spend bundles are added, they are serialized into the final block generator with back-references (deduplication). This makes the final byte-cost difficult to predict, hence the iterative approach.This patch reproduces some logic from the current mempool block building function, such as the logic of when to give up adding more spend bundles to the block.
cost
When adding a spend bundle you also have to specify the cost of it. This cost is computed when the mempool item is first validated. In existing block creation logic, we use the total cost of the spend bundle, execution cost, condition cost and byte-cost. However, with the
BlockBuilder
, the accompanied cost is supposed to only be execution cost + condition cost. This is because the byte-cost is only known after the spend bundle has been added.test
The test picks random permutations of the spend bundles in the
test-bundles
directory and creates blocks by feeding the bundles one-by-one. The test tracks how long it takes to fill the block, and how long the most expensive call toadd_spend_bundle()
took.We need to compute the cost of each spend bundle, which is done on start-up, when all bundles are being loaded.
The test then parses the resulting block and runs it through
run_block_generator2()
(just like consensus). This ensures the signature is correct, and that the cost is correct.See the example output below, run on Ubuntu/Threadripper:
Some of these timings are not great. There's separate work in progress to optimize the CLVM compression.
test data
This PR adds some test spend bundles to the
test-bundles
directory. My intention is to, in a future update, make CI pull down additional test bundles ( Chia-Network/test-cache#16 ) to run more comprehensive tests.