Skip to content

Commit 6e70388

Browse files
committed
fix: added hard fork date for responseConfirmedBlockHeightExists lut change
1 parent 71c0d6b commit 6e70388

4 files changed

Lines changed: 41 additions & 13 deletions

File tree

src/verification/confirmed-block-height-exists/confirmed-block-height-exists.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ export function responseConfirmedBlockHeightExists(
2626
numberOfConfirmations: number,
2727
request: ConfirmedBlockHeightExists_Request,
2828
) {
29+
// Delete me after 1777366800 Thursday, 28 April 2026 at 11:00:00 CEST
30+
let lut = lowerQueryWindowBlock.timestamp.toString();
31+
const now = Math.round(Date.now() / 1000);
32+
if (now < 1777366800) { // Thursday, 28 April 2026 at 11:00:00 CEST
33+
lut = dbBlock.timestamp.toString();
34+
}
35+
2936
const response = new ConfirmedBlockHeightExists_Response({
3037
attestationType: request.attestationType,
3138
sourceId: request.sourceId,
3239
votingRound: '0',
33-
lowestUsedTimestamp: lowerQueryWindowBlock.timestamp.toString(),
40+
lowestUsedTimestamp: lut,
3441
requestBody: serializeBigInts(request.requestBody),
3542
responseBody: new ConfirmedBlockHeightExists_ResponseBody({
3643
blockTimestamp: dbBlock.timestamp.toString(),

test/e2e_tests/btc/confirmed_block_height_exists/confirmed_block_height_exists_prepare_response.e2e-spec.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { expect } from 'chai';
22
import * as request from 'supertest';
33
import { app, baseHooks, getTestFile } from '../helper';
44

5+
// Hard fork for ConfirmedBlockHeightExists lowestUsedTimestamp.
6+
// Before: LUT = dbBlock.timestamp. After: LUT = lowerQueryWindowBlock.timestamp.
7+
// Keep in sync with src/verification/confirmed-block-height-exists/confirmed-block-height-exists.ts.
8+
const CBHE_LUT_HARDFORK_TIMESTAMP = 1777366800;
9+
const isBeforeLutHardfork = () =>
10+
Math.round(Date.now() / 1000) < CBHE_LUT_HARDFORK_TIMESTAMP;
11+
512
describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)})`, () => {
613
baseHooks();
714
it('should get status', async () => {
@@ -31,7 +38,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
3138
);
3239
expect(response.body.response.votingRound).to.be.equal('0');
3340
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
34-
'1732779896',
41+
isBeforeLutHardfork() ? '1732779898' : '1732779896',
3542
);
3643
expect(response.body.response.requestBody.blockNumber).to.be.equal(
3744
'3490156',
@@ -97,7 +104,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
97104
);
98105
expect(response.body.response.votingRound).to.be.equal('0');
99106
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
100-
'1732779897',
107+
isBeforeLutHardfork() ? '1732779898' : '1732779897',
101108
);
102109
expect(response.body.response.requestBody.blockNumber).to.be.equal(
103110
'3490156',
@@ -273,7 +280,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
273280
);
274281
expect(response.body.response.votingRound).to.be.equal('0');
275282
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
276-
'1732779896',
283+
isBeforeLutHardfork() ? '1732779898' : '1732779896',
277284
);
278285
expect(response.body.response.requestBody.blockNumber).to.be.equal(
279286
'3490156',
@@ -319,7 +326,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
319326
);
320327
expect(response.body.response.votingRound).to.be.equal('0');
321328
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
322-
'1732779896',
329+
isBeforeLutHardfork() ? '1732779898' : '1732779896',
323330
);
324331
expect(response.body.response.requestBody.blockNumber).to.be.equal(
325332
'3490156',
@@ -365,7 +372,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
365372
);
366373
expect(response.body.response.votingRound).to.be.equal('0');
367374
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
368-
'1732779896',
375+
isBeforeLutHardfork() ? '1732779898' : '1732779896',
369376
);
370377
expect(response.body.response.requestBody.blockNumber).to.be.equal(
371378
'3490156',
@@ -411,7 +418,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
411418
);
412419
expect(response.body.response.votingRound).to.be.equal('0');
413420
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
414-
'1732779896',
421+
isBeforeLutHardfork() ? '1732779898' : '1732779896',
415422
);
416423
expect(response.body.response.requestBody.blockNumber).to.be.equal(
417424
'3490156',

test/e2e_tests/doge/confirmed_block_height_exists/confirmed_block_height_exists_prepare_response.e2e-spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { expect } from 'chai';
22
import * as request from 'supertest';
33
import { app, baseHooks, getTestFile } from '../helper';
44

5+
// Hard fork for ConfirmedBlockHeightExists lowestUsedTimestamp.
6+
// Before: LUT = dbBlock.timestamp. After: LUT = lowerQueryWindowBlock.timestamp.
7+
// Keep in sync with src/verification/confirmed-block-height-exists/confirmed-block-height-exists.ts.
8+
const CBHE_LUT_HARDFORK_TIMESTAMP = 1777366800;
9+
const isBeforeLutHardfork = () =>
10+
Math.round(Date.now() / 1000) < CBHE_LUT_HARDFORK_TIMESTAMP;
11+
512
describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)})`, () => {
613
baseHooks();
714
it('should get status', async () => {
@@ -31,7 +38,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
3138
);
3239
expect(response.body.response.votingRound).to.be.equal('0');
3340
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
34-
'1732810035',
41+
isBeforeLutHardfork() ? '1732810040' : '1732810035',
3542
);
3643
expect(response.body.response.requestBody.blockNumber).to.be.equal(
3744
'6724543',
@@ -97,7 +104,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
97104
);
98105
expect(response.body.response.votingRound).to.be.equal('0');
99106
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
100-
'1732810035',
107+
isBeforeLutHardfork() ? '1732810040' : '1732810035',
101108
);
102109
expect(response.body.response.requestBody.blockNumber).to.be.equal(
103110
'6724543',
@@ -273,7 +280,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
273280
);
274281
expect(response.body.response.votingRound).to.be.equal('0');
275282
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
276-
'1732810035',
283+
isBeforeLutHardfork() ? '1732810040' : '1732810035',
277284
);
278285
expect(response.body.response.requestBody.blockNumber).to.be.equal(
279286
'6724543',
@@ -319,7 +326,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
319326
);
320327
expect(response.body.response.votingRound).to.be.equal('0');
321328
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
322-
'1732810035',
329+
isBeforeLutHardfork() ? '1732810040' : '1732810035',
323330
);
324331
expect(response.body.response.requestBody.blockNumber).to.be.equal(
325332
'6724543',

test/e2e_tests/xrp/confirmed_block_height_exists/confirmed_block_height_exists_prepare_response.e2e-spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { expect } from 'chai';
22
import * as request from 'supertest';
33
import { app, baseHooks, getTestFile } from '../helper';
44

5+
// Hard fork for ConfirmedBlockHeightExists lowestUsedTimestamp.
6+
// Before: LUT = dbBlock.timestamp. After: LUT = lowerQueryWindowBlock.timestamp.
7+
// Keep in sync with src/verification/confirmed-block-height-exists/confirmed-block-height-exists.ts.
8+
const CBHE_LUT_HARDFORK_TIMESTAMP = 1777366800;
9+
const isBeforeLutHardfork = () =>
10+
Math.round(Date.now() / 1000) < CBHE_LUT_HARDFORK_TIMESTAMP;
11+
512
describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)})`, () => {
613
baseHooks();
714
it('should get status', async () => {
@@ -31,7 +38,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
3138
);
3239
expect(response.body.response.votingRound).to.be.equal('0');
3340
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
34-
'1733476512',
41+
isBeforeLutHardfork() ? '1733476521' : '1733476512',
3542
);
3643
expect(response.body.response.requestBody.blockNumber).to.be.equal(
3744
'2882191',
@@ -97,7 +104,7 @@ describe(`/ConfirmedBlockHeightExists/prepareResponse (${getTestFile(__filename)
97104
);
98105
expect(response.body.response.votingRound).to.be.equal('0');
99106
expect(response.body.response.lowestUsedTimestamp).to.be.equal(
100-
'1733476520',
107+
isBeforeLutHardfork() ? '1733476521' : '1733476520',
101108
);
102109
expect(response.body.response.requestBody.blockNumber).to.be.equal(
103110
'2882191',

0 commit comments

Comments
 (0)