-
Notifications
You must be signed in to change notification settings - Fork 132
Proof-system-v1 #1453
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
base: main
Are you sure you want to change the base?
Proof-system-v1 #1453
Conversation
Pull Request Test Coverage Report for Build 15070461131Details
💛 - Coveralls |
4eef445
to
f65456c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, this looks pretty good 🎉
Have a couple of suggestions, after which we can probably take this out of draft.
@@ -2026,15 +2038,6 @@ func ValidateAnchorInputs(anchorPacket *psbt.Packet, packets []*tappsbt.VPacket, | |||
) | |||
} | |||
|
|||
// Each input must have a valid set of AltLeaves at this point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there might've already been alt leaves in the vPacket, should we still validate them? Or is this added back in another place in another commit? Still going through the diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I follow. This is a sanity check that makes sure we have at least a valid set of AltLeaves
. If we don't have them here during ValidateAnchorInputs
we can fail early.
Yes, we do check them during FundPacket
as well, so it should not be possible to have invalid AltLEaves
at this point in the code, but it doesn't hurt to check here. Also, future flows might be different and warrant a check here even more.
9c4d5c9
to
0055fb3
Compare
0055fb3
to
7af5271
Compare
7af5271
to
e0e4bf8
Compare
e0e4bf8
to
c971e08
Compare
Extracted some commits into #1465 to ease review on this one. Pushed up a rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did another pass. Definitely looks better, but I think we still need an iteration on the core verification logic, to make it easier to understand.
c971e08
to
da7b212
Compare
171f7ae
to
c8a7971
Compare
Sorry, I don't think I made things easier for you as an author by splitting the PR into two. And now I noticed that the commit c9b1d54 does need to go into this one instead... |
da7b212
to
6badb61
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a clean review, focusing on the tests in particular. Feels like we're pretty close.
The linter is failing, and also the unit tests panic as one of the test cases is incomplete:
--- FAIL: TestVerifyV1ExclusionProof (0.12s)
--- FAIL: TestVerifyV1ExclusionProof/multiple_assets_with_an_exclusion_proof_each (0.00s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 25 of 25 files at r1, 28 of 28 files at r2, 9 of 9 files at r3, all commit messages.
Reviewable status: all files reviewed, 61 unresolved discussions (waiting on @gijswijs and @guggero)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a single fixup commit that adds more unit tests (and also uncovered a small bug that is fixed too). Feel free to check and apply that commit directly (not attribution required).
Other than that only nits are left in the code (which I didn't fix, I leave that to you).
The litd itest failure is related to the changes here though:
error funding channel: unable to bind PSBT: rpc error: code = Unknown desc = error verifying PSBT: funding output not found in PSBT
So I'll need to take a look into that. But hopefully it's something small (will take a closer look tomorrow).
81c690e
to
2bc57a2
Compare
I think what's missing is that we need to mind the alt leaves when we manually create the funding output our selves. |
Yeah, I got everything to work today. Now I'm just making sure this doesn't introduce another backward incompatibility vector. |
Because we retrieve AltLeaves from the proof during anchor input validation, we don't need to store them in the vInputs struct. This commit removes the AltLeaves field from the vInputs struct and the associated methods.
Since we're only ever passing nil (and we use the previous witness in the script/burn key), we just remove the witness parameter completely.
This commit stores the STXOs in the output commitments using AltLeaves.
This commit adds a new field to the CommitmentProof struct that will house STXO proofs. We also add encoding/decoding functions for that new sub type and update the test vectors accordingly.
Co-authored-by: Gijs van Dam <gijs@lightning.engineering>
Instead of using alt leaves from the inputs, we use the alt leaves from the proof. We also remove the deduplication func `AddLeafKeysVerifyMerge` because it's not needed anymore.
This commit adds the STXO exclusion proof to the proof parameters. It stores them in `params.ExclusionProofs[].CommitmentProof.STXOProofs[]` where they are later encoded when creating the actual proofs.
The proof version is bumped to indicate the usage and support of stxo style proofs.
`verifyExclusionProofs` now checks if the stxo exclusion proofs are present in the `ExclusionProofs[idx].CommitmentProof` and if so will verify those in preference of the old style proofs.
This commit adds an itest that test whether the stxo exclusion proof is added to the proof suffix and whether the proof is actually a valid exclusion proof for the minimal asset we expect to see in the stxo set.
This commit adds v1 inclusion proof verification.
Since we now produce STXO commitments in certain situations, it makes sense to update the test vectors that are produced from a regtest itest run and are therefore not deterministic.
This commit moves the split commit witness trimming into the addToFundingCommitment and then use that function in both places where we create a commitment from assets during the channel funding process.
To avoid breaking backward compatibility with older nodes and existing channels, we need to make sure we don't add STXO proofs to channel related transactions.
I've pushed up a set of changes that make everything backward compatible. What we decided to do in this PR is the following:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the above comment and a (hopefully) green CI, I approve this PR. Great work, super happy to finally see this getting over the finish line.
This pull request introduces several enhancements and refactors related to inclusion and exclusion proof handling. The key changes include:
AltLeaves
.proof/verifier.go
Considerations
multi: remove AssertInputsUnique
. Although with this proof system we are able to parse a proof for non-unique inputs, older nodes cannot. So for now this check should probably remain in place.This change is