-
Notifications
You must be signed in to change notification settings - Fork 844
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
Reduce receipt size #6602
Reduce receipt size #6602
Conversation
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
…ForStorage to make intent clearer Signed-off-by: Jason Frame <[email protected]>
… clearer Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
I like the results of this PR, looking promising! Had a very quick first pass and the first thing I saw was some tests defaulting the creation of a "PrefixedKeyBlockchainStorage" to "false". It makes sense to test both scenarios where possible (I think you already do for unit tests). And In case where the creation of the blockchain isn't actually being tested but created to fulfill a dependency I would rather have that set to true since this is going to be the default value. |
Will the user get a startup error instead?
Is this showing response time measured in ms? What's your interpretation of the results - seems like receipts are better than control (if significant)? |
They will get a startup error saying the database version is incompatible.
Response time is measured in ms. Not clear to me from the data that it's better as there is a fair bit of variance between test runs. The only thing I think can I say is that receipts seem at least as good as the control. |
…t compaction to true in tests Signed-off-by: Jason Frame <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good PR description and tests 👍
Are we planning on enabling this by default soon? If so, might be worth making this the default config in the integration/acceptance tests?
LGTM but wouldn't mind a second opinion particularly about the new database versioning stuff, downgrading etc.
CHANGELOG.md
Outdated
@@ -4,6 +4,7 @@ | |||
|
|||
### Breaking Changes | |||
- RocksDB database metadata format has changed to be more expressive, the migration of an existing metadata file to the new format is automatic at startup. Before performing a downgrade to a previous version it is mandatory to revert to the original format using the subcommand `besu --data-path=/path/to/besu/datadir storage revert-metadata v2-to-v1`. | |||
- RocksDB database version incremented for receipt compaction. It will not be possible to downgrade to the previous Besu version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be wary of merging this before Dencun dust has settled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds sensible. Could even make the default disabled and toggle it on by default at a later date if makes more sense.
@@ -61,6 +62,12 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration> | |||
arity = "1") | |||
private Long bonsaiMaxLayersToLoad = DEFAULT_BONSAI_MAX_LAYERS_TO_LOAD; | |||
|
|||
@Option( | |||
names = "--receipt-compaction-enabled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java
Show resolved
Hide resolved
@fab-10 Would you be able to take a look at the use of the database versioning I'm using in the PR? |
…e receipt compaction to true in tests" This reverts commit 7cffb80. Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall look good, some minor code suggestions, and some open questions on the UX:
- When enabling compact receipts on an existing DB, past receipts will not be touched, what about a subcommand to convert them to compact?
- Downgrade is only possible with a full resync, evaluate the option to add a revert subcommand
- Prevent the user from doing enable->disable?
@@ -6,6 +6,7 @@ | |||
- RocksDB database metadata format has changed to be more expressive, the migration of an existing metadata file to the new format is automatic at startup. Before performing a downgrade to a previous version it is mandatory to revert to the original format using the subcommand `besu --data-path=/path/to/besu/datadir storage revert-metadata v2-to-v1`. | |||
|
|||
### Upcoming Breaking Changes | |||
- Receipt compaction will be enabled by default in a future version of Besu. After this change it will not be possible to downgrade to the previous Besu version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you evaluated the possibility to add a storage subcommand to revert to previous format? does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested some migration code as part of my testing as it took approximately 17 hours on mainnet so it would be better to just resync with it taking that long. It's not the exact code as I would use for a subcommand as this put the receipts in a different column family so I could compare sizes but I think it would take a similar time.
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/StorageProvider.java
Outdated
Show resolved
Hide resolved
plugin-api/src/main/java/org/hyperledger/besu/plugin/services/BesuConfiguration.java
Show resolved
Hide resolved
...perledger/besu/plugin/services/storage/rocksdb/configuration/BaseVersionedStorageFormat.java
Show resolved
Hide resolved
...java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java
Show resolved
Hide resolved
…ersioned with receipt compaction Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
…ceipt compaction flag Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have been thinking about the database versioning, wanted to discuss the following options:
-
Current state of PR: new format enabled/disabled in tandem with optional flag. Backwards compatible but not forwards compatible if a user downgraded.
-
Update the database version regardless of the feature flag, i.e. version 3 supports
--receipt-compaction-enabled
behaviour even when the flag is disabled. Effectively the same as (1) but versioning is coupled to the release rather than flag. -
Avoid updating the database version for this: a justification could be that we introduce a convention where we only use the versioning for "schema" changes rather than changes to the data contents. Non-forwards-compatible downgrade issue remains though, once the feature has been enabled.
I think you said the only benefit of the updated database version is ability to generate an appropriate warning message if they downgrade?
Orthogonal to the versioning...think the original plan was to enable the flag by default. Maybe this can be reconsidered now Dencun has passed. Do any exclusions apply to this (e.g. FULL sync?), or do we rely on announcement/breaking changes warning for users who require historic RPC to evaluate this feature?
* Current Bonsai version, with receipts using compaction, in order to make Receipts use less disk | ||
* space | ||
*/ | ||
BONSAI_WITH_RECEIPT_COMPACTION(DataStorageFormat.BONSAI, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent here to be "BONSAI_WITH_VARIABLES_AND_WITH_RECEIPT_COMPACTION
" (V2 + RECEIPT_COMPACTION)
or "BONSAI_ORIGINAL_WITH_RECEIPT_COMPACTION
"
and you'd need both versions to make up the right combination of features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's the former i.e. a one-way cumulation of features then I'm a bit dubious of using feature names for the different versions. Could this be confusing when we're several versions down the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a one-way cumulation of features. You are right the name for BONSAI_ORIGINAL_WITH_RECEIPT_COMPACTION
isn't quite right as it isn't Bonsai original + receipts, it also includes variables.
What about BONSAI_VARIABLES_WITH_RECEIPT_COMPACTION
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought I think will become a mess if we just keep accumulating the changes from every version into the name. Rather just keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming this was not easy for me, so I appreciate suggestions for improvements, perhaps we can just, name them like BONSAI_V3, and leverage the javadoc to specify that it is based on V2 plus the receipt compaction, so move the accumulation of the changes from the name to javadoc.
Note, that *_ORIGINAL are there only for reference, since it is not possible to use them anymore, so we could also remove them, or better document that are no more supported
if (runtimeVersion == BONSAI_WITH_VARIABLES || runtimeVersion == FOREST_WITH_VARIABLES) { | ||
LOG.warn( | ||
"Database contains compacted receipts but receipt compaction is not enabled, new receipts will " | ||
+ "be not stored in the compacted format. If you want to remove compacted receipts from the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ "be not stored in the compacted format. If you want to remove compacted receipts from the " | |
+ "be not stored in the compacted format. If you want to restore complete receipts to the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think describing the receipts as complete bit misleading. The data missing is redundant so it's not missing anything. Not sure on the best terminology here but I was going with compacted and non-compacted.
Had a discussion with @siladu on these points and the outcome was to leave the PR as is using 1. Using option 2 has the benefit of a single version and is more directly tied to the capabilities rather than the configuration of By having this version conditional the backwards compatibility only affects users who have explicitly enabled this feature rather than everyone and give people plenty of time to be aware of the change. In a future release, the plan is to enable this by default and remove the conditional database version upgrade. At this point, we will have several versions of Besu that users can downgrade if there is an issue in the release. |
Doing another sync on mainnet to ensure the receipt changes still work after receipt changes |
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]> Signed-off-by: Justin Florentine <[email protected]>
Signed-off-by: Jason Frame <[email protected]> Signed-off-by: amsmota <[email protected]>
Signed-off-by: Jason Frame <[email protected]> Signed-off-by: amsmota <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Thanks for sending a pull request! Have you done the following?
doc-change-required
label to this PR if updates are required.Most advanced CI tests are deferred until PR approval, but you could:
./gradlew build
./gradlew acceptanceTest
./gradlew integrationTest
./gradlew ethereum:referenceTests:referenceTests
PR description
Reduce receipt by introducing a new compact receipt encoding saving approximately 78GB on a freshly synced mainnet snapsync node. This new compact receipt encoding does not include the bloom filter and trims zeros from the log topics and log data similar to what was done in the Geth and Nethermind receipt encoding PRs.
I've added a version for the database format. So users won't be able to downgrade after once this is merged.
Testing
Engine API performance
Under normal load see similar performance to the nodes not using receipt compaction
Load testing
eth_getLogs with 2 req/s over 5 minutes using Gatling on the node while it syncing
receipts
min: 2, max: 147, mean: 12, std dev: 11, response 95th percentile: 26, response 99th percentile: 53
min: 3, max: 107, mean: 12, std dev: 8, response 95th percentile: 24, response 99th percentile: 43
min: 3, max: 73, mean: 12, std dev: 8, response 95th percentile: 23, response 99th percentile: 52
control:
min: 2, max: 140, mean: 16, std dev: 14, response 95th percentile: 41, response 99th percentile: 58
min: 2, max: 73, mean: 10, std dev: 6, response 95th percentile: 21, response 99th percentile: 32
min: 3, max: 118, mean: 11, std dev: 10, response 95th percentile: 20, response 99th percentile: 55
Storage improvement
control:
receipts:
Disk space saving of ~78GB
Fixed Issue(s)
fixes #6476