Skip to content

Commit

Permalink
drs upgrade msgs refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Dec 11, 2024
1 parent b7f6555 commit 9c5c819
Showing 1 changed file with 9 additions and 2 deletions.
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 @@ func (m *Manager) doFork(instruction types.Instruction) error {
// 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

0 comments on commit 9c5c819

Please sign in to comment.