Skip to content

Commit 6f0a922

Browse files
refactor: rename network-account note allowlist API (#3049)
* refactor: rename network-account note allowlist API
1 parent 92de56e commit 6f0a922

10 files changed

Lines changed: 25 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
- [BREAKING] `AuthNetworkAccount` now gates transaction scripts with a root allowlist instead of banning them outright, enabling network accounts to run approved tx scripts such as setting the expiration delta ([#3028](https://github.com/0xMiden/protocol/pull/3028)).
3434
- [BREAKING] `TransactionScript::root()` now returns `TransactionScriptRoot` instead of `Word` ([#3028](https://github.com/0xMiden/protocol/pull/3028)).
35+
- Renamed `AuthNetworkAccount::with_allowlist` to `with_allowed_notes` and aligned the component's internal allowlist field names, for consistency with `with_allowed_tx_scripts` ([#3049](https://github.com/0xMiden/protocol/pull/3049)).
3536

3637
## v0.15.1 (TBD)
3738

crates/miden-agglayer/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn generate_agglayer_constants(
326326
// The allowlist lives in storage, not code, and here we only care about the code commitment
327327
// of the accounts, so we can init the allowlists with dummy values.
328328
let placeholder_allowlist = BTreeSet::from([NoteScriptRoot::from_raw(Word::default())]);
329-
let auth_component = AuthNetworkAccount::with_allowlist(placeholder_allowlist)
329+
let auth_component = AuthNetworkAccount::with_allowed_notes(placeholder_allowlist)
330330
.expect("placeholder allowlist is non-empty");
331331
let mut components: Vec<AccountComponent> =
332332
vec![AccountComponent::from(auth_component), agglayer_component];

crates/miden-agglayer/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn create_bridge_account_builder(
138138
.account_type(AccountType::Public)
139139
.with_component(AggLayerBridge::new(bridge_admin_id, ger_manager_id))
140140
.with_auth_component(
141-
AuthNetworkAccount::with_allowlist(AggLayerBridge::allowed_notes())
141+
AuthNetworkAccount::with_allowed_notes(AggLayerBridge::allowed_notes())
142142
.expect("bridge note allowlist is non-empty"),
143143
)
144144
}
@@ -212,7 +212,7 @@ fn create_agglayer_faucet_builder(
212212
.with_components(token_policy_manager)
213213
.with_component(BurnAllowAll)
214214
.with_auth_component(
215-
AuthNetworkAccount::with_allowlist(AggLayerFaucet::allowed_notes())
215+
AuthNetworkAccount::with_allowed_notes(AggLayerFaucet::allowed_notes())
216216
.expect("faucet note allowlist is non-empty"),
217217
)
218218
}

crates/miden-standards/src/account/auth/network_account/auth_network_account.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ account_component_code!(NETWORK_ACCOUNT_AUTH_CODE, "auth/network_account.masl");
6060
/// that the node would likely not yet respect updates made to the list after deployment, but there
6161
/// is in principle nothing preventing us from supporting mutation in the future.
6262
pub struct AuthNetworkAccount {
63-
allowlist: NetworkAccountNoteAllowlist,
64-
tx_script_allowlist: NetworkAccountTxScriptAllowlist,
63+
allowed_notes: NetworkAccountNoteAllowlist,
64+
allowed_tx_scripts: NetworkAccountTxScriptAllowlist,
6565
}
6666

6767
impl AuthNetworkAccount {
@@ -85,12 +85,12 @@ impl AuthNetworkAccount {
8585
///
8686
/// Returns an error if `allowed_script_roots` is empty since the account could not consume any
8787
/// notes.
88-
pub fn with_allowlist(
88+
pub fn with_allowed_notes(
8989
allowed_script_roots: BTreeSet<NoteScriptRoot>,
9090
) -> Result<Self, NetworkAccountNoteAllowlistError> {
9191
Ok(Self {
92-
allowlist: NetworkAccountNoteAllowlist::new(allowed_script_roots)?,
93-
tx_script_allowlist: NetworkAccountTxScriptAllowlist::default(),
92+
allowed_notes: NetworkAccountNoteAllowlist::new(allowed_script_roots)?,
93+
allowed_tx_scripts: NetworkAccountTxScriptAllowlist::default(),
9494
})
9595
}
9696

@@ -107,7 +107,7 @@ impl AuthNetworkAccount {
107107
mut self,
108108
allowed_tx_script_roots: BTreeSet<TransactionScriptRoot>,
109109
) -> Self {
110-
self.tx_script_allowlist = NetworkAccountTxScriptAllowlist::new(allowed_tx_script_roots);
110+
self.allowed_tx_scripts = NetworkAccountTxScriptAllowlist::new(allowed_tx_script_roots);
111111
self
112112
}
113113

@@ -151,8 +151,8 @@ impl AuthNetworkAccount {
151151
impl From<AuthNetworkAccount> for AccountComponent {
152152
fn from(component: AuthNetworkAccount) -> Self {
153153
let storage_slots = vec![
154-
component.allowlist.into_storage_slot(),
155-
component.tx_script_allowlist.into_storage_slot(),
154+
component.allowed_notes.into_storage_slot(),
155+
component.allowed_tx_scripts.into_storage_slot(),
156156
];
157157
let metadata = AuthNetworkAccount::component_metadata();
158158

@@ -180,7 +180,7 @@ mod tests {
180180

181181
let _account = AccountBuilder::new([0; 32])
182182
.with_auth_component(
183-
AuthNetworkAccount::with_allowlist(BTreeSet::from_iter([root_a, root_b]))
183+
AuthNetworkAccount::with_allowed_notes(BTreeSet::from_iter([root_a, root_b]))
184184
.expect("non-empty allowlist should construct"),
185185
)
186186
.with_component(BasicWallet)
@@ -190,15 +190,15 @@ mod tests {
190190

191191
#[test]
192192
fn auth_network_account_with_empty_allowlist_is_rejected() {
193-
let result = AuthNetworkAccount::with_allowlist(BTreeSet::new());
193+
let result = AuthNetworkAccount::with_allowed_notes(BTreeSet::new());
194194
assert!(matches!(result, Err(NetworkAccountNoteAllowlistError::EmptyAllowlist)));
195195
}
196196

197197
#[test]
198198
fn auth_network_account_uses_standardized_allowlist_slot() {
199199
let root_a = NoteScriptRoot::from_array([1, 2, 3, 4]);
200200
let component: AccountComponent =
201-
AuthNetworkAccount::with_allowlist(BTreeSet::from_iter([root_a]))
201+
AuthNetworkAccount::with_allowed_notes(BTreeSet::from_iter([root_a]))
202202
.expect("non-empty allowlist should construct")
203203
.into();
204204

crates/miden-standards/src/account/auth/network_account/network_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod tests {
101101
AccountBuilder::new([0; 32])
102102
.account_type(account_type)
103103
.with_auth_component(
104-
AuthNetworkAccount::with_allowlist(roots).expect("non-empty allowlist"),
104+
AuthNetworkAccount::with_allowed_notes(roots).expect("non-empty allowlist"),
105105
)
106106
.with_component(BasicWallet)
107107
.build()

crates/miden-standards/src/account/auth/network_account/note_allowlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ mod tests {
217217

218218
let account = AccountBuilder::new([0; 32])
219219
.with_auth_component(
220-
AuthNetworkAccount::with_allowlist(original_roots.clone())
220+
AuthNetworkAccount::with_allowed_notes(original_roots.clone())
221221
.expect("non-empty allowlist should construct"),
222222
)
223223
.with_component(BasicWallet)

crates/miden-standards/src/account/auth/network_account/tx_script_allowlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ mod tests {
206206

207207
let account = AccountBuilder::new([0; 32])
208208
.with_auth_component(
209-
AuthNetworkAccount::with_allowlist(BTreeSet::from_iter([
209+
AuthNetworkAccount::with_allowed_notes(BTreeSet::from_iter([
210210
miden_protocol::note::NoteScriptRoot::from_array([9, 9, 9, 9]),
211211
]))
212212
.expect("non-empty note allowlist should construct")

crates/miden-standards/src/account/faucets/fungible/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ fn build_auth_component(
673673
allowed_script_roots,
674674
allowed_tx_script_roots,
675675
},
676-
) => Ok(AuthNetworkAccount::with_allowlist(allowed_script_roots)
676+
) => Ok(AuthNetworkAccount::with_allowed_notes(allowed_script_roots)
677677
.map_err(|err| {
678678
FungibleFaucetError::UnsupportedAuthMethod(alloc::format!(
679679
"invalid network account allowlist: {err}"

crates/miden-testing/src/mock_chain/auth.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ impl Auth {
187187
allowed_script_roots,
188188
allowed_tx_script_roots,
189189
} => {
190-
let component = AuthNetworkAccount::with_allowlist(allowed_script_roots.clone())
191-
.expect("network account allowlist must be non-empty")
192-
.with_allowed_tx_scripts(allowed_tx_script_roots.clone())
193-
.into();
190+
let component =
191+
AuthNetworkAccount::with_allowed_notes(allowed_script_roots.clone())
192+
.expect("network account allowlist must be non-empty")
193+
.with_allowed_tx_scripts(allowed_tx_script_roots.clone())
194+
.into();
194195
(component, None)
195196
},
196197
}

crates/miden-testing/tests/auth/network_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn build_account_with_allowlists(
3939
allowed_note_script_roots: Vec<Word>,
4040
allowed_tx_script_roots: Vec<TransactionScriptRoot>,
4141
) -> anyhow::Result<Account> {
42-
let auth_component = AuthNetworkAccount::with_allowlist(
42+
let auth_component = AuthNetworkAccount::with_allowed_notes(
4343
allowed_note_script_roots.into_iter().map(NoteScriptRoot::from_raw).collect(),
4444
)?
4545
.with_allowed_tx_scripts(allowed_tx_script_roots.into_iter().collect::<BTreeSet<_>>());

0 commit comments

Comments
 (0)