@@ -361,6 +361,86 @@ func buildTransitionTests(
361361 }
362362}
363363
364+ // RunTraceExtensionActivationTest verifies that trace extension correctly
365+ // activates (or not) based on whether the claim timestamp has been reached.
366+ func RunTraceExtensionActivationTest (t devtest.T , sys * presets.SimpleInterop ) {
367+ t .Require ().NotNil (sys .SuperRoots , "supernode is required for this test" )
368+
369+ chains := orderedChains (sys )
370+ t .Require ().Len (chains , 2 , "expected exactly 2 interop chains" )
371+
372+ endTimestamp := uint64 (time .Now ().Unix ())
373+ sys .SuperRoots .AwaitValidatedTimestamp (endTimestamp )
374+ l1Head := latestRequiredL1 (sys .SuperRoots .SuperRootAtTimestamp (endTimestamp + 1 ))
375+
376+ startTimestamp := endTimestamp - 1
377+ agreedSuperRoot := superRootAtTimestamp (t , chains , endTimestamp )
378+ agreedClaim := agreedSuperRoot .Marshal ()
379+
380+ // The disputed claim transitions to the next timestamp by including the
381+ // first chain's optimistic block at endTimestamp+1.
382+ firstOptimistic := optimisticBlockAtTimestamp (t , chains [0 ], endTimestamp + 1 )
383+ disputedClaim := marshalTransition (agreedSuperRoot , 1 , firstOptimistic )
384+ disputedTraceIndex := int64 (stepsPerTimestamp )
385+
386+ tests := []* transitionTest {
387+ {
388+ Name : "CorrectlyDidNotActivate" ,
389+ AgreedClaim : agreedClaim ,
390+ DisputedClaim : disputedClaim ,
391+ DisputedTraceIndex : disputedTraceIndex ,
392+ L1Head : l1Head ,
393+ // Trace extension does not activate because we have not reached the proposal timestamp yet.
394+ ClaimTimestamp : endTimestamp + 1 ,
395+ ExpectValid : true ,
396+ },
397+ {
398+ Name : "IncorrectlyDidNotActivate" ,
399+ AgreedClaim : agreedClaim ,
400+ DisputedClaim : disputedClaim ,
401+ DisputedTraceIndex : disputedTraceIndex ,
402+ L1Head : l1Head ,
403+ // Trace extension should have activated because we have reached the proposal timestamp.
404+ ClaimTimestamp : endTimestamp ,
405+ ExpectValid : false ,
406+ },
407+ {
408+ Name : "CorrectlyActivated" ,
409+ AgreedClaim : agreedClaim ,
410+ DisputedClaim : agreedClaim ,
411+ DisputedTraceIndex : disputedTraceIndex ,
412+ L1Head : l1Head ,
413+ // Trace extension activated at the proposal timestamp, claim stays the same.
414+ ClaimTimestamp : endTimestamp ,
415+ ExpectValid : true ,
416+ },
417+ {
418+ Name : "IncorrectlyActivated" ,
419+ AgreedClaim : agreedClaim ,
420+ DisputedClaim : agreedClaim ,
421+ DisputedTraceIndex : disputedTraceIndex ,
422+ L1Head : l1Head ,
423+ // Trace extension should not have activated because we haven't reached the proposal timestamp.
424+ ClaimTimestamp : endTimestamp + 1 ,
425+ ExpectValid : false ,
426+ },
427+ }
428+
429+ challengerCfg := sys .L2ChainA .Escape ().L2Challengers ()[0 ].Config ()
430+ gameDepth := sys .DisputeGameFactory ().GameImpl (gameTypes .SuperCannonKonaGameType ).SplitDepth ()
431+
432+ for _ , test := range tests {
433+ t .Run (test .Name + "-fpp" , func (t devtest.T ) {
434+ runKonaInteropProgram (t , challengerCfg .CannonKona , test .L1Head .Hash ,
435+ test .AgreedClaim , crypto .Keccak256Hash (test .DisputedClaim ),
436+ test .ClaimTimestamp , test .ExpectValid )
437+ })
438+ t .Run (test .Name + "-challenger" , func (t devtest.T ) {
439+ runChallengerProviderTest (t , sys .SuperRoots .QueryAPI (), gameDepth , startTimestamp , test .ClaimTimestamp , test )
440+ })
441+ }
442+ }
443+
364444// RunSuperFaultProofTest encapsulates the basic super fault proof test flow.
365445func RunSuperFaultProofTest (t devtest.T , sys * presets.SimpleInterop ) {
366446 t .Require ().NotNil (sys .SuperRoots , "supernode is required for this test" )
0 commit comments