Fix token claim/cancel fallback property-version collision - #67
Open
sausagee wants to merge 2 commits into
Open
Conversation
Key TokenV1Claimed/Canceled by (token_data_id, property_version) so two PendingClaims deletes for the same named token resolve the correct offerer when the parent resource is not rewritten. Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
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
On the PendingClaims-not-rewritten path,
from_delete_table_itemrecoversfrom_addressfrom in-transaction claim/cancel events. Those maps were keyed only bytoken_data_id.Token V1 treats
(token_data_id, property_version, from_address, to_address)as the pending-claim PK. Two offers of the same named token with different property versions (e.g. original vs mutated copy, different offerers, claimed in one txn) therefore collide in the event map. The last event wins, so the other delete writes the wrong offerer into the upsert key: the real row is never zeroed (silent skip) and a different PK is written (wrong-row update). Checkpoints still advance.Same-offerer two-PV cancel/claim is harmless (same
from_address). The failing case is different offerers + different property versions in one user transaction — a realistic Token V1 batch-claim script.This is the existing delete-path fallback, not #42 (write-path offer fallback) and not #16–#66.
Root cause
property_versionandto_addressalready come from theTokenOfferIdtable key. Onlyfrom_addressis recovered from the map, so a collision changes the PK.Fix
Key
TokenV1Claimed/TokenV1Canceledby(token_data_id, property_version)and look up with the delete item's property version.Test plan
cargo test -p processor --lib token_claims— 2 passed:claim_fallback_does_not_reuse_offerer_across_property_versionscancel_fallback_does_not_overwrite_other_property_version_claimcargo clippy -p processor --all-targets -- -D warnings(rust-toolchain 1.85)No workspace-level
diesel/postgresor SDKpostgres_full/testing_frameworkfeatures were added.Out of scope
TokenV1Offeredmap (still token_data_id-only on that PR)