Skip to content

Commit 409bb4d

Browse files
author
Naohiro Yoshida
committed
expand skip count
Signed-off-by: Naohiro Yoshida <naohiro.yoshida@datachain.jp>
1 parent 9c5cd37 commit 409bb4d

File tree

3 files changed

+45
-44
lines changed

3 files changed

+45
-44
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ jobs:
5454
run: |
5555
make chain
5656
make contracts
57-
# epoch is 200, 400, 500, 1000
58-
# Since we want the previous epoch to be before HF we wait for 800 block (0.75sec * 800)
59-
sleep 600
57+
# Wait for Maxwell HF to be enabled (0.75sec * 2000)
58+
sleep 1500
6059
make relayer
6160
make test
6261
- name: integration-test
63-
run: go test -v ./tests -tags dev -ldflags="-X github.com/datachainlab/ibc-parlia-relay/module/constant.blocksPerEpoch=20"
62+
run: go test -v ./tests

module/setup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
)
1212

1313
// Maximum header interval to be submitted to LCP
14-
const skip = 100
14+
// Supports after Maxwell HF only
15+
const skip = 1000
1516

1617
type queryVerifiableNeighboringEpochHeaderFn = func(context.Context, uint64, uint64) (core.Header, error)
1718

module/setup_test.go

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ func (ts *SetupTestSuite) SetupTest() {
2626
ts.Require().NoError(err)
2727
}
2828

29+
var forkSpecsAfterMaxwell = []*ForkSpec{
30+
{
31+
// Must Set Milli timestamp
32+
HeightOrTimestamp: &ForkSpec_Height{Height: 0},
33+
AdditionalHeaderItemCount: 1,
34+
EpochLength: 1000,
35+
},
36+
}
37+
2938
func (ts *SetupTestSuite) TestSuccess_setupHeadersForUpdate_neighboringEpoch() {
3039

3140
verify := func(trustedHeight, nextHeight uint64, expected int) {
@@ -54,7 +63,7 @@ func (ts *SetupTestSuite) TestSuccess_setupHeadersForUpdate_neighboringEpoch() {
5463
}, nil
5564
}
5665

57-
targets, err := setupHeadersForUpdate(context.Background(), neighborFn, headerFn, clientStateLatestHeight, latestFinalizedHeader, clienttypes.NewHeight(0, 100000), GetForkParameters(Localnet))
66+
targets, err := setupHeadersForUpdate(context.Background(), neighborFn, headerFn, clientStateLatestHeight, latestFinalizedHeader, clienttypes.NewHeight(0, 100000), forkSpecsAfterMaxwell)
5867
ts.Require().NoError(err)
5968
ts.Require().Len(targets, expected)
6069
for i, h := range targets {
@@ -114,7 +123,7 @@ func (ts *SetupTestSuite) TestSuccess_setupHeadersForUpdate_allEmpty() {
114123
}
115124
targets, err := setupHeadersForUpdate(context.Background(), neighboringEpochFn, headerFn, clientStateLatestHeight, latestFinalizedHeader,
116125
clienttypes.NewHeight(0,
117-
1000000), GetForkParameters(Localnet))
126+
1000000), forkSpecsAfterMaxwell)
118127
ts.Require().NoError(err)
119128
ts.Require().Len(targets, expected)
120129
}
@@ -151,19 +160,11 @@ func (ts *SetupTestSuite) TestSuccess_setupHeadersForUpdate_withHFBoundary() {
151160
}
152161

153162
hftime := now.Add(time.Duration(trustedHeight+(nextHeight-trustedHeight)/2) * time.Second).Unix()
154-
forkSpecs := []*ForkSpec{
155-
{
156-
// Must Set Milli timestamp
157-
HeightOrTimestamp: &ForkSpec_Height{Height: 0},
158-
AdditionalHeaderItemCount: 1,
159-
EpochLength: 200,
160-
},
161-
{
162-
HeightOrTimestamp: &ForkSpec_Timestamp{Timestamp: uint64(hftime * 1000)},
163-
AdditionalHeaderItemCount: 1,
164-
EpochLength: 500,
165-
},
166-
}
163+
forkSpecs := append(forkSpecsAfterMaxwell, &ForkSpec{
164+
HeightOrTimestamp: &ForkSpec_Timestamp{Timestamp: uint64(hftime * 1000)},
165+
AdditionalHeaderItemCount: 1,
166+
EpochLength: 2000,
167+
})
167168
clientStateLatestHeight := clienttypes.NewHeight(0, trustedHeight)
168169
target, err := newETHHeader(&types2.Header{
169170
Number: big.NewInt(int64(nextHeight)),
@@ -234,51 +235,51 @@ func (ts *SetupTestSuite) Test_makeSubmittingHeights() {
234235
rq.Len(makeSubmittingHeights(10, 1, 11, &msec, 9), 1)
235236
rq.Len(makeSubmittingHeights(10, 9, 11, &msec, 9), 0)
236237
rq.Equal(
237-
[]uint64{99, 100, 200, 300, 400, 500},
238-
makeSubmittingHeights(501, 0, 100, &msec, 99),
238+
[]uint64{skip - 1, skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
239+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, skip-1),
239240
)
240241
rq.Equal(
241-
[]uint64{100, 200, 300, 400, 500},
242-
makeSubmittingHeights(501, 99, 100, &msec, 99),
242+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
243+
makeSubmittingHeights(5*skip+1, skip-1, skip, &msec, skip-1),
243244
)
244245
rq.Equal(
245-
[]uint64{100, 200, 300, 400, 500},
246-
makeSubmittingHeights(501, 0, 100, &msec, 100),
246+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
247+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, skip),
247248
)
248249
rq.Equal(
249-
[]uint64{100, 101, 200, 300, 400, 500},
250-
makeSubmittingHeights(501, 0, 100, &msec, 101),
250+
[]uint64{skip, skip + 1, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
251+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, skip+1),
251252
)
252253
rq.Equal(
253-
[]uint64{100, 200, 300, 400, 500},
254-
makeSubmittingHeights(501, 0, 100, nil, 101),
254+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
255+
makeSubmittingHeights(5*skip+1, 0, skip, nil, skip+1),
255256
)
256257
rq.Equal(
257-
[]uint64{100, 200, 201, 300, 400, 500},
258-
makeSubmittingHeights(501, 0, 100, &msec, 201),
258+
[]uint64{skip, 2 * skip, 2*skip + 1, 3 * skip, 4 * skip, 5 * skip},
259+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, 2*skip+1),
259260
)
260261
rq.Equal(
261-
[]uint64{100, 200, 300, 301, 400, 500},
262-
makeSubmittingHeights(501, 0, 100, &msec, 301),
262+
[]uint64{skip, 2 * skip, 3 * skip, 3*skip + 1, 4 * skip, 5 * skip},
263+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, 3*skip+1),
263264
)
264265
rq.Equal(
265-
[]uint64{100, 200, 300, 400, 401, 500},
266-
makeSubmittingHeights(501, 0, 100, &msec, 401),
266+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 4*skip + 1, 5 * skip},
267+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, 4*skip+1),
267268
)
268269
rq.Equal(
269-
[]uint64{100, 200, 300, 400, 500},
270-
makeSubmittingHeights(501, 0, 100, nil, 401),
270+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
271+
makeSubmittingHeights(5*skip+1, 0, skip, nil, 4*skip+1),
271272
)
272273
rq.Equal(
273-
[]uint64{100, 200, 300, 400, 500},
274-
makeSubmittingHeights(501, 0, 100, &msec, 501),
274+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
275+
makeSubmittingHeights(5*skip+1, 0, skip, &msec, 5*skip+1),
275276
)
276277
rq.Equal(
277-
[]uint64{100, 200, 300, 400, 500, 501},
278-
makeSubmittingHeights(502, 0, 100, &msec, 501),
278+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip, 5*skip + 1},
279+
makeSubmittingHeights(5*skip+2, 0, skip, &msec, 5*skip+1),
279280
)
280281
rq.Equal(
281-
[]uint64{100, 200, 300, 400, 500},
282-
makeSubmittingHeights(502, 0, 100, nil, 501),
282+
[]uint64{skip, 2 * skip, 3 * skip, 4 * skip, 5 * skip},
283+
makeSubmittingHeights(5*skip+2, 0, skip, nil, 5*skip+1),
283284
)
284285
}

0 commit comments

Comments
 (0)