-
Notifications
You must be signed in to change notification settings - Fork 578
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
New Block structure #3101
New Block structure #3101
Conversation
96cbde5
to
6ab368e
Compare
6ab368e
to
facb07d
Compare
linera-core/src/client/mod.rs
Outdated
if certificate.executed_block().block | ||
== confirmed_value.inner().executed_block().block => | ||
if certificate.block() == confirmed_value.inner().block() => | ||
// TODO: double check this. Previously we were comparing the Proposal only. |
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.
TODO: Double-check. Same here as above.
6a9cccf
to
bb50374
Compare
} | ||
|
||
/// Returns whether this value contains the message with the specified ID. | ||
pub fn has_message(&self, message_id: &MessageId) -> bool { | ||
self.executed_block().message_by_id(message_id).is_some() | ||
self.block().message_by_id(message_id).is_some() |
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.
Would it make sense the handle the renaming executed_block
-> block
first in a separate PR?
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.
Actually, I didn't get rid of ExecutedBlock
. I tried but the Proposal
/BlockExecutionOutcome
is used in a couple of places (we execute before proposing, we execute when we receive a proposal, we re-execute when we receive a confirmed certificate, etc.) so I kept the ExecutedBlock
as an internal data structure that caries the result of execution.
This particular change that you commented on is a follow-up to changing the ConfirmedBlock(ExecutedBlock)
to ConfirmedBlock(Block)
so it's not a rename only, it's actually a new Block
type inside.
dca5da3
to
d13da68
Compare
When (de)serializing a Block, don't (de)serialize the hashes from the BlockHeader but rather compute them from the elements of the BlockBody. This makes sure that we never simply _trust_ the values that are being sent and rather compute them ourselves.
f3c8e49
to
652604e
Compare
@@ -395,16 +399,16 @@ impl OutgoingMessage { | |||
} | |||
} | |||
|
|||
/// A [`Block`], together with the outcome from its execution. | |||
/// A [`Proposal`], together with the outcome from its execution. | |||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, SimpleObject)] | |||
pub struct ExecutedBlock { |
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.
Maybe ProposalWithOutcome
. Or even inline it, if it's not used in many places anymore?
@@ -76,7 +76,7 @@ pub struct Block { | |||
pub previous_block_hash: Option<CryptoHash>, | |||
} | |||
|
|||
impl Block { | |||
impl Proposal { |
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.
Now a BlockProposal
contains a ProposalContent
which contains a Proposal
.
Maybe call this type ProposedBlock
?
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 didn't call it ProposedBlock
on purpose b/c we have the BlockProposal
which sounds basically equivalent that is the encompassing type. It seemed weird that BlockProposal
contains ProposedBlock
.
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.
But isn't a BlockProposal
containing a Proposal
even worse?
Maybe BlockInput
? BlockTemplate
? BlockPlan
? 😕
51161cf
to
543802f
Compare
543802f
to
5cbe42e
Compare
authenticated_signer: parent_block.authenticated_signer, | ||
timestamp: parent_block.timestamp, | ||
height: parent_header.height.try_add_one().unwrap(), | ||
authenticated_signer: parent_header.authenticated_signer, |
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.
(Weird! What if this is proposed by someone else? Not new in this PR, of course.)
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.
No blockers from my side, but:
- Can we remove
ExecutedBlock
now? (Maybe in another PR.) - One test is still failing.
- Since this is a very central type, it would be great if we could get a second review.
Discussed offline - and decided not to do that.
I think I fixed that now.
I agree, let's wait. |
## Motivation The discussion #3101 (comment) was never resolved; a proposal has a content, which has a proposal. ## Proposal Rename `Proposal` to `ProposedBlock`, to distinguish it from the outer type. (I also added some destructuring in `Block::new`, because I ran into a naming conflict and this way the compiler will warn us if we add any fields and forget them there.) ## Test Plan Only renaming. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - Related to #3101 - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
Motivation
Verifying Linera (micro)chains with a light client requires following the chain's blocks and subsequently confirming whether an event, a message, state change, were part of that block. Our current block definition -
ExecutedBlock
type - was not made for this purpose:BlockExecutionOutcome
w/o a way to easily verify whether a particular event is part of that set other than sending the whole vector.Proposal
In this PR we introduce the new block structures. The new
Block
type consists of two elements:BlockHeader
is a succint representation of the chain's new block. It contains metadata that suffices to track the chain's progress:BlockBody
holds the data that is not necessary for (light) verification but was either an input to the block's execution (incoming bundles, operations) or its output (oracle responses, messages sent, events emitted). Each vector is deterministically hashed (intoCryptoHash
) and the result of that hashing is put into theBlockHeader
. This way it's possible to verify inclusion of any specific element w/o having to sent all of the body.Test Plan
All of the tests have been updated to work with the new types.
Release Plan
Links