Skip to content
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

node: add missing_iterations logs #1154

Merged
merged 2 commits into from
Nov 24, 2023
Merged

node: add missing_iterations logs #1154

merged 2 commits into from
Nov 24, 2023

Conversation

herr-seppia
Copy link
Member

Resolves #1150

prov.create_committee(&sortition::Config {
committee_size: SELECTION_COMMITTEE_SIZE,
round: blk.header().height,
seed: blk.header().seed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. You need mrb.header().seed here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also returns:

{"level":"ERROR","message":"Unable to generate voting committee for missed block","target":"node::chain::acceptor"}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve this error you need to update eligiblity_flag:

 
             for iter in 0..blk.header().iteration {
                 let mut prov = provisioners_list.clone();
+                prov.update_eligibility_flag(blk.header().height);
                 let committee_keys =
                     prov.create_committee(&sortition::Config {
                         committee_size: SELECTION_COMMITTEE_SIZE,
                         round: blk.header().height,
-                        seed: blk.header().seed,
+                        seed: mrb.header().seed,
                         step: iter * 3,
                     });

This should fix all issues and generate correct result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is the need of update eligibility flag if the block height is already specified in the sortition config?
Maybe we should change that API (unless there is a use case for calling one of those two methods without the other one)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are distinct scenarios. In essence, for each step within a single round, it is necessary to invoke the create_committee, whereas the update_eligibility_flag is called only once per round execution.

@@ -270,6 +298,7 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
fsv_bitset,
ssv_bitset,
block_time,
generator = blk.header().generator_bls_pubkey.to_base58(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is printed in Info level, why don't we use the truncated bs58 version?

{"level":"INFO","event":"block accepted","height":6,"iter":2,"hash":"ab91718e2b839959...f9e24b5b90e49eac","txs":0,"state_hash":"e72889f7b945edbf...3185aaf382334050","fsv_bitset":15,"ssv_bitset":14,"block_time":13,"generator":"rm6jwcM9xQChnVeHYw6W8HP7kW3E8nejgs4XhmKoYspQnrZL5dDcQjVR5e2UmbyNNF4DJDRdZGdYLgJfZ3qQXuhSCL6UTDkcQ2QEf6RW3aCtfqQMKCFMNaBsfNrZuzrP23Z","dur_ms":"5","target":"node::chain::acceptor"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For different reason:

  • Previous node was logging it as full bs58 to properly match the staking address
  • There is no truncated bs58 for the PublicKeyBytes

Anyway, we can get rid of previous impl, moving it to shortened bs58

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no value of having a full bs58 here. We may introduce (if not available already) an grpc/graphql API that prints full bs58 of the generator only on demand instead of polluting INFO level logs with extra data.

Comment on lines 232 to 277
for iter in 0..blk.header().iteration {
let mut prov = provisioners_list.clone();
let committee_keys =
prov.create_committee(&sortition::Config {
committee_size: SELECTION_COMMITTEE_SIZE,
round: blk.header().height,
seed: blk.header().seed,
step: iter * 3,
});
if committee_keys.len() != 1 {
error!(
"Unable to generate voting committee for missed block"
)
} else {
let generator = committee_keys
.first()
.expect("committee to have 1 entry")
.to_full_bs58();
warn!(
event = "missed iteration",
height = blk.header().height,
iter,
generator,
);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Could you move this block in a separate function for better readability? I try to keep try_accept_block lean.

});
if committee_keys.len() != 1 {
error!(
"Unable to generate voting committee for missed block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print here the committee_keys.len().

@@ -228,6 +229,33 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> Acceptor<N, DB, VM> {
Ok(txs)
})?;

for iter in 0..blk.header().iteration {
let mut prov = provisioners_list.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicating the provisioners_list for every iteration could be inefficient, especially if a block originates from a higher iteration

@herr-seppia herr-seppia merged commit c5c8718 into master Nov 24, 2023
3 checks passed
@herr-seppia herr-seppia deleted the missing_iterations branch November 24, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing block detection
2 participants