Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

ship: reduce spam #7139

Merged
merged 6 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosi
}

template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::account_metadata_object>& obj) {
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::account_metadata_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.value));
fc::raw::pack(ds, as_type<bool>(obj.obj.is_privileged()));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_code_update));
bool has_code = obj.obj.code_hash != eosio::chain::digest_type();
fc::raw::pack(ds, has_code);
if(has_code) {
if (has_code) {
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_type));
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_version));
fc::raw::pack(ds, as_type<eosio::chain::digest_type>(obj.obj.code_hash));
Expand All @@ -133,7 +134,6 @@ datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosi
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_type));
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_version));
fc::raw::pack(ds, as_type<eosio::chain::digest_type>(obj.obj.code_hash));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code_ref_count));
fc::raw::pack(ds, as_type<eosio::chain::shared_string>(obj.obj.code));
return ds;
}
Expand Down Expand Up @@ -548,7 +548,8 @@ datastream<ST>& operator<<(datastream<ST>&

fc::raw::pack(ds, bool(obj.obj.account_ram_delta));
if (obj.obj.account_ram_delta) {
fc::raw::pack(ds, make_history_serial_wrapper(obj.db, as_type<eosio::chain::account_delta>(*obj.obj.account_ram_delta)));
fc::raw::pack(
ds, make_history_serial_wrapper(obj.db, as_type<eosio::chain::account_delta>(*obj.obj.account_ram_delta)));
}

fc::optional<std::string> e;
Expand Down
51 changes: 50 additions & 1 deletion plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,54 @@ static bytes zlib_compress_bytes(bytes in) {
return out;
}

template <typename T>
bool include_delta(const T& old, const T& curr) {
return true;
}

bool include_delta(const eosio::chain::table_id_object& old, const eosio::chain::table_id_object& curr) {
return old.payer != curr.payer;
}

bool include_delta(const eosio::chain::resource_limits::resource_limits_object& old,
const eosio::chain::resource_limits::resource_limits_object& curr) {
return //
old.net_weight != curr.net_weight || //
old.cpu_weight != curr.cpu_weight || //
old.ram_bytes != curr.ram_bytes;
}

bool include_delta(const eosio::chain::resource_limits::resource_limits_state_object& old,
const eosio::chain::resource_limits::resource_limits_state_object& curr) {
return //
old.average_block_net_usage.last_ordinal != curr.average_block_net_usage.last_ordinal || //
old.average_block_net_usage.value_ex != curr.average_block_net_usage.value_ex || //
old.average_block_net_usage.consumed != curr.average_block_net_usage.consumed || //
old.average_block_cpu_usage.last_ordinal != curr.average_block_cpu_usage.last_ordinal || //
old.average_block_cpu_usage.value_ex != curr.average_block_cpu_usage.value_ex || //
old.average_block_cpu_usage.consumed != curr.average_block_cpu_usage.consumed || //
old.total_net_weight != curr.total_net_weight || //
old.total_cpu_weight != curr.total_cpu_weight || //
old.total_ram_bytes != curr.total_ram_bytes || //
old.virtual_net_limit != curr.virtual_net_limit || //
old.virtual_cpu_limit != curr.virtual_cpu_limit;
}

bool include_delta(const eosio::chain::account_metadata_object& old,
const eosio::chain::account_metadata_object& curr) {
return //
old.name.value != curr.name.value || //
old.is_privileged() != curr.is_privileged() || //
old.last_code_update != curr.last_code_update || //
old.vm_type != curr.vm_type || //
old.vm_version != curr.vm_version || //
old.code_hash != curr.code_hash;
}

bool include_delta(const eosio::chain::code_object& old, const eosio::chain::code_object& curr) { //
return false;
}

struct state_history_plugin_impl : std::enable_shared_from_this<state_history_plugin_impl> {
chain_plugin* chain_plug = nullptr;
fc::optional<state_history_log> trace_log;
Expand Down Expand Up @@ -453,7 +501,8 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
delta.name = name;
for (auto& old : undo.old_values) {
auto& row = index.get(old.first);
delta.rows.obj.emplace_back(true, pack_row(row));
if (include_delta(old.second, row))
delta.rows.obj.emplace_back(true, pack_row(row));
}
for (auto& old : undo.removed_values)
delta.rows.obj.emplace_back(false, pack_row(old.second));
Expand Down
1 change: 0 additions & 1 deletion plugins/state_history_plugin/state_history_plugin_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ extern const char* const state_history_plugin_abi = R"({
{ "type": "uint8", "name": "vm_type" },
{ "type": "uint8", "name": "vm_version" },
{ "type": "checksum256", "name": "code_hash" },
{ "type": "uint64", "name": "code_ref_count" },
{ "type": "bytes", "name": "code" }
]
},
Expand Down