-
Notifications
You must be signed in to change notification settings - Fork 123
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
Conversation
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.
Pull Request Test Coverage Report for Build 13019619266Details
💛 - Coveralls |
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.
LGTM 🐧
MetaDataHash []byte | ||
MetaDataType sql.NullInt16 | ||
MetaDataBlob []byte | ||
AssetsMetum AssetsMetum |
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.
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) { |
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.
IIUC this was in place to not mutate the meta reveal receiver here. AFAICT, was mainly a defensive precaution.
Extracted refactor and standalone fixes from #1335 so we can get them in earlier.