-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add proof type to universe identifer #540
Conversation
e00273b
to
f8eb8f7
Compare
universe/interface.go
Outdated
@@ -92,6 +92,27 @@ func (i *Identifier) StringForLog() string { | |||
i.MsSmtNamespace(), i.AssetID[:], groupKey, i.ProofType) | |||
} | |||
|
|||
// ValidateProofUniverseType validates that the proof type matches the universe | |||
// identifier proof type. | |||
func ValidateProofUniverseType(proof proof.Proof, uniID Identifier) 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.
Should add some unit + itests for this.
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've added a unit test for this. ValidateProofUniverseType
is already covered in itests for the positive case. Should I add more on the itest front for this PR?
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 quick first pass, changes make sense, nice work!
7b813c1
to
5557ce6
Compare
e224f9d
to
9478962
Compare
|
||
-- This field is an enum representing the proof type stored in the given | ||
-- universe. | ||
proof_type TEXT NOT NULL CHECK(proof_type IN ('issuance', 'transfer')) |
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.
Also IIUC, namespace_root
now also includes this as a prefix. May want to update some of the comments in the schema file.
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.
Right now, the schema doesn't explain what's in namespace_root
:
-- For the namespace root, we set the foreign key constraint evaluation to
-- be deferred until after the database transaction ends. Otherwise, if the
-- root of the SMT is deleted temporarily before inserting a new root, then
-- this constraint is violated as there's no longer a root that this
-- universe tree can point to.
namespace_root VARCHAR UNIQUE NOT NULL REFERENCES mssmt_roots(namespace) DEFERRABLE INITIALLY DEFERRED,
// The target proof type was unspecified. Assume that the proof | ||
// type is a transfer proof (more transfer proofs exist then | ||
// issuance proofs). | ||
universeID.ProofType = universe.ProofTypeTransfer |
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.
Hmm, maybe we should just return an error in this case? Otherwise if they want issuance, then we error out?
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.
The caller (client calling QueryProof
) may not know if the proof they're querying for is a transfer or issuance proof. The universe RPC proof courier is one such caller. And the caller shouldn't need to specify the proof type. Proof type specification only helps the server figure out where the proof is stored. In other words, the client already provides the necessary args for proof identification.
|
||
// The proof type was originally unspecified by the client. We | ||
// will therefore try again with the other proof type. | ||
switch universeID.ProofType { |
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.
Ah ok, I see the switcheroo here.
I do wonder if we should just hide this one layer deeper, so at the layer right above the db where methods like FetchIssuanceProof
are implemented.
// Construct universe namespace. | ||
proofType, err := tap.UnmarshalUniProofType(newRoot.Id.ProofType) | ||
require.NoError(t.t, err) | ||
uniNamespace := fmt.Sprintf("%s-%s", proofType, uniKey) |
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.
Hmm, still thinking about if we want to also manifest the prefix on this level, which arguably could/should just be something internal.
I think will get a better feel of how it all looks on the CLI.
9478962
to
641fd47
Compare
b1c6588
to
3ab1c01
Compare
@Roasbeef @guggero There are universe events stats changes that we need following the addition of the proof type to the universe identifier. I'll open a new PR (based on this PR) to address those changes. I would prefer not to block this PR on those changes so that we can merge this PR and #537 EDIT: PR to address universe event stats changes: #561 |
This needs a fixup rebase before it's merged. |
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.
Needs a rebase as mentioned. Other than that only two (very optional/non-blocking) nits, so LGTM 💯
28e4a6b
to
dbafc97
Compare
This method returns true if the asset is a genesis asset.
6bb6a33
to
b2d27d6
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.
LGTM 🎎
Towards the end result of two separate universe trees for each asset/asset group. One tree for issuance proofs and one for transfer proofs.