Conversation
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left some comments inline. As I mentioned in some of the comments, it may make sense to do a couple of "preparatory" PRs first and then rebase this PR on top of them. These would be:
- A PR in
miden-baseto addSignedBlock. - A PR here to move
apply_block()into a separate file.
| use miden_protocol::batch::OrderedBatches; | ||
| use miden_protocol::block::{BlockHeader, BlockInputs, BlockProof}; | ||
| use miden_remote_prover_client::RemoteProverClientError; | ||
| use miden_remote_prover_client::remote_prover::block_prover::RemoteBlockProver; |
There was a problem hiding this comment.
nit (and not for this PR): the namespacing here feels a bit "too nested" - e.g., could this not be just miden_remote_prover_client::block_prover::RemoteBlockProver?
There was a problem hiding this comment.
Yea because we are doing pub mod block_prover; instead of pub use block_prover::BlockProver in miden_remote_prover_client. I can make a PR for that after this one.
Bringing in |
Should be already up to date - no? (#1595 got merged a few hours ago). |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left few comments inline and some suggestions for future improvements.
| let header = signed_block.header(); | ||
| let body = signed_block.body(); | ||
|
|
||
| // Validate that header and body match. |
There was a problem hiding this comment.
We should probably validate that the signature is valid since, theoretically, the store could receive a block with an invalid signature.
Not for this PR, but we could do this as a method on SignedBlock (in miden-base) - something like:
impl SignedBlock {
pub fn validate_signature(&self) -> Result<(), SomeError> {
...
}
}We could also do this at SignedBlock construction time - but not sure that's much better.
There was a problem hiding this comment.
Was thinking we could put it in the non-unchecked constructor and use it a bit earlier in the flow (before apply_block() is called here).
Anything else we would want to check in that constructor (the error enum is overkill if there is nothing else). If there is a fair bit of other stuff to check (compare header/body) then might be worth adding the validate_signature() fn rather than doing unnecessary checks in this stack for example.
| let tx_commitment = body.transactions().commitment(); | ||
| if header.tx_commitment() != tx_commitment { | ||
| return Err(InvalidBlockError::InvalidBlockTxCommitment { | ||
| expected: tx_commitment, | ||
| actual: header.tx_commitment(), | ||
| } | ||
| .into()); | ||
| } |
There was a problem hiding this comment.
Related to the above comment, we could probably move this into SignedBlock as well - e.g., SignedBlock::validate_transaction_commitment(). Or this could also be done at construction time.
There was a problem hiding this comment.
Added to constructor in base PR (above comment)
| @@ -78,20 +78,19 @@ | |||
| return Err(InvalidBlockError::NewBlockInvalidPrevCommitment.into()); | |||
| } | |||
There was a problem hiding this comment.
Along the same lines as the previous two comments: this could probably be moved into something like SignedBlock::validate_parent().
There was a problem hiding this comment.
Added in same PR as above comments
|
One other thing we should do once the structure is closer to its final shape is update the docs (and related diagrams) with the up-to-date explanation of the node's architecture. @sergerad - could you create an issue for this? |
8f2fe60 to
4107125
Compare
Context
The state transitions of blocks have changed such that signed (instead of proven) blocks are applied to Store state, leaving block proving to be done asynchronously some time after. The block proving logic is being moved out of the Block Producer so the the Store can managed asynchronous proving after signed blocks are committed to its state.
NOTE: Block proofs are not used in the PR. Follow-up work will be done to make proving deferred/asynchronous to the rest of the Store's
apply_block()flow.Relates to #1316.
Changes
ApplyBlockRPC endpoint to take data required to perform proving.signaturecolumn toblock_headertable.