Skip to content

Commit

Permalink
tapchannel: use limit spewer only
Browse files Browse the repository at this point in the history
This fixes an issue of an infinite loop when attempting to spew a proof
structure.
  • Loading branch information
guggero authored and Roasbeef committed Nov 20, 2024
1 parent 9000263 commit ab71028
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
6 changes: 3 additions & 3 deletions tapchannel/aux_closer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
20 changes: 11 additions & 9 deletions tapchannel/aux_funding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tapchannel/aux_invoice_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()]
Expand Down
3 changes: 1 addition & 2 deletions tapchannel/aux_leaf_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 (
Expand Down
21 changes: 12 additions & 9 deletions tapchannel/aux_sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -375,7 +374,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.
Expand Down Expand Up @@ -1235,7 +1234,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 {
Expand Down Expand Up @@ -1268,7 +1267,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)
}
Expand Down Expand Up @@ -1327,7 +1327,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.
Expand Down Expand Up @@ -1360,7 +1360,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
Expand Down Expand Up @@ -1832,7 +1832,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.
Expand Down Expand Up @@ -2270,7 +2271,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.
Expand Down Expand Up @@ -2431,7 +2433,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.
Expand Down

0 comments on commit ab71028

Please sign in to comment.