Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(audit): scope provider attribute queries to provider keys#2076

Open
modernzju wants to merge 1 commit into
akash-network:main from
modernzju:main
Open

fix(audit): scope provider attribute queries to provider keys #2076
modernzju wants to merge 1 commit into
akash-network:main from
modernzju:main

Conversation

@modernzju

@modernzju modernzju commented Jun 20, 2026
edited
Loading

Copy link
Copy Markdown

Description

Closes: akash-network/support#619

Scopes the AllProvidersAttributes and AuditorAttributes query pagination to the audit provider key prefix.

Previously both query handlers paginated over the full audit KV store and called ParseIDFromKey for every key. That works while the store only contains provider keys, but it is fragile: any future non-provider key under the same store key could be parsed as a provider ID and cause incorrect results or a panic.

This change wraps the audit store with prefix.NewStore(..., types.PrefixProviderID()) before paginating, so only provider attribute records are scanned. The tests add a non-provider key to the audit store and verify both query paths ignore it.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Signed-off-by: modernzju <modernzju@outlook.com>

coderabbitai Bot commented Jun 20, 2026
edited
Loading

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Two gRPC query handlers (AllProvidersAttributes and AuditorAttributes) in the audit keeper are updated to iterate over a prefix.NewStore scoped to types.PrefixProviderID() instead of the raw KVStore. Iterator keys are reconstructed with the prefix before ParseIDFromKey. Tests add a foreign key to the store to verify isolation.

Changes

Audit Provider Query Prefix Scoping

Layer / File(s) Summary
Prefix-scoped iteration in AllProvidersAttributes and AuditorAttributes
x/audit/keeper/grpc_query.go
Imports cosmossdk.io/store/prefix and wraps ctx.KVStore(q.skey) with prefix.NewStore(..., types.PrefixProviderID()) in both handlers; restores the prefix bytes onto the stripped iterator key before calling ParseIDFromKey.
Rogue-key test fixtures
x/audit/keeper/grpc_query_test.go
TestGRPCQueryProviders and TestGRPCQueryAuditorAttributes each pre-seed the KVStore with []byte{0xff} → []byte{0x01} before running assertions, verifying that foreign keys are excluded from results.
Changelog
CHANGELOG.md
Adds a Bug Fixes entry noting provider attribute queries are scoped to audit provider keys.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • akash-network/node#2070: Directly modifies the same AllProvidersAttributes and AuditorAttributes handlers in x/audit/keeper/grpc_query.go, changing how provider records are decoded from KV keys/values; this PR is the follow-up fix identified during that review.

Suggested reviewers

  • troian

Poem

🐇 Hopping through the store with care,
Only provider keys allowed in there!
A rogue 0xff tried to sneak past the gate,
But prefix.NewStore said "Sorry, too late!"
Now queries are scoped, clean, and bright —
This bunny fixed the key scope right. 🔑

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: scoping provider attribute queries to provider keys, which is the core fix implemented across the modified files.
Linked Issues check ✅ Passed The PR fully implements the proposed fix from issue #619: wrapping the audit store with prefix.NewStore(..., types.PrefixProviderID()) in both AllProvidersAttributes and AuditorAttributes query handlers, plus adding defensive test cases.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue: the two query functions are modified as specified, tests are enhanced to validate the fix, and CHANGELOG.md is updated appropriately.
Description check ✅ Passed The PR description clearly relates to the changeset by explaining the bug fix to scope provider attribute queries to audit provider keys, matching the code changes in the three modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

audit: scope AllProvidersAttributes and AuditorAttributes pagination to provider prefix

1 participant

AltStyle によって変換されたページ (->オリジナル) /