From 216314762b9bda2647cbe4290b44cb7a0b00a33b Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 15 Nov 2024 14:24:16 +0100 Subject: [PATCH] tapchannel: use limit spewer only This fixes an issue of an infinite loop when attempting to spew a proof structure. --- tapchannel/aux_closer.go | 6 +++--- tapchannel/aux_funding_controller.go | 20 +++++++++++--------- tapchannel/aux_invoice_manager.go | 4 ++-- tapchannel/aux_leaf_signer.go | 3 +-- tapchannel/aux_sweeper.go | 21 ++++++++++++--------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tapchannel/aux_closer.go b/tapchannel/aux_closer.go index cfa32ae53..eaff1ece3 100644 --- a/tapchannel/aux_closer.go +++ b/tapchannel/aux_closer.go @@ -10,7 +10,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightninglabs/taproot-assets/address" "github.com/lightninglabs/taproot-assets/asset" "github.com/lightninglabs/taproot-assets/fn" @@ -250,7 +249,8 @@ func (a *AuxChanCloser) AuxCloseOutputs( } log.Tracef("Decoded local_shutdown=%v, remote_shutdown=%v", - spew.Sdump(localShutdown), spew.Sdump(remoteShutdown)) + limitSpewer.Sdump(localShutdown), + limitSpewer.Sdump(remoteShutdown)) // To start with, we'll now create the allocations for the asset // outputs. We track the amount that'll go to the anchor assets, so we @@ -570,7 +570,7 @@ func (a *AuxChanCloser) ShutdownBlob( return none, err } - log.Infof("Constructed shutdown record: %v", spew.Sdump(records)) + log.Infof("Constructed shutdown record: %v", limitSpewer.Sdump(records)) return lfn.Some[lnwire.CustomRecords](records), nil } diff --git a/tapchannel/aux_funding_controller.go b/tapchannel/aux_funding_controller.go index e0c5c9e37..defce2d91 100644 --- a/tapchannel/aux_funding_controller.go +++ b/tapchannel/aux_funding_controller.go @@ -19,7 +19,6 @@ import ( "github.com/btcsuite/btcd/btcutil/psbt" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightninglabs/taproot-assets/address" "github.com/lightninglabs/taproot-assets/asset" "github.com/lightninglabs/taproot-assets/commitment" @@ -522,7 +521,7 @@ func (p *pendingAssetFunding) unlockAssetInputs(ctx context.Context, coinSelect tapfreighter.CoinSelector) error { log.Debugf("unlocking asset inputs: %v", - spew.Sdump(p.lockedAssetInputs)) + limitSpewer.Sdump(p.lockedAssetInputs)) err := coinSelect.ReleaseCoins(ctx, p.lockedAssetInputs...) if err != nil { @@ -936,7 +935,8 @@ func (f *FundingController) anchorVPackets(fundedPkt *tapsend.FundedPsbt, func (f *FundingController) signAndFinalizePsbt(ctx context.Context, pkt *psbt.Packet) (*wire.MsgTx, error) { - log.Debugf("Signing and finalizing PSBT w/ lnd: %v", spew.Sdump(pkt)) + log.Debugf("Signing and finalizing PSBT w/ lnd: %v", + limitSpewer.Sdump(pkt)) // By default, the wallet won't try to finalize output it sees are watch // only (like the asset input), so we'll have it sign ourselves first. @@ -945,7 +945,7 @@ func (f *FundingController) signAndFinalizePsbt(ctx context.Context, return nil, fmt.Errorf("unable to sign PSBT: %w", err) } - log.Debugf("Signed PSBT: %v", spew.Sdump(signedPkt)) + log.Debugf("Signed PSBT: %v", limitSpewer.Sdump(signedPkt)) finalizedPkt, err := f.cfg.ChainWallet.SignAndFinalizePsbt( ctx, signedPkt, @@ -954,7 +954,7 @@ func (f *FundingController) signAndFinalizePsbt(ctx context.Context, return nil, fmt.Errorf("unable to finalize PSBT: %w", err) } - log.Debugf("Finalized PSBT: %v", spew.Sdump(signedPkt)) + log.Debugf("Finalized PSBT: %v", limitSpewer.Sdump(signedPkt)) // Extra the tx manually, then perform some manual sanity checks to // make sure things are ready for broadcast. @@ -1056,7 +1056,8 @@ func (f *FundingController) completeChannelFunding(ctx context.Context, // with lnd that we arrived at the proper TxOut. fundingPsbt.UnsignedTx.TxOut[0].Value = int64(fundingReq.ChanAmt) - log.Debugf("Funding PSBT pre funding: %s", spew.Sdump(fundingPsbt)) + log.Debugf("Funding PSBT pre funding: %s", + limitSpewer.Sdump(fundingPsbt)) // With the PSBT template created, we'll now ask lnd to fund the PSBT. // This'll add yet another output (lnd's change output) to the @@ -1068,7 +1069,8 @@ func (f *FundingController) completeChannelFunding(ctx context.Context, return nil, fmt.Errorf("unable to fund PSBT: %w", err) } - log.Infof("Funding PSBT post funding: %s", spew.Sdump(finalFundedPsbt)) + log.Infof("Funding PSBT post funding: %s", + limitSpewer.Sdump(finalFundedPsbt)) // If we fail at any step in the process, we want to make sure we // unlock the inputs, so we'll add them to funding state now. @@ -1111,7 +1113,7 @@ func (f *FundingController) completeChannelFunding(ctx context.Context, } log.Debugf("Submitting finalized PSBT to lnd for verification: %s", - spew.Sdump(finalFundedPsbt.Pkt)) + limitSpewer.Sdump(finalFundedPsbt.Pkt)) // At this point, we're nearly done, we'll now present the final PSBT // to lnd to verification. If this passes, then we're clear to @@ -1650,7 +1652,7 @@ func (f *FundingController) chanFunder() { } log.Infof("Returning funding desc: %v", - spew.Sdump(fundingDesc)) + limitSpewer.Sdump(fundingDesc)) req.resp <- lfn.Some(*fundingDesc) diff --git a/tapchannel/aux_invoice_manager.go b/tapchannel/aux_invoice_manager.go index 37009e718..d767094d1 100644 --- a/tapchannel/aux_invoice_manager.go +++ b/tapchannel/aux_invoice_manager.go @@ -5,7 +5,6 @@ import ( "fmt" "sync" - "github.com/davecgh/go-spew/spew" "github.com/lightninglabs/lndclient" "github.com/lightninglabs/taproot-assets/address" "github.com/lightninglabs/taproot-assets/fn" @@ -254,7 +253,8 @@ func (s *AuxInvoiceManager) priceFromQuote(rfqID rfqmsg.ID) ( acceptedSellQuotes := s.cfg.RfqManager.LocalAcceptedSellQuotes() log.Tracef("Currently available quotes: buy %v, sell %v", - spew.Sdump(acceptedBuyQuotes), spew.Sdump(acceptedSellQuotes)) + limitSpewer.Sdump(acceptedBuyQuotes), + limitSpewer.Sdump(acceptedSellQuotes)) buyQuote, isBuy := acceptedBuyQuotes[rfqID.Scid()] sellQuote, isSell := acceptedSellQuotes[rfqID.Scid()] diff --git a/tapchannel/aux_leaf_signer.go b/tapchannel/aux_leaf_signer.go index da0742409..f728b1ec4 100644 --- a/tapchannel/aux_leaf_signer.go +++ b/tapchannel/aux_leaf_signer.go @@ -9,7 +9,6 @@ import ( "github.com/btcsuite/btcd/btcutil/psbt" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightninglabs/taproot-assets/address" "github.com/lightninglabs/taproot-assets/asset" "github.com/lightninglabs/taproot-assets/commitment" @@ -649,7 +648,7 @@ func (v *schnorrSigValidator) ValidateWitnesses(newAsset *asset.Asset, if !ok { return fmt.Errorf("%w: no prev asset for "+ "input_prev_id=%v", vm.ErrNoInputs, - spew.Sdump(witness.PrevID)) + limitSpewer.Sdump(witness.PrevID)) } var ( diff --git a/tapchannel/aux_sweeper.go b/tapchannel/aux_sweeper.go index 34985c0ce..27c32639a 100644 --- a/tapchannel/aux_sweeper.go +++ b/tapchannel/aux_sweeper.go @@ -15,7 +15,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightninglabs/taproot-assets/address" "github.com/lightninglabs/taproot-assets/asset" "github.com/lightninglabs/taproot-assets/fn" @@ -370,7 +369,7 @@ func (a *AuxSweeper) signSweepVpackets(vPackets []*tappsbt.VPacket, vIn.TaprootLeafScript[0].ControlBlock = ctrlBlock log.Debugf("signing vPacket for input=%v", - spew.Sdump(vIn.PrevID)) + limitSpewer.Sdump(vIn.PrevID)) // With everything set, we can now sign the new leaf we'll // sweep into. @@ -1228,7 +1227,7 @@ func (a *AuxSweeper) importCommitScriptKeys(req lnwallet.ResolutionReq) error { return fmt.Errorf("unknown close type: %v", req.CloseType) } - log.Debugf("Importing script_keys=%v", spew.Sdump(keysToImport)) + log.Debugf("Importing script_keys=%v", limitSpewer.Sdump(keysToImport)) ctxb := context.Background() for _, key := range keysToImport { @@ -1261,7 +1260,8 @@ func (a *AuxSweeper) importOutputScriptKeys(desc tapscriptSweepDescs) error { }, } - log.Debugf("Importing script_keys=%v", spew.Sdump(scriptKey)) + log.Debugf("Importing script_keys=%v", + limitSpewer.Sdump(scriptKey)) return a.cfg.AddrBook.InsertScriptKey(ctxb, scriptKey, true) } @@ -1320,7 +1320,7 @@ func importOutputProofs(scid lnwire.ShortChannelID, } log.Infof("Fetching funding input proof, locator=%v", - spew.Sdump(inputProofLocator)) + limitSpewer.Sdump(inputProofLocator)) // First, we'll make a courier to use in fetching the proofs we // need. @@ -1353,7 +1353,7 @@ func importOutputProofs(scid lnwire.ShortChannelID, } log.Infof("All proofs fetched, importing locator=%v", - spew.Sdump(inputProofLocator)) + limitSpewer.Sdump(inputProofLocator)) // Before we combine the proofs below, we'll be sure to update // the transition proof to include the proper block+merkle proof @@ -1828,7 +1828,8 @@ func (a *AuxSweeper) resolveContract( } log.Infof("Sweeping %v asset outputs (second_level=%v): %v", - len(assetOutputs), needsSecondLevel, spew.Sdump(assetOutputs)) + len(assetOutputs), needsSecondLevel, + limitSpewer.Sdump(assetOutputs)) // With the sweep desc constructed above, we'll create vPackets for each // of the local assets, then sign them all. @@ -2281,7 +2282,8 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest, // TODO(roasbeef): need to handle replacement -- will porter just // upsert in place? - log.Infof("Register broadcast of sweep_tx=%v", spew.Sdump(sweepTx)) + log.Infof("Register broadcast of sweep_tx=%v", + limitSpewer.Sdump(sweepTx)) // In order to properly register the sweep, we'll need to first extra a // unified set of vPackets from the specified inputs. @@ -2441,7 +2443,8 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest, } } - log.Infof("Proofs generated for sweep_tx=%v", spew.Sdump(sweepTx)) + log.Infof("Proofs generated for sweep_tx=%v", + limitSpewer.Sdump(sweepTx)) // With the output commitments re-created, we have all we need to log // and ship the transaction.