Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/voterecord.h
Show All 11 Lines | |||||
#include <cstdint> | #include <cstdint> | ||||
/** | /** | ||||
* Finalization score. | * Finalization score. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_FINALIZATION_SCORE = 128; | static constexpr int AVALANCHE_FINALIZATION_SCORE = 128; | ||||
/** | /** | ||||
* Number of votes before a record may be considered as stale. | |||||
*/ | |||||
static constexpr uint32_t AVALANCHE_VOTE_STALE_THRESHOLD = 512; | |||||
deadalnix: Reaching finalization, if everything goes perfect, is going to take at least 140 - 150 rounds. | |||||
/** | |||||
* Scaling factor applied to confidence to determine staleness threshold. | |||||
* As confidence increases, the staleness threshold should as well. This | |||||
* ensures that slowly increasing confidence is not marked stale. | |||||
*/ | |||||
static constexpr uint32_t AVALANCHE_VOTE_STALE_FACTOR = 16; | |||||
deadalnixUnsubmitted Not Done Inline ActionsSame here, you'll get a factor > 1 if everything goes perfect, maybe 2 with some inconclusive rounds. In addition you take a 2x every time you flip flop, and you'll flip flop more in cases where there are a lot of inconclusive rounds. In fact, If a block takes 2s to propagate on the network, you'll need to poll with mostly inconclusive rounds for 2s, that's 200 rounds right there. If there is a race, that's 200 to start flip flopping. deadalnix: Same here, you'll get a factor > 1 if everything goes perfect, maybe 2 with some inconclusive… | |||||
/** | |||||
* How many inflight requests can exist for one item. | * How many inflight requests can exist for one item. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_MAX_INFLIGHT_POLL = 10; | static constexpr int AVALANCHE_MAX_INFLIGHT_POLL = 10; | ||||
namespace avalanche { | namespace avalanche { | ||||
/** | /** | ||||
* Vote history. | * Vote history. | ||||
Show All 37 Lines | public: | ||||
*/ | */ | ||||
bool isAccepted() const { return confidence & 0x01; } | bool isAccepted() const { return confidence & 0x01; } | ||||
uint16_t getConfidence() const { return confidence >> 1; } | uint16_t getConfidence() const { return confidence >> 1; } | ||||
bool hasFinalized() const { | bool hasFinalized() const { | ||||
return getConfidence() >= AVALANCHE_FINALIZATION_SCORE; | return getConfidence() >= AVALANCHE_FINALIZATION_SCORE; | ||||
} | } | ||||
bool isStale() const { | |||||
return successfulVotes > AVALANCHE_VOTE_STALE_THRESHOLD && | |||||
successfulVotes > getConfidence() * AVALANCHE_VOTE_STALE_FACTOR; | |||||
} | |||||
/** | /** | ||||
* Register a new vote for an item and update confidence accordingly. | * Register a new vote for an item and update confidence accordingly. | ||||
* Returns true if the acceptance or finalization state changed. | * Returns true if the acceptance or finalization state changed. | ||||
*/ | */ | ||||
bool registerVote(NodeId nodeid, uint32_t error); | bool registerVote(NodeId nodeid, uint32_t error); | ||||
/** | /** | ||||
* Register that a request is being made regarding that item. | * Register that a request is being made regarding that item. | ||||
Show All 27 Lines |
Reaching finalization, if everything goes perfect, is going to take at least 140 - 150 rounds. Add a couple of inconclusive rounds in there and you are not far from the thresold. This still doesn't seem high to me.