Skip to content

Commit 2f2dda0

Browse files
committed
Merge remote-tracking branch 'origin/main' into ax/event-stream
2 parents f9651fa + e588a71 commit 2f2dda0

File tree

44 files changed

+590
-462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+590
-462
lines changed

.github/workflows/push-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ jobs:
4545
uses: docker/build-push-action@v6
4646
with:
4747
push: true
48-
platforms: linux/amd64,linux/arm64
48+
platforms: linux/amd64
4949
file: ./docker/timeboost.Dockerfile
5050
tags: ghcr.io/espressosystems/timeboost:${{ env.TAG }}

Cargo.lock

Lines changed: 19 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adapters/src/bytes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::convert::Infallible;
22

33
use bytes::{Bytes, BytesMut};
4+
use minicbor::CborLen;
45
use minicbor::decode::{Decoder, Error as DecodeError};
56
use minicbor::encode::{Encoder, Error as EncodeError, Write};
67

@@ -15,6 +16,11 @@ pub fn decode<'b, C>(d: &mut Decoder<'b>, _: &mut C) -> Result<Bytes, DecodeErro
1516
Ok(Bytes::copy_from_slice(d.bytes()?))
1617
}
1718

19+
pub fn cbor_len<C>(b: &Bytes, c: &mut C) -> usize {
20+
let n = b.len();
21+
n.cbor_len(c) + n
22+
}
23+
1824
/// `BytesWrite` can be used to encode directly into `BytesMut`.
1925
#[derive(Default)]
2026
pub struct BytesWriter(BytesMut);

adapters/src/commitment.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use committable::{Commitment, Committable};
2+
use minicbor::CborLen;
23
use minicbor::decode::{Decoder, Error as DecodeError};
34
use minicbor::encode::{Encoder, Error as EncodeError, Write};
45

@@ -13,7 +14,9 @@ where
1314
W: Write,
1415
D: Committable,
1516
{
16-
e.bytes(d.as_ref())?.ok()
17+
let b: &[u8] = d.as_ref();
18+
debug_assert_eq!(b.len(), LEN);
19+
e.bytes(b)?.ok()
1720
}
1821

1922
pub fn decode<'b, D, C>(d: &mut Decoder<'b>, _: &mut C) -> Result<Commitment<D>, DecodeError>
@@ -26,3 +29,10 @@ where
2629
.map(Commitment::from_raw)
2730
.map_err(|e| DecodeError::custom(e).at(p))
2831
}
32+
33+
pub fn cbor_len<D, C>(_: &Commitment<D>, c: &mut C) -> usize
34+
where
35+
D: Committable,
36+
{
37+
LEN.cbor_len(c) + LEN
38+
}

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test-contract-deploy *ARGS:
177177
scripts/test-contract-deploy {{ARGS}}
178178

179179
test-all: build_release build-test-utils
180-
env RUST_LOG=block_checker=info,warn target/release/run \
180+
env RUST_LOG=timeboost_builder::submit=debug,block_checker=info,warn target/release/run \
181181
--verbose \
182182
--timeout 120 \
183183
--spawn "1:anvil --port 8545" \

multisig/src/cert.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ use std::{collections::BTreeMap, num::NonZeroUsize};
22

33
use committable::{Commitment, Committable, RawCommitmentBuilder};
44
use constant_time_eq::constant_time_eq;
5-
use minicbor::{Decode, Encode};
5+
use minicbor::{CborLen, Decode, Encode};
66
use serde::{Deserialize, Serialize};
77

88
use crate::{Committee, KeyId, PublicKey, Signature};
99

1010
#[derive(
11-
Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, Encode, Decode,
11+
Debug,
12+
Clone,
13+
PartialEq,
14+
Eq,
15+
Hash,
16+
PartialOrd,
17+
Ord,
18+
Serialize,
19+
Deserialize,
20+
Encode,
21+
Decode,
22+
CborLen,
1223
)]
1324
#[cbor(map)]
1425
pub struct Certificate<D: Committable> {

multisig/src/committee.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55

66
use bimap::BiBTreeMap;
77
use committable::{Commitment, Committable, RawCommitmentBuilder};
8-
use minicbor::{Decode, Encode};
8+
use minicbor::{CborLen, Decode, Encode};
99
use serde::{Deserialize, Serialize};
1010

1111
use super::{KeyId, PublicKey};
@@ -105,7 +105,19 @@ impl Committee {
105105
}
106106

107107
#[derive(
108-
Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
108+
Debug,
109+
Copy,
110+
Clone,
111+
PartialEq,
112+
Eq,
113+
PartialOrd,
114+
Ord,
115+
Hash,
116+
Serialize,
117+
Deserialize,
118+
Encode,
119+
Decode,
120+
CborLen,
109121
)]
110122
#[cbor(transparent)]
111123
#[serde(transparent)]

multisig/src/lib.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod x25519;
1010
use std::fmt;
1111

1212
use committable::{Commitment, Committable, RawCommitmentBuilder};
13-
use minicbor::{Decode, Encode};
13+
use minicbor::{CborLen, Decode, Encode};
1414
use secp256k1::rand::Rng;
1515
use serde::{Deserialize, Serialize};
1616

@@ -21,7 +21,19 @@ pub use signed::Signed;
2121
pub use votes::VoteAccumulator;
2222

2323
#[derive(
24-
Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
24+
Debug,
25+
Copy,
26+
Clone,
27+
PartialEq,
28+
Eq,
29+
PartialOrd,
30+
Ord,
31+
Hash,
32+
Serialize,
33+
Deserialize,
34+
Encode,
35+
Decode,
36+
CborLen,
2537
)]
2638
#[cbor(transparent)]
2739
#[serde(transparent)]
@@ -85,14 +97,26 @@ pub struct SecretKey {
8597
}
8698

8799
#[derive(
88-
Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Encode, Decode,
100+
Copy,
101+
Clone,
102+
PartialEq,
103+
Eq,
104+
PartialOrd,
105+
Ord,
106+
Hash,
107+
Serialize,
108+
Deserialize,
109+
Encode,
110+
Decode,
111+
CborLen,
89112
)]
90113
#[cbor(transparent)]
91114
#[serde(transparent)]
92115
pub struct Signature {
93116
#[cbor(
94117
encode_with = "util::encode_secp256k1_sig",
95-
decode_with = "util::decode_secp256k1_sig"
118+
decode_with = "util::decode_secp256k1_sig",
119+
cbor_len = "util::cbor_len_secp256k1_sig"
96120
)]
97121
sig: secp256k1::ecdsa::Signature,
98122
}

multisig/src/util.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Deref;
22

33
use ed25519_compact::x25519;
4+
use minicbor::CborLen;
45
use minicbor::decode::{Decode, Decoder, Error as DecodeError};
56
use minicbor::encode::{Encoder, Error as EncodeError, Write};
67
use serde::{Deserialize, Deserializer, Serialize, Serializer, de};
@@ -108,6 +109,8 @@ where
108109
}
109110
}
110111

112+
const SECP256K1_SIG_LEN: usize = 64;
113+
111114
pub fn encode_secp256k1_sig<C, W>(
112115
s: &secp256k1::ecdsa::Signature,
113116
e: &mut Encoder<W>,
@@ -116,7 +119,7 @@ pub fn encode_secp256k1_sig<C, W>(
116119
where
117120
W: Write,
118121
{
119-
let a: [u8; 64] = s.serialize_compact();
122+
let a: [u8; SECP256K1_SIG_LEN] = s.serialize_compact();
120123
e.bytes(&a)?;
121124
Ok(())
122125
}
@@ -151,3 +154,7 @@ pub fn decode_secp256k1_pk<'b, C>(
151154
let a: [u8; 33] = minicbor::bytes::ByteArray::<33>::decode(d, c)?.into();
152155
secp256k1::PublicKey::from_byte_array_compressed(a).map_err(|e| DecodeError::custom(e).at(p))
153156
}
157+
158+
pub fn cbor_len_secp256k1_sig<C>(_: &secp256k1::ecdsa::Signature, c: &mut C) -> usize {
159+
SECP256K1_SIG_LEN.cbor_len(c) + SECP256K1_SIG_LEN
160+
}

0 commit comments

Comments
 (0)