-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat(manager): state update mishbehavior detection #1130
Conversation
29d9dff
to
62ed34e
Compare
3133aa3
to
cd01dd7
Compare
651e920
to
5552b77
Compare
e6a6e50
to
6726b93
Compare
c2d36f1
to
a62066c
Compare
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 think the DRS in-memory management makes the code cumbersome and unnecessary complicated vs just saving DRS per height (like we do with block
, commit
, proposer
) etc and just get it where necessary.
we should strive to keep the code simple vs micro optimizations.
block/block.go
Outdated
@@ -122,7 +122,15 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta | |||
m.logger.Error("pruning channel full. skipping pruning", "retainHeight", retainHeight) | |||
} | |||
} | |||
|
|||
if responses.EndBlock.RollappParamUpdates != nil { | |||
newDRS := m.DRSVersionHistory.AddDRSVersion(block.Header.Height, responses.EndBlock.RollappParamUpdates.Version) |
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.
Few questions/comments here:
- can we have plz a comment explainig why are we saving the history
- I get the optimization here but what happens if we get a reboot? than we save a DRS which is not acutally new
- I don't think there is an inherent problem just saving the DRS per height (even if not unique - as anyway you don't prevent it now due to (2))
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.
drs history replaced by storing drs per height.
block/validate.go
Outdated
// LoadDrsHistoryFromStore loads drs history from store | ||
func (m *Manager) LoadDrsHistoryFromStore() error { | ||
drsHistory, err := m.Store.LoadDRSVersionHistory() | ||
if errors.Is(err, gerrc.ErrNotFound) { | ||
m.logger.Info("failed to find drs history in the store, creating new") | ||
m.DRSVersionHistory = &types.DRSVersionHistory{} | ||
return nil | ||
} else if err != nil { | ||
return fmt.Errorf("get drs version history: %w", err) | ||
} | ||
|
||
m.DRSVersionHistory = drsHistory | ||
|
||
return nil | ||
} |
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.
// LoadDrsHistoryFromStore loads drs history from store | |
func (m *Manager) LoadDrsHistoryFromStore() error { | |
drsHistory, err := m.Store.LoadDRSVersionHistory() | |
if errors.Is(err, gerrc.ErrNotFound) { | |
m.logger.Info("failed to find drs history in the store, creating new") | |
m.DRSVersionHistory = &types.DRSVersionHistory{} | |
return nil | |
} else if err != nil { | |
return fmt.Errorf("get drs version history: %w", err) | |
} | |
m.DRSVersionHistory = drsHistory | |
return nil | |
} | |
// LoadDrsHistoryFromStore loads drs history from store | |
func (m *Manager) LoadDrsHistoryFromStore() error { | |
drsHistory, err := m.Store.LoadDRSVersionHistory() | |
if errors.Is(err, gerrc.ErrNotFound) { | |
m.logger.Info("failed to find drs history in the store, creating new") | |
drsHistory = &types.DRSVersionHistory{} | |
} else if err != nil { | |
return fmt.Errorf("get drs version history: %w", err) | |
} | |
m.DRSVersionHistory = drsHistory | |
return nil | |
} |
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.
this has been removed
block/validate.go
Outdated
return fmt.Errorf("get drs version history: %w", err) | ||
} | ||
|
||
m.DRSVersionHistory = drsHistory |
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.
as to my other comment on the applyBlock - not sure the optimization of saving it in memory and than only saving the uniqe changes in store (which I'm not sure is actually the case) is necessary for optimization.
I'd simply just save the DRS per height and also get rid of the new manager memeber (i.e DRSVersionHistory
)
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.
removed
block/manager.go
Outdated
@@ -161,6 +164,11 @@ func NewManager( | |||
return nil, fmt.Errorf("get initial state: %w", err) | |||
} | |||
|
|||
err = m.LoadDrsHistoryFromStore() |
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.
as to my other comment - don't think maintining this in memory is necessary
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.
removed
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.
drs history replaced by drs per height in store
block/block.go
Outdated
if responses.EndBlock.RollappParamUpdates != nil { | ||
newDRS := m.DRSVersionHistory.AddDRSVersion(block.Header.Height, responses.EndBlock.RollappParamUpdates.Version) | ||
if newDRS { | ||
_, err = m.Store.SaveDRSVersionHistory(m.DRSVersionHistory, nil) |
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 think we should simply save DRS per height in the store (so the key is per height, similiar to how we save the proposer changes. And prune it when necessary. it will simplify all the DRS management and validation imo)
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
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.
Approved. 2 issues im not sure about but we can address it in seperate issues.
da batch is written to celestia without including drs version and last batch, since it is not included when mashall / unmmarshal, but its used when submitting to sl to generate the block descriptors. added an issue to improve it #1171 |
PR Standards
ADR x: State update misbehavior detection
Opening a pull request should be able to meet the following requirements
--
PR naming convention: https://hackmd.io/@nZpxHZ0CT7O5ngTp0TP9mg/HJP_jrm7A
Close #1106
<-- Briefly describe the content of this pull request -->
For Author:
godoc
commentsFor Reviewer:
After reviewer approval: