diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ab38e17..c928e77ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - [BREAKING] Renamed `SubmitProvenBatch` RPC endpoint to `SubmitProvenTxBatch` ([#2094](https://github.com/0xMiden/node/pull/2094)). - Fixed block producer mempool panic when selecting transactions that depend on notes created by pruned committed transactions ([#2097](https://github.com/0xMiden/node/pull/2097)). - Implemented filtering based on the network account note script root allowlist in ntx-builder ([#2042](https://github.com/0xMiden/node/issues/2042)). +- Added SQL conversion trait coverage for common store database binary types ([#1477](https://github.com/0xMiden/node/issues/1477)). - [BREAKING] Renamed `ExplorerStatusDetails` fields in the network monitor's `/status` payload from `number_of_*` to `total_*` (`total_transactions`, `total_nullifiers`, `total_notes`, `total_account_updates`). The values now represent network-wide cumulative totals from the explorer's `overviewStats` query instead of last-block counts. - [BREAKING] Removed `--wallet-filepath` / `--counter-filepath` flags and the `MIDEN_MONITOR_WALLET_FILEPATH` / `MIDEN_MONITOR_COUNTER_FILEPATH` env vars from the network monitor. The monitor now keeps wallet and counter accounts fully in memory and regenerates them on every startup; the dashboard's counter value resets to zero on restart. diff --git a/crates/store/src/db/models/conv.rs b/crates/store/src/db/models/conv.rs index 25b6047f9..0849eee59 100644 --- a/crates/store/src/db/models/conv.rs +++ b/crates/store/src/db/models/conv.rs @@ -33,11 +33,30 @@ )] use miden_crypto::Word; -use miden_crypto::utils::Deserializable; +use miden_crypto::utils::{Deserializable, Serializable}; use miden_protocol::Felt; -use miden_protocol::account::{StorageSlotName, StorageSlotType}; +use miden_protocol::account::{ + AccountCode, + AccountId, + AccountStorageHeader, + StorageMapKey, + StorageSlotName, + StorageSlotType, +}; +use miden_protocol::asset::Asset; use miden_protocol::block::{BlockHeader, BlockNumber}; -use miden_protocol::note::NoteTag; +use miden_protocol::crypto::merkle::SparseMerklePath; +use miden_protocol::note::{ + NoteAssets, + NoteAttachments, + NoteId, + NoteMetadata, + NoteScript, + NoteStorage, + NoteTag, + Nullifier, +}; +use miden_protocol::transaction::TransactionId; use crate::db::models::queries::{BlockHeaderCommitment, NetworkAccountType}; @@ -91,10 +110,46 @@ impl SqlTypeConvert for BlockHeader { } fn to_raw_sql(self) -> Self::Raw { - miden_crypto::utils::Serializable::to_bytes(&self) + Serializable::to_bytes(&self) } } +macro_rules! impl_binary_sql_convert { + ($($ty:ty),+ $(,)?) => { + $( + impl SqlTypeConvert for $ty { + type Raw = Vec; + + fn from_raw_sql(raw: Self::Raw) -> Result { + ::read_from_bytes(raw.as_slice()).map_err(Self::map_err) + } + + fn to_raw_sql(self) -> Self::Raw { + Serializable::to_bytes(&self) + } + } + )+ + }; +} + +impl_binary_sql_convert!( + AccountCode, + AccountId, + AccountStorageHeader, + Asset, + NoteAssets, + NoteAttachments, + NoteId, + NoteMetadata, + NoteScript, + NoteStorage, + Nullifier, + SparseMerklePath, + StorageMapKey, + TransactionId, + Word, +); + impl SqlTypeConvert for NetworkAccountType { type Raw = i32;