diff --git a/chain-abstraction/sol-implementation/edge_challenge_manager_test.go b/chain-abstraction/sol-implementation/edge_challenge_manager_test.go index 311df1348..b3bb9092a 100644 --- a/chain-abstraction/sol-implementation/edge_challenge_manager_test.go +++ b/chain-abstraction/sol-implementation/edge_challenge_manager_test.go @@ -212,267 +212,6 @@ func TestEdgeChallengeManager_ConfirmByOneStepProof(t *testing.T) { ) require.ErrorContains(t, err, "execution reverted") }) - // t.Run("edge not pending", func(t *testing.T) { - // bisectionScenario := setupBisectionScenario(t) - // honestStateManager := bisectionScenario.honestStateManager - // honestEdge := bisectionScenario.honestLevelZeroEdge - // challengeManager, err := bisectionScenario.topLevelFork.Chains[1].SpecChallengeManager(ctx) - // require.NoError(t, err) - - // honestBisectCommit, err := honestStateManager.HistoryCommitmentUpToBatch(ctx, 0, challenge_testing.LevelZeroBlockEdgeHeight/2, 1) - // require.NoError(t, err) - // honestProof, err := honestStateManager.PrefixProofUpToBatch(ctx, 0, challenge_testing.LevelZeroBlockEdgeHeight/2, challenge_testing.LevelZeroBlockEdgeHeight, 1) - // require.NoError(t, err) - // honestChildren1, honestChildren2, err := honestEdge.Bisect(ctx, honestBisectCommit.Merkle, honestProof) - // require.NoError(t, err) - - // s1, err := honestChildren1.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgePending, s1) - // s2, err := honestChildren2.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgePending, s2) - - // // Adjust well beyond a challenge period. - // for i := 0; i < 200; i++ { - // bisectionScenario.topLevelFork.Backend.Commit() - // } - - // require.NoError(t, honestChildren1.ConfirmByTimer(ctx, []protocol.EdgeId{honestEdge.Id()})) - // require.NoError(t, honestChildren2.ConfirmByTimer(ctx, []protocol.EdgeId{honestEdge.Id()})) - // s1, err = honestChildren1.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgeConfirmed, s1) - // s2, err = honestChildren2.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgeConfirmed, s2) - - // executionHash, _, wasmModuleRoot, err := bisectionScenario.topLevelFork.Chains[0].GenesisAssertionHashes(ctx) - // require.NoError(t, err) - // wasmModuleRootProof, err := statemanager.WasmModuleProofAbi.Pack(common.Hash{}, executionHash, common.Hash{}) - // require.NoError(t, err) - - // inboxMaxCountProof, err := statemanager.ExecutionStateAbi.Pack( - // common.Hash{}, - // common.Hash{}, - // uint64(0), - // uint64(0), - // protocol.MachineStatusFinished, - // ) - // require.NoError(t, err) - - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // honestChildren1.Id(), - // &protocol.OneStepData{ - // BeforeHash: common.Hash{}, - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // make([]common.Hash, 0), - // make([]common.Hash, 0), - // ) - // require.ErrorContains(t, err, "Edge not pending") - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // honestChildren2.Id(), - // &protocol.OneStepData{ - // BeforeHash: common.Hash{}, - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // make([]common.Hash, 0), - // make([]common.Hash, 0), - // ) - // require.ErrorContains(t, err, "Edge not pending") - // }) - // t.Run("edge not small step type", func(t *testing.T) { - // bisectionScenario := setupBisectionScenario(t) - // honestStateManager := bisectionScenario.honestStateManager - // honestEdge := bisectionScenario.honestLevelZeroEdge - // challengeManager, err := bisectionScenario.topLevelFork.Chains[1].SpecChallengeManager(ctx) - // require.NoError(t, err) - - // honestBisectCommit, err := honestStateManager.HistoryCommitmentUpToBatch(ctx, 0, challenge_testing.LevelZeroBlockEdgeHeight/2, 1) - // require.NoError(t, err) - // honestProof, err := honestStateManager.PrefixProofUpToBatch(ctx, 0, challenge_testing.LevelZeroBlockEdgeHeight/2, challenge_testing.LevelZeroBlockEdgeHeight, 1) - // require.NoError(t, err) - // honestChildren1, honestChildren2, err := honestEdge.Bisect(ctx, honestBisectCommit.Merkle, honestProof) - // require.NoError(t, err) - - // s1, err := honestChildren1.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgePending, s1) - // s2, err := honestChildren2.Status(ctx) - // require.NoError(t, err) - // require.Equal(t, protocol.EdgePending, s2) - - // executionHash, _, wasmModuleRoot, err := bisectionScenario.topLevelFork.Chains[0].GenesisAssertionHashes(ctx) - // require.NoError(t, err) - // wasmModuleRootProof, err := statemanager.WasmModuleProofAbi.Pack(common.Hash{}, executionHash, common.Hash{}) - // require.NoError(t, err) - - // inboxMaxCountProof, err := statemanager.ExecutionStateAbi.Pack( - // common.Hash{}, - // common.Hash{}, - // uint64(0), - // uint64(0), - // protocol.MachineStatusFinished, - // ) - - // require.NoError(t, err) - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // honestChildren1.Id(), - // &protocol.OneStepData{ - // BeforeHash: common.Hash{}, - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // make([]common.Hash, 0), - // make([]common.Hash, 0), - // ) - // require.ErrorContains(t, err, "Edge is not a small step") - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // honestChildren2.Id(), - // &protocol.OneStepData{ - // BeforeHash: common.Hash{}, - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // make([]common.Hash, 0), - // make([]common.Hash, 0), - // ) - // require.ErrorContains(t, err, "Edge is not a small step") - // }) - // t.Run("before state not in history", func(t *testing.T) { - // scenario := setupOneStepProofScenario(t) - // honestEdge := scenario.smallStepHonestEdge - - // challengeManager, err := scenario.topLevelFork.Chains[1].SpecChallengeManager(ctx) - // require.NoError(t, err) - - // honestStateManager := scenario.honestStateManager - // fromAssertion := uint64(0) - // toAssertion := uint64(1) - // fromBigStep := uint64(0) - // toBigStep := fromBigStep + 1 - // toSmallStep := uint64(0) - // honestCommit, err := honestStateManager.SmallStepCommitmentUpTo( - // ctx, - // fromAssertion, - // toAssertion, - // fromBigStep, - // toBigStep, - // toSmallStep, - // ) - // require.NoError(t, err) - - // executionHash, _, wasmModuleRoot, err := scenario.topLevelFork.Chains[0].GenesisAssertionHashes(ctx) - // require.NoError(t, err) - // wasmModuleRootProof, err := statemanager.WasmModuleProofAbi.Pack(common.Hash{}, executionHash, common.Hash{}) - // require.NoError(t, err) - - // inboxMaxCountProof, err := statemanager.ExecutionStateAbi.Pack( - // common.Hash{}, - // common.Hash{}, - // uint64(0), - // uint64(0), - // protocol.MachineStatusFinished, - // ) - // require.NoError(t, err) - - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // honestEdge.Id(), - // &protocol.OneStepData{ - // BeforeHash: common.BytesToHash([]byte("foo")), - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // honestCommit.FirstLeafProof, - // honestCommit.LastLeafProof, - // ) - // require.ErrorContains(t, err, "Invalid inclusion proof") - // }) - // t.Run("one step proof fails", func(t *testing.T) { - // scenario := setupOneStepProofScenario(t) - // evilEdge := scenario.smallStepEvilEdge - - // challengeManager, err := scenario.topLevelFork.Chains[1].SpecChallengeManager(ctx) - // require.NoError(t, err) - - // evilStateManager := scenario.evilStateManager - // fromAssertion := uint64(0) - // toAssertion := uint64(1) - // fromBigStep := uint64(0) - // toBigStep := fromBigStep + 1 - // toSmallStep := uint64(0) - // startCommit, err := evilStateManager.SmallStepCommitmentUpTo( - // ctx, - // fromAssertion, - // toAssertion, - // fromBigStep, - // toBigStep, - // toSmallStep, - // ) - // require.NoError(t, err) - // endCommit, err := evilStateManager.SmallStepCommitmentUpTo( - // ctx, - // fromAssertion, - // toAssertion, - // fromBigStep, - // toBigStep, - // toSmallStep, - // ) - // require.NoError(t, err) - - // executionHash, _, wasmModuleRoot, err := scenario.topLevelFork.Chains[0].GenesisAssertionHashes(ctx) - // require.NoError(t, err) - // wasmModuleRootProof, err := statemanager.WasmModuleProofAbi.Pack(common.Hash{}, executionHash, common.Hash{}) - // require.NoError(t, err) - - // inboxMaxCountProof, err := statemanager.ExecutionStateAbi.Pack( - // common.Hash{}, - // common.Hash{}, - // uint64(0), - // uint64(0), - // protocol.MachineStatusFinished, - // ) - // require.NoError(t, err) - - // err = challengeManager.ConfirmEdgeByOneStepProof( - // ctx, - // evilEdge.Id(), - // &protocol.OneStepData{ - // BeforeHash: startCommit.LastLeaf, - // Proof: genesisOspData, - // InboxMsgCountSeen: big.NewInt(1), - // InboxMsgCountSeenProof: inboxMaxCountProof, - // WasmModuleRoot: wasmModuleRoot, - // WasmModuleRootProof: wasmModuleRootProof, - // }, - // startCommit.LastLeafProof, - // endCommit.LastLeafProof, - // ) - // require.ErrorContains(t, err, "Invalid inclusion proof") - // }) t.Run("OK", func(t *testing.T) { scenario := setupOneStepProofScenario(t) honestEdge := scenario.smallStepHonestEdge