Page MenuHomePhabricator

[avalanche] Make sure each proof is added to contender cache before mining the next block in contender voting test
ClosedPublic

Authored by roqqit on Thu, Dec 12, 22:08.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC0657e8a86eeb: [avalanche] Make sure each proof is added to contender cache before mining the…
Summary

As part of generating proofs, it is possible for the node to mine the next block before adding the proof to the contender cache because mining a block takes a lock on cs_main, for which addStakeContender() also requires a lock. This patch ensures the proof was added to the cache before generating the next proof and mining the block associated with that.

This should fix some flakiness with the contender voting test.

Test Plan
./test/functional/test_runner.py abc_p2p_avalanche_contender_voting

Diff Detail

Event Timeline

Owners added a reviewer: Restricted Owners Package.Thu, Dec 12, 22:08
roqqit requested review of this revision.Thu, Dec 12, 22:08
Fabien requested changes to this revision.Fri, Dec 13, 08:22
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/avalanche/processor.cpp
1001 ↗(On Diff #51564)

This will bloat the avalanche debug log with no useful info as it's sole purpose is to help you in this test.
Please find another way to achieve the same result. Maybe a debug RPC ?

This revision now requires changes to proceed.Fri, Dec 13, 08:22

waiting for len(getavalanchepeerinfo) == QUORUM_NODE_COUNT should be enough here

Use a debug RPC. Waiting for getavalanchepeerinfo is not sufficient here because its possible for this value to be updated before the contender is added to the cache.

Fabien requested changes to this revision.Tue, Dec 17, 10:14
Fabien added inline comments.
src/avalanche/processor.cpp
1003 ↗(On Diff #51637)

imo you should just return the vote status instead of a bool (that's your function signature btw). It's just more versatile. Or maybe use getStakeContenderStatus which already exists (and will tell you if computation is pending) ?

src/rpc/avalanche.cpp
1807 ↗(On Diff #51637)

same, getstakecontendervote is just more versatile. Also just take the prevblockhash and the proofid so the rpc computes the stakecontenderid locally. No need to expose the implementation details.

This revision now requires changes to proceed.Tue, Dec 17, 10:14
  • just use getStakeContenderStatus instead of a new accessor
  • hasstakecontender -> getstakecontendervote per feedback
  • pass in prevblockhash and proofid instead of stakecontenderid
Fabien added inline comments.
src/rpc/avalanche.cpp
1810–1811
This revision is now accepted and ready to land.Wed, Dec 18, 20:15