Skip to content

Commit 41874af

Browse files
authored
Add new, unused for now, fields and types. (#4391)
## Motivation Otherwise hotfixing won't be possible due to non-compatible changes in the original PR. ## Proposal Add the types, fields, but not use them. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 5a8977f commit 41874af

File tree

7 files changed

+81
-20
lines changed

7 files changed

+81
-20
lines changed

linera-core/src/data_types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ pub struct ChainInfoQuery {
9090
/// Include a vote to switch to fallback mode, if appropriate.
9191
#[debug(skip_if = Not::not)]
9292
pub request_fallback: bool,
93+
/// Query for certificate hashes at block heights.
94+
#[debug(skip_if = Vec::is_empty)]
95+
pub request_sent_certificate_hashes_by_heights: Vec<BlockHeight>,
9396
}
9497

9598
impl ChainInfoQuery {
@@ -105,6 +108,7 @@ impl ChainInfoQuery {
105108
request_manager_values: false,
106109
request_leader_timeout: None,
107110
request_fallback: false,
111+
request_sent_certificate_hashes_by_heights: Vec::new(),
108112
}
109113
}
110114

linera-core/src/node.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ pub enum NodeError {
288288
EmptyBlobsNotFound,
289289
#[error("Local error handling validator response: {error}")]
290290
ResponseHandlingError { error: String },
291+
292+
#[error("Missing certificates for chain {chain_id} in heights {heights:?}")]
293+
MissingCertificatesByHeights {
294+
chain_id: ChainId,
295+
heights: Vec<BlockHeight>,
296+
},
297+
298+
#[error("Too many certificates returned for chain {chain_id} from {remote_node}")]
299+
TooManyCertificatesReturned {
300+
chain_id: ChainId,
301+
remote_node: Box<ValidatorPublicKey>,
302+
},
291303
}
292304

293305
impl From<tonic::Status> for NodeError {

linera-rpc/src/grpc/conversions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ impl TryFrom<api::ChainInfoQuery> for ChainInfoQuery {
610610
request_manager_values: chain_info_query.request_manager_values,
611611
request_leader_timeout,
612612
request_fallback: chain_info_query.request_fallback,
613+
request_sent_certificate_hashes_by_heights: vec![],
613614
})
614615
}
615616
}
@@ -1152,6 +1153,7 @@ pub mod tests {
11521153
request_manager_values: false,
11531154
request_leader_timeout: None,
11541155
request_fallback: true,
1156+
request_sent_certificate_hashes_by_heights: vec![],
11551157
};
11561158
round_trip_check::<_, api::ChainInfoQuery>(chain_info_query_some);
11571159
}

linera-rpc/src/message.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use linera_base::{
66
crypto::CryptoHash,
7-
data_types::{BlobContent, NetworkDescription},
7+
data_types::{BlobContent, BlockHeight, NetworkDescription},
88
identifiers::{BlobId, ChainId},
99
};
1010
use linera_chain::{
@@ -39,6 +39,7 @@ pub enum RpcMessage {
3939
HandlePendingBlob(Box<(ChainId, BlobContent)>),
4040
DownloadConfirmedBlock(Box<CryptoHash>),
4141
DownloadCertificates(Vec<CryptoHash>),
42+
DownloadCertificatesByHeights(ChainId, Vec<BlockHeight>),
4243
BlobLastUsedBy(Box<BlobId>),
4344
MissingBlobIds(Vec<BlobId>),
4445
VersionInfoQuery,
@@ -55,6 +56,7 @@ pub enum RpcMessage {
5556
DownloadPendingBlobResponse(Box<BlobContent>),
5657
DownloadConfirmedBlockResponse(Box<ConfirmedBlock>),
5758
DownloadCertificatesResponse(Vec<ConfirmedBlockCertificate>),
59+
DownloadCertificatesByHeightsResponse(Vec<ConfirmedBlockCertificate>),
5860
BlobLastUsedByResponse(Box<CryptoHash>),
5961
MissingBlobIdsResponse(Vec<BlobId>),
6062

@@ -93,6 +95,8 @@ impl RpcMessage {
9395
| DownloadPendingBlobResponse(_)
9496
| DownloadConfirmedBlock(_)
9597
| DownloadConfirmedBlockResponse(_)
98+
| DownloadCertificatesByHeights(_, _)
99+
| DownloadCertificatesByHeightsResponse(_)
96100
| DownloadCertificates(_)
97101
| BlobLastUsedBy(_)
98102
| BlobLastUsedByResponse(_)
@@ -140,7 +144,9 @@ impl RpcMessage {
140144
| DownloadConfirmedBlockResponse(_)
141145
| BlobLastUsedByResponse(_)
142146
| MissingBlobIdsResponse(_)
143-
| DownloadCertificatesResponse(_) => false,
147+
| DownloadCertificatesResponse(_)
148+
| DownloadCertificatesByHeights(_, _)
149+
| DownloadCertificatesByHeightsResponse(_) => false,
144150
}
145151
}
146152
}

linera-rpc/src/simple/server.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ where
384384
| RpcMessage::DownloadCertificates(_)
385385
| RpcMessage::DownloadCertificatesResponse(_)
386386
| RpcMessage::UploadBlob(_)
387-
| RpcMessage::UploadBlobResponse(_) => Err(NodeError::UnexpectedMessage),
387+
| RpcMessage::UploadBlobResponse(_)
388+
| RpcMessage::DownloadCertificatesByHeights(_, _)
389+
| RpcMessage::DownloadCertificatesByHeightsResponse(_) => {
390+
Err(NodeError::UnexpectedMessage)
391+
}
388392
};
389393

390394
self.server.packets_processed += 1;

linera-rpc/tests/snapshots/format__format.yaml.snap

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ ChainInfoQuery:
362362
- TYPENAME: BlockHeight
363363
- TYPENAME: Round
364364
- request_fallback: BOOL
365+
- request_sent_certificate_hashes_by_heights:
366+
SEQ:
367+
TYPENAME: BlockHeight
365368
ChainInfoResponse:
366369
STRUCT:
367370
- info:
@@ -789,6 +792,21 @@ NodeError:
789792
ResponseHandlingError:
790793
STRUCT:
791794
- error: STR
795+
29:
796+
MissingCertificatesByHeights:
797+
STRUCT:
798+
- chain_id:
799+
TYPENAME: ChainId
800+
- heights:
801+
SEQ:
802+
TYPENAME: BlockHeight
803+
30:
804+
TooManyCertificatesReturned:
805+
STRUCT:
806+
- chain_id:
807+
TYPENAME: ChainId
808+
- remote_node:
809+
TYPENAME: Secp256k1PublicKey
792810
OpenChainConfig:
793811
STRUCT:
794812
- ownership:
@@ -1038,69 +1056,80 @@ RpcMessage:
10381056
SEQ:
10391057
TYPENAME: CryptoHash
10401058
12:
1059+
DownloadCertificatesByHeights:
1060+
TUPLE:
1061+
- TYPENAME: ChainId
1062+
- SEQ:
1063+
TYPENAME: BlockHeight
1064+
13:
10411065
BlobLastUsedBy:
10421066
NEWTYPE:
10431067
TYPENAME: BlobId
1044-
13:
1068+
14:
10451069
MissingBlobIds:
10461070
NEWTYPE:
10471071
SEQ:
10481072
TYPENAME: BlobId
1049-
14:
1050-
VersionInfoQuery: UNIT
10511073
15:
1052-
NetworkDescriptionQuery: UNIT
1074+
VersionInfoQuery: UNIT
10531075
16:
1076+
NetworkDescriptionQuery: UNIT
1077+
17:
10541078
Vote:
10551079
NEWTYPE:
10561080
TYPENAME: LiteVote
1057-
17:
1081+
18:
10581082
ChainInfoResponse:
10591083
NEWTYPE:
10601084
TYPENAME: ChainInfoResponse
1061-
18:
1085+
19:
10621086
Error:
10631087
NEWTYPE:
10641088
TYPENAME: NodeError
1065-
19:
1089+
20:
10661090
VersionInfoResponse:
10671091
NEWTYPE:
10681092
TYPENAME: VersionInfo
1069-
20:
1093+
21:
10701094
NetworkDescriptionResponse:
10711095
NEWTYPE:
10721096
TYPENAME: NetworkDescription
1073-
21:
1097+
22:
10741098
UploadBlobResponse:
10751099
NEWTYPE:
10761100
TYPENAME: BlobId
1077-
22:
1101+
23:
10781102
DownloadBlobResponse:
10791103
NEWTYPE:
10801104
TYPENAME: BlobContent
1081-
23:
1105+
24:
10821106
DownloadPendingBlobResponse:
10831107
NEWTYPE:
10841108
TYPENAME: BlobContent
1085-
24:
1109+
25:
10861110
DownloadConfirmedBlockResponse:
10871111
NEWTYPE:
10881112
TYPENAME: Block
1089-
25:
1113+
26:
10901114
DownloadCertificatesResponse:
10911115
NEWTYPE:
10921116
SEQ:
10931117
TYPENAME: ConfirmedBlockCertificate
1094-
26:
1118+
27:
1119+
DownloadCertificatesByHeightsResponse:
1120+
NEWTYPE:
1121+
SEQ:
1122+
TYPENAME: ConfirmedBlockCertificate
1123+
28:
10951124
BlobLastUsedByResponse:
10961125
NEWTYPE:
10971126
TYPENAME: CryptoHash
1098-
27:
1127+
29:
10991128
MissingBlobIdsResponse:
11001129
NEWTYPE:
11011130
SEQ:
11021131
TYPENAME: BlobId
1103-
28:
1132+
30:
11041133
CrossChainRequest:
11051134
NEWTYPE:
11061135
TYPENAME: CrossChainRequest

linera-service/src/proxy/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,11 @@ where
385385
| MissingBlobIdsResponse(_)
386386
| DownloadConfirmedBlockResponse(_)
387387
| DownloadCertificatesResponse(_)
388-
| UploadBlobResponse(_) => Err(anyhow::Error::from(NodeError::UnexpectedMessage)),
388+
| UploadBlobResponse(_)
389+
| DownloadCertificatesByHeights(_, _)
390+
| DownloadCertificatesByHeightsResponse(_) => {
391+
Err(anyhow::Error::from(NodeError::UnexpectedMessage))
392+
}
389393
}
390394
}
391395
}

0 commit comments

Comments
 (0)