Skip to content

Fix TokenStore deposit/withdraw owner fallback property-version collision - #68

Open
sausagee wants to merge 3 commits into
mainfrom
cursor/tokenstore-deposit-pv-collision-1c0c
Open

Fix TokenStore deposit/withdraw owner fallback property-version collision#68
sausagee wants to merge 3 commits into
mainfrom
cursor/tokenstore-deposit-pv-collision-1c0c

Conversation

@sausagee

@sausagee sausagee commented Sep 6, 2026

Copy link
Copy Markdown

Bug

When a Token V1 TokenStore is not rewritten in a transaction (the usual case after the store is first created), owner fallback for table-item writes/deletes comes from module-event maps:

  • TokenDeposittokens_deposited
  • TokenWithdrawtokens_withdrawn

Those maps were keyed only by token_data_id. Token V1 current-ownership PK is (token_data_id, property_version, owner, storage_id). Two property versions of the same named token in one txn (original vs mutated) collided: last event won, the upsert used the wrong owner, and the real row was never updated. Checkpoints still advanced.

This is the sibling that #67 explicitly left out of scope (claim/cancel maps). Distinct from #42 (offer write-path).

Root cause

TokenV1DepositModuleEvents / TokenV1WithdrawModuleEvents were AHashMap<TokenDataIdHash, …>. Inserts and fallback lookups ignored property_version.

Fix

Key and look up by (token_data_id, property_version).

Out of scope: same PV + different owners in one txn (module events have no table handle). Same remaining ambiguity as #67.

Tests

  • deposit_fallback_does_not_reuse_owner_across_property_versions
  • withdraw_fallback_does_not_reuse_owner_across_property_versions

Verified locally:

  • cargo test -p processor --lib fallback_does_not_reuse_owner — 2 passed
  • cargo clippy -p processor --all-targets -- -D warnings (plus repo xclippy allows) — clean
  • cargo +nightly fmt -- --check on the three touched files — clean

Near-misses killed (not in this PR)

  1. Objects history “last ObjectCore in txn” — Aptos write-sets are unique per StateKey; at most one 0x1::object::ObjectCore per object per txn.
  2. Parquet max_gas_octa storing gas units — same as upstream aptos-labs; naming quirk, not Movement-specific corruption.
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 6, 2026 17:51
Token V1 module-event maps used for TokenStore-not-rewritten owner
fallback were keyed only by token_data_id. Two property versions of
the same named token in one txn overwrote each other, so the current
ownership upsert used the wrong owner and the real row was skipped.

Key and look up by (token_data_id, property_version).

Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
WriteTableItem/DeleteTableItem data is WriteTableData/DeleteTableData
in aptos-protos 1.3.1, not nested write_table_item::Data modules.

Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
@sausagee
sausagee marked this pull request as ready for review September 6, 2026 18:01
@sausagee
sausagee changed the base branch from main to fix/lint-stable-xclippy September 7, 2026 22:20
@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