-
Notifications
You must be signed in to change notification settings - Fork 848
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
Code storage by hash #5889
Code storage by hash #5889
Conversation
|
.../main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorage.java
Fixed
Show fixed
Hide fixed
b254b42
to
325fc54
Compare
a4d26f8
to
ea8893e
Compare
…erledger#5889. Signed-off-by: garyschulte <[email protected]>
…erledger#5889. Signed-off-by: garyschulte <[email protected]>
…erledger#5889. Signed-off-by: garyschulte <[email protected]>
…erledger#5889. Signed-off-by: garyschulte <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
d254d70
to
f68da4e
Compare
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]>
…count for code count updates Signed-off-by: Jason Frame <[email protected]>
…erledger#5889. Signed-off-by: garyschulte <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
…ncremented unnecessarily 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]>
...rc/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/CodeStorageStrategy.java
Dismissed
Show dismissed
Hide dismissed
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
Signed-off-by: Jason Frame <[email protected]>
final SegmentedKeyValueStorageTransaction transaction, | ||
final Hash accountHash, | ||
final Hash codeHash) { | ||
// TODO JF add reference counting so that code can be removed when there are no more usages |
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.
👍 , we should like the issue for context
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 idea, I'll update the comment with the issue
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.
Looks good, the only significant concern is the ability for code storage CLI param to affect besu's worldstate consistency when it is initially synced with a different code storage method
this.codeStorageStrategy = | ||
useCodeStoredByHash | ||
? new CodeHashCodeStorageStrategy() | ||
: new AccountHashCodeStorageStrategy(); | ||
|
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.
can we move this up into FlatDbStrategyProvider, and pass a CodeStorageStrategy rather than a boolean ?
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.
done
final boolean isCodeStoredByHashEnabled = | ||
dataStorageConfiguration.getUnstable().getBonsaiCodeStoredByCodeHashEnabled(); | ||
LOG.info( | ||
"Bonsai flat db mode with code stored using code hash enabled = {}", | ||
isCodeStoredByHashEnabled); |
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.
the risk of driving this from command line only is that we can fall out of consensus if the user changes this config parameter without resyncing. It isn't fun to plumb in the check but we should try to derive the codehash vs accounthash as it exists in the database and only allow the cli parameter to affect an as-yet-unsynced node.
we already have the notion of using loadFlatDbStrategy(..)
in BonsaiWorldStateKeyValueStorage, and it will override the CLI supplied flat db strategy based on what it finds. We can work a code storage check into that method and ensure that we use the correct code storage strategy based on what is in the db, and perhaps log a big ugly warning message if the CLI param does not match the db storage
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.
Added detection code in the FlatDbStrategyProvider
which will warn if there is an inconsistency and use the strategy in the database.
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class BonsaiWorldStateTest { |
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.
IMO we should add a test that asserts the correct FlatDBStrategy (with the correct CodeStorageStrategy) is constructed when the db storage and the cli param disagree.
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.
Added some tests for that in the FlatDbStrategyProvider
since that's where it's created
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]>
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.
🚢 great test coverage
💯 🚀 |
This reverts commit 9c02518. Signed-off-by: Jason Frame <[email protected]>
This reverts commit 9c02518. Signed-off-by: Jason Frame <[email protected]>
Add a storage mode for Bonsai that can store the code by hash instead of account hash Signed-off-by: Jason Frame <[email protected]>
Add a storage mode for Bonsai that can store the code by hash instead of account hash Signed-off-by: Jason Frame <[email protected]> Signed-off-by: Gabriel-Trintinalia <[email protected]>
…6504) This reverts commit 9c02518. Signed-off-by: Jason Frame <[email protected]> Signed-off-by: Gabriel-Trintinalia <[email protected]>
PR description
Storing code by hash instead of by address. This is needed so that Besu can serve snapsync as we need to be able to retrieve the code by hash.
After syncing with this change it's not possible to downgrade to an older version of Besu. If we think this is needed I could add a subcommand to do the conversion.
Testing
CODE_HASH_COUNT
is using 38 MiB.Fixed Issue(s)
fixed #5388