use of tech.pegasys.teku.storage.server.Database in project teku by ConsenSys.
the class InMemoryStorageSystemBuilder method build.
public StorageSystem build() {
final Database database;
switch(version) {
case LEVELDB_TREE:
database = createLevelDbTreeDatabase();
break;
// Leveldb only varies by db type which doesn't apply to in-memory
case LEVELDB2:
case V6:
database = createV6Database();
break;
// Leveldb only varies by db type which doesn't apply to in-memory
case LEVELDB1:
case V5:
database = createV5Database();
break;
case V4:
database = createV4Database();
break;
default:
throw new UnsupportedOperationException("Unsupported database version: " + version);
}
final List<BLSKeyPair> validatorKeys = new MockStartValidatorKeyPairFactory().generateKeyPairs(0, numberOfValidators);
return StorageSystem.create(database, createRestartSupplier(), storageMode, storeConfig, spec, ChainBuilder.create(spec, validatorKeys));
}
use of tech.pegasys.teku.storage.server.Database in project teku by ConsenSys.
the class FileBackedStorageSystemBuilder method build.
public StorageSystem build() {
final Database database;
switch(version) {
case LEVELDB_TREE:
database = createLevelDbTrieDatabase();
break;
case LEVELDB2:
database = createLevelDb2Database();
break;
case LEVELDB1:
database = createLevelDb1Database();
break;
case V6:
database = createV6Database();
break;
case V5:
database = createV5Database();
break;
case V4:
database = createV4Database();
break;
default:
throw new UnsupportedOperationException("Unsupported database version: " + version);
}
validate();
return StorageSystem.create(database, createRestartSupplier(), storageMode, storeConfig, spec, ChainBuilder.create(spec));
}
use of tech.pegasys.teku.storage.server.Database in project teku by ConsenSys.
the class DebugDbCommand method getLatestFinalizedState.
@Command(name = "get-latest-finalized-state", description = "Get the latest finalized state, if available, as SSZ", mixinStandardHelpOptions = true, showDefaultValues = true, abbreviateSynopsis = true, versionProvider = PicoCliVersionProvider.class, synopsisHeading = "%n", descriptionHeading = "%nDescription:%n%n", optionListHeading = "%nOptions:%n", footerHeading = "%n", footer = "Teku is licensed under the Apache License 2.0")
public int getLatestFinalizedState(@Mixin final BeaconNodeDataOptions dataOptions, @Mixin final DataStorageOptions dataStorageOptions, @Mixin final Eth2NetworkOptions eth2NetworkOptions, @Option(required = true, names = { "--output", "-o" }, description = "File to write state to") final Path outputFile, @Option(names = { "--block-output" }, description = "File to write the block matching the latest finalized state to") final Path blockOutputFile) throws Exception {
final AsyncRunner asyncRunner = ScheduledExecutorAsyncRunner.create("async", 1, new MetricTrackingExecutorFactory(new NoOpMetricsSystem()));
try (final Database database = createDatabase(dataOptions, dataStorageOptions, eth2NetworkOptions)) {
final Optional<AnchorPoint> finalizedAnchor = database.createMemoryStore().map(builder -> builder.blockProvider(BlockProvider.NOOP).asyncRunner(asyncRunner).stateProvider(StateAndBlockSummaryProvider.NOOP).build()).map(UpdatableStore::getLatestFinalized);
int result = writeState(outputFile, finalizedAnchor.map(AnchorPoint::getState));
if (result == 0 && blockOutputFile != null) {
final Optional<SignedBeaconBlock> finalizedBlock = finalizedAnchor.flatMap(AnchorPoint::getSignedBeaconBlock);
result = writeBlock(blockOutputFile, finalizedBlock);
}
return result;
} finally {
asyncRunner.shutdown();
}
}
use of tech.pegasys.teku.storage.server.Database in project teku by ConsenSys.
the class DebugDbCommand method getDeposits.
@Command(name = "get-deposits", description = "List the ETH1 deposit information stored in the database", mixinStandardHelpOptions = true, showDefaultValues = true, abbreviateSynopsis = true, versionProvider = PicoCliVersionProvider.class, synopsisHeading = "%n", descriptionHeading = "%nDescription:%n%n", optionListHeading = "%nOptions:%n", footerHeading = "%n", footer = "Teku is licensed under the Apache License 2.0")
public int getDeposits(@Mixin final BeaconNodeDataOptions dataOptions, @Mixin final DataStorageOptions dataStorageOptions, @Mixin final Eth2NetworkOptions eth2NetworkOptions) throws Exception {
try (final YamlEth1EventsChannel eth1EventsChannel = new YamlEth1EventsChannel(System.out);
final Database database = createDatabase(dataOptions, dataStorageOptions, eth2NetworkOptions)) {
final DepositStorage depositStorage = DepositStorage.create(eth1EventsChannel, database);
depositStorage.replayDepositEvents().join();
}
return 0;
}
use of tech.pegasys.teku.storage.server.Database in project teku by ConsenSys.
the class WeakSubjectivityCommand method clearWeakSubjectivityState.
@CommandLine.Command(name = "clear-state", description = "Clears stored weak subjectivity configuration", mixinStandardHelpOptions = true, showDefaultValues = true, abbreviateSynopsis = true, versionProvider = PicoCliVersionProvider.class, synopsisHeading = "%n", descriptionHeading = "%nDescription:%n%n", optionListHeading = "%nOptions:%n", footerHeading = "%n", footer = "Teku is licensed under the Apache License 2.0")
public int clearWeakSubjectivityState(@CommandLine.Mixin final BeaconNodeDataOptions dataOptions, @CommandLine.Mixin final DataStorageOptions dataStorageOptions, @CommandLine.Mixin final Eth2NetworkOptions eth2NetworkOptions) throws Exception {
try (final Database db = createDatabase(dataOptions, dataStorageOptions, eth2NetworkOptions)) {
// Pull value before updating
final WeakSubjectivityState original = db.getWeakSubjectivityState();
if (original.isEmpty()) {
SUB_COMMAND_LOG.display("Weak subjectivity state is already empty - nothing to clear.");
return 0;
}
SUB_COMMAND_LOG.display("Clearing weak subjectivity state: " + stateToString(original));
db.updateWeakSubjectivityState(WeakSubjectivityUpdate.clearWeakSubjectivityCheckpoint());
SUB_COMMAND_LOG.display("Successfully cleared weak subjectivity state.");
return 0;
}
}
Aggregations