Skip to content

Commit

Permalink
#1870 add patch timestamp for rocksdb
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Jul 31, 2024
1 parent 3b81360 commit 018d090
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
36 changes: 28 additions & 8 deletions libdevcore/RocksDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
#include "Log.h"
#include <libdevcore/microprofile.h>

#include <libethereum/SchainPatch.h>

#include <leveldb/filter_policy.h>

#include <rocksdb/table.h>
#include <rocksdb/utilities/leveldb_options.h>

using std::string, std::runtime_error;

Expand Down Expand Up @@ -89,30 +94,45 @@ void RocksDBWriteBatch::kill( Slice _key ) {

rocksdb::ReadOptions RocksDB::defaultReadOptions() {
rocksdb::ReadOptions readOptions = rocksdb::ReadOptions();
if ( !RocksDbPatch::isEnabledInWorkingBlock() )
return readOptions;
readOptions.ignore_range_deletions = true;
return readOptions;
}

rocksdb::WriteOptions RocksDB::defaultWriteOptions() {
rocksdb::WriteOptions writeOptions = rocksdb::WriteOptions();
if ( !RocksDbPatch::isEnabledInWorkingBlock() )
return writeOptions;
return writeOptions;
}

rocksdb::Options RocksDB::defaultDBOptions() {
rocksdb::Options options;
options.create_if_missing = true;
options.max_open_files = c_maxOpenRocksdbFiles;

rocksdb::BlockBasedTableOptions table_options;
table_options.filter_policy.reset( rocksdb::NewRibbonFilterPolicy( 10 ) );
options.table_factory.reset( rocksdb::NewBlockBasedTableFactory( table_options ) );
if ( !RocksDbPatch::isEnabledInWorkingBlock() ) {
rocksdb::LevelDBOptions opt = rocksdb::LevelDBOptions();
opt.create_if_missing = true;
opt.max_open_files = c_maxOpenRocksdbFiles;
opt.filter_policy = rocksdb::NewBloomFilterPolicy( 10 );

options = rocksdb::ConvertOptions( opt );
} else {
options.create_if_missing = true;
options.max_open_files = c_maxOpenRocksdbFiles;

rocksdb::BlockBasedTableOptions table_options;
table_options.filter_policy.reset( rocksdb::NewRibbonFilterPolicy( 10 ) );
options.table_factory.reset( rocksdb::NewBlockBasedTableFactory( table_options ) );
}
return options;
}

rocksdb::ReadOptions RocksDB::defaultSnapshotReadOptions() {
rocksdb::ReadOptions options;
options.ignore_range_deletions = true;
rocksdb::ReadOptions options = rocksdb::ReadOptions();
options.fill_cache = false;
if ( !RocksDbPatch::isEnabledInWorkingBlock() )
return options;
options.ignore_range_deletions = true;
options.async_io = true;
return options;
}
Expand Down
4 changes: 4 additions & 0 deletions libethereum/SchainPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ SchainPatchEnum getEnumForPatchName( const std::string& _patchName ) {
return SchainPatchEnum::VerifyBlsSyncPatch;
else if ( _patchName == "FlexibleDeploymentPatch" )
return SchainPatchEnum::FlexibleDeploymentPatch;
else if ( _patchName == "RocksDbPatch" )
return SchainPatchEnum::RocksDbPatch;
else
throw std::out_of_range( _patchName );
}
Expand Down Expand Up @@ -72,6 +74,8 @@ std::string getPatchNameForEnum( SchainPatchEnum _enumValue ) {
return "VerifyBlsSyncPatch";
case SchainPatchEnum::FlexibleDeploymentPatch:
return "FlexibleDeploymentPatch";
case SchainPatchEnum::RocksDbPatch:
return "RocksDbPatch";
default:
throw std::out_of_range(
"UnknownPatch #" + std::to_string( static_cast< size_t >( _enumValue ) ) );
Expand Down
6 changes: 6 additions & 0 deletions libethereum/SchainPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,10 @@ DEFINE_AMNESIC_PATCH( VerifyBlsSyncPatch );
*/
DEFINE_SIMPLE_PATCH( FlexibleDeploymentPatch );

/*
* Purpose: migrate from LevelDb to RocksDb
* Version introduced: 3.20.0
*/
DEFINE_AMNESIC_PATCH( RocksDbPatch );

#endif // SCHAINPATCH_H
1 change: 1 addition & 0 deletions libethereum/SchainPatchEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum class SchainPatchEnum {
EIP1559TransactionsPatch,
VerifyBlsSyncPatch,
FlexibleDeploymentPatch,
RocksDbPatch,
PatchesCount
};

Expand Down

0 comments on commit 018d090

Please sign in to comment.