diff --git a/channel/conclude.go b/channel/conclude.go index d4b6d50..9a2f3e9 100644 --- a/channel/conclude.go +++ b/channel/conclude.go @@ -52,16 +52,8 @@ func (a *Adjudicator) ensureConcluded(ctx context.Context, req channel.Adjudicat return nil } - // If the secondary flag is set, we wait for someone else to conclude. - concluded, err := a.waitConcludedSecondary(ctx, req) - if err != nil { - return errors.WithMessage(err, "waiting for secondary conclude") - } else if concluded { - return nil - } - // Wait until we can conclude. - err = a.waitConcludable(ctx, req) + err := a.waitConcludable(ctx, req) if err != nil { return fmt.Errorf("waiting for concludability: %w", err) } @@ -161,25 +153,6 @@ func (a *Adjudicator) checkConcludedState( } } -func (a *Adjudicator) waitConcludedSecondary(ctx context.Context, req channel.AdjudicatorReq) (concluded bool, err error) { - // In final Register calls, as the non-initiator, we optimistically wait for - // the other party to send the transaction first for - // `secondaryWaitBlocks + TxFinalityDepth` many blocks. - if req.Tx.IsFinal && req.Secondary { - // Create subscription. - sub, events, subErr, err := a.createEventSub(ctx, req.Tx.ID, false) - if err != nil { - return false, errors.WithMessage(err, "subscribing") - } - defer sub.Close() - - // Wait for concluded event. - waitBlocks := secondaryWaitBlocks + int(a.txFinalityDepth) - return waitConcludedForNBlocks(ctx, a, events, subErr, waitBlocks) - } - return false, nil -} - func (a *Adjudicator) conclude(ctx context.Context, req channel.AdjudicatorReq, subStates channel.StateMap) error { // If the on-chain state resulted from forced execution, we do not have a fully-signed state and cannot call concludeFinal. forceExecuted, err := a.isForceExecuted(ctx, req.Params.ID()) diff --git a/channel/conclude_test.go b/channel/conclude_test.go index 37e5561..6ec76cb 100644 --- a/channel/conclude_test.go +++ b/channel/conclude_test.go @@ -71,28 +71,19 @@ func testConcludeFinal(t *testing.T, numParts int) { ctx, cancel := context.WithTimeout(context.Background(), defaultTxTimeout) defer cancel() ct = pkgtest.NewConcurrent(t) - initiator := int(rng.Int31n(int32(numParts))) // pick a random initiator for i := 0; i < numParts; i++ { i := i go ct.StageN("register", numParts, func(t pkgtest.ConcT) { req := channel.AdjudicatorReq{ - Params: params, - Acc: s.Accs[i], - Idx: channel.Index(i), - Tx: tx, - Secondary: (i != initiator), + Params: params, + Acc: s.Accs[i], + Idx: channel.Index(i), + Tx: tx, } - diff, err := test.NonceDiff(s.Accs[i].Address(), s.Adjs[i], func() error { - return s.Adjs[i].Register(ctx, req, nil) - }) + err := s.Adjs[i].Register(ctx, req, nil) + require.NoError(t, err, "Withdrawing should succeed") - if !req.Secondary { - // The Initiator must send a TX. - require.Equal(t, diff, 1) - } else { - // Everyone else must NOT send a TX. - require.Equal(t, diff, 0) - } + }) } ct.Wait("register") @@ -254,11 +245,10 @@ func register(ctx context.Context, adj *test.SimAdjudicator, accounts []*keystor } req := channel.AdjudicatorReq{ - Params: ch.params, - Acc: accounts[0], - Idx: 0, - Tx: tx, - Secondary: false, + Params: ch.params, + Acc: accounts[0], + Idx: 0, + Tx: tx, } return adj.Register(ctx, req, sub) } @@ -277,11 +267,10 @@ func withdraw(ctx context.Context, adj *test.SimAdjudicator, accounts []*keystor for i, a := range accounts { req := channel.AdjudicatorReq{ - Params: c.params, - Acc: a, - Idx: channel.Index(i), - Tx: tx, - Secondary: i != 0, + Params: c.params, + Acc: a, + Idx: channel.Index(i), + Tx: tx, } if err := adj.Withdraw(ctx, req, subStates); err != nil { diff --git a/go.mod b/go.mod index 404f8bf..1a2d2eb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - perun.network/go-perun v0.10.5 + perun.network/go-perun v0.10.7-0.20230808153546-74844191e56e polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37 ) diff --git a/go.sum b/go.sum index 87856e9..49ed4e1 100644 --- a/go.sum +++ b/go.sum @@ -653,6 +653,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= perun.network/go-perun v0.10.5 h1:bIaAoLLh8R+RXdPh+MkCJcbtumsFkNvoVAJwb60JKjg= perun.network/go-perun v0.10.5/go.mod h1:BGBZC3npkX457u87pjDd0NEIXr1a4dsH4H/YpLdGGe8= +perun.network/go-perun v0.10.7-0.20230808153546-74844191e56e h1:4SOKO0WZtcsQUwP5nKVUrLUohgUPIhMa8wto5iNCA/k= +perun.network/go-perun v0.10.7-0.20230808153546-74844191e56e/go.mod h1:BGBZC3npkX457u87pjDd0NEIXr1a4dsH4H/YpLdGGe8= polycry.pt/poly-go v0.0.0-20220222131629-aa4bdbaab60b/go.mod h1:XUBrNtqgEhN3EEOP/5gh7IBd3xVHKidCjXDZfl9+kMU= polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37 h1:iA5GzEa/hHfVlQpimEjPV09NATwHXxSjWNB0VVodtew= polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37/go.mod h1:XUBrNtqgEhN3EEOP/5gh7IBd3xVHKidCjXDZfl9+kMU=