refactor(lee_core): carry diff_data as Data instead of raw bytes

AccountDiff.diff_data, ProgramCall::UpdateFromDiff.diff_data,
UpdateFromDiffOutput.diff_data, and write_update_from_diff_output's
parameter all move from Vec<u8>/&[u8] to Data, so this payload carries
Data's length restriction (DATA_MAX_LENGTH) and validated deserialization
everywhere it flows, rather than only once it lands in account.data.
This commit is contained in:
Marvin Jones
2026-08-20 12:32:48 -04:00
parent dcf7537c5f
commit 795b79a2ac
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ pub enum BalanceDiffError {
pub struct AccountDiff {
pub id: AccountId,
pub diff_balance: BalanceDiff,
pub diff_data: Option<Vec<u8>>,
pub diff_data: Option<Data>,
}
/// Account to be used both in public and private contexts.
+5 -5
View File
@@ -700,7 +700,7 @@ pub enum ProgramCall<T> {
Execute(ProgramInput<T>, InstructionData),
UpdateFromDiff {
pre_state: Account,
diff_data: Vec<u8>,
diff_data: Data,
},
}
@@ -716,7 +716,7 @@ pub enum ProgramCall<T> {
#[derive(Serialize, Deserialize)]
pub struct UpdateFromDiffOutput {
pub pre_state: Account,
pub diff_data: Vec<u8>,
pub diff_data: Data,
pub data: Data,
}
@@ -766,7 +766,7 @@ pub fn read_lee_call<T: DeserializeOwned>() -> ProgramCall<T> {
}
CallKind::UpdateFromDiff => {
let pre_state: Account = env::read();
let diff_data: Vec<u8> = env::read();
let diff_data: Data = env::read();
ProgramCall::UpdateFromDiff {
pre_state,
diff_data,
@@ -906,10 +906,10 @@ fn validate_uniqueness_of_account_ids(pre_states: &[AccountWithMetadata]) -> boo
}
/// Commits an `update_from_diff` result to the journal, bound to the inputs that produced it.
pub fn write_update_from_diff_output(pre_state: &Account, diff_data: &[u8], data: &Data) {
pub fn write_update_from_diff_output(pre_state: &Account, diff_data: &Data, data: &Data) {
env::commit(&UpdateFromDiffOutput {
pre_state: pre_state.clone(),
diff_data: diff_data.to_vec(),
diff_data: diff_data.clone(),
data: data.clone(),
});
}