-
Notifications
You must be signed in to change notification settings - Fork 138
Reject unregistered accounts #2612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mirko-von-Leipzig
merged 7 commits into
mirko/account-whitelist-registration
from
mirko/account-whitelist-enforcement
Sep 15, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c39343b
Reject unregistered accounts
Mirko-von-Leipzig cd7dd7d
fix(rpc): trace admission and update submission fixtures
Mirko-von-Leipzig 37c8d1a
Instrument
Mirko-von-Leipzig 0df6e08
Disable allowlist by default in local setups
Mirko-von-Leipzig ca7c954
Merge branch 'mirko/account-whitelist-registration' into mirko/accoun…
Mirko-von-Leipzig 9f57007
Merge branch 'mirko/account-whitelist-registration' into mirko/accoun…
Mirko-von-Leipzig b081fb3
Merge branch 'mirko/account-whitelist-registration' into mirko/accoun…
Mirko-von-Leipzig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| use std::sync::Arc; | ||
|
|
||
| use miden_node_store::allowlist::AccountAllowlist; | ||
| use miden_node_tracing::{error, miden_instrument}; | ||
| use miden_protocol::account::{Account, AccountUpdateDetails}; | ||
| use miden_protocol::transaction::TxAccountUpdate; | ||
| use miden_standards::account::auth::NetworkAccount; | ||
| use tonic::Status; | ||
|
|
||
| use crate::{COMPONENT, LOG_TARGET}; | ||
|
|
||
| /// Account creation policy shared by the public and internal sequencer APIs. | ||
| #[derive(Clone)] | ||
| pub struct AccountAdmission { | ||
| pub(crate) allowlist: Arc<AccountAllowlist>, | ||
| disabled: bool, | ||
| } | ||
|
|
||
| impl AccountAdmission { | ||
| pub fn enabled(allowlist: Arc<AccountAllowlist>) -> Self { | ||
| Self { allowlist, disabled: false } | ||
| } | ||
|
|
||
| pub fn disabled(allowlist: Arc<AccountAllowlist>) -> Self { | ||
| Self { allowlist, disabled: true } | ||
| } | ||
|
|
||
| /// Rejects the submission if it creates an unregistered, non-network account. | ||
| #[miden_instrument( | ||
| target = COMPONENT, | ||
| name = "account_admission.check", | ||
| fields(account.id = update.account_id()), | ||
| err, | ||
| )] | ||
| pub(crate) async fn check(&self, update: &TxAccountUpdate) -> tonic::Result<()> { | ||
| if self.disabled || !update.initial_state_commitment().is_empty() { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| // New public accounts include their full state. Use the store's network-account | ||
| // classification rule before the account exists on chain. | ||
| if let AccountUpdateDetails::Public(patch) = update.details() { | ||
| let account = Account::try_from(patch) | ||
| .map_err(|error| Status::invalid_argument(error.to_string()))?; | ||
| if NetworkAccount::new(account).is_ok() { | ||
| return Ok(()); | ||
| } | ||
| } | ||
|
|
||
| let account_id = update.account_id(); | ||
| let registered = self.allowlist.contains_account(account_id).await.map_err(|err| { | ||
| error!(err, target: LOG_TARGET, "Account allowlist lookup failed"); | ||
| Status::internal("account allowlist lookup failed") | ||
| })?; | ||
| if !registered { | ||
| return Err(Status::permission_denied(format!( | ||
| "account {account_id} is not registered" | ||
| ))); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.