-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make election behavior mutable to support dynamic behaviour transition #4799
Make election behavior mutable to support dynamic behaviour transition #4799
Conversation
Test Results for Commit bcf8ac0Pull Request 4799: Results Test Case Results
Last updated: 2024-12-03 16:41:13 UTC |
Can you include a test or two that ensures this works? So I imagine and election would be manually inserted via |
I added a simple testcase to validate the behavior transitioning works. Ideally I'd like to also make sure the
If that approach is right I can create another testcase that makes sure voting happens as intended. |
42c81d5
to
ac04d88
Compare
nano/node/active_elections.cpp
Outdated
{ | ||
count_by_behavior[previous_behavior]--; | ||
count_by_behavior[election_behavior_a]++; | ||
result.election->transition_priority (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guaranteed to always succeed? This probably works but is unnecessary leaving space for subtle bugs. Should be something like:
bool transitioned = result.election->transition_priority ();
if (transitioned)
{
// success, update counts, stats, log
}
else
{
// failed for some reason, inc failed stats
}
Regarding testing the voting behaviour, I don't think having two nodes is necessary. Each election should keep counters for number of vote broadcasts and confirmation requests and those can be queried directly. There is still a need to setup a rep key for node with weight higher than primary rep threshold but not enough to confirm blocks on its own, but that's rather simple. |
|
You should be able to setup a representative with eg. 111K nano weight which will be generating votes but not be able to confirm elections. Am I missing something in this setup? |
Yes exactly. My initial question was how to best do it. I didn't see see a helper method to set this up.
This requires quite a bit of code. If that's the right way, I'll go for it. Just wanted to make sure this is the right approach. |
There is |
520f369
to
ae5f991
Compare
ae5f991
to
d457891
Compare
Replace inline initializations with the new constructor syntax while maintaining the same behavior.
Problem:
network.vote_broadcast_interval
)Changes:
Benefits: