Skip to content

Commit

Permalink
Merge branch 'main' into p2p-peer-throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiszczak authored Sep 1, 2023
2 parents 28bb38d + 5018093 commit 1eb1e44
Show file tree
Hide file tree
Showing 51 changed files with 571 additions and 502 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/performance_harness_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Setup Input Params
id: overrides
run: |
echo test-params=testBpOpMode >> $GITHUB_OUTPUT
echo test-params=findMax testBpOpMode >> $GITHUB_OUTPUT
if [[ "${{inputs.override-test-params}}" != "" ]]; then
echo test-params=${{inputs.override-test-params}} >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -103,18 +103,18 @@ jobs:
run: |
zstdcat build.tar.zst | tar x
cd build
./tests/performance_tests/performance_test.py ${{needs.v.outputs.test-params}}
./tests/PerformanceHarnessScenarioRunner.py ${{needs.v.outputs.test-params}}
- name: Prepare results
id: prep-results
run: |
tar -pc build/performance_test | zstd --long -T0 -9 > performance_test_logs.tar.zst
tar -pc build/PerformanceHarnessScenarioRunnerLogs | zstd --long -T0 -9 > PerformanceHarnessScenarioRunnerLogs.tar.zst
- name: Upload results
uses: AntelopeIO/upload-artifact-large-chunks-action@v1
with:
name: performance-test-results
path: performance_test_logs.tar.zst
path: PerformanceHarnessScenarioRunnerLogs.tar.zst
- name: Upload report
uses: actions/upload-artifact@v3
with:
name: performance-test-report
path: ./build/performance_test/**/report.json
path: ./build/PerformanceHarnessScenarioRunnerLogs/**/report.json
2 changes: 1 addition & 1 deletion libraries/chain/authority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace fc {
void to_variant(const eosio::chain::shared_public_key& var, fc::variant& vo) {
vo = var.to_string();
vo = var.to_string({});
}
} // namespace fc
2 changes: 1 addition & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ struct controller_impl {
auth.accounts.push_back({{p.producer_name, config::active_name}, 1});
}

if( static_cast<authority>(permission.auth) != auth ) { // TODO: use a more efficient way to check that authority has not changed
if( permission.auth != auth ) {
db.modify(permission, [&]( auto& po ) {
po.auth = auth;
});
Expand Down
43 changes: 30 additions & 13 deletions libraries/chain/include/eosio/chain/authority.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace eosio { namespace chain {
using shared_public_key_data = std::variant<fc::ecc::public_key_shim, fc::crypto::r1::public_key_shim, shared_string>;

struct shared_public_key {
shared_public_key( shared_public_key_data&& p ) :
explicit shared_public_key( shared_public_key_data&& p ) :
pubkey(std::move(p)) {}

operator public_key_type() const {
public_key_type to_public_key() const {
fc::crypto::public_key::storage_type public_key_storage;
std::visit(overloaded {
[&](const auto& k1r1) {
Expand All @@ -29,8 +29,8 @@ struct shared_public_key {
return std::move(public_key_storage);
}

std::string to_string() const {
return this->operator public_key_type().to_string();
std::string to_string(const fc::yield_function_t& yield) const {
return this->to_public_key().to_string(yield);
}

shared_public_key_data pubkey;
Expand Down Expand Up @@ -90,6 +90,8 @@ struct permission_level_weight {
}
};

struct shared_key_weight;

struct key_weight {
public_key_type key;
weight_type weight;
Expand All @@ -98,6 +100,8 @@ struct key_weight {
return tie( lhs.key, lhs.weight ) == tie( rhs.key, rhs.weight );
}

friend bool operator==( const key_weight& lhs, const shared_key_weight& rhs );

friend bool operator < ( const key_weight& lhs, const key_weight& rhs ) {
return tie( lhs.key, lhs.weight ) < tie( rhs.key, rhs.weight );
}
Expand All @@ -108,8 +112,8 @@ struct shared_key_weight {
shared_key_weight(shared_public_key_data&& k, const weight_type& w) :
key(std::move(k)), weight(w) {}

operator key_weight() const {
return key_weight{key, weight};
key_weight to_key_weight() const {
return key_weight{key.to_public_key(), weight};
}

static shared_key_weight convert(chainbase::allocator<char> allocator, const key_weight& k) {
Expand Down Expand Up @@ -138,6 +142,10 @@ struct shared_key_weight {
}
};

inline bool operator==( const key_weight& lhs, const shared_key_weight& rhs ) {
return tie( lhs.key, lhs.weight ) == tie( rhs.key, rhs.weight );
}

struct wait_weight {
uint32_t wait_sec;
weight_type weight;
Expand Down Expand Up @@ -168,6 +176,8 @@ namespace config {
};
}

struct shared_authority;

struct authority {
authority( public_key_type k, uint32_t delay_sec = 0 )
:threshold(1),keys({{k,1}})
Expand All @@ -178,7 +188,7 @@ struct authority {
}
}

authority( permission_level p, uint32_t delay_sec = 0 )
explicit authority( permission_level p, uint32_t delay_sec = 0 )
:threshold(1),accounts({{p,1}})
{
if( delay_sec > 0 ) {
Expand All @@ -200,9 +210,7 @@ struct authority {
return tie( lhs.threshold, lhs.keys, lhs.accounts, lhs.waits ) == tie( rhs.threshold, rhs.keys, rhs.accounts, rhs.waits );
}

friend bool operator != ( const authority& lhs, const authority& rhs ) {
return tie( lhs.threshold, lhs.keys, lhs.accounts, lhs.waits ) != tie( rhs.threshold, rhs.keys, rhs.accounts, rhs.waits );
}
friend bool operator == ( const authority& lhs, const shared_authority& rhs );

void sort_fields () {
std::sort(std::begin(keys), std::end(keys));
Expand All @@ -213,7 +221,7 @@ struct authority {


struct shared_authority {
shared_authority( chainbase::allocator<char> alloc )
explicit shared_authority( chainbase::allocator<char> alloc )
:keys(alloc),accounts(alloc),waits(alloc){}

shared_authority& operator=(const authority& a) {
Expand All @@ -233,14 +241,13 @@ struct shared_authority {
shared_vector<permission_level_weight> accounts;
shared_vector<wait_weight> waits;

operator authority()const { return to_authority(); }
authority to_authority()const {
authority auth;
auth.threshold = threshold;
auth.keys.reserve(keys.size());
auth.accounts.reserve(accounts.size());
auth.waits.reserve(waits.size());
for( const auto& k : keys ) { auth.keys.emplace_back( k ); }
for( const auto& k : keys ) { auth.keys.emplace_back( k.to_key_weight() ); }
for( const auto& a : accounts ) { auth.accounts.emplace_back( a ); }
for( const auto& w : waits ) { auth.waits.emplace_back( w ); }
return auth;
Expand All @@ -259,6 +266,16 @@ struct shared_authority {
}
};

inline bool operator==( const authority& lhs, const shared_authority& rhs ) {
return lhs.threshold == rhs.threshold &&
lhs.keys.size() == rhs.keys.size() &&
lhs.accounts.size() == rhs.accounts.size() &&
lhs.waits.size() == rhs.waits.size() &&
std::equal(lhs.keys.cbegin(), lhs.keys.cend(), rhs.keys.cbegin(), rhs.keys.cend()) &&
std::equal(lhs.accounts.cbegin(), lhs.accounts.cend(), rhs.accounts.cbegin(), rhs.accounts.cend()) &&
std::equal(lhs.waits.cbegin(), lhs.waits.cend(), rhs.waits.cbegin(), rhs.waits.cend());
}

namespace config {
template<>
struct billable_size<shared_authority> {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/producer_schedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace eosio { namespace chain {
result.threshold = src.threshold;
result.keys.reserve(src.keys.size());
for (const auto& k: src.keys) {
result.keys.push_back(k);
result.keys.push_back(k.to_key_weight());
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion libraries/chainbase
9 changes: 4 additions & 5 deletions libraries/libfc/include/fc/crypto/private_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace fc { namespace crypto {
private_key() = default;
private_key( private_key&& ) = default;
private_key( const private_key& ) = default;
private_key& operator= (const private_key& ) = default;
private_key& operator=(const private_key& ) = default;

public_key get_public_key() const;
signature sign( const sha256& digest, bool require_canonical = true ) const;
Expand All @@ -47,7 +47,7 @@ namespace fc { namespace crypto {

// serialize to/from string
explicit private_key(const std::string& base58str);
std::string to_string(const fc::yield_function_t& yield = fc::yield_function_t()) const;
std::string to_string(const fc::yield_function_t& yield) const;

private:
storage_type _storage;
Expand All @@ -56,9 +56,8 @@ namespace fc { namespace crypto {
:_storage(other_storage)
{}

friend bool operator == ( const private_key& p1, const private_key& p2);
friend bool operator != ( const private_key& p1, const private_key& p2);
friend bool operator < ( const private_key& p1, const private_key& p2);
friend bool operator==( const private_key& p1, const private_key& p2 );
friend bool operator<( const private_key& p1, const private_key& p2 );
friend struct reflector<private_key>;
}; // private_key

Expand Down
10 changes: 5 additions & 5 deletions libraries/libfc/include/fc/crypto/public_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ namespace fc { namespace crypto {

// serialize to/from string
explicit public_key(const std::string& base58str);
std::string to_string(const fc::yield_function_t& yield = fc::yield_function_t()) const;
std::string to_string(const fc::yield_function_t& yield) const;

storage_type _storage;

private:
friend std::ostream& operator<< (std::ostream& s, const public_key& k);
friend bool operator == ( const public_key& p1, const public_key& p2);
friend bool operator != ( const public_key& p1, const public_key& p2);
friend bool operator < ( const public_key& p1, const public_key& p2);
friend std::ostream& operator<<(std::ostream& s, const public_key& k);
friend bool operator==( const public_key& p1, const public_key& p2);
friend bool operator!=( const public_key& p1, const public_key& p2);
friend bool operator<( const public_key& p1, const public_key& p2);
friend struct reflector<public_key>;
friend class private_key;
}; // public_key
Expand Down
2 changes: 1 addition & 1 deletion libraries/libfc/libraries/bls12-381
9 changes: 2 additions & 7 deletions libraries/libfc/src/crypto/private_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,11 @@ namespace fc { namespace crypto {
return std::string(config::private_key_base_prefix) + "_" + data_str;
}

std::ostream& operator<<(std::ostream& s, const private_key& k) {
s << "private_key(" << k.to_string() << ')';
return s;
}

bool operator == ( const private_key& p1, const private_key& p2) {
bool operator==( const private_key& p1, const private_key& p2 ) {
return eq_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
}

bool operator < ( const private_key& p1, const private_key& p2)
bool operator<( const private_key& p1, const private_key& p2 )
{
return less_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/libfc/src/crypto/public_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ namespace fc { namespace crypto {
}

std::ostream& operator<<(std::ostream& s, const public_key& k) {
s << "public_key(" << k.to_string() << ')';
s << "public_key(" << k.to_string({}) << ')';
return s;
}

bool operator == ( const public_key& p1, const public_key& p2) {
bool operator==( const public_key& p1, const public_key& p2) {
return eq_comparator<public_key::storage_type>::apply(p1._storage, p2._storage);
}

bool operator != ( const public_key& p1, const public_key& p2) {
bool operator!=( const public_key& p1, const public_key& p2) {
return !(p1 == p2);
}

bool operator < ( const public_key& p1, const public_key& p2)
bool operator<( const public_key& p1, const public_key& p2)
{
return less_comparator<public_key::storage_type>::apply(p1._storage, p2._storage);
}
Expand Down
28 changes: 14 additions & 14 deletions libraries/libfc/test/crypto/test_cypher_suites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ BOOST_AUTO_TEST_CASE(test_k1) try {
auto test_private_key = private_key(private_key_string);
auto test_public_key = test_private_key.get_public_key();

BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string());
BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string());
BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string({}));
BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string({}));
} FC_LOG_AND_RETHROW();

BOOST_AUTO_TEST_CASE(test_r1) try {
Expand All @@ -25,8 +25,8 @@ BOOST_AUTO_TEST_CASE(test_r1) try {
auto test_private_key = private_key(private_key_string);
auto test_public_key = test_private_key.get_public_key();

BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string());
BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string());
BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string({}));
BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string({}));
} FC_LOG_AND_RETHROW();

BOOST_AUTO_TEST_CASE(test_k1_recovery) try {
Expand All @@ -37,9 +37,9 @@ BOOST_AUTO_TEST_CASE(test_k1_recovery) try {
auto sig = key.sign(digest);

auto recovered_pub = public_key(sig, digest);
std::cout << recovered_pub << std::endl;
std::cout << recovered_pub.to_string({}) << std::endl;

BOOST_CHECK_EQUAL(recovered_pub.to_string(), pub.to_string());
BOOST_CHECK_EQUAL(recovered_pub.to_string({}), pub.to_string({}));
} FC_LOG_AND_RETHROW();

BOOST_AUTO_TEST_CASE(test_r1_recovery) try {
Expand All @@ -50,31 +50,31 @@ BOOST_AUTO_TEST_CASE(test_r1_recovery) try {
auto sig = key.sign(digest);

auto recovered_pub = public_key(sig, digest);
std::cout << recovered_pub << std::endl;
std::cout << recovered_pub.to_string({}) << std::endl;

BOOST_CHECK_EQUAL(recovered_pub.to_string(), pub.to_string());
BOOST_CHECK_EQUAL(recovered_pub.to_string({}), pub.to_string({}));
} FC_LOG_AND_RETHROW();

BOOST_AUTO_TEST_CASE(test_k1_recyle) try {
auto key = private_key::generate<ecc::private_key_shim>();
auto pub = key.get_public_key();
auto pub_str = pub.to_string();
auto pub_str = pub.to_string({});
auto recycled_pub = public_key(pub_str);

std::cout << pub << " -> " << recycled_pub << std::endl;
std::cout << pub.to_string({}) << " -> " << recycled_pub.to_string({}) << std::endl;

BOOST_CHECK_EQUAL(pub.to_string(), recycled_pub.to_string());
BOOST_CHECK_EQUAL(pub.to_string({}), recycled_pub.to_string({}));
} FC_LOG_AND_RETHROW();

BOOST_AUTO_TEST_CASE(test_r1_recyle) try {
auto key = private_key::generate<r1::private_key_shim>();
auto pub = key.get_public_key();
auto pub_str = pub.to_string();
auto pub_str = pub.to_string({});
auto recycled_pub = public_key(pub_str);

std::cout << pub << " -> " << recycled_pub << std::endl;
std::cout << pub.to_string({}) << " -> " << recycled_pub.to_string({}) << std::endl;

BOOST_CHECK_EQUAL(pub.to_string(), recycled_pub.to_string());
BOOST_CHECK_EQUAL(pub.to_string({}), recycled_pub.to_string({}));
} FC_LOG_AND_RETHROW();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosi

template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper_stateless<eosio::chain::shared_key_weight>& obj) {
fc::raw::pack(ds, as_type<eosio::chain::public_key_type>(obj.obj.key));
fc::raw::pack(ds, as_type<eosio::chain::public_key_type>(obj.obj.key.to_public_key()));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
return ds;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/chain_plugin/account_query_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ namespace eosio::chain_apis {

// for each key, add this permission info's non-owning reference to the bimap for keys
for (const auto& k: po.auth.keys) {
chain::public_key_type key = k.key;
key_bimap.insert(key_bimap_t::value_type {{std::move(key), k.weight}, pi});
key_bimap.insert(key_bimap_t::value_type {{k.key.to_public_key(), k.weight}, pi});
}
}

Expand Down
5 changes: 4 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,11 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) {
resmon_plugin->monitor_directory(chain_config->state_dir);
}

if( options.count( "chain-state-db-size-mb" ))
if( options.count( "chain-state-db-size-mb" )) {
chain_config->state_size = options.at( "chain-state-db-size-mb" ).as<uint64_t>() * 1024 * 1024;
EOS_ASSERT( chain_config->state_size <= 8ull * 1024 * 1024 * 1024 * 1024, plugin_config_exception,
"The maximum supported size for the chain state db (chain-state-db-size-mb) is 8TiB" );
}

if( options.count( "chain-state-db-guard-size-mb" ))
chain_config->state_guard_size = options.at( "chain-state-db-guard-size-mb" ).as<uint64_t>() * 1024 * 1024;
Expand Down
Loading

0 comments on commit 1eb1e44

Please sign in to comment.