Fix FA store-deletion flipping is_primary to false - #60
Open
sausagee wants to merge 3 commits into
Open
Conversation
Primary FungibleStore objects can be deleted when empty. The delete path hardcoded is_primary=false, so current_fungible_asset_balances upserts would mark a deleted primary store as secondary. Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
sausagee
marked this pull request as ready for review
September 6, 2026 15:47
This was referenced Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
FungibleAssetBalance::get_v2_from_delete_resourcehardcodedis_primary: falsewith the comment “Deleted stores can only be secondary.”That assumption is wrong. A primary store is a normal
0x1::fungible_asset::FungibleStoreobject at a derived address and can be deleted when empty (fungible_asset::remove_store/ ObjectGroup delete +FungibleStoreDeletion). The write path already computesis_primaryviais_primary(owner, metadata, storage_id).Root cause
On delete, the zeroed row is upserted into
current_fungible_asset_balanceswithis_primary = false. Queries that look up an owner’s primary store (is_primary = true) then miss the store after it is emptied and removed, even thoughstorage_idis still the derived primary address.This is independent of #50 (store-address standardization skip on the deletion-event map key).
Fix
Reuse
FungibleAssetBalance::is_primaryon the delete path, same as writes.Tests
cargo test -p processor --lib fungible_asset::fungible_asset_models::v2_fungible_asset_balances— 6 passed (includingdelete_resource_preserves_primary_store_flaganddelete_resource_keeps_secondary_store_flag)cargo clippy -p processor --lib -- -D warnings— clean on rustc 1.85.0Lint / Rustusescargo +nightly xclippyand fails inallocative(Infalliblevs!). That is a pre-existing nightly/toolchain issue, not this change.