Conversation
|
…ersion < version recorded in DB metadata. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
…ates the Besu version in the metadata file to the downgraded version. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
deb1d75 to
494c8d3
Compare
...java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java
Fixed
Show fixed
Hide fixed
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
64cc64a to
ee188cf
Compare
ee188cf to
f813e5f
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
f813e5f to
14014fa
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
|
LGTM functionality wise --> what you are proposing is a change to the existing default behavior (allowing downgrades). Should we consider the inverse (a flag to prevent downgrades or just switching to |
|
Thanks for the comments @non-fungible-nelson I'll give that some thought and reply properly tomorrow. In the meantime I wanted to highlight that I've just updated the description and commits somewhat, as I originally had the checks happening in the RocksDB plugin but have decided that it's better that Besu can perform this check regardless of the storage provider being used. The main difference in the latest commits is the introduction of a new |
d75e5b5 to
9dce227
Compare
Yeah I agree that it changes behaviour, but the main cost to a user who is expecting to be able to do this is to set |
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
9dce227 to
4c4b66b
Compare
|
Moving out of draft as I think this is ready for review |
…ery big Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
|
PR refactored to offer |
|
I've manually re-tested with the new
|
ab7968b to
1d0c021
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
5d4264d to
719a174
Compare
Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
fab-10
left a comment
There was a problem hiding this comment.
LGTM, just a couple of edits
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
…/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
…/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
* Add Besu version to DB metadata. Check for downgrades and reject if version < version recorded in DB metadata. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add --allow-downgrade CLI arg. If set it allows the downgrade and updates the Besu version in the metadata file to the downgraded version. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update gradle verification XML Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add and update tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactoring Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove versioning from RocksDB, now in separate VERSION_DATADATA.json Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Tidy up and tests for the new class Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Move downgrade logic into VersionMetadata as BesuCommand is already very big Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add more tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor the naming of the option to version-compatibility-protection Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove remaining references to allow-downgrade Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Rename test Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Metadata verification update Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * gradle fix Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Enable version downgrade protection by default for non-named networks Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix default logic Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * mock-maker-inline no longer needed Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
* Add Besu version to DB metadata. Check for downgrades and reject if version < version recorded in DB metadata. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add --allow-downgrade CLI arg. If set it allows the downgrade and updates the Besu version in the metadata file to the downgraded version. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update gradle verification XML Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add and update tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactoring Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove versioning from RocksDB, now in separate VERSION_DATADATA.json Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Tidy up and tests for the new class Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Move downgrade logic into VersionMetadata as BesuCommand is already very big Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add more tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor the naming of the option to version-compatibility-protection Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove remaining references to allow-downgrade Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Rename test Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Metadata verification update Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * gradle fix Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Enable version downgrade protection by default for non-named networks Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix default logic Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * mock-maker-inline no longer needed Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: amsmota <antonio.mota@citi.com>
* Add Besu version to DB metadata. Check for downgrades and reject if version < version recorded in DB metadata. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add --allow-downgrade CLI arg. If set it allows the downgrade and updates the Besu version in the metadata file to the downgraded version. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update gradle verification XML Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add and update tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactoring Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove versioning from RocksDB, now in separate VERSION_DATADATA.json Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Tidy up and tests for the new class Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Move downgrade logic into VersionMetadata as BesuCommand is already very big Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add more tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor the naming of the option to version-compatibility-protection Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove remaining references to allow-downgrade Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Rename test Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Metadata verification update Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * gradle fix Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Enable version downgrade protection by default for non-named networks Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix default logic Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * Update ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/VersionMetadata.java Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> * mock-maker-inline no longer needed Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Signed-off-by: Matt Whitehead <matthew1001@hotmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: amsmota <antonio.mota@citi.com>
PR description
This PR aims to prevent accidental downgrade of Besu, which can potentially cause the DB to be irrevocably corrupted.
The approach I've used is as follows:
VERSION_METADATA.jsonin the configured data pathbesuVersionfield, e.g.{"besuVersion":"23.10.3"}--version-compatibility-protectionconfiguration optionorg.apache.maven:maven-artifactto provide access to the mavenComparableVersionclassperformVersionCompatibilityChecks()toVersionMetadataas the first function to call after configuration options have been validated.performVersionCompatibilityChecks()throws an exception if the version inVERSION_METADATA.jsonis higher (when compared using the mavenComparableVersionclass) than the version as recorded in theBesuCommandclass implementation versionAny value after the first
-character in the version number is ignored. This limits version comparison to the 3 calver digits, which is all that can be logically compared as higher or lower. An example of a version number that has trailing characters is23.10.4-dev-c9338660where the latest commit has been appended to the version. The-dev-c9338660is ignored in the version comparison.The validation logic is as follows:
VERSION_METADATA.jsonfile doesn't exist, no further checks are made and the node starts. TheVERSION_METADATA.jsonfile is written to allow version checks from this point onwards.besuVersionfield are present and the version is lower than the installed/runtime version, Besu updates it to have the latest version in it and continues to start upbesuVersionfield are present and the version is greater than the installed/runtime version, Besu fails to start if--version-compatibility-protectionis set, because a lower version of Besu is being started than the version that most recently updated the file.Fixed Issue(s)
Fixes #6266