Skip to content

Commit 01a0dd2

Browse files
authored
op-acceptance: Add tests to prove validation of valid interop messages. (#19229)
* op-acceptance: Add tests to prove validation of valid interop messages. * kona-proofs: Fix interop header_by_number lookup. Previously it would often enter an infinite loop because it would always look up the current block header and return that, never making any progress.
1 parent afe708e commit 01a0dd2

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

op-acceptance-tests/tests/interop/proofs/interop_fault_proofs_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ func TestInteropFaultProofs(gt *testing.T) {
1313
sys := presets.NewSimpleInterop(t)
1414
sfp.RunSuperFaultProofTest(t, sys)
1515
}
16+
17+
func TestInteropFaultProofs_ConsolidateValidCrossChainMessage(gt *testing.T) {
18+
t := devtest.SerialT(gt)
19+
sys := presets.NewSimpleInterop(t)
20+
sfp.RunConsolidateValidCrossChainMessageTest(t, sys)
21+
}

op-acceptance-tests/tests/superfaultproofs/superfaultproofs.go

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package superfaultproofs
22

33
import (
4+
"context"
45
"math/big"
6+
"math/rand"
57
"os"
68
"os/exec"
79
"path/filepath"
810
"slices"
11+
"strings"
912
"time"
1013

1114
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/trace/super"
@@ -19,6 +22,7 @@ import (
1922
"github.com/ethereum-optimism/optimism/op-node/rollup"
2023
interopTypes "github.com/ethereum-optimism/optimism/op-program/client/interop/types"
2124
"github.com/ethereum-optimism/optimism/op-service/apis"
25+
"github.com/ethereum-optimism/optimism/op-service/bigs"
2226
"github.com/ethereum-optimism/optimism/op-service/eth"
2327
"github.com/ethereum/go-ethereum/common"
2428
"github.com/ethereum/go-ethereum/crypto"
@@ -175,7 +179,10 @@ func runKonaInteropProgram(t devtest.T, cfg vm.Config, l1Head common.Hash, agree
175179

176180
exePath, err := filepath.Abs(argv[0])
177181
t.Require().NoError(err)
178-
cmd := exec.Command(exePath, argv[1:]...)
182+
t.Logf("Executing kona interop program: %s", strings.Join(argv, " "))
183+
ctx, cancel := context.WithTimeout(t.Ctx(), 2*time.Minute)
184+
defer cancel()
185+
cmd := exec.CommandContext(ctx, exePath, argv[1:]...)
179186
cmd.Dir = tmpDir
180187
cmd.Env = append(append(cmd.Env, os.Environ()...), "NO_COLOR=1")
181188

@@ -518,3 +525,69 @@ func RunSuperFaultProofTest(t devtest.T, sys *presets.SimpleInterop) {
518525
})
519526
}
520527
}
528+
529+
func RunConsolidateValidCrossChainMessageTest(t devtest.T, sys *presets.SimpleInterop) {
530+
t.Require().NotNil(sys.SuperRoots, "supernode is required for this test")
531+
rng := rand.New(rand.NewSource(1234))
532+
533+
chains := orderedChains(sys)
534+
t.Require().Len(chains, 2, "expected exactly 2 interop chains")
535+
536+
aliceA := sys.FunderA.NewFundedEOA(eth.OneEther)
537+
aliceB := aliceA.AsEL(sys.L2ELB)
538+
sys.FunderB.Fund(aliceB, eth.OneEther)
539+
540+
eventLogger := aliceA.DeployEventLogger()
541+
initMsg := aliceA.SendRandomInitMessage(rng, eventLogger, 2, 10)
542+
execMsg := aliceB.SendExecMessage(initMsg)
543+
544+
endTimestamp := sys.L2ChainB.TimestampForBlockNum(bigs.Uint64Strict(execMsg.BlockNumber()))
545+
startTimestamp := endTimestamp - 1
546+
547+
sys.SuperRoots.AwaitValidatedTimestamp(endTimestamp)
548+
l1HeadCurrent := latestRequiredL1(sys.SuperRoots.SuperRootAtTimestamp(endTimestamp))
549+
550+
start := superRootAtTimestamp(t, chains, startTimestamp)
551+
end := superRootAtTimestamp(t, chains, endTimestamp)
552+
553+
firstOptimistic := optimisticBlockAtTimestamp(t, chains[0], endTimestamp)
554+
secondOptimistic := optimisticBlockAtTimestamp(t, chains[1], endTimestamp)
555+
paddingStep := func(step uint64) []byte {
556+
return marshalTransition(start, step, firstOptimistic, secondOptimistic)
557+
}
558+
559+
tests := []*transitionTest{
560+
{
561+
Name: "Consolidate-AllValid",
562+
AgreedClaim: paddingStep(consolidateStep),
563+
DisputedClaim: end.Marshal(),
564+
DisputedTraceIndex: consolidateStep,
565+
ExpectValid: true,
566+
L1Head: l1HeadCurrent,
567+
ClaimTimestamp: endTimestamp,
568+
},
569+
{
570+
Name: "Consolidate-AllValid-InvalidNoChange",
571+
AgreedClaim: paddingStep(consolidateStep),
572+
DisputedClaim: paddingStep(consolidateStep),
573+
DisputedTraceIndex: consolidateStep,
574+
ExpectValid: false,
575+
L1Head: l1HeadCurrent,
576+
ClaimTimestamp: endTimestamp,
577+
},
578+
}
579+
580+
challengerCfg := sys.L2ChainA.Escape().L2Challengers()[0].Config()
581+
gameDepth := sys.DisputeGameFactory().GameImpl(gameTypes.SuperCannonKonaGameType).SplitDepth()
582+
for _, test := range tests {
583+
t.Run(test.Name+"-fpp", func(t devtest.T) {
584+
runKonaInteropProgram(t, challengerCfg.CannonKona, test.L1Head.Hash,
585+
test.AgreedClaim, crypto.Keccak256Hash(test.DisputedClaim),
586+
test.ClaimTimestamp, test.ExpectValid)
587+
})
588+
589+
t.Run(test.Name+"-challenger", func(t devtest.T) {
590+
runChallengerProviderTest(t, sys.SuperRoots.QueryAPI(), gameDepth, startTimestamp, test.ClaimTimestamp, test)
591+
})
592+
}
593+
}

rust/kona/crates/proof/proof-interop/src/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ where
142142
// If Isthmus is active, the EIP-2935 contract is used to perform leaping lookbacks
143143
// through consulting the ring buffer within the contract. If this
144144
// lookup fails for any reason, we fall back to linear walk back.
145-
let block_hash = match eip_2935_history_lookup(&header, 0, self, self).await {
145+
let block_hash = match eip_2935_history_lookup(&header, number, self, self).await {
146146
Ok(hash) => hash,
147147
Err(_) => {
148148
// If the EIP-2935 lookup fails for any reason, attempt fallback to linear

0 commit comments

Comments
 (0)