Bitcoin ABC  0.29.1
P2P Digital Currency
Classes | Typedefs | Enumerations | Functions | Variables
avalanche Namespace Reference

Classes

struct  PrefilledProof
 
struct  ShortIdProcessorPrefilledProofAdapter
 
struct  ProofRefCompare
 
class  CompactProofs
 
class  ProofsRequest
 
struct  Config
 
class  Delegation
 
class  DelegationBuilder
 
struct  DelegationId
 
struct  Node
 
struct  Slot
 
struct  Peer
 
struct  proof_index
 
struct  score_index
 
struct  next_request_time
 
struct  PendingNode
 
struct  RemoteProof
 
class  ProofRegistrationState
 
class  PeerManager
 
class  VoteItemUpdate
 
class  VoteMapComparator
 
struct  query_timeout
 
class  Processor
 
struct  StakeCommitment
 
class  Stake
 
class  SignedStake
 
class  Proof
 
class  SaltedProofHasher
 
class  ProofBuilder
 
struct  ProofRefComparatorByAddress
 Compare proof references by pointer address. More...
 
struct  ProofComparatorByScore
 Compare proofs by score, then by id in case of equality. More...
 
struct  ConflictingProofComparator
 Compare conflicting proofs. More...
 
struct  ProofId
 
struct  LimitedProofId
 
class  SaltedProofIdHasher
 
struct  ProofPoolEntry
 
struct  ProofPoolEntryProofIdKeyExtractor
 
class  ProofPool
 Map a proof to each utxo. More...
 
struct  ProofRadixTreeAdapter
 Radix tree adapter for storing a proof as a tree element. More...
 
class  Vote
 
class  Response
 
class  Poll
 
class  Hello
 
struct  TestVoteRecord
 
struct  TestProofBuilder
 
class  ProofValidationState
 
class  DelegationState
 
struct  VoteRecord
 Vote history. More...
 

Typedefs

using ProofShortIdProcessor = ShortIdProcessor< PrefilledProof, ShortIdProcessorPrefilledProofAdapter, ProofRefCompare >
 
using AnyVoteItem = std::variant< const ProofRef, const CBlockIndex *, const CTransactionRef >
 
using VoteMap = std::map< AnyVoteItem, VoteRecord, VoteMapComparator >
 
using StakeId = uint256
 
using ProofRef = RCUPtr< const Proof >
 
using ProofIdSet = std::unordered_set< ProofId, SaltedProofIdHasher >
 

Enumerations

enum class  ProofRegistrationResult {
  NONE = 0 , ALREADY_REGISTERED , IMMATURE , INVALID ,
  CONFLICTING , REJECTED , COOLDOWN_NOT_ELAPSED , DANGLING ,
  MISSING_UTXO
}
 
enum class  VoteStatus : uint8_t {
  Invalid , Rejected , Accepted , Finalized ,
  Stale
}
 
enum class  ProofValidationResult {
  NONE = 0 , NO_STAKE , DUST_THRESHOLD , DUPLICATE_STAKE ,
  WRONG_STAKE_ORDERING , INVALID_STAKE_SIGNATURE , TOO_MANY_UTXOS , INVALID_PAYOUT_SCRIPT ,
  INVALID_PROOF_SIGNATURE , EXPIRED , MISSING_UTXO , COINBASE_MISMATCH ,
  HEIGHT_MISMATCH , AMOUNT_MISMATCH , NON_STANDARD_DESTINATION , DESTINATION_NOT_SUPPORTED ,
  DESTINATION_MISMATCH , IMMATURE_UTXO
}
 
enum class  DelegationResult { NONE = 0 , INVALID_SIGNATURE , TOO_MANY_LEVELS }
 

Functions

template<typename L , typename F >
static bool reduceLevels (uint256 &hash, const std::vector< L > &levels, F f)
 
template<typename L >
static bool reduceLevels (uint256 &hash, const std::vector< L > &levels)
 
static bool isImmatureState (const ProofValidationState &state)
 
PeerId selectPeerImpl (const std::vector< Slot > &slots, const uint64_t slot, const uint64_t max)
 Internal methods that are exposed for testing purposes. More...
 
static const uint256 GetVoteItemId (const AnyVoteItem &item)
 
static bool VerifyProof (const Amount &stakeUtxoDustThreshold, const Proof &proof, bilingual_str &error)
 
static bool VerifyDelegation (const Delegation &dg, const CPubKey &expectedPubKey, bilingual_str &error)
 
static bool isNull (const AnyVoteItem &item)
 
static bool IsStandardPayoutScript (const CScript &scriptPubKey)
 
ProofRef buildRandomProof (Chainstate &active_chainstate, uint32_t score, int height, const CKey &masterKey)
 
bool hasDustStake (const ProofRef &proof)
 

Variables

constexpr size_t MAX_DELEGATION_LEVELS {20}
 The maximum number of delegation levels we are willing to verify. More...
 
static constexpr uint64_t PEERS_DUMP_VERSION {1}
 
static constexpr uint32_t AVALANCHE_MAX_IMMATURE_PROOFS = 4000
 Maximum number of immature proofs the peer manager will accept from the network. More...
 
static constexpr Amount PROOF_DUST_THRESHOLD = 100 * COIN
 Minimum amount per utxo. More...
 
constexpr uint32_t MIN_VALID_PROOF_SCORE = 100 * PROOF_DUST_THRESHOLD / COIN
 
const CScript UNSPENDABLE_ECREG_PAYOUT_SCRIPT
 

Typedef Documentation

◆ AnyVoteItem

using avalanche::AnyVoteItem = typedef std::variant<const ProofRef, const CBlockIndex *, const CTransactionRef>

Definition at line 86 of file processor.h.

◆ ProofIdSet

using avalanche::ProofIdSet = typedef std::unordered_set<ProofId, SaltedProofIdHasher>

Definition at line 52 of file proofpool.h.

◆ ProofRef

using avalanche::ProofRef = typedef RCUPtr<const Proof>

Definition at line 185 of file proof.h.

◆ ProofShortIdProcessor

Definition at line 50 of file compactproofs.h.

◆ StakeId

using avalanche::StakeId = typedef uint256

Definition at line 44 of file proof.h.

◆ VoteMap

Definition at line 172 of file processor.h.

Enumeration Type Documentation

◆ DelegationResult

Enumerator
NONE 
INVALID_SIGNATURE 
TOO_MANY_LEVELS 

Definition at line 37 of file validation.h.

◆ ProofRegistrationResult

Enumerator
NONE 
ALREADY_REGISTERED 
IMMATURE 
INVALID 
CONFLICTING 
REJECTED 
COOLDOWN_NOT_ELAPSED 
DANGLING 
MISSING_UTXO 

Definition at line 145 of file peermanager.h.

◆ ProofValidationResult

Enumerator
NONE 
NO_STAKE 
DUST_THRESHOLD 
DUPLICATE_STAKE 
WRONG_STAKE_ORDERING 
INVALID_STAKE_SIGNATURE 
TOO_MANY_UTXOS 
INVALID_PAYOUT_SCRIPT 
INVALID_PROOF_SIGNATURE 
EXPIRED 
MISSING_UTXO 
COINBASE_MISMATCH 
HEIGHT_MISMATCH 
AMOUNT_MISMATCH 
NON_STANDARD_DESTINATION 
DESTINATION_NOT_SUPPORTED 
DESTINATION_MISMATCH 
IMMATURE_UTXO 

Definition at line 12 of file validation.h.

◆ VoteStatus

enum avalanche::VoteStatus : uint8_t
strong
Enumerator
Invalid 
Rejected 
Accepted 
Finalized 
Stale 

Definition at line 78 of file processor.h.

Function Documentation

◆ buildRandomProof()

ProofRef avalanche::buildRandomProof ( Chainstate active_chainstate,
uint32_t  score,
int  height,
const CKey masterKey 
)

Definition at line 20 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVoteItemId()

static const uint256 avalanche::GetVoteItemId ( const AnyVoteItem item)
static

Definition at line 41 of file processor.cpp.

Here is the caller graph for this function:

◆ hasDustStake()

bool avalanche::hasDustStake ( const ProofRef proof)

Definition at line 42 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isImmatureState()

static bool avalanche::isImmatureState ( const ProofValidationState state)
static

Definition at line 201 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNull()

static bool avalanche::isNull ( const AnyVoteItem item)
static

Definition at line 405 of file processor.cpp.

Here is the caller graph for this function:

◆ IsStandardPayoutScript()

static bool avalanche::IsStandardPayoutScript ( const CScript scriptPubKey)
static

Definition at line 111 of file proof.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduceLevels() [1/2]

template<typename L >
static bool avalanche::reduceLevels ( uint256 hash,
const std::vector< L > &  levels 
)
static

Definition at line 52 of file delegation.cpp.

Here is the call graph for this function:

◆ reduceLevels() [2/2]

template<typename L , typename F >
static bool avalanche::reduceLevels ( uint256 hash,
const std::vector< L > &  levels,
f 
)
static

Definition at line 36 of file delegation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectPeerImpl()

PeerId avalanche::selectPeerImpl ( const std::vector< Slot > &  slots,
const uint64_t  slot,
const uint64_t  max 
)

Internal methods that are exposed for testing purposes.

Definition at line 904 of file peermanager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyDelegation()

static bool avalanche::VerifyDelegation ( const Delegation dg,
const CPubKey expectedPubKey,
bilingual_str error 
)
static

Definition at line 91 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyProof()

static bool avalanche::VerifyProof ( const Amount stakeUtxoDustThreshold,
const Proof proof,
bilingual_str error 
)
static

Definition at line 59 of file processor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ AVALANCHE_MAX_IMMATURE_PROOFS

constexpr uint32_t avalanche::AVALANCHE_MAX_IMMATURE_PROOFS = 4000
staticconstexpr

Maximum number of immature proofs the peer manager will accept from the network.

Note that reorgs can cause the immature pool to temporarily exceed this limit, but a change in chaintip cause previously reorged proofs to be trimmed.

Definition at line 44 of file peermanager.h.

◆ MAX_DELEGATION_LEVELS

constexpr size_t avalanche::MAX_DELEGATION_LEVELS {20}
constexpr

The maximum number of delegation levels we are willing to verify.

A Schnorr signature verification takes about 35us on a 2022 average machine, so 20 levels will roughly take under 1ms (accounting some overhead) while being more than enough to cover all the real world usage.

Definition at line 26 of file delegation.h.

◆ MIN_VALID_PROOF_SCORE

constexpr uint32_t avalanche::MIN_VALID_PROOF_SCORE = 100 * PROOF_DUST_THRESHOLD / COIN
constexpr

Definition at line 17 of file util.h.

◆ PEERS_DUMP_VERSION

constexpr uint64_t avalanche::PEERS_DUMP_VERSION {1}
staticconstexpr

Definition at line 28 of file peermanager.cpp.

◆ PROOF_DUST_THRESHOLD

constexpr Amount avalanche::PROOF_DUST_THRESHOLD = 100 * COIN
staticconstexpr

Minimum amount per utxo.

Definition at line 40 of file proof.h.

◆ UNSPENDABLE_ECREG_PAYOUT_SCRIPT

const CScript avalanche::UNSPENDABLE_ECREG_PAYOUT_SCRIPT
Initial value:
=
CScript() << OP_DUP << OP_HASH160 << std::vector<uint8_t>(20, 0)
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:431
@ OP_CHECKSIG
Definition: script.h:163
@ OP_EQUALVERIFY
Definition: script.h:120

Definition at line 19 of file util.h.