Skip to content

Commit 410a068

Browse files
Mani BrarMani Brar
authored andcommitted
fix(validator): claimable epoch calculation fix
1 parent 66c1fc6 commit 410a068

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

validator-cli/src/utils/epochHandler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("epochHandler", () => {
1111
const now = (currentTimestamp + mockedEpochPeriod + 1) * 1000; // In ms
1212
const startEpoch =
1313
Math.floor((currentTimestamp - (mockedSeqDelayLimit + mockedEpochPeriod + startCoolDown)) / mockedEpochPeriod) -
14-
2;
14+
1;
1515
it("should return the correct epoch range", () => {
1616
const mockedFetchBridgeConfig = jest.fn(() => ({
1717
epochPeriod: mockedEpochPeriod,
@@ -31,7 +31,7 @@ describe("epochHandler", () => {
3131
now,
3232
fetchBridgeConfig: mockedFetchBridgeConfig as any,
3333
});
34-
expect(result[result.length - 1]).toEqual(currentEpoch - 1);
34+
expect(result[result.length - 1]).toEqual(currentEpoch);
3535
expect(result[0]).toEqual(startEpoch);
3636
});
3737
});

validator-cli/src/utils/epochHandler.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ const setEpochRange = ({
4141

4242
let veaEpochOutboxClaimableNow = Math.floor(timeLocal / epochPeriod) - 1;
4343
// only past epochs are claimable, hence shift by one here
44-
const veaEpochOutboxRange = veaEpochOutboxClaimableNow - veaEpochOutboxWatchLowerBound;
45-
const veaEpochOutboxCheckClaimsRangeArray: number[] = new Array(veaEpochOutboxRange)
46-
.fill(veaEpochOutboxWatchLowerBound)
47-
.map((el, i) => el + i);
44+
const length = veaEpochOutboxClaimableNow - veaEpochOutboxWatchLowerBound;
45+
const veaEpochOutboxCheckClaimsRangeArray: number[] = Array.from(
46+
{ length },
47+
(_, i) => veaEpochOutboxWatchLowerBound + i + 1
48+
);
4849
return veaEpochOutboxCheckClaimsRangeArray;
4950
};
5051

0 commit comments

Comments
 (0)