-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Private state update metadata and migration #354
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8d9f4aa
Private state update metadata and migration
lucassaldanha c28fb51
Fix migration of failed txs
lucassaldanha 2d7ea37
Remove restriction for priv_call
lucassaldanha b6d2855
Merge branch 'master' into updated-migration
lucassaldanha 73adcf1
Fix import
lucassaldanha 1740211
Merge branch 'master' into updated-migration
lucassaldanha 5111882
Fix unit test
lucassaldanha aa0f1a6
Changed migration msg
lucassaldanha dc7917d
Merge branch 'master' into updated-migration
pinges f4da438
Merge branch 'master' into updated-migration
lucassaldanha ea2af20
Minor PR comments
lucassaldanha 6fce1b2
Reorg test
lucassaldanha 65704c2
Spotless
lucassaldanha 118c7e5
Fix unused warnings
lucassaldanha 9652a9d
Revert "Fix unused warnings"
lucassaldanha 16d938a
Fix test
lucassaldanha 57194da
Handling enclave error
lucassaldanha 2653938
Merge branch 'master' into updated-migration
lucassaldanha e095b5b
Merge
lucassaldanha ca11476
Fix AT
lucassaldanha 177982f
[draft] private metadata migration v2
lucassaldanha 5c5b83c
Updated migration logic
lucassaldanha f1ca3c5
Merge branch 'master' into updated-migration
lucassaldanha 08837d9
Fix rawtypes warning
lucassaldanha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
besu/src/main/java/org/hyperledger/besu/cli/presynctasks/PreSynchronizationTask.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright ConsenSys AG. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.cli.presynctasks; | ||
|
|
||
| import org.hyperledger.besu.cli.BesuCommand; | ||
| import org.hyperledger.besu.controller.BesuController; | ||
|
|
||
| /** | ||
| * All PreSynchronizationTask instances execute after the {@link BesuController} instance in {@link | ||
| * BesuCommand} is ready and before {@link BesuCommand#startSynchronization()} is called | ||
| */ | ||
| public interface PreSynchronizationTask { | ||
|
|
||
| void run(final BesuController<?> besuController); | ||
| } |
33 changes: 33 additions & 0 deletions
33
besu/src/main/java/org/hyperledger/besu/cli/presynctasks/PreSynchronizationTaskRunner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright ConsenSys AG. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.cli.presynctasks; | ||
|
|
||
| import org.hyperledger.besu.controller.BesuController; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class PreSynchronizationTaskRunner { | ||
|
|
||
| private final List<PreSynchronizationTask> tasks = new ArrayList<>(); | ||
|
|
||
| public void addTask(final PreSynchronizationTask task) { | ||
| tasks.add(task); | ||
| } | ||
|
|
||
| public void runTasks(final BesuController<?> besuController) { | ||
| tasks.forEach(t -> t.run(besuController)); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
.../main/java/org/hyperledger/besu/cli/presynctasks/PrivateDatabaseMigrationPreSyncTask.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright ConsenSys AG. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.cli.presynctasks; | ||
|
|
||
| import org.hyperledger.besu.controller.BesuController; | ||
| import org.hyperledger.besu.ethereum.core.PrivacyParameters; | ||
| import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMigrationService; | ||
| import org.hyperledger.besu.util.PrivateStorageMigrationBuilder; | ||
|
|
||
| public class PrivateDatabaseMigrationPreSyncTask implements PreSynchronizationTask { | ||
|
|
||
| private final PrivacyParameters privacyParameters; | ||
| private final boolean migratePrivateDatabaseFlag; | ||
|
|
||
| public PrivateDatabaseMigrationPreSyncTask( | ||
| final PrivacyParameters privacyParameters, final boolean migratePrivateDatabaseFlag) { | ||
| this.privacyParameters = privacyParameters; | ||
| this.migratePrivateDatabaseFlag = migratePrivateDatabaseFlag; | ||
| } | ||
|
|
||
| @Override | ||
| public void run(final BesuController<?> besuController) { | ||
| final PrivateStorageMigrationBuilder privateStorageMigrationBuilder = | ||
| new PrivateStorageMigrationBuilder(besuController, privacyParameters); | ||
| final PrivateStorageMigrationService privateStorageMigrationService = | ||
| new PrivateStorageMigrationService( | ||
| privacyParameters.getPrivateStateStorage(), | ||
| migratePrivateDatabaseFlag, | ||
| privateStorageMigrationBuilder::build); | ||
|
|
||
| privateStorageMigrationService.runMigrationIfRequired(); | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
besu/src/main/java/org/hyperledger/besu/util/PrivateStorageMigrationBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright ConsenSys AG. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.util; | ||
|
|
||
| import org.hyperledger.besu.controller.BesuController; | ||
| import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
| import org.hyperledger.besu.ethereum.core.Address; | ||
| import org.hyperledger.besu.ethereum.core.PrivacyParameters; | ||
| import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; | ||
| import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; | ||
| import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage; | ||
| import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; | ||
| import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateMigrationBlockProcessor; | ||
| import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMigration; | ||
| import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; | ||
|
|
||
| public class PrivateStorageMigrationBuilder { | ||
|
|
||
| private final BesuController<?> besuController; | ||
| private final PrivacyParameters privacyParameters; | ||
|
|
||
| public PrivateStorageMigrationBuilder( | ||
| final BesuController<?> besuController, final PrivacyParameters privacyParameters) { | ||
| this.besuController = besuController; | ||
| this.privacyParameters = privacyParameters; | ||
| } | ||
|
|
||
| public PrivateStorageMigration build() { | ||
| final Blockchain blockchain = besuController.getProtocolContext().getBlockchain(); | ||
| final Address privacyPrecompileAddress = | ||
| Address.privacyPrecompiled(privacyParameters.getPrivacyAddress()); | ||
| final ProtocolSchedule<?> protocolSchedule = besuController.getProtocolSchedule(); | ||
| final WorldStateArchive publicWorldStateArchive = | ||
| besuController.getProtocolContext().getWorldStateArchive(); | ||
| final PrivateStateStorage privateStateStorage = privacyParameters.getPrivateStateStorage(); | ||
| final PrivateStateRootResolver privateStateRootResolver = | ||
| new PrivateStateRootResolver(privateStateStorage); | ||
| final LegacyPrivateStateStorage legacyPrivateStateStorage = | ||
| privacyParameters.getPrivateStorageProvider().createLegacyPrivateStateStorage(); | ||
|
|
||
| return new PrivateStorageMigration( | ||
| blockchain, | ||
| privacyPrecompileAddress, | ||
| protocolSchedule, | ||
| publicWorldStateArchive, | ||
| privateStateStorage, | ||
| privateStateRootResolver, | ||
| legacyPrivateStateStorage, | ||
| PrivateMigrationBlockProcessor::new); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.