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

whois: Add bitfield performance subcommand #834

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

alexggh
Copy link
Contributor

@alexggh alexggh commented Jan 6, 2025

Add BitfieldPerformace subcommand that uses the onchain data to list the validator's performance regarding the availability bitfields. The tool logic which validators don't have the right performance is really naive, but useful it was used in root causing: paritytech/polkadot-sdk#6910.

The command just crawls back from a give start block a specified number of blocks a prints the stats about validators that are bellow a user-defined performance threshold. For example you can use the tool to determine all validators that didn't populate their bitfields in 30% of the relay chain blocks.

Usage:

polkadot-whois --ws <WS> --session-index <SESSION_INDEX> bit-fields-performance \
  <START_BLOCK>   # The block to start from
  <NUM_TO_SKIP>   # Number of blocks to skip between two queries
  <NUM_BLOCKS>  # Number of blocks to query
  <NUM_SESSIONS_BELLOW_THRESHOLD>  # Print only validators that have poor performance for this number of sessions
  <POOR_PERFORMANCE_THRESHOLD> # Consider validators as having poor performance if they didn't properly populate their bitfields at least this number of times.

Output example

cargo run  --bin polkadot-whois --  --ws=wss://polkadot-rpc-tn.dwellir.com \
--bootnodes /dns/polkadot-boot.dwellir.com/tcp/30334/ws/p2p/12D3KooWKvdDyRKqUfSAaUCbYiLwKY8uK3wDWpCuy2FiDLbkPTDJ   \
--session-index 10114 bit-fields-performance 24167182 20 30 1 30.0


session: 10114 timestamp: 2025-01-06 09:36
block_start: 24167182, session: 10114: validator: 0 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 1 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 2 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 3 has 0 zero bits 0.000%
....
block_start: 24167182, session: 10114: validator: 211 has 30 zero bits 100.000%
block_start: 24167182, session: 10114: validator: 212 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 213 has 30 zero bits 100.000%
block_start: 24167182, session: 10114: validator: 495 has 19 zero bits 65.517%
block_start: 24167182, session: 10114: validator: 496 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 497 has 0 zero bits 0.000%
block_start: 24167182, session: 10114: validator: 498 has 0 zero bits 0.000%

block_start: 24167182, session: 10114: 2025-01-06 09:36 Number of validators with 10% missing 89 count_all_with_0 1

block_start: 24167182, account: 5C4mJ9LFLkUJ9ccUrsQtHtU1WpmijdwRzH3PCZXCGLEVZaL8 name: Parity Polkadot/v1.12.0-b4016902ac7 (29107)
     at 2025-01-06 09:36 session: 10114, has 28 with zero bits, 96.55% percent
block_start: 24167182, account: 5C5mTZZkUqHinG4j5N4DmpmqEZPwuLfLjpqjuEzkNRokannM name: Parity Polkadot/v1.16.2-dba2dd59101 (RfnUEAbt)
     at 2025-01-06 09:36 session: 10114, has 12 with zero bits, 40.00% percent
block_start: 24167182, account: 5CB9tg2F96XhpDwJn15ChmrKxdGoHrwGxst6DfbGChdmNboj name: Parity Polkadot/v1.16.2-dba2dd59101 (cojakr7ca2694o4mno30)
     at 2025-01-06 09:36 session: 10114, has 28 with zero bits, 93.33% percent
block_start: 24167182, account: 5CD1tq46tqb255XLZZUHsWmS7pv9NqCLTD6PXpgqGV58b5c2 name: Parity Polkadot/v1.16.1-835e0767fe8 (BitcoinSuisse val23)
     at 2025-01-06 09:36 session: 10114, has 30 with zero bits, 100.00% percent
block_start: 24167182, account: 5HphQUNBfBnaRxFjMdjp5AJJBm8bT59qGq72CxgHhQLYLyXo name: Parity Polkadot/v1.16.2-dba2dd59101 (FIGMENT-1 tor-7)
     at 2025-01-06 09:36 session: 10114, has 30 with zero bits, 100.00% percent

Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
Signed-off-by: Alexandru Gheorghe <[email protected]>
@alexggh alexggh requested review from AndreiEres and sandreim January 6, 2025 14:21
@@ -89,6 +95,35 @@ enum WhoisCommand {
ByPeerId(PeerIdOptions),
/// Display information about all validators.
DumpAll,
/// Display performance statistics for bitfields for each validator.
BitFieldsPerformance(BitFieldsPerformance),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
BitFieldsPerformance(BitFieldsPerformance),
BitfieldsPerformance(BitfieldsPerformance),

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we should use the common spelling for bitfields


for _ in 0..opts.num_blocks {
let Ok(Some(block_hash)) = executor.get_block_hash(&self.opts.ws, Some(start)).await else {
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we print some output on error?

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.

2 participants