From b79e9bbfeca4b4541fc8ab033788cca12282b0ad Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Thu, 27 Mar 2025 09:40:36 -0300 Subject: [PATCH] chore: Speed up and deflake sentinel test The sentinel e2e test was sometimes failing since not enough blocks were mined in time. We believe this was because the offline validator was being picked up as proposer, so multiple slots end up being missed. This PR fixes it by bumping timeout and reducing the number of blocks we mine. We used to mine so many to make sure that each validator was picked at least one as proposer, so no matter which one we inspected, we could assert there was at least one block proposed in its stats. We now just look for one with proposals and assert on it. --- .../src/e2e_p2p/validators_sentinel.test.ts | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_p2p/validators_sentinel.test.ts b/yarn-project/end-to-end/src/e2e_p2p/validators_sentinel.test.ts index 0822b14f5fb9..bc766de90ad9 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/validators_sentinel.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/validators_sentinel.test.ts @@ -67,8 +67,8 @@ describe('e2e_p2p_validators_sentinel', () => { // Wait for a few blocks to be mined const currentBlock = t.monitor.l2BlockNumber; - const blockCount = NUM_VALIDATORS * 2; - const timeout = SHORTENED_BLOCK_TIME_CONFIG.aztecSlotDuration * blockCount * 2 + 20; + const blockCount = 3; + const timeout = SHORTENED_BLOCK_TIME_CONFIG.aztecSlotDuration * blockCount * 8; t.logger.info(`Waiting until L2 block ${currentBlock + blockCount}`, { currentBlock, blockCount, timeout }); await retryUntil(() => t.monitor.l2BlockNumber >= currentBlock + blockCount, 'blocks mined', timeout); @@ -86,13 +86,22 @@ describe('e2e_p2p_validators_sentinel', () => { expect(offlineStats.missedAttestations.rate).toEqual(1); expect(offlineStats.missedProposals.rate).toBeOneOf([1, NaN]); - // Check stats for a working validator - const okValidator = t.validators[0].attester.toLowerCase(); - const okStats = stats.stats[okValidator]; - t.logger.info(`Asserting stats for ok validator ${okValidator}`); - expect(okStats.history.length).toBeGreaterThanOrEqual(blockCount - 1); - expect(okStats.history.some(h => h.status === 'attestation-sent')).toBeTrue(); - expect(okStats.history.some(h => h.status === 'block-mined' || 'block-proposed')).toBeTrue(); - expect(okStats.missedAttestations.rate).toBeLessThan(1); + // Check stats for a validator that mined a block + const [proposerValidator, proposerStats] = Object.entries(stats.stats).find(([_, v]) => + v?.history?.some(h => h.status === 'block-mined'), + )!; + t.logger.info(`Asserting stats for proposer validator ${proposerValidator}`); + expect(t.validators.map(v => v.attester.toLowerCase())).toContain(proposerValidator); + expect(proposerStats.history.length).toBeGreaterThanOrEqual(blockCount - 1); + expect(proposerStats.missedProposals.rate).toBeLessThan(1); + + // Check stats for a validator that attested to a block + const [attestorValidator, attestorStats] = Object.entries(stats.stats).find(([_, v]) => + v?.history?.some(h => h.status === 'attestation-sent'), + )!; + t.logger.info(`Asserting stats for attestor validator ${attestorValidator}`); + expect(t.validators.map(v => v.attester.toLowerCase())).toContain(attestorValidator); + expect(attestorStats.history.length).toBeGreaterThanOrEqual(blockCount - 1); + expect(attestorStats.missedAttestations.rate).toBeLessThan(1); }); });