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

feat(drs): only send consensus msgs for drs upgrade when necessary #1277

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions block/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,28 @@
// It performs version validation and generates the necessary upgrade messages for the sequencer.
//
// The function implements the following logic:
// - If no faulty DRS version is provided (faultyDRS is nil), returns no messages
// - Validates the current DRS version against the potentially faulty version
// - Generates an upgrade message with the current valid DRS version
// - If DRS version used (binary version) is obsolete returns error
// - If DRS version used (binary version) is different from rollapp params, generates an upgrade message with the binary DRS version
// - Otherwise no upgrade messages are returned
func (m *Manager) prepareDRSUpgradeMessages(obsoleteDRS []uint32) ([]proto.Message, error) {
drsVersion, err := version.GetDRSVersion()
if err != nil {
return nil, err
}

// if binary DRS is obsolete return error (to panic)
for _, drs := range obsoleteDRS {
if drs == drsVersion {
return nil, gerrc.ErrCancelled.Wrapf("obsolete DRS version: %d", drs)
}
}

// same DRS message detected, no upgrade is necessary
if m.State.RollappParams.DrsVersion == drsVersion {
return []proto.Message{}, nil
}

Check warning on line 161 in block/fork.go

View check run for this annotation

Codecov / codecov/patch

block/fork.go#L159-L161

Added lines #L159 - L161 were not covered by tests

return []proto.Message{
&sequencers.MsgUpgradeDRS{
Authority: authtypes.NewModuleAddress("sequencers").String(),
Expand Down
Loading