-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce and use TimeoutCertificate #2845
Conversation
ba08b43
to
f1a1bf1
Compare
9ce84b5
to
c9199ed
Compare
f1a1bf1
to
cb35338
Compare
linera-chain/src/certificate.rs
Outdated
@@ -30,6 +30,9 @@ pub type ValidatedBlockCertificate = GenericCertificate<ValidatedBlock>; | |||
/// Certificate for a [`ConfirmedBlock`] instance. | |||
pub type ConfirmedBlockCertificate = GenericCertificate<ConfirmedBlock>; | |||
|
|||
/// Certificate for a Timeout instance. | |||
pub type TimeoutCerificate = GenericCertificate<Timeout>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo TimeoutCerificate
-> TimeoutCertificate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
linera-chain/src/certificate.rs
Outdated
let cert = Certificate::deserialize(deserializer)?; | ||
TimeoutCerificate::try_from(cert).map_err(<D::Error as serde::de::Error>::custom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so this won't work because serde_reflection::trace_type
must produce a value of type Certificate
at line 106 but it has no way to know which variant of Certificate
will work line 107.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I've implemented the (de)serializers manually.
486d6e9
to
7431f43
Compare
state.serialize_field("value", &self.inner())?; | ||
state.serialize_field("round", &self.round)?; | ||
state.serialize_field("signatures", &self.signatures)?; | ||
state.end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that really BCS-serialize to the same bytes as a Certificate
with Timeout
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter? I carry-on the hash and I map to/from the old ConfirmedValue
types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it will only matter in the future, when we use this directly to compute the hash.
Or at least it will matter then that ConfirmedBlockCertificate
serializes to something different than ValidatedBlockCertificate
(in BCS).
@@ -130,7 +130,7 @@ where | |||
pub(super) async fn read_certificate( | |||
&mut self, | |||
height: BlockHeight, | |||
) -> Result<Option<Certificate>, WorkerError> { | |||
) -> Result<Option<linera_chain::data_types::Certificate>, WorkerError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should double-check, but I believe this will always be a ConfirmedBlockCertificate
read from storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct (and one of the benefits of this refactoring)
c9199ed
to
3d3666b
Compare
linera-chain/src/certificate.rs
Outdated
#[derive(Deserialize)] | ||
#[serde(rename = "TimeoutCertificate")] | ||
struct Inner { | ||
timeout: Timeout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use value
here? (and everywhere)
This code could be factorized using serde_name
by the way, but I'm happy to do it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it was value
and then I changed it to timeout
:) I'll change it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fe66e51.
437ace7
to
3fd347a
Compare
3fd347a
to
fe66e51
Compare
Motivation
Similarly to the previous PRs - add a new
TimeoutCertificate
type and use where appropriately.Proposal
Test Plan
Release Plan
devnet
branch, thentestnet
branch, thendevnet
and release a newSDK soon.
Links
Closes #2843