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

[EI-461] Index royalty in royalty tables #381

Merged
merged 5 commits into from
Jun 10, 2024
Merged

[EI-461] Index royalty in royalty tables #381

merged 5 commits into from
Jun 10, 2024

Conversation

rtso
Copy link
Collaborator

@rtso rtso commented May 22, 2024

Description

  • Separate royalty tocurrent_token_royalty_v1 table (note that v2 royalty requires collection id which isn't currently supported in this PR)
  • Move the indexing to token_v2_processor

Backfill

Testnet: 0
Mainnet: 0

Test Plan

Mainnet transaction 613858541
Screenshot 2024-05-21 at 5 48 17 PM

Screenshot 2024-05-21 at 5 48 06 PM Screenshot 2024-05-21 at 5 47 34 PM

@rtso rtso marked this pull request as ready for review May 22, 2024 00:49
@rtso rtso requested review from bowenyang007, a team and CapCap May 22, 2024 00:49
@rtso rtso changed the title Index royalty in royalty tables [EI-461] Index royalty in royalty tables May 22, 2024
Copy link

linear bot commented May 22, 2024

);

CREATE TABLE current_token_royalty (
token_data_id VARCHAR(66) NOT NULL,
Copy link
Collaborator

@larry-aptos larry-aptos May 22, 2024

Choose a reason for hiding this comment

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

I forgot why we don't have a unique id for the token.. but using hash value alone as primary key can be dangerous since collision may happen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point. Including creator_address in the primary key can help with collision. Let me add that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@larry-aptos explained to me how collision can happen, but i forgot the reason cc @grao1991

Copy link
Collaborator

Choose a reason for hiding this comment

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

hash id is not guaranteed to be unique. It may be a problem when two different entities have the same hash value.

it seems ahash uses 64bit and considering 10million items, we get this

image

If we consider the number of items(i.e. token) can go up to 10m, we should take the probability of collision into account and add a field to make pk unique, otherwise, we should be fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

wait what? these hashes aren't randomly generated though so can collision still happen? I don't think that creator address is necessary b/c it's part of the hash.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the tokens tables don't have this level of protection so we'll end up with issues anyway.

@rtso
Copy link
Collaborator Author

rtso commented Jun 10, 2024

New changes lgtm. Thanks @bowenyang007 !

@bowenyang007 bowenyang007 merged commit 6255230 into main Jun 10, 2024
7 checks passed
@bowenyang007 bowenyang007 deleted the rtso/royalty branch June 10, 2024 21:46
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.

5 participants