Skip to content
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

Persist block validator state to the database #324

Merged
merged 17 commits into from
Mar 18, 2022

Conversation

PlasmaPower
Copy link
Collaborator

@PlasmaPower PlasmaPower commented Mar 8, 2022

TODO:

  • Testing
  • Figure out how to handle reorgs (separate PR?)

@codecov
Copy link

codecov bot commented Mar 8, 2022

Codecov Report

Merging #324 (046c1e5) into master (1991eb0) will decrease coverage by 0.21%.
The diff coverage is 42.56%.

@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
- Coverage   49.10%   48.89%   -0.22%     
==========================================
  Files         161      161              
  Lines       16266    16525     +259     
  Branches      458      458              
==========================================
+ Hits         7988     8080      +92     
- Misses       7115     7276     +161     
- Partials     1163     1169       +6     

@PlasmaPower PlasmaPower marked this pull request as ready for review March 17, 2022 01:55
Comment on lines 167 to 169
if s.validator != nil {
s.validator.ReorgToBlock(targetBlock.NumberU64())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be concerned with atomicity here when exiting? If there are issues there I think it would only affect force kill since anything caught by the the signal handler should exit gracefully

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to call ReorgToBlock on the validator before the blockchain is reorg'd. That said, I'm thinking we'll want a more resilient scheme in the longer term, which I'll discuss a bit more in Tsahi's first review comment.

validator/block_validator.go Show resolved Hide resolved
validator/block_validator.go Outdated Show resolved Hide resolved
validator/block_validator.go Outdated Show resolved Hide resolved
validator/block_validator.go Outdated Show resolved Hide resolved
validator/block_validator.go Show resolved Hide resolved
validator/block_validator.go Show resolved Hide resolved
validator/block_validator.go Outdated Show resolved Hide resolved
log.Error("sequencer message bad format", "blockNr", validationEntry.BlockNumber, "msgNum", start.BatchNumber)
return
BlockHash: entry.PrevBlockHash,
SendRoot: entry.PrevSendRoot,
}

if arbstate.IsDASMessageHeaderByte(seqMsg[40]) {
if v.das == nil {
log.Error("No DAS configured, but sequencer message found with DAS header")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove that return?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a DAS message is posted on a non-DAS chain, it should just be mostly ignored, but validation should still succeed. I'm changing this to gate the return behind a check of ArbitrumChainParams.DataAvailabilityCommittee.

if err != nil {
log.Error("Couldn't retrieve message from DAS", "err", err)
return
log.Error("Failed to deserialize DAS message", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same Q (why no return?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the DAS message can't be deserialized, it should just be ignored, but validation can still succeed

validator/block_validator.go Outdated Show resolved Hide resolved
@@ -489,43 +587,41 @@ func (v *BlockValidator) validate(ctx context.Context, validationEntry *validati
}
// stupid search for now, assuming the list will always be empty or very mall
for _, blockNr := range v.config.BlocksToRecord {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this entire block and BlocksToRecord config, and replace it with a better way to manually record blocks. Not urgent..

validator/block_validator.go Outdated Show resolved Hide resolved
validator/block_validator.go Outdated Show resolved Hide resolved
validator/block_validator_schema.go Show resolved Hide resolved
Copy link
Contributor

@hkalodner hkalodner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hkalodner hkalodner enabled auto-merge (rebase) March 18, 2022 18:10
auto-merge was automatically disabled March 18, 2022 18:27

Rebase failed

@hkalodner hkalodner enabled auto-merge (rebase) March 18, 2022 18:58
auto-merge was automatically disabled March 18, 2022 21:12

Rebase failed

@hkalodner hkalodner merged commit 040c7ea into master Mar 18, 2022
@hkalodner hkalodner deleted the persist-block-validator branch March 18, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants