Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@
approach. Benchmarks show a ~7x speedup for files with many unique
headers.

- [PR#2045](https://github.com/lightninglabs/taproot-assets/pull/2045)
Added a raw proof append path that appends pre-encoded proofs directly to an
encoded proof file blob in space, plus benchmark coverage for append
performance.

## Deprecations

# Technical and Architectural Updates
Expand Down
8 changes: 5 additions & 3 deletions itest/custom_channels/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2550,9 +2550,11 @@ func locateAssetTransfers(t *testing.T, node *itest.IntegratedNode,

transfer = forceCloseTransfer.Transfers[0]

if transfer.AnchorTxBlockHash == nil {
return fmt.Errorf("missing anchor block hash, " +
"transfer not confirmed")
// Transfer confirmation metadata is persisted
// asynchronously after block inclusion, so wait
// until the transfer is marked as confirmed.
if transfer.AnchorTxBlockHeight == 0 {
return fmt.Errorf("transfer not confirmed")
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions itest/custom_channels/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var (
ccShortTimeout = time.Second * 10

// ccTransferTimeout is the timeout used when waiting for an asset
// transfer to appear as confirmed. On CI runners with multiple
// parallel tranches, tapd block processing can be slow so we use a
// generous timeout.
ccTransferTimeout = 2 * time.Minute
// transfer to appear as confirmed. On CI runners with many parallel
// tranches, anchor confirmation bookkeeping can lag block mining, so
// we keep this timeout generous.
ccTransferTimeout = 4 * time.Minute
)

// lndArgsTemplate contains lnd flags used by all custom channel test nodes.
Expand Down
55 changes: 33 additions & 22 deletions proof/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,13 @@ type TransitionParams struct {
func AppendTransition(blob Blob, params *TransitionParams, vCtx VerifierCtx,
opts ...GenOption) (Blob, *Proof, error) {

// Decode the proof blob into a proper file structure first.
f := NewEmptyFile(V0)
if err := f.Decode(bytes.NewReader(blob)); err != nil {
return nil, nil, fmt.Errorf("error decoding proof file: %w",
err)
}

// Cannot add a transition to an empty proof file.
if f.IsEmpty() {
return nil, nil, fmt.Errorf("invalid empty proof file")
}

lastProof, err := f.LastProof()
// Read only the last proof from the blob to obtain the previous
// outpoint and append metadata, while avoiding allocation of the full
// proof chain.
lastProof, _, appendHint, err := lastProofFromBlobWithHint(blob)
if err != nil {
return nil, nil, fmt.Errorf("error fetching last proof: %w",
err)
return nil, nil, fmt.Errorf("error reading last proof from "+
"blob: %w", err)
}

lastPrevOut := wire.OutPoint{
Expand All @@ -114,9 +105,20 @@ func AppendTransition(blob Blob, params *TransitionParams, vCtx VerifierCtx,
"proof: %w", err)
}

// Before we encode and return the proof, we want to validate it. For
// that we need to start at the beginning.
// Before we return the proof we want to validate the full chain. For
// that we still need to decode the entire file into memory.
ctx := context.Background()

f := NewEmptyFile(V0)
if err := f.Decode(bytes.NewReader(blob)); err != nil {
return nil, nil, fmt.Errorf("error decoding proof file: %w",
err)
}

if f.IsEmpty() {
return nil, nil, fmt.Errorf("invalid empty proof file")
}

if err := f.AppendProof(*newProof); err != nil {
return nil, nil, fmt.Errorf("error appending proof: %w", err)
}
Expand All @@ -126,14 +128,23 @@ func AppendTransition(blob Blob, params *TransitionParams, vCtx VerifierCtx,
return nil, nil, fmt.Errorf("error verifying proof: %w", err)
}

// Encode the full file again, with the new proof appended.
var buf bytes.Buffer
if err := f.Encode(&buf); err != nil {
return nil, nil, fmt.Errorf("error encoding proof file: %w",
// Encode the new proof bytes so we can use the streaming append to
// avoid re-encoding the entire file.
newProofBytes, err := newProof.Bytes()
if err != nil {
return nil, nil, fmt.Errorf("error encoding new proof: %w",
err)
}

result, err := appendRawProofToBlobWithHint(
blob, newProofBytes, appendHint,
)
if err != nil {
return nil, nil, fmt.Errorf("error appending proof to blob: %w",
err)
}

return buf.Bytes(), newProof, nil
return result, newProof, nil
}

// UpdateTransitionProof computes a new transaction merkle proof from the given
Expand Down
Loading
Loading