diff --git a/node/libs/roles/src/proto/validator.proto b/node/libs/roles/src/proto/validator.proto index f1ec2438..33c09ee9 100644 --- a/node/libs/roles/src/proto/validator.proto +++ b/node/libs/roles/src/proto/validator.proto @@ -144,11 +144,16 @@ message NetAddress { optional std.Timestamp timestamp = 3; // required } +message L1BatchSignature { + optional bytes signature = 1; // required +} + message Msg { oneof t { // required ConsensusMsg consensus = 1; bytes session_id = 2; NetAddress net_address = 3; + L1BatchSignature l1_batch_signature = 4; } } diff --git a/node/libs/roles/src/validator/conv.rs b/node/libs/roles/src/validator/conv.rs index 04886834..f33ba58d 100644 --- a/node/libs/roles/src/validator/conv.rs +++ b/node/libs/roles/src/validator/conv.rs @@ -1,8 +1,9 @@ use super::{ AggregateSignature, BlockHeader, BlockHeaderHash, BlockNumber, CommitQC, ConsensusMsg, - FinalBlock, Fork, ForkNumber, Genesis, GenesisHash, LeaderCommit, LeaderPrepare, Msg, MsgHash, - NetAddress, Payload, PayloadHash, Phase, PrepareQC, ProtocolVersion, PublicKey, ReplicaCommit, - ReplicaPrepare, Signature, Signed, Signers, ValidatorSet, View, ViewNumber, + FinalBlock, Fork, ForkNumber, Genesis, GenesisHash, L1BatchSignature, LeaderCommit, + LeaderPrepare, Msg, MsgHash, NetAddress, Payload, PayloadHash, Phase, PrepareQC, + ProtocolVersion, PublicKey, ReplicaCommit, ReplicaPrepare, Signature, Signed, Signers, + ValidatorSet, View, ViewNumber, }; use crate::{node::SessionId, proto::validator as proto}; use anyhow::Context as _; @@ -355,6 +356,20 @@ impl ProtoFmt for NetAddress { } } +impl ProtoFmt for L1BatchSignature { + type Proto = proto::L1BatchSignature; + + fn read(r: &Self::Proto) -> anyhow::Result { + Ok(Self(ByteFmt::decode(required(&r.signature)?)?)) + } + + fn build(&self) -> Self::Proto { + Self::Proto { + signature: Some(self.0.encode()), + } + } +} + impl ProtoFmt for Msg { type Proto = proto::Msg; @@ -364,6 +379,9 @@ impl ProtoFmt for Msg { T::Consensus(r) => Self::Consensus(ProtoFmt::read(r).context("Consensus")?), T::SessionId(r) => Self::SessionId(SessionId(r.clone())), T::NetAddress(r) => Self::NetAddress(ProtoFmt::read(r).context("NetAddress")?), + T::L1BatchSignature(r) => { + Self::L1BatchSignature(ProtoFmt::read(r).context("L1BatchSignature")?) + } }) } @@ -374,6 +392,7 @@ impl ProtoFmt for Msg { Self::Consensus(x) => T::Consensus(x.build()), Self::SessionId(x) => T::SessionId(x.0.clone()), Self::NetAddress(x) => T::NetAddress(x.build()), + Self::L1BatchSignature(x) => T::L1BatchSignature(x.build()), }; Self::Proto { t: Some(t) }