Skip to content

starknet role discovery script#162

Merged
remollemo merged 2 commits into
mainfrom
remo/roles/role_discovery
Apr 12, 2026
Merged

starknet role discovery script#162
remollemo merged 2 commits into
mainfrom
remo/roles/role_discovery

Conversation

@remollemo

@remollemo remollemo commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

Note

Low Risk
Additive Python utility plus tests; main risk is incorrect role/event parsing or fallback behavior against diverse RPC providers, but it does not modify existing production paths.

Overview
Adds a standalone/importable python/utils/role_discovery.py utility to discover current (or historical) CommonRoles role holders on Starknet by scanning RoleGranted events and optionally verifying membership via has_role.

Includes robustness fallbacks: supports multiple event layouts, falls back to raw getEvents RPC when starknet_py event validation fails, and switches to legacy is_<role> entrypoints when has_role is missing. Adds pytest coverage for these fallback paths and a small python/utils/requirements.txt for running the script/tests.

Written by Cursor Bugbot for commit ddec176. This will update automatically on new commits. Configure here.


This change is Reviewable

@remollemo remollemo requested a review from RoeeGross March 31, 2026 15:24
@remollemo remollemo self-assigned this Mar 31, 2026
@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@8f41888). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #162   +/-   ##
=======================================
  Coverage        ?   94.69%           
=======================================
  Files           ?       57           
  Lines           ?     3993           
  Branches        ?        0           
=======================================
  Hits            ?     3781           
  Misses          ?      212           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread python/utils/role_discovery.py
@RoeeGross

Copy link
Copy Markdown
Contributor

python/utils/role_discovery.py line 64 at r2 (raw file):

# Each is keccak256("ROLE_<NAME>") & MASK_250.
ROLE_IDS: Dict[RoleName, int] = {
    RoleName.AppGovernor: 0xD2EAD78C620E94B02D0A996E99298C59DDCCFA1D8A0149080AC3A20DE06068,

Consider locating these constants in a different file

@RoeeGross

Copy link
Copy Markdown
Contributor

python/utils/role_discovery.py line 93 at r2 (raw file):

}

RPCS = {

considier remove

@RoeeGross RoeeGross left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RoeeGross reviewed 3 files and all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on remollemo).

@RoeeGross RoeeGross left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on remollemo).

@remollemo remollemo force-pushed the remo/roles/role_discovery branch from ddec176 to c1dbd4c Compare April 12, 2026 15:35
@remollemo remollemo requested a review from RoeeGross April 12, 2026 15:36

@remollemo remollemo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remollemo resolved 2 discussions.
Reviewable status: 2 of 3 files reviewed, all discussions resolved (waiting on RoeeGross).

@remollemo remollemo merged commit 49c4612 into main Apr 12, 2026
4 of 5 checks passed
@remollemo remollemo deleted the remo/roles/role_discovery branch April 12, 2026 15:37
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