Skip to content

Commit 3ae652f

Browse files
authored
fix(rpc): check for public state (#1711)
1 parent 0fb05fb commit 3ae652f

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.13.7 (2026-02-25)
4+
5+
- Updated `SyncAccountStorageMaps` and `SyncAccountVault` to allow all accounts with public state, including network accounts ([#1711](https://github.com/0xMiden/node/pull/1711)).
6+
37
## v0.13.6 (2026-02-25)
48

59
- Fixed CORS headers missing from version-rejection responses ([#1707](https://github.com/0xMiden/node/pull/1707)).

crates/store/src/db/models/queries/accounts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub(crate) fn select_account_vault_assets(
370370
const ROW_OVERHEAD_BYTES: usize = 2 * size_of::<Word>() + size_of::<u32>(); // key + asset + block_num
371371
const MAX_ROWS: usize = MAX_RESPONSE_PAYLOAD_BYTES / ROW_OVERHEAD_BYTES;
372372

373-
if !account_id.is_public() {
373+
if !account_id.has_public_state() {
374374
return Err(DatabaseError::AccountNotPublic(account_id));
375375
}
376376

@@ -666,7 +666,7 @@ pub(crate) fn select_account_storage_map_values(
666666
2 * size_of::<Word>() + size_of::<u32>() + size_of::<u8>(); // key + value + block_num + slot_idx
667667
pub const MAX_ROWS: usize = MAX_RESPONSE_PAYLOAD_BYTES / ROW_OVERHEAD_BYTES;
668668

669-
if !account_id.is_public() {
669+
if !account_id.has_public_state() {
670670
return Err(DatabaseError::AccountNotPublic(account_id));
671671
}
672672

crates/store/src/db/tests.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,42 @@ fn select_storage_map_sync_values() {
12141214
assert_eq!(page.values, expected, "should return latest values ordered by key");
12151215
}
12161216

1217+
#[test]
1218+
fn select_storage_map_sync_values_for_network_account() {
1219+
let mut conn = create_db();
1220+
let block_num = BlockNumber::from(1);
1221+
create_block(&mut conn, block_num);
1222+
1223+
let (account_id, _) =
1224+
make_account_and_note(&mut conn, block_num, [42u8; 32], AccountStorageMode::Network);
1225+
let slot_name = StorageSlotName::mock(7);
1226+
let key = num_to_word(1);
1227+
let value = num_to_word(10);
1228+
1229+
queries::insert_account_storage_map_value(
1230+
&mut conn,
1231+
account_id,
1232+
block_num,
1233+
slot_name.clone(),
1234+
key,
1235+
value,
1236+
)
1237+
.unwrap();
1238+
1239+
let page = queries::select_account_storage_map_values(
1240+
&mut conn,
1241+
account_id,
1242+
BlockNumber::GENESIS..=block_num,
1243+
)
1244+
.unwrap();
1245+
1246+
assert_eq!(
1247+
page.values,
1248+
vec![StorageMapValue { block_num, slot_name, key, value }],
1249+
"network accounts with public state should be accepted",
1250+
);
1251+
}
1252+
12171253
// UTILITIES
12181254
// -------------------------------------------------------------------------------------------
12191255
fn num_to_word(n: u64) -> Word {

crates/store/src/server/rpc_api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl rpc_server::Rpc for StoreApi {
266266

267267
let account_id: AccountId = read_account_id::<SyncAccountVaultError>(request.account_id)?;
268268

269-
if !account_id.is_public() {
269+
if !account_id.has_public_state() {
270270
return Err(SyncAccountVaultError::AccountNotPublic(account_id).into());
271271
}
272272

@@ -314,7 +314,7 @@ impl rpc_server::Rpc for StoreApi {
314314

315315
let account_id = read_account_id::<SyncAccountStorageMapsError>(request.account_id)?;
316316

317-
if !account_id.is_public() {
317+
if !account_id.has_public_state() {
318318
Err(SyncAccountStorageMapsError::AccountNotPublic(account_id))?;
319319
}
320320

0 commit comments

Comments
 (0)