-
Notifications
You must be signed in to change notification settings - Fork 69
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
fix(validation): added da batch validation against state BD desc #1218
Conversation
refactored nextSequencer validation
// last block of the batch | ||
lastDABlock := daBlocks[len(daBlocks)-1] | ||
expectedNextSeqHash := lastDABlock.Header.SequencerHash | ||
if slBatch.NextSequencer != slBatch.Sequencer { |
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.
- instead of using state proposer, doing
slBatch.NextSequencer != slBatch.Sequencer
to check for a change - skipped
UpdateSequencerSetFromSL
as we can assume sync with SL metadata
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.
looks good though didn't figure out the extra validation of height vs end height on the retriever.
@@ -47,6 +47,12 @@ func (m *Manager) ApplyBatchFromSL(slBatch *settlement.Batch) error { | |||
m.blockCache.Delete(block.Header.Height) | |||
} | |||
} | |||
|
|||
// validate the batch applied successfully and we are at the end height |
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.
if the batch isn't applied succesfully wouldn't we get an err from the applyBlockWithFraudHandling
?
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're looping over for i, block := range batch.Blocks
, which data on the DA
it can be empty/missing
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.
Not sure I got this @mtsitrin . Is it related to rollback on L1 truncating state info?
block/slvalidator.go
Outdated
@@ -47,7 +47,7 @@ func (v *SettlementValidator) ValidateStateUpdate(batch *settlement.ResultRetrie | |||
for height := batch.StartHeight; height <= batch.EndHeight; height++ { | |||
source, err := v.blockManager.Store.LoadBlockSource(height) | |||
if err != nil { | |||
v.logger.Error("load block source", "error", err) | |||
// v.logger.Error("load block source", "error", err) |
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 dont think you need to remove this log. this will just happen in case no block is stored for the height, which should not happen, i think, because there will be always a block applied for the validated height.
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'll add the log back.
But I think it can happen
if u at height H, and the state info is [H-1, H+100],
u'll have 100 logs of it
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.
im not sure this can happen. if you are at height h, and there is a new state update for h+100, then the node will sync first to height h+100, and then validate for the whole state info. upon reception of a new state update where endheight is higher than node height, it first calls the sync loop and from the sync loop it triggers validation once blocks are applied. so when a state info is validated the block should exist locally always, unless there is a bug.
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.
yes u right
it actually handled by the validation added to the ApplyBatchFromSL
@@ -47,6 +47,12 @@ func (m *Manager) ApplyBatchFromSL(slBatch *settlement.Batch) error { | |||
m.blockCache.Delete(block.Header.Height) | |||
} | |||
} | |||
|
|||
// validate the batch applied successfully and we are at the end height |
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.
Not sure I got this @mtsitrin . Is it related to rollback on L1 truncating state info?
@@ -84,8 +82,12 @@ func (v *SettlementValidator) ValidateStateUpdate(batch *settlement.ResultRetrie | |||
if errors.Is(checkBatchResult.Error, da.ErrBlobNotIncluded) { | |||
return types.NewErrStateUpdateBlobNotAvailableFraud(batch.StateIndex, string(batch.MetaData.DA.Client), batch.MetaData.DA.Height, hex.EncodeToString(batch.MetaData.DA.Commitment)) | |||
} | |||
|
|||
// FIXME: how to handle non-happy case? not returning error? | |||
continue |
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.
continue | |
if numSLBlocks != numSlBDs || numDABlocks < numSlBDs { | ||
return types.NewErrStateUpdateNumBlocksNotMatchingFraud(slBatch.EndHeight, numSLBlocks, numSLBlocks, numDABlocks) |
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.
why do we check numSLBlocks != numSlBDs . Isn't it guaranteed to be true by the hub?
refactored nextSequencer validation
PR Standards
Opening a pull request should be able to meet the following requirements
--
PR naming convention: https://hackmd.io/@nZpxHZ0CT7O5ngTp0TP9mg/HJP_jrm7A
Close #XXX
<-- Briefly describe the content of this pull request -->
For Author:
godoc
commentsFor Reviewer:
After reviewer approval: