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

fix: collection hash indexing #104

Merged
merged 3 commits into from
Jul 27, 2023
Merged

Conversation

NicolasPennie
Copy link

Overview

  • DRAFT: DO NOT MERGE
  • Depends on fix: collection hash indexing blockbuster#2
  • Still testing out to ensure that the leaf hash is correct (see comments). Testing with the following devnet txn 5ZKjPxm3WAZzuqqkCDjgKpm9b5XjB9cuvv68JvXxWThvJaJxcMJgpSbYs4gDA9dGJyeLzsgNtnS6oubANF1KbBm" for asset 2WjoMU1hBGXv8sKcxQDGnu1tgMduzdZEmEEGjh8MZYfC. This txn sets and verifies a collection for a cNFT that does not have a collection.
  • I also tested with devnet txn 7nK9a2DSDZ4Gh6DatmxGJmuLiDEswaY9bYSSPTtQppk7PtLKXYE84jWzm7AC4G1fpa831GaXuXcn5n5ybWqB4e5 and asset 2gEbvG3Cb6JRaGWAx5e85Bf5z4u37EURBeyPBqXDzZoY. This txn unverifies a cNFT with a verified collection.

Testing

  • In progress

Comment on lines +134 to +136
// TODO: Support collection unverification.
// We will likely need to nullify the collection field so we can maintain
// the seq value and avoid out-of-order indexing bugs.
Copy link

@danenbm danenbm Jul 26, 2023

Choose a reason for hiding this comment

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

I originally was thinking along this route but ended up just adding a verified field the asset_grouping table, and then changing the Read API calls to filter on Verified.eq(true). I did that because it is more consistent with the asset_creators table approach and the contract does in fact have the concept of verify so it made sense to me.

Maybe after your change to blockbuster, I would not need a separate sequence number because i could update collection and slot_updated when just doing VerifyCollection and UnverifyCollection, all protected by a single sequence number. Either way I need to make some change based on the blockbuster change to pick up the new data hash. We should chat offline about approach before I merge my PR.

Here is my PR for reference: metaplex-foundation#90

Copy link
Author

Choose a reason for hiding this comment

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

The only thing to factor in is that creators can be removed, so we need to be able to support that case too.

Copy link

Choose a reason for hiding this comment

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

yeah I agree nullification is better future proofing for when we have metadata updates

&[v],
id_bytes.clone().as_ref(),
e.owner.as_ref().unwrap(),
e.delegate.unwrap_or(Default::default()).as_ref(),
Copy link

Choose a reason for hiding this comment

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

The problem could be because for the txs being used in testing, owner == delegate. And then in our off-chain data store we do NOT save a delegate (we set it to NULL and you would end up getting Default::default() here). But on chain would require the actual delegate pubkey to be used.

So I think you might need to do something like e.delegate.unwrap_or(e.owner.as_ref().unwrap())

Copy link
Author

Choose a reason for hiding this comment

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

Ah ok thank you, let me try that!

id_bytes.clone().as_ref(),
e.owner.as_ref().unwrap(),
e.delegate.unwrap_or(Default::default()).as_ref(),
cl.index.to_le_bytes().as_ref(),
Copy link

Choose a reason for hiding this comment

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

Another thing that could be the issue is if this index might not be correct. Isn't this supposed to be the nonce value rather than the cl index value? So in this case would it be like e.nonce?

Copy link
Author

Choose a reason for hiding this comment

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

There is no nonce in the asset data. I believe nonce == leaf id

Copy link

Choose a reason for hiding this comment

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

Yeah nonce in the actual asset table gets called leaf_id when returned from the API

@NicolasPennie NicolasPennie marked this pull request as ready for review July 27, 2023 00:11
@NicolasPennie NicolasPennie merged commit 4b5f778 into helius Jul 27, 2023
2 checks passed
Copy link

@danenbm danenbm left a comment

Choose a reason for hiding this comment

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

LGTM

.to_owned(),
)
.build(DbBackend::Postgres);
query.sql = format!(
"{} WHERE excluded.slot_updated > asset_grouping.slot_updated AND excluded.seq >= asset_grouping.seq",
Copy link

Choose a reason for hiding this comment

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

Yeah not sure if we want the slot_updated here because there could be multiple tx in the same slot when just dealing with bubblegum transactions?

NicolasPennie pushed a commit that referenced this pull request Oct 15, 2023
* Updating test workflow

* Adding some annotations

* Fixing path issue.

* Fixing fetch_trees name

* Adding push condition

* Main (#104)

* Fix raw name build (#122)

* Added fetch trees tool (#123)

Fetches a list of trees from an RPC endpoint.

---------

Co-authored-by: Linus Kendall <git@linuskendall.com>

---------

Co-authored-by: Linus Kendall <git@linuskendall.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants