Skip to content

Commit

Permalink
Manually serialize FullExit flag in data_restore
Browse files Browse the repository at this point in the history
  • Loading branch information
slumber committed Jun 17, 2021
1 parent 03b1261 commit 3e0ae32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions core/lib/storage/src/data_restore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use zksync_types::{
aggregated_operations::{
AggregatedActionType, AggregatedOperation, BlocksCommitOperation, BlocksExecuteOperation,
},
AccountId, AccountUpdate, BlockNumber, Token,
AccountId, AccountUpdate, BlockNumber, Token, ZkSyncOp,
};
// Local imports
use self::records::{
Expand Down Expand Up @@ -242,7 +242,16 @@ impl<'a, 'c> DataRestoreSchema<'a, 'c> {
let operations: Vec<_> = block
.ops
.iter()
.map(|op| serde_json::to_value(op.clone()).unwrap())
.map(|op| {
let mut value = serde_json::to_value(op.clone()).unwrap();
if let ZkSyncOp::FullExit(full_exit) = op {
// In general, this field is not expected to be serialized,
// however it is used in data_restore to determine the number of
// required chunks
value["priority_op"]["is_legacy"] = full_exit.priority_op.is_legacy.into();
}
value
})
.collect();
sqlx::query!(
"INSERT INTO data_restore_rollup_block_ops (block_num, operation)
Expand Down
5 changes: 3 additions & 2 deletions core/lib/types/src/priority_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ pub struct FullExit {
pub token: TokenId,
/// A flag that indicates whether the operation was performed
/// before the NFT upgrade with an old number of required block chunks.
/// Required by the `data_restore`, `false` by default.
#[serde(default = "bool::default")]
/// Only serialized manually by the `data_restore`, `false` by default.
#[serde(default)]
#[serde(skip_serializing)]
pub is_legacy: bool,
}

Expand Down

0 comments on commit 3e0ae32

Please sign in to comment.