From 775dcbca7608334d774d860b1f2687be138ecdaf Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 4 Sep 2023 17:44:31 +0200 Subject: [PATCH 1/5] proof: fix log output --- proof/courier.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proof/courier.go b/proof/courier.go index 72e8b9e90..b86f3ecca 100644 --- a/proof/courier.go +++ b/proof/courier.go @@ -510,7 +510,7 @@ func (h *HashMailCourier) DeliverProof(ctx context.Context, proof *AnnotatedProof) error { log.Infof("Attempting to deliver receiver proof for send of "+ - "asset_id=%x, amt=%v", h.recipient.AssetID, h.recipient.Amount) + "asset_id=%v, amt=%v", h.recipient.AssetID, h.recipient.Amount) // Compute the stream IDs for the sender and receiver. senderStreamID := deriveSenderStreamID(h.recipient) From 69fd59155f546e89db8aaa68475aa1a340158f8f Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 4 Sep 2023 17:44:53 +0200 Subject: [PATCH 2/5] proof: add OutPoint method to proof --- proof/proof.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proof/proof.go b/proof/proof.go index ea8852303..7074eeeff 100644 --- a/proof/proof.go +++ b/proof/proof.go @@ -147,6 +147,15 @@ type Proof struct { ChallengeWitness wire.TxWitness } +// OutPoint returns the outpoint that commits to the asset associated with this +// proof. +func (p *Proof) OutPoint() wire.OutPoint { + return wire.OutPoint{ + Hash: p.AnchorTx.TxHash(), + Index: p.InclusionProof.OutputIndex, + } +} + // EncodeRecords returns the set of known TLV records to encode a Proof. func (p *Proof) EncodeRecords() []tlv.Record { records := make([]tlv.Record, 0, 9) From bbd15e6b34fbfbfa1c3ebe7d96ae9e1ba37ac001 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 4 Sep 2023 17:45:24 +0200 Subject: [PATCH 3/5] tapgarden: fix custodian to support sending to addr multiple times --- tapgarden/custodian.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tapgarden/custodian.go b/tapgarden/custodian.go index 88e0995e5..5bbe4ba86 100644 --- a/tapgarden/custodian.go +++ b/tapgarden/custodian.go @@ -337,11 +337,16 @@ func (c *Custodian) inspectWalletTx(walletTx *lndclient.Transaction) error { return err } + // We are not interested in the outpoint if we don't know of a + // pre-stored address associated with it. + if addr == nil { + continue + } + // TODO(ffranr): This proof courier disabled check should be // removed. It was implemented because some integration test do // not setup and use a proof courier. - skipProofCourier := c.cfg.ProofCourierCfg == nil || addr == nil - if skipProofCourier { + if c.cfg.ProofCourierCfg == nil { continue } @@ -580,12 +585,20 @@ func (c *Custodian) mapProofToEvent(p proof.Blob) error { // Check if any of our in-flight events match the last proof's state. for _, event := range c.events { - if AddrMatchesAsset(event.Addr, &lastProof.Asset) { + if AddrMatchesAsset(event.Addr, &lastProof.Asset) && + event.Outpoint == lastProof.OutPoint() { + // Importing a proof already creates the asset in the // database. Therefore, all we need to do is update the // state of the address event to mark it as completed // successfully. - return c.setReceiveCompleted(event, lastProof, file) + err = c.setReceiveCompleted(event, lastProof, file) + if err != nil { + return fmt.Errorf("error updating event: %w", + err) + } + + delete(c.events, event.Outpoint) } } From 328e9094caf401e6e395da8a1f5acd2e1c2b70e9 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 4 Sep 2023 17:45:51 +0200 Subject: [PATCH 4/5] itest: fix hashmail backoff time An itest sends to the same address multiple times in a row, which causes the hashmail courier to go into a backoff wait that was longer than the amount of time we waited in the itest. --- itest/tapd_harness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itest/tapd_harness.go b/itest/tapd_harness.go index 56d719d8c..9066932ba 100644 --- a/itest/tapd_harness.go +++ b/itest/tapd_harness.go @@ -144,7 +144,7 @@ func newTapdHarness(ht *harnessTest, cfg tapdConfig, case *ApertureHarness: // Use passed in backoff config or default config. backoffCfg := &proof.BackoffCfg{ - BackoffResetWait: 20 * time.Second, + BackoffResetWait: 2 * time.Second, NumTries: 3, InitialBackoff: 2 * time.Second, MaxBackoff: 2 * time.Second, From eb415c35db4c13fccecad461795875968b52c439 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 4 Sep 2023 17:48:28 +0200 Subject: [PATCH 5/5] itest: remove sendProof from courier enabled tests --- itest/send_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/itest/send_test.go b/itest/send_test.go index 42a3b38dc..f2a2ec299 100644 --- a/itest/send_test.go +++ b/itest/send_test.go @@ -119,9 +119,6 @@ func testBasicSendUnidirectional(t *harnessTest) { t, t.tapd, sendResp, genInfo.AssetId, []uint64{currentUnits, numUnits}, i, i+1, ) - _ = sendProof( - t, t.tapd, secondTapd, bobAddr.ScriptKey, genInfo, - ) AssertNonInteractiveRecvComplete(t.t, secondTapd, i+1) } @@ -212,10 +209,6 @@ func testResumePendingPackageSend(t *harnessTest) { t.lndHarness.MineBlocks(6) } - _ = sendProof( - t, sendTapd, recvTapd, recvAddr.ScriptKey, genInfo, - ) - // Confirm with the receiver node that the asset was fully // received. AssertNonInteractiveRecvComplete(t.t, recvTapd, i+1)