5
5
"testing"
6
6
7
7
"github.com/iotaledger/hive.go/lo"
8
+ "github.com/iotaledger/hive.go/log"
8
9
"github.com/iotaledger/hive.go/runtime/options"
9
10
"github.com/iotaledger/iota-core/pkg/protocol"
10
11
"github.com/iotaledger/iota-core/pkg/protocol/engine/notarization/slotnotarization"
@@ -13,6 +14,7 @@ import (
13
14
"github.com/iotaledger/iota-core/pkg/testsuite"
14
15
"github.com/iotaledger/iota-core/pkg/testsuite/mock"
15
16
iotago "github.com/iotaledger/iota.go/v4"
17
+ "github.com/iotaledger/iota.go/v4/api"
16
18
)
17
19
18
20
func TestConfirmationFlags (t * testing.T ) {
@@ -245,3 +247,90 @@ func TestConfirmationFlags(t *testing.T) {
245
247
)
246
248
}
247
249
}
250
+
251
+ func TestConfirmationOverEpochBoundary (t * testing.T ) {
252
+ ts := testsuite .NewTestSuite (t ,
253
+ testsuite .WithProtocolParametersOptions (
254
+ iotago .WithTimeProviderOptions (
255
+ 0 ,
256
+ testsuite .GenesisTimeWithOffsetBySlots (1000 , testsuite .DefaultSlotDurationInSeconds ),
257
+ testsuite .DefaultSlotDurationInSeconds ,
258
+ 3 ,
259
+ ),
260
+ iotago .WithLivenessOptions (
261
+ 10 ,
262
+ 10 ,
263
+ 3 ,
264
+ 4 ,
265
+ 5 ,
266
+ ),
267
+ ),
268
+ )
269
+ defer ts .Shutdown ()
270
+
271
+ ts .AddValidatorNode ("node0" )
272
+ ts .AddValidatorNode ("node1" )
273
+ ts .AddValidatorNode ("node2" )
274
+ ts .AddValidatorNode ("node3" )
275
+ ts .AddNode ("node4" )
276
+
277
+ ts .Run (true )
278
+
279
+ ts .Node ("node0" ).Protocol .SetLogLevel (log .LevelTrace )
280
+
281
+ // Issue blocks up until 1 slot more than the epoch.
282
+ {
283
+ ts .IssueBlocksAtSlots ("" , []iotago.SlotIndex {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }, 4 , "Genesis" , ts .Nodes (), true , false )
284
+
285
+ ts .AssertNodeState (ts .Nodes (),
286
+ testsuite .WithLatestFinalizedSlot (5 ),
287
+ testsuite .WithLatestCommitmentSlotIndex (6 ),
288
+ testsuite .WithEqualStoredCommitmentAtIndex (6 ),
289
+ testsuite .WithEvictedSlot (6 ),
290
+ )
291
+
292
+ // Verify propagation of witness weight over epoch boundaries (slot 7).
293
+ {
294
+ // We propagate witness weight for pre-acceptance and acceptance over epoch boundaries.
295
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" , "7.3" ), true , ts .Nodes ()... )
296
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" , "7.3" ), true , ts .Nodes ()... )
297
+
298
+ // We don't propagate pre-confirmation and confirmation over epoch boundaries:
299
+ // There's 4 rows in a slot, everything except the last row should be pre-confirmed.
300
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" ), true , ts .Nodes ()... )
301
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("7.3" ), false , ts .Nodes ()... )
302
+ // Accordingly, only the first 2 rows are confirmed.
303
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("7.0" , "7.1" ), true , ts .Nodes ()... )
304
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("7.2" , "7.3" ), false , ts .Nodes ()... )
305
+
306
+ }
307
+
308
+ // Slot 8 and 9 behaves normally, as they are in the new epoch.
309
+ {
310
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("8.0" , "8.1" , "8.2" , "8.3" , "9.0" , "9.1" ), true , ts .Nodes ()... )
311
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("9.2" , "9.3" ), false , ts .Nodes ()... )
312
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("9.2" ), true , ts .Nodes ()... )
313
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("9.3" ), false , ts .Nodes ()... )
314
+
315
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("8.0" , "8.1" , "8.2" , "8.3" , "9.0" , "9.1" ), true , ts .Nodes ()... )
316
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("9.2" , "9.3" ), false , ts .Nodes ()... )
317
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("9.2" ), true , ts .Nodes ()... )
318
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("9.3" ), false , ts .Nodes ()... )
319
+ }
320
+ }
321
+
322
+ // Issue more so that blocks at end of epoch become confirmed via finalization.
323
+ {
324
+ ts .IssueBlocksAtSlots ("" , []iotago.SlotIndex {10 , 11 , 12 }, 4 , "9.3" , ts .Nodes (), true , false )
325
+
326
+ ts .AssertNodeState (ts .Nodes (),
327
+ testsuite .WithLatestFinalizedSlot (8 ),
328
+ testsuite .WithLatestCommitmentSlotIndex (9 ),
329
+ testsuite .WithEqualStoredCommitmentAtIndex (9 ),
330
+ testsuite .WithEvictedSlot (9 ),
331
+ )
332
+
333
+ ts .AssertRetainerBlocksState (ts .BlocksWithPrefixes ("7" , "8" ), api .BlockStateFinalized , ts .Nodes ()... )
334
+ ts .AssertRetainerBlocksState (ts .BlocksWithPrefixes ("9" , "10" , "11" ), api .BlockStateConfirmed , ts .Nodes ()... )
335
+ }
336
+ }
0 commit comments