Skip to content

Commit

Permalink
Merge pull request #11028 from EOSIO/ds-epe-1841-no-rocksdb-for-nodeos
Browse files Browse the repository at this point in the history
rocksdb integration for nodeos removed 📦
  • Loading branch information
dimas1185 authored Feb 7, 2022
2 parents 437ca7c + f808948 commit 28ec0df
Show file tree
Hide file tree
Showing 76 changed files with 1,125 additions and 11,204 deletions.
8 changes: 1 addition & 7 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ add_library( eosio_chain
block_header_state.cpp
block_state.cpp
fork_database.cpp
combined_database.cpp
db_util.cpp
controller.cpp
authorization_manager.cpp
resource_limits.cpp
Expand Down Expand Up @@ -134,10 +134,6 @@ add_library( eosio_chain
platform_timer_accuracy.cpp
backing_store/kv_context.cpp
backing_store/db_context.cpp
backing_store/db_context_chainbase.cpp
backing_store/db_context_rocksdb.cpp
backing_store/db_key_value_format.cpp
backing_store/db_key_value_any_lookup.cpp
${PLATFORM_TIMER_IMPL}
${HEADERS}
)
Expand Down Expand Up @@ -190,8 +186,6 @@ if(EOSIO_REQUIRE_CHAIN_ID)
target_compile_definitions(eosio_chain PUBLIC "EOSIO_REQUIRE_CHAIN_ID=\"${EOSIO_REQUIRE_CHAIN_ID}\"")
endif()

add_subdirectory ( backing_store/tests )

install( TARGETS eosio_chain
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
Expand Down
43 changes: 17 additions & 26 deletions libraries/chain/apply_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
#include <eosio/chain/kv_chainbase_objects.hpp>

using boost::container::flat_set;
using namespace eosio::chain::backing_store;

namespace eosio { namespace chain {

using db_context = backing_store::db_context;

static inline void print_debug(account_name receiver, const action_trace& ar) {
if (!ar.console.empty()) {
auto prefix = fc::format_string(
Expand Down Expand Up @@ -51,7 +50,6 @@ apply_context::apply_context(controller& con, transaction_context& trx_ctx, uint
act = &trace.act;
receiver = trace.receiver;
context_free = trace.context_free;
_db_context = control.kv_db().create_db_context(*this, receiver);
}

template <typename Exception>
Expand Down Expand Up @@ -104,7 +102,7 @@ void apply_context::exec_one()
kv_iterators.resize(1);
kv_destroyed_iterators.clear();
if (!context_free) {
kv_backing_store = control.kv_db().create_kv_context(receiver, create_kv_resource_manager(*this), control.get_global_properties().kv_configuration);
kv_backing_store = db_util::create_kv_context(control, receiver, create_kv_resource_manager(*this), control.get_global_properties().kv_configuration);
}
receiver_account = &db.get<account_metadata_object,by_name>( receiver );
if( !(context_free && control.skip_trx_checks()) ) {
Expand Down Expand Up @@ -222,7 +220,6 @@ void apply_context::exec()
increment_action_id();
for( uint32_t i = 1; i < _notified.size(); ++i ) {
std::tie( receiver, action_ordinal ) = _notified[i];
_db_context->receiver = receiver;
exec_one();
increment_action_id();
}
Expand Down Expand Up @@ -846,7 +843,7 @@ int apply_context::get_context_free_data( uint32_t index, char* buffer, size_t b
return copy_size;
}

int apply_context::db_store_i64_chainbase( name scope, name table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) {
int apply_context::db_store_i64( name scope, name table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) {
// require_write_lock( scope );
const auto& tab = find_or_create_table( receiver, scope, table, payer );
auto tableid = tab.id;
Expand Down Expand Up @@ -881,7 +878,7 @@ int apply_context::db_store_i64_chainbase( name scope, name table, const account
return db_iter_store.add( obj );
}

void apply_context::db_update_i64_chainbase( int iterator, account_name payer, const char* buffer, size_t buffer_size ) {
void apply_context::db_update_i64( int iterator, account_name payer, const char* buffer, size_t buffer_size ) {
const key_value_object& obj = db_iter_store.get( iterator );

const auto& table_obj = db_iter_store.get_table( obj.t_id );
Expand Down Expand Up @@ -922,7 +919,7 @@ void apply_context::db_update_i64_chainbase( int iterator, account_name payer, c
});
}

void apply_context::db_remove_i64_chainbase( int iterator ) {
void apply_context::db_remove_i64( int iterator ) {
const key_value_object& obj = db_iter_store.get( iterator );

const auto& table_obj = db_iter_store.get_table( obj.t_id );
Expand Down Expand Up @@ -953,7 +950,7 @@ void apply_context::db_remove_i64_chainbase( int iterator ) {
db_iter_store.remove( iterator );
}

int apply_context::db_get_i64_chainbase( int iterator, char* buffer, size_t buffer_size ) {
int apply_context::db_get_i64( int iterator, char* buffer, size_t buffer_size ) {
const key_value_object& obj = db_iter_store.get( iterator );

auto s = obj.value.size();
Expand All @@ -965,7 +962,7 @@ int apply_context::db_get_i64_chainbase( int iterator, char* buffer, size_t buff
return copy_size;
}

int apply_context::db_next_i64_chainbase( int iterator, uint64_t& primary ) {
int apply_context::db_next_i64( int iterator, uint64_t& primary ) {
if( iterator < -1 ) return -1; // cannot increment past end iterator of table

const auto& obj = db_iter_store.get( iterator ); // Check for iterator != -1 happens in this call
Expand All @@ -980,7 +977,7 @@ int apply_context::db_next_i64_chainbase( int iterator, uint64_t& primary ) {
return db_iter_store.add( *itr );
}

int apply_context::db_previous_i64_chainbase( int iterator, uint64_t& primary ) {
int apply_context::db_previous_i64( int iterator, uint64_t& primary ) {
const auto& idx = db.get_index<key_value_index, by_scope_primary>();

if( iterator < -1 ) // is end iterator
Expand Down Expand Up @@ -1012,7 +1009,7 @@ int apply_context::db_previous_i64_chainbase( int iterator, uint64_t& primary )
return db_iter_store.add(*itr);
}

int apply_context::db_find_i64_chainbase( name code, name scope, name table, uint64_t id ) {
int apply_context::db_find_i64( name code, name scope, name table, uint64_t id ) {
//require_read_lock( code, scope ); // redundant?

const auto* tab = find_table( code, scope, table );
Expand All @@ -1026,7 +1023,7 @@ int apply_context::db_find_i64_chainbase( name code, name scope, name table, uin
return db_iter_store.add( *obj );
}

int apply_context::db_lowerbound_i64_chainbase( name code, name scope, name table, uint64_t id ) {
int apply_context::db_lowerbound_i64( name code, name scope, name table, uint64_t id ) {
//require_read_lock( code, scope ); // redundant?

const auto* tab = find_table( code, scope, table );
Expand All @@ -1042,7 +1039,7 @@ int apply_context::db_lowerbound_i64_chainbase( name code, name scope, name tabl
return db_iter_store.add( *itr );
}

int apply_context::db_upperbound_i64_chainbase( name code, name scope, name table, uint64_t id ) {
int apply_context::db_upperbound_i64( name code, name scope, name table, uint64_t id ) {
//require_read_lock( code, scope ); // redundant?

const auto* tab = find_table( code, scope, table );
Expand All @@ -1058,7 +1055,7 @@ int apply_context::db_upperbound_i64_chainbase( name code, name scope, name tabl
return db_iter_store.add( *itr );
}

int apply_context::db_end_i64_chainbase( name code, name scope, name table ) {
int apply_context::db_end_i64( name code, name scope, name table ) {
//require_read_lock( code, scope ); // redundant?

const auto* tab = find_table( code, scope, table );
Expand All @@ -1068,19 +1065,19 @@ int apply_context::db_end_i64_chainbase( name code, name scope, name table ) {
}

int64_t apply_context::kv_erase(uint64_t contract, const char* key, uint32_t key_size) {
return kv_get_backing_store().kv_erase(contract, key, key_size);
return get_kv_context().kv_erase(contract, key, key_size);
}

int64_t apply_context::kv_set(uint64_t contract, const char* key, uint32_t key_size, const char* value, uint32_t value_size, account_name payer) {
return kv_get_backing_store().kv_set(contract, key, key_size, value, value_size, payer);
return get_kv_context().kv_set(contract, key, key_size, value, value_size, payer);
}

bool apply_context::kv_get(uint64_t contract, const char* key, uint32_t key_size, uint32_t& value_size) {
return kv_get_backing_store().kv_get(contract, key, key_size, value_size);
return get_kv_context().kv_get(contract, key, key_size, value_size);
}

uint32_t apply_context::kv_get_data(uint32_t offset, char* data, uint32_t data_size) {
return kv_get_backing_store().kv_get_data(offset, data, data_size);
return get_kv_context().kv_get_data(offset, data, data_size);
}

uint32_t apply_context::kv_it_create(uint64_t contract, const char* prefix, uint32_t size) {
Expand All @@ -1094,7 +1091,7 @@ uint32_t apply_context::kv_it_create(uint64_t contract, const char* prefix, uint
itr = kv_iterators.size();
kv_iterators.emplace_back();
}
kv_iterators[itr] = kv_get_backing_store().kv_it_create(contract, prefix, size);
kv_iterators[itr] = get_kv_context().kv_it_create(contract, prefix, size);
return itr;
}

Expand Down Expand Up @@ -1201,10 +1198,4 @@ uint32_t apply_context::get_action_id() const {
void apply_context::increment_action_id() {
trx_context.action_id.increment();
}

db_context& apply_context::db_get_context() {
EOS_ASSERT( _db_context, action_validate_exception,
"context-free actions cannot access state" );
return *_db_context;
}
} } /// eosio::chain
44 changes: 20 additions & 24 deletions libraries/chain/backing_store/db_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/backing_store/db_context.hpp>

namespace eosio { namespace chain { namespace backing_store {
namespace eosio { namespace chain { namespace backing_store { namespace db_context {

std::string db_context::table_event(name code, name scope, name table) {
std::string table_event(name code, name scope, name table) {
return STORAGE_EVENT_ID("${code}:${scope}:${table}",
("code", code)
("scope", scope)
("table", table)
);
}

std::string db_context::table_event(name code, name scope, name table, name qualifier) {
std::string table_event(name code, name scope, name table, name qualifier) {
return STORAGE_EVENT_ID("${code}:${scope}:${table}:${qualifier}",
("code", code)
("scope", scope)
Expand All @@ -21,7 +21,7 @@ std::string db_context::table_event(name code, name scope, name table, name qual
);
}

void db_context::log_insert_table(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table, account_name payer) {
void log_insert_table(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table, account_name payer) {
fc_dlog(deep_mind_logger, "TBL_OP INS ${action_id} ${code} ${scope} ${table} ${payer}",
("action_id", action_id)
("code", code)
Expand All @@ -31,7 +31,7 @@ void db_context::log_insert_table(fc::logger& deep_mind_logger, uint32_t action_
);
}

void db_context::log_remove_table(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table, account_name payer) {
void log_remove_table(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table, account_name payer) {
fc_dlog(deep_mind_logger, "TBL_OP REM ${action_id} ${code} ${scope} ${table} ${payer}",
("action_id", action_id)
("code", code)
Expand All @@ -41,7 +41,7 @@ void db_context::log_remove_table(fc::logger& deep_mind_logger, uint32_t action_
);
}

void db_context::log_row_insert(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
void log_row_insert(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
account_name payer, account_name primkey, const char* buffer, size_t buffer_size) {
fc_dlog(deep_mind_logger, "DB_OP INS ${action_id} ${payer} ${table_code} ${scope} ${table_name} ${primkey} ${ndata}",
("action_id", action_id)
Expand All @@ -54,7 +54,7 @@ void db_context::log_row_insert(fc::logger& deep_mind_logger, uint32_t action_id
);
}

void db_context::log_row_update(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
void log_row_update(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
account_name old_payer, account_name new_payer, account_name primkey,
const char* old_buffer, size_t old_buffer_size, const char* new_buffer, size_t new_buffer_size) {
fc_dlog(deep_mind_logger, "DB_OP UPD ${action_id} ${opayer}:${npayer} ${table_code} ${scope} ${table_name} ${primkey} ${odata}:${ndata}",
Expand All @@ -70,7 +70,7 @@ void db_context::log_row_update(fc::logger& deep_mind_logger, uint32_t action_id
);
}

void db_context::log_row_remove(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
void log_row_remove(fc::logger& deep_mind_logger, uint32_t action_id, name code, name scope, name table,
account_name payer, account_name primkey, const char* buffer, size_t buffer_size) {
fc_dlog(deep_mind_logger, "DB_OP REM ${action_id} ${payer} ${table_code} ${scope} ${table_name} ${primkey} ${odata}",
("action_id", action_id)
Expand All @@ -83,52 +83,48 @@ void db_context::log_row_remove(fc::logger& deep_mind_logger, uint32_t action_id
);
}

storage_usage_trace db_context::add_table_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace add_table_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table", "add", "create_table");
}

storage_usage_trace db_context::rem_table_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace rem_table_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table", "remove", "remove_table");
}

storage_usage_trace db_context::row_add_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace row_add_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table_row", "add", "primary_index_add");
}

storage_usage_trace db_context::row_update_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace row_update_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table_row", "update", "primary_index_update");
}

storage_usage_trace db_context::row_update_add_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace row_update_add_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table_row", "add", "primary_index_update_add_new_payer");
}

storage_usage_trace db_context::row_update_rem_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace row_update_rem_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table_row", "remove", "primary_index_update_remove_old_payer");
}

storage_usage_trace db_context::row_rem_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace row_rem_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "table_row", "remove", "primary_index_remove");
}

storage_usage_trace db_context::secondary_add_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace secondary_add_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "secondary_index", "add", "secondary_index_add");
}

storage_usage_trace db_context::secondary_rem_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace secondary_rem_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "secondary_index", "remove", "secondary_index_remove");
}

storage_usage_trace db_context::secondary_update_add_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace secondary_update_add_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "secondary_index", "add", "secondary_index_update_add_new_payer");
}

storage_usage_trace db_context::secondary_update_rem_trace(uint32_t action_id, std::string&& event_id) {
storage_usage_trace secondary_update_rem_trace(uint32_t action_id, std::string&& event_id) {
return storage_usage_trace(action_id, std::move(event_id), "secondary_index", "remove", "secondary_index_update_remove_old_payer");
}

void db_context::update_db_usage( const account_name& payer, int64_t delta, const storage_usage_trace& trace ) {
context.update_db_usage(payer, delta, trace);
}

}}} // namespace eosio::chain::backing_store
}}}} // namespace eosio::chain::backing_store::db_context
Loading

0 comments on commit 28ec0df

Please sign in to comment.