Fix inactive-share delete writing shares table as parent_table_handle - #48
Open
sausagee wants to merge 2 commits into
Open
Fix inactive-share delete writing shares table as parent_table_handle#48sausagee wants to merge 2 commits into
sausagee wants to merge 2 commits into
Conversation
The delete path stored current_delegator_balances.parent_table_handle as the per-delegator shares table handle. Write and history rows use the inactive-pool table handle, which get_by_inactive_share_handle looks up later. After a withdraw that deletes inactive shares, later pool-address lookups miss the mapping. 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
CurrentDelegatorBalance::get_inactive_share_from_delete_table_itemwrote two differentparent_table_handlevalues for the same inactive-share delete:delegator_balances): inactive-pool table handle (inactive_pool_handle)current_delegator_balances): shares table handle (table_handle)The write path stores the inactive-pool handle on both rows.
get_staking_pool_from_inactive_share_handle/get_by_inactive_share_handlelater look upcurrent_delegator_balances.parent_table_handle.After a withdraw/unlock that deletes the last inactive shares for a delegator, the current snapshot is overwritten with the shares-table handle. Later transactions that resolve
pool_addressvia that parent handle miss the mapping (or hit a different row). That is snapshot corruption and can drop subsequent inactive-share writes (the skip path already tracked in #35).This is the same two-layer mapping as the write path (
shares table→inactive pool table→ staking pool). Active-share delete correctly usestable_handlefor parent because there is only one layer. The inactive delete path copied that assignment.Not covered by open PRs #16–#47. #35 is the write-path lookup
Err→Ok(None)skip; it does not change this field. Upstreamaptos-labs/aptos-indexer-processors-v2still has the same delete-path assignment.Root cause
Copy-paste from
get_active_share_from_delete_table_item, whereparent_table_handle == table_handleis correct. For inactive shares those handles differ:table_handleis the per-delegator shares table;parent_table_handlemust stay the inactive-pool table.Fix
inactive_share_rowsconstructor used by write and delete.inactive_pool_handle, matching history and write.Test plan
cargo test -p processor --lib processors::stake::models::delegator_balances— 2 passed:delete_current_row_uses_inactive_pool_parent_handlewrite_and_delete_agree_on_parent_table_handlecargo clippy -p processor --all-targets -- -D warnings(rust-toolchain 1.85)SHA:
aaa8122CI on this SHA
On-PR jobs that exercise this change:
Pre-existing failures, same class as #16 / #17 / #18 / #20 / #25 / #34 / #35 and unrelated to this diff:
cargo +nightly xclippyfails compiling third-partyallocative 0.3.4(conflicting implementations of trait Allocative for type !after nightly unifiedInfallibleand!). Local clippy on rust-toolchain 1.85 is clean.apt-get404s forlinux-libc-dev_5.10.262-1while installinglibdw-devinDockerfile.address-reputation-api. This PR does not touch that Dockerfile.No workspace-level
diesel/postgresor SDKpostgres_full/testing_frameworkfeatures were added.Aikido SAST was invoked; the MCP required a user sign-in (
/aikido:setup) so the scan did not complete in this environment.Out of scope