-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tion IF: Modify set_finalizer host function struct type
- Loading branch information
Showing
7 changed files
with
102 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <eosio/chain/finalizer_set.hpp> | ||
#include <eosio/chain/finalizer_authority.hpp> | ||
#include <fc/crypto/bls_public_key.hpp> | ||
|
||
namespace eosio::chain { | ||
|
||
/** | ||
* These definitions are all here to avoid including bls_public_key.hpp which includes <bls12-381/bls12-381.hpp> | ||
* and pulls in bls12-381 types. This keeps bls12-381 out of libtester. | ||
*/ | ||
|
||
finalizer_set::finalizer_set() = default; | ||
finalizer_set::~finalizer_set() = default; | ||
|
||
finalizer_set::finalizer_set(const finalizer_set&) = default; | ||
finalizer_set::finalizer_set(finalizer_set&&) noexcept = default; | ||
|
||
finalizer_set& finalizer_set::operator=(const finalizer_set&) = default; | ||
finalizer_set& finalizer_set::operator=(finalizer_set&&) noexcept = default; | ||
|
||
auto finalizer_set::operator<=>(const finalizer_set&) const = default; | ||
|
||
} /// eosio::chain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
libraries/chain/include/eosio/chain/finalizer_authority.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <fc/crypto/bls_public_key.hpp> | ||
#include <string> | ||
|
||
namespace eosio::chain { | ||
|
||
struct finalizer_authority { | ||
|
||
std::string description; | ||
uint64_t fweight = 0; // weight that this finalizer's vote has for meeting fthreshold | ||
fc::crypto::blslib::bls_public_key public_key; | ||
|
||
auto operator<=>(const finalizer_authority&) const = default; | ||
}; | ||
|
||
} /// eosio::chain | ||
|
||
FC_REFLECT( eosio::chain::finalizer_authority, (description)(fweight)(public_key) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,39 @@ | ||
#pragma once | ||
|
||
#include <eosio/chain/config.hpp> | ||
#include <eosio/chain/types.hpp> | ||
#include <chainbase/chainbase.hpp> | ||
#include <eosio/chain/authority.hpp> | ||
#include <eosio/chain/snapshot.hpp> | ||
|
||
#include <fc/crypto/bls_public_key.hpp> | ||
|
||
namespace eosio::chain { | ||
|
||
struct finalizer_authority { | ||
struct finalizer_authority; | ||
|
||
struct finalizer_set { | ||
finalizer_set(); | ||
~finalizer_set(); | ||
|
||
finalizer_set(const finalizer_set&); | ||
finalizer_set(finalizer_set&&) noexcept; | ||
|
||
std::string description; | ||
uint64_t fweight = 0; // weight that this finalizer's vote has for meeting fthreshold | ||
fc::crypto::blslib::bls_public_key public_key; | ||
finalizer_set& operator=(const finalizer_set&); | ||
finalizer_set& operator=(finalizer_set&&) noexcept; | ||
|
||
friend bool operator == ( const finalizer_authority& lhs, const finalizer_authority& rhs ) { | ||
return tie( lhs.description, lhs.fweight, lhs.public_key ) == tie( rhs.description, rhs.fweight, rhs.public_key ); | ||
} | ||
friend bool operator != ( const finalizer_authority& lhs, const finalizer_authority& rhs ) { | ||
return !(lhs == rhs); | ||
} | ||
auto operator<=>(const finalizer_set&) const; | ||
|
||
uint32_t generation = 0; ///< sequentially incrementing version number | ||
uint64_t fthreshold = 0; ///< vote fweight threshold to finalize blocks | ||
std::vector<finalizer_authority> finalizers; ///< Instant Finality voter set | ||
}; | ||
|
||
struct finalizer_set { | ||
finalizer_set() = default; | ||
|
||
finalizer_set( uint32_t version, uint64_t fthreshold, std::initializer_list<finalizer_authority> finalizers ) | ||
:version(version) | ||
,fthreshold(fthreshold) | ||
,finalizers(finalizers) | ||
{} | ||
|
||
uint32_t version = 0; ///< sequentially incrementing version number | ||
uint64_t fthreshold = 0; // vote fweight threshold to finalize blocks | ||
vector<finalizer_authority> finalizers; // Instant Finality voter set | ||
|
||
friend bool operator == ( const finalizer_set& a, const finalizer_set& b ) | ||
{ | ||
if( a.version != b.version ) return false; | ||
if( a.fthreshold != b.fthreshold ) return false; | ||
if ( a.finalizers.size() != b.finalizers.size() ) return false; | ||
for( uint32_t i = 0; i < a.finalizers.size(); ++i ) | ||
if( ! (a.finalizers[i] == b.finalizers[i]) ) return false; | ||
return true; | ||
} | ||
|
||
friend bool operator != ( const finalizer_set& a, const finalizer_set& b ) | ||
{ | ||
return !(a==b); | ||
} | ||
using finalizer_set_ptr = std::shared_ptr<finalizer_set>; | ||
|
||
/** | ||
* Block Header Extension Compatibility | ||
*/ | ||
struct hs_finalizer_set_extension : finalizer_set { | ||
static constexpr uint16_t extension_id() { return 2; } // TODO 3 instead? | ||
static constexpr bool enforce_unique() { return true; } | ||
}; | ||
|
||
} /// eosio::chain | ||
|
||
FC_REFLECT( eosio::chain::finalizer_authority, (description)(fweight)(public_key) ) | ||
FC_REFLECT( eosio::chain::finalizer_set, (version)(fthreshold)(finalizers) ) | ||
FC_REFLECT( eosio::chain::finalizer_set, (generation)(fthreshold)(finalizers) ) | ||
FC_REFLECT_DERIVED( eosio::chain::hs_finalizer_set_extension, (eosio::chain::finalizer_set), ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters