Private state update metadata and migration#354
Conversation
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
87e32b0 to
8d9f4aa
Compare
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
39f920f to
5111882
Compare
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
8ea2920 to
aa0f1a6
Compare
| final PrivacyParameters privacyParameters = privacyParametersBuilder.build(); | ||
|
|
||
| if (isPrivacyEnabled) { | ||
| preSynchronizationTaskRunner.addTask( |
There was a problem hiding this comment.
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.
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 |
| this.privacyParameters = privacyParameters; | ||
|
|
||
| final PrivateStateRootResolver privateStateRootResolver = | ||
| new PrivateStateRootResolver(privacyParameters.getPrivateStateStorage()); |
| return privacyParameters; | ||
| } | ||
|
|
||
| public PrivateNonceProvider getPrivateNonceProvider() { |
There was a problem hiding this comment.
IntelliJ says this method is never called. Do we need it? And the privateNonceProvider?
There was a problem hiding this comment.
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.
s/privacyGroupHeadBlockHash/privacyGroupHeadBlockMap/
| privateStateRootResolver, blockchain, STATE_ROOT_AFTER_TRANSACTION_APPENDED_TO_EMTPY_STATE); | ||
|
|
||
| final String secondForkBlockStateRoot = | ||
| "0xd35eea814b8b5a0b12e690ab320785f3a33d9685bbf6875637c40a64203915da"; |
|
|
||
| // Add another private transaction | ||
| final String thirdForkBlockStateRoot = | ||
| "0xe22344ade05260177b79dcc6c4fed8f87ab95a506c2a6147631ac6547cf44846"; |
| parentBlock); | ||
| } | ||
|
|
||
| private BlockDataGenerator.BlockOptions getBlockOptionsNoTransaction( |
There was a problem hiding this comment.
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.
Use the constant ENCLAVE_PUBLIC_KEY
There was a problem hiding this comment.
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.
We can use ENCLAVE_PUBLIC_KEY.toBase64String()
| @@ -0,0 +1,540 @@ | |||
| /* | |||
There was a problem hiding this comment.
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 <lucas.saldanha@consensys.net>
| return Optional.empty(); | ||
| } | ||
|
|
||
| final MutableWorldState publicWorldState = |
There was a problem hiding this comment.
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 <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
This reverts commit 118c7e5 Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
|
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