From 9c5c819377bf482259de9187ceca887f95142daf Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Wed, 11 Dec 2024 12:25:00 +0100 Subject: [PATCH] drs upgrade msgs refactor --- block/fork.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/block/fork.go b/block/fork.go index c559ba132..8867a6319 100644 --- a/block/fork.go +++ b/block/fork.go @@ -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 + } + return []proto.Message{ &sequencers.MsgUpgradeDRS{ Authority: authtypes.NewModuleAddress("sequencers").String(),