-
Notifications
You must be signed in to change notification settings - Fork 849
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
Private state update metadata and migration #354
Private state update metadata and migration #354
Conversation
Signed-off-by: Lucas Saldanha <[email protected]>
87e32b0
to
8d9f4aa
Compare
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
39f920f
to
5111882
Compare
Signed-off-by: Lucas Saldanha <[email protected]>
8ea2920
to
aa0f1a6
Compare
final PrivacyParameters privacyParameters = privacyParametersBuilder.build(); | ||
|
||
if (isPrivacyEnabled) { | ||
preSynchronizationTaskRunner.addTask( |
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 that how it is done in besu? Why not check whether migratePrivateDatabase is true and then add the task?
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.
Because part of the task is to evaluate the different triggering conditions. And one of the conditions is: you have a private db that needs migration but you don't have the migratePrivateDatabase flag enabled.
import org.hyperledger.besu.controller.BesuController; | ||
|
||
/** | ||
* All PreSynchronizationTask insatnces execute after the {@link BesuController} instance in {@link |
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.
s/insatnces/instances/
@@ -55,6 +59,14 @@ public PrivacyApiGroupJsonRpcMethods( | |||
this.protocolSchedule = protocolSchedule; | |||
this.transactionPool = transactionPool; | |||
this.privacyParameters = privacyParameters; | |||
|
|||
final PrivateStateRootResolver privateStateRootResolver = | |||
new PrivateStateRootResolver(privacyParameters.getPrivateStateStorage()); |
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.
inline?
@@ -73,6 +85,10 @@ public PrivacyParameters getPrivacyParameters() { | |||
return privacyParameters; | |||
} | |||
|
|||
public PrivateNonceProvider getPrivateNonceProvider() { |
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.
IntelliJ says this method is never called. Do we need it? And the privateNonceProvider?
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 believe we don't need getPrivateNonceProvider()
anymore. We definitely need PrivateNonceProvider
though. :)
I have removed the method.
final BlockHeader blockHeader, | ||
final List<Transaction> transactions, | ||
final List<BlockHeader> ommers) { | ||
final PrivacyGroupHeadBlockMap privacyGroupHeadBlockHash = |
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.
s/privacyGroupHeadBlockHash/privacyGroupHeadBlockMap/
privateStateRootResolver, blockchain, STATE_ROOT_AFTER_TRANSACTION_APPENDED_TO_EMTPY_STATE); | ||
|
||
final String secondForkBlockStateRoot = | ||
"0xd35eea814b8b5a0b12e690ab320785f3a33d9685bbf6875637c40a64203915da"; |
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.
constant
|
||
// Add another private transaction | ||
final String thirdForkBlockStateRoot = | ||
"0xe22344ade05260177b79dcc6c4fed8f87ab95a506c2a6147631ac6547cf44846"; |
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.
constant
parentBlock); | ||
} | ||
|
||
private BlockDataGenerator.BlockOptions getBlockOptionsNoTransaction( |
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.
this block will have a transaction!!! Fix the name!
.setEnclaveUrl(enclave.clientUrl()) | ||
.setEnclaveFactory(new EnclaveFactory(Vertx.vertx())) | ||
.build(); | ||
privacyParameters.setEnclavePublicKey("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="); |
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.
Use the constant ENCLAVE_PUBLIC_KEY
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.
In lines 154 and 410 we are using the String for that key as a parameter. Can we have a constant for the String as well (ENCLAVE_PUBLIC_KEY_STRING) to make clear what we are doing?
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 can use ENCLAVE_PUBLIC_KEY.toBase64String()
@@ -0,0 +1,540 @@ | |||
/* |
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.
would be nice if we could create constants for the "magic" numbers, but if we cannot do that we should provide some kind of clue where these numbers come from ...
Signed-off-by: Lucas Saldanha <[email protected]>
return Optional.empty(); | ||
} | ||
|
||
final MutableWorldState publicWorldState = |
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.
When we are simulating this private transaction we need to use the public state at the end of the public Tx just before the PMT.
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
This reverts commit 118c7e5 Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Signed-off-by: Lucas Saldanha <[email protected]>
Superseeded by #404 |
PR description
• Updated the private state storage with new data structures that aren't backwards compatible.
• Added PrivateStateRootResolver that handles public chain forks and their impact on the private state
• Created migration logic that will process previous private txs and re-create the data in the update 1.4.x format.
• Migration is based on the schema version, defined in the
PrivateStateStorage
• Added flag that user needs to "opt-in" to migrate the data
• Remove restriction for "latest" block from
priv_call