Replace bincode with borsh (#452)

* Add SignalsConfig to chain_spec

* Correct multiexp feature flagging for rand_core std

* Remove bincode for borsh

Replaces a non-canonical encoding with a canonical encoding which additionally
should be faster.

Also fixes an issue where we used bincode in transcripts where it cannot be
trusted.

This ended up fixing a myriad of other bugs observed, unfortunately.
Accordingly, it either has to be merged or the bug fixes from it must be ported
to a new PR.

* Make serde optional, minimize usage

* Make borsh an optional dependency of substrate/ crates

* Remove unused dependencies

* Use [u8; 64] where possible in the processor messages

* Correct borsh feature flagging
This commit is contained in:
Luke Parker
2023-11-25 04:01:11 -05:00
committed by GitHub
parent 6b2876351e
commit b296be8515
52 changed files with 468 additions and 309 deletions

View File

@@ -10,7 +10,7 @@ impl<D: Db> Queue<D> {
}
fn message_count_key(&self) -> Vec<u8> {
Self::key(b"message_count", bincode::serialize(&(self.1, self.2)).unwrap())
Self::key(b"message_count", borsh::to_vec(&(self.1, self.2)).unwrap())
}
pub(crate) fn message_count(&self) -> u64 {
self
@@ -21,7 +21,7 @@ impl<D: Db> Queue<D> {
}
fn last_acknowledged_key(&self) -> Vec<u8> {
Self::key(b"last_acknowledged", bincode::serialize(&(self.1, self.2)).unwrap())
Self::key(b"last_acknowledged", borsh::to_vec(&(self.1, self.2)).unwrap())
}
pub(crate) fn last_acknowledged(&self) -> Option<u64> {
self
@@ -31,7 +31,7 @@ impl<D: Db> Queue<D> {
}
fn message_key(&self, id: u64) -> Vec<u8> {
Self::key(b"message", bincode::serialize(&(self.1, self.2, id)).unwrap())
Self::key(b"message", borsh::to_vec(&(self.1, self.2, id)).unwrap())
}
// TODO: This is fine as-used, yet gets from the DB while having a txn. It should get from the
// txn