forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checkpoint sync (hyperledger#3849)
Add a new way to synchronize which is X_CHECKPOINT. This mode is experimental so use it at your own risk. This mode allows you to do like a snapsync but starting from a specific checkpoint instead of starting from the genesis. This checkpoint will be in the genesis configuration of each network. To add the checkpoint mechanism in a network you just have to add the checkpoint section in the genesis. Currently there is a checkpoint for ropten, goerli and mainnet. Mainnet on i3.2xlarge <6 hours Goerli on i3.2xlarge <1 hours Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
- Loading branch information
Showing
61 changed files
with
1,641 additions
and
332 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
63 changes: 63 additions & 0 deletions
63
config/src/main/java/org/hyperledger/besu/config/CheckpointConfigOptions.java
This file contains 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 contributors to Hyperledger Besu | ||
* | ||
* 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.config; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.OptionalLong; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
public class CheckpointConfigOptions { | ||
|
||
public static final CheckpointConfigOptions DEFAULT = | ||
new CheckpointConfigOptions(JsonUtil.createEmptyObjectNode()); | ||
|
||
private final ObjectNode checkpointConfigRoot; | ||
|
||
CheckpointConfigOptions(final ObjectNode checkpointConfigRoot) { | ||
this.checkpointConfigRoot = checkpointConfigRoot; | ||
} | ||
|
||
public Optional<String> getTotalDifficulty() { | ||
return JsonUtil.getString(checkpointConfigRoot, "totaldifficulty"); | ||
} | ||
|
||
public OptionalLong getNumber() { | ||
return JsonUtil.getLong(checkpointConfigRoot, "number"); | ||
} | ||
|
||
public Optional<String> getHash() { | ||
return JsonUtil.getString(checkpointConfigRoot, "hash"); | ||
} | ||
|
||
public boolean isValid() { | ||
return getTotalDifficulty().isPresent() && getNumber().isPresent() && getHash().isPresent(); | ||
} | ||
|
||
Map<String, Object> asMap() { | ||
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); | ||
getTotalDifficulty().ifPresent(l -> builder.put("totaldifficulty", l)); | ||
getNumber().ifPresent(l -> builder.put("number", l)); | ||
getHash().ifPresent(l -> builder.put("hash", l)); | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CheckpointConfigOptions{" + "checkpointConfigRoot=" + checkpointConfigRoot + '}'; | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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
Oops, something went wrong.