perf(types): network fee and solvency voters count active signers through the node index
🔎 Visual review of5f5da162: explainer, review flags and prompts to ask an AI about the change
What
ObservedNetworkFeeVoter and SolvencyVoter decoded every signer's bech32 address on each HasSigned and HasConsensus call, and HasConsensus then scanned the node accounts linearly per signer (IsNodeKeys, ~100 × ~100 compares plus an interface conversion each). Both run for every attestation in the network-fee and solvency quorum handlers.
They now use the memoized signer decoding (common.SignerAddressString) and the activeNodeIndex that ObservedTxVoter.getConsensusTx already uses, via two small helpers in x/thorchain/types/type_observed_tx.go:
countActiveSigners— same count asGetSigners()+IsNodeKeysper entry (repeated signers count each time, undecodable ones are skipped)signersInclude— same result asGetSigners()+AccAddress.Equals(decoded signers are never empty, soEqualsis byte equality)
GetSigners is unchanged.
Behaviour
No state, event or gas change: the old and new paths are pure in-memory work with no store access.
- Randomized test (
type_voter_signers_test.go) checks both helpers and both voters against the old decode-and-scan loops: repeated, upper-case, bad-checksum and empty signers; inactive, empty and duplicate node addresses; nil/empty signer argument. Mutation-checked (fails if the count is off). - Unit tests
-tags=mocknetpass for the touched packages,./x/thorchainand./common/.... - Unfiltered regtest, develop
eb4cd97541vs this branch: 2481 files compared, state, events andgas_usedidentical. - An independent adversarial review found no difference. The only divergence it could build needs the SDK address verifier to change after the memo is filled, which cannot happen in thornode (prefix + verifier are set and sealed at startup in
cmd/thornode/root.go); the memo already serves theObservedTxVoterconsensus path.
Speed
Mainnet replay of blocks 28124001..28125999 (2000 blocks, 3 rounds each side, app hashes match mainnet), round-8 perf stack vs. the same plus this change:
| before | after | |
|---|---|---|
| median replay | 234.2 s (117.1 ms/block) | 224.0 s (112.0 ms/block) −4.3% |
| p90 / p99 block | 171 / 247 ms | 158 / 223 ms |
| FinalizeBlock CPU | 506.9 s | 481.5 s (−5.0%) |
| network-fee + solvency voter CPU | ~24 s | ~1.5 s |