private Optional<DatabaseMetadata> handleVersionUpgrade(
      final Path dataDir,
      final DatabaseMetadata existingMetadata,
      final BaseVersionedStorageFormat runtimeVersion) {
    // here we put the code, or the messages, to perform an automated, or manual, upgrade of the
    // database.
    // In case we do an automated upgrade, then we also need to update the metadata on disk to
    // reflect the change to the runtime version, and return it.

    // Besu supports both formats of receipts so no upgrade is needed other than updating metadata
    final VersionedStorageFormat existingVersionedStorageFormat =
        existingMetadata.getVersionedStorageFormat();
    if ((existingVersionedStorageFormat == BONSAI_WITH_VARIABLES
            && runtimeVersion == BONSAI_WITH_RECEIPT_COMPACTION)
        || (existingVersionedStorageFormat == FOREST_WITH_VARIABLES
            && runtimeVersion == FOREST_WITH_RECEIPT_COMPACTION)) {
      final DatabaseMetadata metadata = new DatabaseMetadata(runtimeVersion);
      try {
        metadata.writeToDirectory(dataDir);
        return Optional.of(metadata);
      } catch (IOException e) {
        throw new StorageException("Database upgrade to use receipt compaction failed", e);
      }
    }

    // for the moment there are no planned automated upgrades, so we just fail.
    String error =
        String.format(
            "Database unsafe downgrade detect: DB at %s is %s with version %s but version %s is expected. "
                + "Please check your config and review release notes for supported downgrade procedures.",
            dataDir,
            existingVersionedStorageFormat.getFormat().name(),
            existingVersionedStorageFormat.getVersion(),
            runtimeVersion.getVersion());

    throw new StorageException(error);
  }
Storage path.

@param commonConfiguration the common configuration
@return the path
plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/RocksDBKeyValueStorageFactory.java