Skip to content
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

Use even/odd TLV numbers everywhere #547

Merged
merged 7 commits into from
Oct 9, 2023
Merged

Use even/odd TLV numbers everywhere #547

merged 7 commits into from
Oct 9, 2023

Conversation

guggero
Copy link
Member

@guggero guggero commented Oct 4, 2023

Definitely and finally closes #347.

Corresponding BIP PR is here: Roasbeef/bips#43

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just a few areas for discussion re if they should be even or odd.

asset/records.go Show resolved Hide resolved
WitnessSplitCommitment WitnessTlvType = 2
WitnessPrevID WitnessTlvType = 1
WitnessTxWitness WitnessTlvType = 3
WitnessSplitCommitment WitnessTlvType = 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only one amongst them that should be odd?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, both the PrevID and TxWitness fields have an explicit check in EncodeRecords:

if w.PrevID != nil {

I guess if we declare PrevID as required, it would no longer need to be a pointer? Not sure how to decide what to take as the source of truth for the decision: our current implementation or the fact that it should in practice never be empty...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, its the ZeroPrevID in both forms of the genesis witness, and the VM already fails if its nil. In favor of promoting to not-pointer.

TxWitness is fine as-is though IIUC should only be empty for genesis assets.

commitment/records.go Show resolved Hide resolved
AnchorTxType tlv.Type = 6
TxMerkleProofType tlv.Type = 8
AssetLeafType tlv.Type = 10
InclusionProofType tlv.Type = 12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we even odd that we could do here is actually assign in pairs. We do this for feature bits in LN so we can flip them to required if needed.

In this case, we would have ExclusionProofsType actually be 15.

Not sure if this is useful though?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Yes, that could be nice so we could turn things on/off when it comes to being required. Happy to do the change if you think we should. But then I'd say we should update the address records as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't feel super strongly about this, as in the future if we wish we can use a new version to redo all the types. So far we don't have a concrete need for this as is though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, me neither... So I guess let's keep it the way they are now?

@jharveyb
Copy link
Collaborator

jharveyb commented Oct 5, 2023

Change in proof/records.go in commit 2 can be dropped, or merged with commit 3 changes? We update it again later on anyways.

Now that we have proper test vectors that we can update automatically,
we no longer need the hard coded single test case in the asset.hex file.
Now that we have proper test vectors that can be updated automatically,
we no longer need the hard coded single test cases in the psbt.b64 and
psbt.hex files.
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 📣

AnchorTxType tlv.Type = 6
TxMerkleProofType tlv.Type = 8
AssetLeafType tlv.Type = 10
InclusionProofType tlv.Type = 12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't feel super strongly about this, as in the future if we wish we can use a new version to redo all the types. So far we don't have a concrete need for this as is though.

@Roasbeef
Copy link
Member

Roasbeef commented Oct 7, 2023

Lost track of if was this PR or another, but: I think we can pull out the changes to the restriction/validation of the meta field into another PR.

@guggero
Copy link
Member Author

guggero commented Oct 9, 2023

Lost track of if was this PR or another, but: I think we can pull out the changes to the restriction/validation of the meta field into another PR.

I think what you mean was in #525, which was merged by now.

Copy link
Collaborator

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have this sorted 💯

@guggero guggero added this pull request to the merge queue Oct 9, 2023
Merged via the queue into main with commit 3944965 Oct 9, 2023
14 checks passed
@guggero guggero deleted the tlv-re-numbering branch October 9, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Add comprehensive versioning to all protocol elements and even/odd compliance structure
3 participants