Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify (simplify) state_history plugin's thread logic; add get_status_request_v1 #96

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions libraries/state_history/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ extern const char* const state_history_plugin_abi = R"({
{
"name": "get_status_request_v0", "fields": []
},
{
"name": "get_status_request_v1", "fields": []
},
{
"name": "block_position", "fields": [
{ "name": "block_num", "type": "uint32" },
Expand All @@ -21,6 +24,19 @@ extern const char* const state_history_plugin_abi = R"({
{ "name": "chain_id", "type": "checksum256$" }
]
},
{
"name": "get_status_result_v1", "fields": [
{ "name": "head", "type": "block_position" },
{ "name": "last_irreversible", "type": "block_position" },
{ "name": "trace_begin_block", "type": "uint32" },
{ "name": "trace_end_block", "type": "uint32" },
{ "name": "chain_state_begin_block", "type": "uint32" },
{ "name": "chain_state_end_block", "type": "uint32" },
{ "name": "chain_id", "type": "checksum256$" },
spoonincode marked this conversation as resolved.
Show resolved Hide resolved
{ "name": "finality_data_begin_block", "type": "uint32" },
{ "name": "finality_data_end_block", "type": "uint32" }
]
},
{
"name": "get_blocks_request_v0", "fields": [
{ "name": "start_block_num", "type": "uint32" },
Expand Down Expand Up @@ -586,8 +602,8 @@ extern const char* const state_history_plugin_abi = R"({
{ "new_type_name": "transaction_id", "type": "checksum256" }
],
"variants": [
{ "name": "request", "types": ["get_status_request_v0", "get_blocks_request_v0", "get_blocks_ack_request_v0", "get_blocks_request_v1"] },
{ "name": "result", "types": ["get_status_result_v0", "get_blocks_result_v0", "get_blocks_result_v1"] },
{ "name": "request", "types": ["get_status_request_v0", "get_blocks_request_v0", "get_blocks_ack_request_v0", "get_blocks_request_v1", "get_status_request_v1"] },
{ "name": "result", "types": ["get_status_result_v0", "get_blocks_result_v0", "get_blocks_result_v1", "get_status_result_v1"] },

{ "name": "action_receipt", "types": ["action_receipt_v0"] },
{ "name": "action_trace", "types": ["action_trace_v0", "action_trace_v1"] },
Expand Down
13 changes: 11 additions & 2 deletions libraries/state_history/include/eosio/state_history/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct block_position {

struct get_status_request_v0 {};

struct get_status_request_v1 : get_status_request_v0 {};

struct get_status_result_v0 {
block_position head = {};
block_position last_irreversible = {};
Expand All @@ -93,6 +95,11 @@ struct get_status_result_v0 {
fc::sha256 chain_id = {};
};

struct get_status_result_v1 : get_status_result_v0 {
uint32_t finality_data_begin_block = 0;
uint32_t finality_data_end_block = 0;
};

struct get_blocks_request_v0 {
uint32_t start_block_num = 0;
uint32_t end_block_num = 0;
Expand Down Expand Up @@ -129,8 +136,8 @@ struct get_blocks_result_v1 : get_blocks_result_v0 {
std::optional<bytes> finality_data;
};

using state_request = std::variant<get_status_request_v0, get_blocks_request_v0, get_blocks_ack_request_v0, get_blocks_request_v1>;
using state_result = std::variant<get_status_result_v0, get_blocks_result_v0, get_blocks_result_v1>;
using state_request = std::variant<get_status_request_v0, get_blocks_request_v0, get_blocks_ack_request_v0, get_blocks_request_v1, get_status_request_v1>;
using state_result = std::variant<get_status_result_v0, get_blocks_result_v0, get_blocks_result_v1, get_status_result_v1>;
using get_blocks_request = std::variant<get_blocks_request_v0, get_blocks_request_v1>;
using get_blocks_result = std::variant<get_blocks_result_v0, get_blocks_result_v1>;

Expand All @@ -141,7 +148,9 @@ using get_blocks_result = std::variant<get_blocks_result_v0, get_blocks_result_v
FC_REFLECT(eosio::state_history::table_delta, (struct_version)(name)(rows));
FC_REFLECT(eosio::state_history::block_position, (block_num)(block_id));
FC_REFLECT_EMPTY(eosio::state_history::get_status_request_v0);
FC_REFLECT_DERIVED(eosio::state_history::get_status_request_v1, (eosio::state_history::get_status_request_v0), )
FC_REFLECT(eosio::state_history::get_status_result_v0, (head)(last_irreversible)(trace_begin_block)(trace_end_block)(chain_state_begin_block)(chain_state_end_block)(chain_id));
FC_REFLECT_DERIVED(eosio::state_history::get_status_result_v1, (eosio::state_history::get_status_result_v0), (finality_data_begin_block)(finality_data_end_block));
FC_REFLECT(eosio::state_history::get_blocks_request_v0, (start_block_num)(end_block_num)(max_messages_in_flight)(have_positions)(irreversible_only)(fetch_block)(fetch_traces)(fetch_deltas));
FC_REFLECT_DERIVED(eosio::state_history::get_blocks_request_v1, (eosio::state_history::get_blocks_request_v0), (fetch_finality_data));
FC_REFLECT(eosio::state_history::get_blocks_ack_request_v0, (num_messages));
Expand Down
7 changes: 6 additions & 1 deletion plugins/state_history_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ add_library( state_history_plugin
target_link_libraries( state_history_plugin state_history chain_plugin eosio_chain appbase )
target_include_directories( state_history_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

add_subdirectory(tests)
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11 )
target_compile_options( state_history_plugin PRIVATE "-fcoroutines" )
endif()

#TODO: revisit
#add_subdirectory(tests)
Loading
Loading