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

[FA migration] Make storage id consistent for transaction tables #688

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

bowenyang007
Copy link
Collaborator

@bowenyang007 bowenyang007 commented Jan 22, 2025

Even those are the same assets storage id is different.
image

Backfill

Testnet: 0
Mainnet: 0
This affects fungible_asset_activities and fungible_asset_balances (for analytics)

Test

Storage id is now the same!
image

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.

Project coverage is 49.5%. Comparing base (efd779d) to head (5dd1d06).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ble_asset_models/raw_v2_fungible_asset_balances.rs 92.1% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #688     +/-   ##
=======================================
- Coverage   49.6%   49.5%   -0.2%     
=======================================
  Files        252     252             
  Lines      28526   28535      +9     
=======================================
- Hits       14166   14137     -29     
- Misses     14360   14398     +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yuunlimm
Copy link
Contributor

I think integration test might fail,

@bowenyang007 bowenyang007 requested review from yuunlimm and rtso January 22, 2025 00:46
@bowenyang007 bowenyang007 changed the title fix storage_id [FA migration] Make storage id consistent for transaction tables Jan 22, 2025

// Storage id should be derived (for the FA migration)
let metadata_addr = get_paired_metadata_address(&coin_type);
let storage_id = get_primary_fungible_store_address(&owner_address, &metadata_addr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if the coin hasn't migrated yet? does it matter what this value is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea cuz eventually you will migrate and we'll have a hard time debugging.

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense. and storage_id can be arbitrary for coin balances since it's only used for the PK of the table.

Comment on lines +339 to +342
// Storage id should be derived (for the FA migration)
let metadata_addr = get_paired_metadata_address(&coin_type);
let storage_id = get_primary_fungible_store_address(&owner_address, &metadata_addr)
.expect("calculate primary fungible store failed");
Copy link
Collaborator

@rtso rtso Jan 22, 2025

Choose a reason for hiding this comment

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

this replaces all coin balances with a new primary key. how do we delete the old rows so the balances don't show up twice in the table?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this only affects parquet so we'll need to first wipe everythign.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yuunlimm correct me if i'm wrong but i think this is also used in the postgres processors

Copy link
Contributor

Choose a reason for hiding this comment

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

it's the legacy table, right? then it was deprecated so the code can be removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh i see, the RawCurrentFungibleAssetBalance is already using get_primary_fungible_store_address

@rtso
Copy link
Collaborator

rtso commented Jan 22, 2025

@yuunlimm we also should enable the cfab tests (non-legacy) so this PR has enough testing

@yuunlimm
Copy link
Contributor

@yuunlimm we also should enable the cfab tests (non-legacy) so this PR has enough testing
https://github.com/aptos-labs/aptos-indexer-processors/pull/690/files#diff-fdebff6c735ac6b5581af94ffb8f889ef988a3dfa320e880a504fefa60f71fba added here

@bowenyang007 bowenyang007 enabled auto-merge (squash) January 22, 2025 21:09
@bowenyang007 bowenyang007 merged commit 54bbd61 into main Jan 22, 2025
11 checks passed
@bowenyang007 bowenyang007 deleted the fix_storage_id branch January 22, 2025 21:51
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.

4 participants