Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/apollo_batcher/src/cende_client_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,22 @@ impl From<StateMaps> for StarknetClientStateDiff {
})
}
}

#[cfg(any(test, feature = "testing"))]
impl StarknetClientStateDiff {
pub fn sort(&mut self) {
// Storage diffs also need inner sorting: sort each address diffs, then sort the addresses.
self.0.storage_diffs.sort_by_key(|address, _| *address);
for (_, address_diffs) in self.0.storage_diffs.iter_mut() {
address_diffs.sort();
}
self.0.deployed_contracts.sort_by_key(|deployed_contract| deployed_contract.address);
self.0.declared_classes.sort_by_key(|declared_class| declared_class.class_hash);
self.0.old_declared_contracts.sort();
self.0.nonces.sort_by_key(|address, _nonce| *address);
self.0.replaced_classes.sort_by_key(|replaced_class| replaced_class.address);
self.0
.migrated_compiled_classes
.sort_by_key(|migrated_compiled_class| migrated_compiled_class.class_hash);
}
}
2 changes: 1 addition & 1 deletion crates/central_systest_blobs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license-file.workspace = true
description = "Keeps blob JSONs for centralized system test, and tests for regression"

[dev-dependencies]
apollo_batcher.workspace = true
apollo_batcher = { workspace = true, features = ["testing"] }
apollo_batcher_types.workspace = true
apollo_class_manager_types = { workspace = true, features = ["testing"] }
apollo_consensus.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,13 @@ impl BlobFactory {
&execution_info,
None,
));
let tx_state_diff = StarknetClientStateDiff::from(state_changes.state_maps).0;
let mut tx_state_diff = StarknetClientStateDiff::from(state_changes.state_maps);
// To keep the output deterministic, sort the state diff.
tx_state_diff.sort();

transactions.push(CendePreconfirmedTransaction::from(internal));
transaction_receipts.push(Some(receipt));
transaction_state_diffs.push(Some(tx_state_diff));
transaction_state_diffs.push(Some(tx_state_diff.0));

// Update the state for the next tx.
state = tx_state.state;
Expand Down
Loading