mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-07 22:03:58 -05:00
fix(encoding): set correct frame limit (#963)
* fix(encoding): set correct frame limit * bugfix for `TranscriptRefs::len` * use current frame limit as cushion room
This commit is contained in:
@@ -28,6 +28,14 @@ impl TranscriptRefs {
|
||||
&self.recv
|
||||
}
|
||||
|
||||
/// Returns the transcript lengths.
|
||||
pub(crate) fn len(&self) -> (usize, usize) {
|
||||
let sent = self.sent.iter().map(|v| v.len()).sum();
|
||||
let recv = self.recv.iter().map(|v| v.len()).sum();
|
||||
|
||||
(sent, recv)
|
||||
}
|
||||
|
||||
/// Returns VM references for the given direction and index, otherwise
|
||||
/// `None` if the index is out of bounds.
|
||||
pub(crate) fn get(&self, direction: Direction, idx: &Idx) -> Option<Vec<Vector<U8>>> {
|
||||
|
||||
@@ -88,7 +88,12 @@ pub(crate) async fn transfer<'a>(
|
||||
.zip(recv_keys)
|
||||
.for_each(|(enc, key)| *enc ^= key);
|
||||
|
||||
// Set frame limit and add some extra bytes cushion room.
|
||||
let (sent, recv) = refs.len();
|
||||
let frame_limit = ENCODING_SIZE * (sent + recv) + ctx.io().limit();
|
||||
|
||||
ctx.io_mut()
|
||||
.with_limit(frame_limit)
|
||||
.send(Encodings {
|
||||
sent: sent_encoding,
|
||||
recv: recv_encoding,
|
||||
@@ -114,7 +119,12 @@ pub(crate) async fn receive<'a>(
|
||||
f: impl Fn(Vector<U8>) -> &'a [Mac],
|
||||
idxs: impl IntoIterator<Item = &(Direction, Idx)>,
|
||||
) -> Result<(EncodingCommitment, EncodingTree), EncodingError> {
|
||||
let Encodings { mut sent, mut recv } = ctx.io_mut().expect_next().await?;
|
||||
// Set frame limit and add some extra bytes cushion room.
|
||||
let (sent, recv) = refs.len();
|
||||
let frame_limit = ENCODING_SIZE * (sent + recv) + ctx.io().limit();
|
||||
|
||||
let Encodings { mut sent, mut recv } =
|
||||
ctx.io_mut().with_limit(frame_limit).expect_next().await?;
|
||||
|
||||
let sent_macs: Vec<u8> = refs
|
||||
.sent()
|
||||
|
||||
Reference in New Issue
Block a user