Skip to content

Add blocklist#626

Open
andrew-fleming wants to merge 5 commits into
OpenZeppelin:mainfrom
andrew-fleming:add-blockList
Open

Add blocklist#626
andrew-fleming wants to merge 5 commits into
OpenZeppelin:mainfrom
andrew-fleming:add-blockList

Conversation

@andrew-fleming

@andrew-fleming andrew-fleming commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Resolves #608

See #625 for rationale

Summary by CodeRabbit

  • New Features

    • Added blocklist (deny-list) functionality for managing blocked accounts with queries to check blocked status, guards to prevent blocked accounts from proceeding, and operations to block or unblock accounts as needed.
  • Tests

    • Added comprehensive test suite and simulator for validating blocklist behavior including membership tracking, idempotent operations, and cross-account isolation.

@andrew-fleming andrew-fleming requested review from a team as code owners June 24, 2026 04:24
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9067f8e7-b676-41bc-a56e-bc5f4168c308

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds a new Blocklist compact contract module to the security package. The module defines a _blocked ledger, isBlocked/assertNotBlocked query circuits, and ungated _block/_unblock mutators. A complete test stack is introduced: a MockBlocklist compact mock, empty witness stubs, a BlocklistSimulator class, and a Vitest suite covering all operations.

Changes

Blocklist Security Module

Layer / File(s) Summary
Core Blocklist contract and changelog
contracts/src/security/Blocklist.compact, CHANGELOG.md
Defines the Blocklist module with an exported _blocked ledger (Map<Bytes<32>, Boolean>), an isBlocked view circuit checking key presence and truthiness, an assertNotBlocked gate that reverts when blocked, and ungated _block/_unblock mutators that set the stored boolean. Changelog entry added.
Test mock, witnesses, and simulator
contracts/src/security/test/mocks/MockBlocklist.compact, contracts/src/security/test/witnesses/BlocklistWitnesses.ts, contracts/src/security/test/simulators/BlocklistSimulator.ts
MockBlocklist re-exports Blocklist__blocked and wraps the four circuits with thin forwarders. BlocklistWitnesses and BlocklistPrivateState are empty stubs. BlocklistSimulator is wired via createSimulator to MockBlocklist and exposes isBlocked, assertNotBlocked, block, and unblock as public methods delegating to this.circuits.impure.
Vitest test suite
contracts/src/security/test/Blocklist.test.ts
Defines deterministic 32-byte test accounts and a fresh simulator per test. Covers default empty state, block idempotency, account isolation, assertNotBlocked throw message, unblock no-op for non-members, block→unblock→block transitions, multi-account independence, and getPublicState() ledger shape.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • 0xisk

Poem

🐇 Hop hop, the list is set,
Some accounts we won't forget—
_block them true, _unblock them free,
assertNotBlocked guards with glee.
The ledger map keeps watch all day,
No unwanted guest shall stay! 🚫

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add blocklist' directly and clearly summarizes the main change—the introduction of a blocklist feature with blocking functionality.
Linked Issues check ✅ Passed The PR fully implements the blocklist feature requested in issue #608, providing per-account deny functionality with all necessary components.
Out of Scope Changes check ✅ Passed All changes are directly related to blocklist implementation; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
contracts/src/security/test/Blocklist.test.ts (1)

70-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tighten the “no-op for non-member” test to validate ledger non-mutation

The current assertion on Line 70-73 only checks isBlocked(BOB) === false, which still passes if unblock writes a false entry. Add a getPublicState().Blocklist__blocked.member(BOB) assertion to codify whether “no-op” means “no new key inserted.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/src/security/test/Blocklist.test.ts` around lines 70 - 73, The "is
a no-op for a non-member" test for the unblock method in Blocklist.test.ts
currently only validates that isBlocked(BOB) returns false, but this alone does
not verify that the unblock operation truly did nothing to the ledger state. Add
an additional assertion to check the underlying public state directly by
verifying that getPublicState().Blocklist__blocked.member(BOB) confirms no new
entry was inserted into the blocklist, ensuring the test properly validates that
unblock is truly a no-op for non-members.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/src/security/Blocklist.compact`:
- Around line 97-99: The _unblock circuit function currently uses
_blocked.insert with a false value instead of actually removing the account from
the blocklist. This causes state growth even when unblocking non-members and
creates a semantic mismatch with the documented behavior. Replace the insert
call with _blocked.remove(disclose(account)) to properly remove the account
entry from the map, ensuring true removal rather than storing a tombstone value.

---

Nitpick comments:
In `@contracts/src/security/test/Blocklist.test.ts`:
- Around line 70-73: The "is a no-op for a non-member" test for the unblock
method in Blocklist.test.ts currently only validates that isBlocked(BOB) returns
false, but this alone does not verify that the unblock operation truly did
nothing to the ledger state. Add an additional assertion to check the underlying
public state directly by verifying that
getPublicState().Blocklist__blocked.member(BOB) confirms no new entry was
inserted into the blocklist, ensuring the test properly validates that unblock
is truly a no-op for non-members.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02772100-7456-4756-bc3b-606cee156b65

📥 Commits

Reviewing files that changed from the base of the PR and between 7582746 and 4f010b2.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • contracts/src/security/Blocklist.compact
  • contracts/src/security/test/Blocklist.test.ts
  • contracts/src/security/test/mocks/MockBlocklist.compact
  • contracts/src/security/test/simulators/BlocklistSimulator.ts
  • contracts/src/security/test/witnesses/BlocklistWitnesses.ts

Comment thread contracts/src/security/Blocklist.compact
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.

Add blocklist

1 participant