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

Add proof type to universe identifer #540

Merged
merged 19 commits into from
Oct 11, 2023
Merged

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Oct 3, 2023

Towards the end result of two separate universe trees for each asset/asset group. One tree for issuance proofs and one for transfer proofs.

@ffranr ffranr force-pushed the uni-namespace-proof-type branch 2 times, most recently from e00273b to f8eb8f7 Compare October 3, 2023 18:07
universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Outdated Show resolved Hide resolved
@@ -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 {
Copy link
Member

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.

Copy link
Contributor Author

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?

@guggero guggero self-requested a review October 4, 2023 07:57
Copy link
Member

@guggero guggero left a 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!

universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Outdated Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
@ffranr ffranr force-pushed the uni-namespace-proof-type branch 2 times, most recently from 7b813c1 to 5557ce6 Compare October 5, 2023 15:52
@ffranr ffranr self-assigned this Oct 6, 2023
@ffranr ffranr force-pushed the uni-namespace-proof-type branch 2 times, most recently from e224f9d to 9478962 Compare October 6, 2023 19:53
universe/interface.go Outdated Show resolved Hide resolved
universe/interface.go Show resolved Hide resolved
universe/base.go Show resolved Hide resolved
universe/base.go Show resolved Hide resolved

-- 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'))
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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.

itest/assertions.go Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
// Construct universe namespace.
proofType, err := tap.UnmarshalUniProofType(newRoot.Id.ProofType)
require.NoError(t.t, err)
uniNamespace := fmt.Sprintf("%s-%s", proofType, uniKey)
Copy link
Member

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.

@ffranr
Copy link
Contributor Author

ffranr commented Oct 11, 2023

@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

@ffranr
Copy link
Contributor Author

ffranr commented Oct 11, 2023

This needs a fixup rebase before it's merged.

Copy link
Member

@guggero guggero left a 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 💯

rpcserver.go Outdated Show resolved Hide resolved
asset/asset.go Show resolved Hide resolved
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 🎎

@Roasbeef Roasbeef merged commit 951c80e into main Oct 11, 2023
14 checks passed
@guggero guggero deleted the uni-namespace-proof-type branch October 11, 2023 21: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.

universe: switch to 128-bit limbs for multiverse leaves or switch to top-level counter sum
3 participants