Skip to content

Commit

Permalink
Vote storage WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 9, 2024
1 parent 2526b75 commit edb3a7d
Show file tree
Hide file tree
Showing 40 changed files with 1,459 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "0")
if(CI_VERSION_PRE_RELEASE)
set(CPACK_PACKAGE_VERSION_PRE_RELEASE "${CI_VERSION_PRE_RELEASE}")
else()
set(CPACK_PACKAGE_VERSION_PRE_RELEASE "99")
set(CPACK_PACKAGE_VERSION_PRE_RELEASE "100")
endif()

if(CI_TAG)
Expand Down
2 changes: 1 addition & 1 deletion nano/lib/lmdbconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class lmdb_config final
/** Sync strategy for the ledger database */
sync_strategy sync{ always };
uint32_t max_databases{ 128 };
size_t map_size{ 256ULL * 1024 * 1024 * 1024 };
size_t map_size{ 512ULL * 1024 * 1024 * 1024 };
};
}
15 changes: 15 additions & 0 deletions nano/lib/numbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ class qualified_root : public uint512_union
}
};

class vote_storage_key : public uint512_union
{
public:
using uint512_union::uint512_union;

nano::block_hash const & block_hash () const
{
return reinterpret_cast<nano::block_hash const &> (uint256s[0]);
}
nano::account const & account () const
{
return reinterpret_cast<nano::account const &> (uint256s[1]);
}
};

nano::signature sign_message (nano::raw_key const &, nano::public_key const &, nano::uint256_union const &);
nano::signature sign_message (nano::raw_key const &, nano::public_key const &, uint8_t const *, size_t);
bool validate_message (nano::public_key const &, nano::uint256_union const &, nano::signature const &);
Expand Down
26 changes: 26 additions & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ enum class type : uint8_t
bootstrap_ascending,
bootstrap_ascending_accounts,

vote_storage,
vote_storage_broadcast,
vote_storage_replies,
vote_storage_write,

_last // Must be the last enum
};

Expand All @@ -74,6 +79,7 @@ enum class detail : uint8_t
none,
success,
unknown,
empty,

// processing queue
queue,
Expand Down Expand Up @@ -328,6 +334,26 @@ enum class detail : uint8_t
deprioritize,
deprioritize_failed,

// vote storage
stored,
stored_votes,
frontier,
frontier_empty,
reply_vote,
reply_duplicate,
broadcast_duplicate,
broadcast_vote_rep,
broadcast_vote_random,
broadcast_rep,
broadcast_random,
low_weight,
reply_channel_full,
broadcast_channel_full,
rep_broadcast_channel_full,
random_broadcast_channel_full,
write_error_broadcast,
write_error_reply,

_last // Must be the last enum
};

Expand Down
3 changes: 3 additions & 0 deletions nano/lib/thread_roles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
case nano::thread_role::name::scheduler_priority:
thread_role_name_string = "Sched Priority";
break;
case nano::thread_role::name::vote_storage:
thread_role_name_string = "Vote storage";
break;
default:
debug_assert (false && "nano::thread_role::get_string unhandled thread role");
}
Expand Down
1 change: 1 addition & 0 deletions nano/lib/thread_roles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum class name
scheduler_manual,
scheduler_optimistic,
scheduler_priority,
vote_storage,
};

/*
Expand Down
2 changes: 2 additions & 0 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ add_library(
vote_cache.cpp
vote_processor.hpp
vote_processor.cpp
vote_storage.hpp
vote_storage.cpp
voting.hpp
voting.cpp
wallet.hpp
Expand Down
8 changes: 7 additions & 1 deletion nano/node/bandwidth_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ void nano::bandwidth_limiter::reset (std::size_t limit_a, double burst_ratio_a)
nano::outbound_bandwidth_limiter::outbound_bandwidth_limiter (nano::outbound_bandwidth_limiter::config config_a) :
config_m{ config_a },
limiter_standard (config_m.standard_limit, config_m.standard_burst_ratio),
limiter_bootstrap{ config_m.bootstrap_limit, config_m.bootstrap_burst_ratio }
limiter_bootstrap{ config_m.bootstrap_limit, config_m.bootstrap_burst_ratio },
limiter_vote_storage{ config_m.vote_storage_limit, config_m.vote_storage_burst_ratio }
{
}

Expand All @@ -39,6 +40,8 @@ nano::bandwidth_limiter & nano::outbound_bandwidth_limiter::select_limiter (nano
return limiter_bootstrap;
case bandwidth_limit_type::standard:
break;
case bandwidth_limit_type::vote_storage:
return limiter_vote_storage;
default:
debug_assert (false);
break;
Expand Down Expand Up @@ -68,6 +71,9 @@ nano::bandwidth_limit_type nano::to_bandwidth_limit_type (const nano::transport:
case nano::transport::traffic_type::bootstrap:
return nano::bandwidth_limit_type::bootstrap;
break;
case nano::transport::traffic_type::vote_storage:
return nano::bandwidth_limit_type::vote_storage;
break;
}
debug_assert (false);
return {};
Expand Down
10 changes: 9 additions & 1 deletion nano/node/bandwidth_limiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ enum class bandwidth_limit_type
/** For all message */
standard,
/** For bootstrap (asc_pull_ack, asc_pull_req) traffic */
bootstrap
bootstrap,
/** For vote storage broadcasts and replies */
vote_storage,
};

nano::bandwidth_limit_type to_bandwidth_limit_type (nano::transport::traffic_type const &);
Expand Down Expand Up @@ -42,9 +44,14 @@ class outbound_bandwidth_limiter final
// standard
std::size_t standard_limit;
double standard_burst_ratio;

// bootstrap
std::size_t bootstrap_limit;
double bootstrap_burst_ratio;

// vote storage
std::size_t vote_storage_limit;
double vote_storage_burst_ratio;
};

public:
Expand Down Expand Up @@ -72,5 +79,6 @@ class outbound_bandwidth_limiter final
private:
bandwidth_limiter limiter_standard;
bandwidth_limiter limiter_bootstrap;
bandwidth_limiter limiter_vote_storage;
};
}
Loading

0 comments on commit edb3a7d

Please sign in to comment.