feat(exex): use rmp-serde for WAL storage (#11353)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Alexey Shekhirin
2024-10-01 12:55:42 +03:00
committed by GitHub
parent f51ac78d5a
commit a8a380ff54
7 changed files with 42 additions and 13 deletions

View File

@ -17,7 +17,7 @@ reth-chain-state.workspace = true
reth-chainspec.workspace = true
reth-config.workspace = true
reth-evm.workspace = true
reth-exex-types = { workspace = true, features = ["serde"] }
reth-exex-types = { workspace = true, features = ["serde", "serde-bincode-compat"] }
reth-fs-util.workspace = true
reth-metrics.workspace = true
reth-node-api.workspace = true
@ -46,7 +46,7 @@ eyre.workspace = true
itertools.workspace = true
metrics.workspace = true
parking_lot.workspace = true
serde_json.workspace = true
rmp-serde = "1.3"
tracing.workspace = true
[dev-dependencies]

View File

@ -116,8 +116,11 @@ impl Storage {
Err(err) => return Err(err.into()),
};
// TODO(alexey): use rmp-serde when Alloy and Reth serde issues are resolved
Ok(serde_json::from_reader(&mut file)?)
// Deserialize using the bincode- and msgpack-compatible serde wrapper
let notification: reth_exex_types::serde_bincode_compat::ExExNotification<'_> =
rmp_serde::decode::from_read(&mut file)?;
Ok(Some(notification.into()))
}
/// Writes the notification to the file with the given ID.
@ -130,9 +133,12 @@ impl Storage {
let file_path = self.file_path(file_id);
debug!(?file_path, "Writing notification to WAL");
// Serialize using the bincode- and msgpack-compatible serde wrapper
let notification =
reth_exex_types::serde_bincode_compat::ExExNotification::from(notification);
Ok(reth_fs_util::atomic_write_file(&file_path, |file| {
// TODO(alexey): use rmp-serde when Alloy and Reth serde issues are resolved
serde_json::to_writer(file, notification)
rmp_serde::encode::write(file, &notification)
})?)
}
}