Skip to content

Fix FA store-deletion flipping is_primary to false - #60

Open
sausagee wants to merge 3 commits into
mainfrom
cursor/fix-fa-delete-is-primary-147f
Open

Fix FA store-deletion flipping is_primary to false#60
sausagee wants to merge 3 commits into
mainfrom
cursor/fix-fa-delete-is-primary-147f

Conversation

@sausagee

@sausagee sausagee commented Sep 6, 2026

Copy link
Copy Markdown

Bug

FungibleAssetBalance::get_v2_from_delete_resource hardcoded is_primary: false with the comment “Deleted stores can only be secondary.”

That assumption is wrong. A primary store is a normal 0x1::fungible_asset::FungibleStore object at a derived address and can be deleted when empty (fungible_asset::remove_store / ObjectGroup delete + FungibleStoreDeletion). The write path already computes is_primary via is_primary(owner, metadata, storage_id).

Root cause

On delete, the zeroed row is upserted into current_fungible_asset_balances with is_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 though storage_id is still the derived primary address.

This is independent of #50 (store-address standardization skip on the deletion-event map key).

Fix

Reuse FungibleAssetBalance::is_primary on the delete path, same as writes.

Tests

  • cargo test -p processor --lib fungible_asset::fungible_asset_models::v2_fungible_asset_balances — 6 passed (including delete_resource_preserves_primary_store_flag and delete_resource_keeps_secondary_store_flag)
  • cargo clippy -p processor --lib -- -D warnings — clean on rustc 1.85.0
  • CI Lint / Rust uses cargo +nightly xclippy and fails in allocative (Infallible vs !). That is a pre-existing nightly/toolchain issue, not this change.
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 6, 2026 15:39
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
sausagee marked this pull request as ready for review September 6, 2026 15:47
@sausagee
sausagee changed the base branch from main to fix/lint-stable-xclippy September 7, 2026 22:19
@sausagee
sausagee changed the base branch from fix/lint-stable-xclippy to main September 7, 2026 22:31
Stack the CI unblocker files from PR #70 (stable cargo xclippy, bookworm Dockerfiles with make) onto this bugfix branch so CI can go green while #70 awaits review. Merge target remains main; this does not merge #70.
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