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

proof+tapdb: refactor and fix TLV unknown odd types bug for backward compatibility #1337

Merged
merged 5 commits into from
Jan 29, 2025

Conversation

guggero
Copy link
Member

@guggero guggero commented Jan 28, 2025

Extracted refactor and standalone fixes from #1335 so we can get them in earlier.

This commit makes use of the sqlc.embed() directive that allows for
re-usable structs, which makes parsing with dedicated functions easier.
To avoid circular package dependencies in the next commits, we move the
URLDecoder and URLEncoder functions from the address to the asset
package. That way we'll be able to also use it from the proof package.
No point in returning a new meta, we can just allow setting the decimal
display on the struct directly.
This fixes a "tlv stream is not canonical" error when calculating the
meta hash of a meta reveal that has multiple unknown odd types that was
caused by the map iterating over the types in a random order.
To make such an error more apparent in the future, we log it when it
occurs.
This unfortunately means that our unknown odd types won't be fully
backward compatible to v0.5.0 but only v0.5.1...
With this commit we add a new test file that will just read the test
vectors and make sure they can be parsed and validated with the current
version.
The idea is that in the future we create a CI step that takes this
backward_compat_test.go file and all test vector files, then copy them
into a cloned directory of an older version of tapd we want to verify
them against.

Because of the fix in the commit right before this one, we can't
actually do this yet... But we should achieve unknown odd type backward
compatibility with v0.5.1-rc2 and later.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13019619266

Details

  • 64 of 110 (58.18%) changed or added relevant lines in 12 files are covered.
  • 43 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+0.03%) to 40.738%

Changes Missing Coverage Covered Lines Changed/Added Lines %
itest/assertions.go 0 1 0.0%
itest/utils.go 0 1 0.0%
rpcserver.go 0 1 0.0%
tapdb/asset_meta.go 6 8 75.0%
tapdb/asset_minting.go 14 16 87.5%
asset/records.go 19 25 76.0%
tapdb/sqlc/assets.sql.go 20 26 76.92%
tapdb/addrs.go 0 8 0.0%
proof/meta.go 2 21 9.52%
Files with Coverage Reduction New Missed Lines %
proof/meta.go 1 46.96%
tappsbt/create.go 2 53.22%
asset/asset.go 2 76.94%
fn/option.go 3 46.39%
tapdb/multiverse.go 6 68.21%
asset/mock.go 6 91.25%
commitment/tap.go 7 83.86%
universe/interface.go 8 53.68%
tapgarden/caretaker.go 8 68.49%
Totals Coverage Status
Change from base Build 13019050511: 0.03%
Covered Lines: 26773
Relevant Lines: 65720

💛 - Coveralls

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 🐧

MetaDataHash []byte
MetaDataType sql.NullInt16
MetaDataBlob []byte
AssetsMetum AssetsMetum
Copy link
Member

Choose a reason for hiding this comment

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

Very cool, weird how it mangles the name here tho...

@@ -306,59 +305,39 @@ func (m *MetaReveal) DecDisplayOption() (fn.Option[uint32], error) {

// SetDecDisplay attempts to set the decimal display value in existing JSON
// metadata. It checks that the new metadata is below the maximum metadata size.
func (m *MetaReveal) SetDecDisplay(decDisplay uint32) (*MetaReveal, error) {
Copy link
Member

Choose a reason for hiding this comment

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

IIUC this was in place to not mutate the meta reveal receiver here. AFAICT, was mainly a defensive precaution.

@Roasbeef Roasbeef merged commit 490a1f6 into main Jan 29, 2025
18 checks passed
@guggero guggero deleted the tlv-refactor-fixes branch January 29, 2025 08:40
@guggero guggero restored the tlv-refactor-fixes branch January 29, 2025 08:41
@guggero guggero deleted the tlv-refactor-fixes branch January 29, 2025 08:41
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.

3 participants