-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement shell quorum balancing #845
Conversation
d58bfe0
to
93e707b
Compare
This comment has been minimized.
This comment has been minimized.
source/agora/node/Validator.d
Outdated
@@ -112,7 +174,8 @@ public class Validator : FullNode, API | |||
|
|||
log.info("Doing network discovery.."); | |||
this.network.discover(required_peer_keys); | |||
this.network.startPeriodicCatchup(this.ledger, &this.nominator.isNominating); | |||
this.network.startPeriodicCatchup(this.ledger, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
93e707b
to
b1efd87
Compare
This comment has been minimized.
This comment has been minimized.
b1efd87
to
fe95bcd
Compare
Codecov Report
@@ Coverage Diff @@
## v0.x.x #845 +/- ##
==========================================
+ Coverage 90.40% 90.43% +0.03%
==========================================
Files 71 73 +2
Lines 5795 5868 +73
==========================================
+ Hits 5239 5307 +68
- Misses 556 561 +5
Continue to review full report at Codecov.
|
caefd1e
to
052786b
Compare
73b7bb7
to
f36abe2
Compare
It seems the test-suite times out (30 minutes). I'm trying to bisect it. |
d51c4e8
to
fa23de1
Compare
source/agora/test/Base.d
Outdated
|
||
Returns: | ||
The genesis block | ||
|
||
*******************************************************************************/ | ||
|
||
private immutable(Block) makeGenesisBlock (in NodeConfig[] node_configs) | ||
private immutable(Block) makeGenesisBlock (in KeyPair[] key_pairs) |
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.
This change should be moved to the previous commit where the function was introduced.
6f65b13
to
523d12a
Compare
I've discovered that what is causing these failures is actually the code coverage mode. The test-suite works fine without it. But with it there are timeouts. Either the code coverage is significantly slowing down the tests, or there is a bug in the coverage generator code in DMD front-end. |
5e3c654
to
3938b9e
Compare
3938b9e
to
b01471c
Compare
b9fb70e
to
393f26f
Compare
The feature I discovered in Geod24/localrest#81 came in useful. I rewrote one test. |
ecc45cc
to
1ab1b1e
Compare
I further simplified the changeset. The diff is much smaller now. |
1c66d18
to
00996a3
Compare
The generator currently takes the set of enrollments and generates the same quorum set for all nodes.
In the same way that we remove transactions from the pool only after they're externalized into a block, we should also remove enrollments at this stage.
The quorum set is now derived from the active set of enrollments in the blockchain. After each block has been externalized, the active validator set is checked. If the set of validators has changed, then the quorum set for any Validators is reconfigured according to the quorum generator algorithm. Fixes bosagora#785
00996a3
to
023698e
Compare
@bpfkorea/core please review when you have the time. |
@@ -228,6 +228,9 @@ public class Ledger | |||
this.enroll_man.clearExpiredValidators(block.header.height); | |||
|
|||
foreach (idx, ref enrollment; block.header.enrollments) | |||
{ | |||
this.enroll_man.pool.remove(enrollment.utxo_key); |
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.
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.
Ah, right. I think in my fixes for #836 I will remove the call within addValidator
because that function can fail.
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.
Overall, it looks Great.
return .buildQuorumConfig(this.config.node.key_pair.address, | ||
enrollments, this.utxo_set.getUTXOFinder()); |
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.
agora.consensus.Quorum.buildQuorumConfig ( const ref PublicKey node_key,
in Enrollment[] enrolls, in UTXOFinder finder )
I think it's pointing here.
There's no problem. But The code is difficult to read.
this.enroll_man.pool.remove(enrollment.utxo_key); | ||
|
||
if (auto r = this.enroll_man.addValidator(enrollment, | ||
block.header.height, this.utxo_set.getUTXOFinder())) |
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.
this.enroll_man.pool.remove
The remove
is run twice here.
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.
Where do you see it?
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.
// at block height 1007 the freeze tx's are available | ||
nodes.enumerate.each!((idx, node) => | ||
retryFor(node.getBlockHeight() == 1007, 5.seconds, | ||
format("Node %s has block height %s. Expected: %s", | ||
idx, node.getBlockHeight(), 1007))); | ||
|
||
// now we can create enrollments | ||
Enrollment enroll_0 = nodes[$ - 2].createEnrollmentData(); | ||
Enrollment enroll_1 = nodes[$ - 1].createEnrollmentData(); | ||
nodes[2].enrollValidator(enroll_0); | ||
nodes[3].enrollValidator(enroll_1); |
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.
Question about this: Should we add the ability to enroll as soon as we freeze ?
Pro:
- Genesis does it;
- It allows to potentially solve the censorship issue if paired with a rule that more validators => Higher priority;
Cons: - Attack vector ?
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.
Let's file an issue for this. And yes, I wanted this feature too.
I don't think the double clear should block the merge. |
|
||
const bool ExtraChecks = true; | ||
const(char)* fail_reason; | ||
enforce(isQuorumSetSane(scp_quorum, ExtraChecks, &fail_reason), |
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.
I think it would be nice to have a test code for isQuorumSetSane
.
format("Quorum %s fails sanity check before normalization: %s", | ||
quorum, fail_reason.fromStringz)); | ||
|
||
normalizeQSet(scp_quorum); |
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.
I think it would be nice to have a test code for normalizeQSet
.
// test up to 1024 nodes | ||
foreach (num_nodes; iota(1, 10).map!(n => 2 ^^ n)) |
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.
// test up to 1022 nodes
unittest
{
import std.algorithm;
import std.stdio;
import std.range;
uint sum;
foreach (num_nodes; iota(1, 10).map!(n => 2 ^^ n))
sum+=num_nodes;
writeln(sum);
}
Result : 1022
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.
It's not testing all node count configurations. That would be too expensive (especially once the algorithm is changed).
What I am testing here is this:
num_nodes : 2
num_nodes : 4
num_nodes : 8
num_nodes : 16
num_nodes : 32
num_nodes : 64
num_nodes : 128
num_nodes : 256
num_nodes : 512
num_nodes : 1024
See?
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.
Well actually it's not inclusive as I forgot to use 11
in the iota call. +1 points to you.
Requires:
#800,#840,#810,#841,#881