-
Notifications
You must be signed in to change notification settings - Fork 143
tapgarden: large scale hardening #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jtobin
wants to merge
50
commits into
lightninglabs:main
Choose a base branch
from
jtobin:tapgarden-hardening
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
edd9646
tapgarden+tapdb: collapse batch-state two-truth dualism
jtobin 8bc4718
tapdb: pin batch-state memory-coherence invariant via test
jtobin f372862
tapgarden: split fundBatch into create vs. apply
jtobin eccd3a6
tapgarden: persist seedlings before mirroring them in-memory
jtobin 23a6f0a
tapgarden: pin validateSeedling/commitSeedling split via test
jtobin f527173
tapgarden: find the unique anchor seedling deterministically
jtobin f0b3a13
tapgarden: pin uniqueAnchorSeedling contract via test
jtobin 8cb33b7
tapgarden: drop MintingOutputKey cache; make it pure in its sibling
jtobin 5fd3049
tapgarden: pin MintingOutputKey purity-in-sibling contract
jtobin c6fd14f
tapdb: enforce singleton pre-broadcast minting batch invariant
jtobin 6013b76
tapgarden: enforce + recover from singleton batch invariant
jtobin d71b181
tapd: add --repair.cancel-duplicate-batches recovery flag
jtobin 2dd3d05
tapdb: dedupe supply_update_events via content hash
jtobin a1fd507
tapgarden: import minting output before persisting Broadcast state
jtobin 022f4f2
itest: pin SignAndFinalizePsbt determinism
jtobin 5a24c83
tapgarden: add rapid restart-recovery property test for caretaker
jtobin 2a5590b
tapgarden: make MintingBatch.Copy actually deep
jtobin 5899008
tapgarden: cap rapid harness iterations to 30 by default
jtobin 4970ca6
tapgarden: bind cancel responses to their request
jtobin 1a4a212
tapgarden: snapshot caretaker batch before returning to caller
jtobin 0aa5254
tapgarden: harden caretaker anchor-index and cancel-reader invariants
jtobin 8e37cb7
tapgarden: make caretaker completion send abandonable on shutdown
jtobin 23cd262
tapdb: roll back empty supply commit transitions on event dedup
jtobin 560c6fe
tapnode: hoist node-side interfaces out of tapgarden
jtobin cd2ea67
tapgarden: preserve empty-vs-nil distinction in copyMetaReveal
jtobin 3321d77
tapnode/tapnodemock: hoist node-side mocks out of tapgarden
jtobin 7f16beb
tapreorg: extract re-org watcher into its own package
jtobin 17da882
tapcustody: extract custodian into its own package
jtobin 3b6148a
tapgarden: collapse state-request plumbing into typed closures
jtobin 4fe5ad1
asset+proof: hoist deep-copy helpers to their proper types
jtobin 7b113a5
tapgarden: split MintingStore into BatchStore and MintingRefReader
jtobin f0c50cc
tapgarden: share GardenKit between planter and caretaker
jtobin a39b9d5
tapgarden: return VerboseBatch directly from FundBatch
jtobin e9b486b
tapgarden: drop MintingState enum and SeedlingUpdate.NewState
jtobin 023f011
tapgarden: rename BatchCaretaker to Cultivator
jtobin 3f7ca95
tapgarden: name PendingAssetGroup's parts
jtobin 37e2aff
tapgarden: collapse AssetMintEvent.BatchState into Batch.State()
jtobin 20bdf69
tapgarden: document UpdateTapSibling's BatchStore-only contract
jtobin caee246
tapgarden: drop the Planter interface
jtobin 4ad39fd
tapgarden+tapdb: thread typed PreCommitBindData through binding API
jtobin e0fcf0b
tapdb: extract SupplyPreCommitStore as supply-commit's read gateway
jtobin 3b69a9e
tapgarden+supplycommit: add GenesisTxAugmenter interface + impl
jtobin 7cc26c2
tapgarden: route batch minting through GenesisTxAugmenter
jtobin 8d5e686
tapgarden: delete supply-commit accidents now subsumed by augmenter
jtobin 3b47f5d
itest+supplyverifier: drop unused tapgarden imports
jtobin c54c13a
tapnode: move group verifier generators out of tapgarden
jtobin 785423d
tapgarden+universe: extract universe publication via MintProofPublisher
jtobin bed9f08
docs: add release note
jtobin 8c29974
tapdb: dedupe legacy duplicate events during migration 62 backfill
jtobin f21a6d7
tapgarden+tapdb: misc review fixes, plus lint
jtobin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package itest | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
|
|
||
| "github.com/btcsuite/btcd/btcutil" | ||
| "github.com/btcsuite/btcd/btcutil/psbt" | ||
| "github.com/btcsuite/btcd/txscript" | ||
| "github.com/btcsuite/btcd/wire" | ||
| "github.com/lightninglabs/taproot-assets/lndservices" | ||
| "github.com/lightningnetwork/lnd/lnwallet/chainfee" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // testSignAndFinalizePsbtDeterministic pins the assumption that | ||
| // Wallet.SignAndFinalizePsbt produces byte-identical output when invoked | ||
| // twice on the same unsigned PSBT. The minting caretaker's Committed | ||
| // branch relies on this on restart: a crash after sign-and-finalize but | ||
| // before persisting the signed PSBT causes the next run to re-sign the | ||
| // same unsigned PSBT loaded from disk, and we expect the resulting | ||
| // signed bytes to match. lnd uses BIP-340 RFC-6979 deterministic | ||
| // Schnorr nonces, so this should hold, but it is load-bearing for | ||
| // idempotent restart semantics and worth verifying directly. | ||
| func testSignAndFinalizePsbtDeterministic(t *harnessTest) { | ||
| ctxb := context.Background() | ||
| ctx, cancel := context.WithCancel(ctxb) | ||
| defer cancel() | ||
|
|
||
| lndClient, err := t.newLndClient(t.tapd.cfg.LndNode) | ||
| require.NoError(t.t, err) | ||
| defer lndClient.Close() | ||
|
|
||
| walletAnchor := lndservices.NewLndRpcWalletAnchor( | ||
| &lndClient.LndServices, | ||
| ) | ||
|
|
||
| // Build a minimal unsigned tx with one P2TR-shaped dummy output; | ||
| // lnd will fund it by adding a wallet input and a change output. | ||
| dummyScript := append( | ||
| []byte{txscript.OP_1, txscript.OP_DATA_32}, | ||
| bytes.Repeat([]byte{0x00}, 32)..., | ||
| ) | ||
| tx := wire.NewMsgTx(2) | ||
| tx.AddTxOut(&wire.TxOut{ | ||
| Value: int64(btcutil.Amount(1000)), | ||
| PkScript: dummyScript, | ||
| }) | ||
|
|
||
| unsignedPkt, err := psbt.NewFromUnsignedTx(tx) | ||
| require.NoError(t.t, err) | ||
|
|
||
| fundedPkt, err := walletAnchor.FundPsbt( | ||
| ctx, unsignedPkt, 1, chainfee.SatPerKWeight(3000), -1, | ||
| ) | ||
| require.NoError(t.t, err) | ||
|
|
||
| // SignAndFinalizePsbt mutates the input, so each call gets its | ||
| // own deep-cloned copy of the unsigned-but-funded PSBT. Round- | ||
| // tripping through Serialize/NewFromRawBytes is the cleanest way | ||
| // to get an independent value. | ||
| clonePsbt := func(p *psbt.Packet) *psbt.Packet { | ||
| var buf bytes.Buffer | ||
| require.NoError(t.t, p.Serialize(&buf)) | ||
| clone, err := psbt.NewFromRawBytes( | ||
| bytes.NewReader(buf.Bytes()), false, | ||
| ) | ||
| require.NoError(t.t, err) | ||
| return clone | ||
| } | ||
|
|
||
| signed1, err := walletAnchor.SignAndFinalizePsbt( | ||
| ctx, clonePsbt(fundedPkt.Pkt), | ||
| ) | ||
| require.NoError(t.t, err) | ||
|
|
||
| signed2, err := walletAnchor.SignAndFinalizePsbt( | ||
| ctx, clonePsbt(fundedPkt.Pkt), | ||
| ) | ||
| require.NoError(t.t, err) | ||
|
|
||
| var buf1, buf2 bytes.Buffer | ||
| require.NoError(t.t, signed1.Serialize(&buf1)) | ||
| require.NoError(t.t, signed2.Serialize(&buf2)) | ||
|
|
||
| require.Equal(t.t, buf1.Bytes(), buf2.Bytes(), | ||
| "SignAndFinalizePsbt must produce byte-identical output "+ | ||
| "for the same unsigned input; the minting caretaker "+ | ||
| "restart path relies on this") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.