From b7f6555f960cb0d7a2e42390edd14a447ce62d63 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Tue, 10 Dec 2024 16:50:59 +0100 Subject: [PATCH] feat(upgrade): move drs check to begin blocker to allow time-based upgrades (#1272) --- block/fork.go | 7 ------- block/manager.go | 9 --------- types/state.go | 6 ++++-- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/block/fork.go b/block/fork.go index ee37f7aa4..c559ba132 100644 --- a/block/fork.go +++ b/block/fork.go @@ -243,13 +243,6 @@ func (m *Manager) updateStateForNextRevision() error { m.State.RevisionStartHeight = nextRevision.StartHeight m.State.SetRevision(nextRevision.Number) - // we set rollappparam to node drs version to pass ValidateConfigWithRollappParams check, when drs upgrade is necessary. - // if the node starts with the wrong version at revision start height, it will stop after applyBlock. - drsVersion, err := version.GetDRSVersion() - if err != nil { - return err - } - m.State.RollappParams.DrsVersion = drsVersion // update stored state _, err = m.Store.SaveState(m.State, nil) return err diff --git a/block/manager.go b/block/manager.go index da2b46ae8..61d74a6ab 100644 --- a/block/manager.go +++ b/block/manager.go @@ -16,7 +16,6 @@ import ( "github.com/dymensionxyz/dymint/store" uerrors "github.com/dymensionxyz/dymint/utils/errors" uevent "github.com/dymensionxyz/dymint/utils/event" - "github.com/dymensionxyz/dymint/version" "github.com/libp2p/go-libp2p/core/crypto" @@ -375,14 +374,6 @@ func (m *Manager) UpdateTargetHeight(h uint64) { // ValidateConfigWithRollappParams checks the configuration params are consistent with the params in the dymint state (e.g. DA and version) func (m *Manager) ValidateConfigWithRollappParams() error { - drsVersion, err := version.GetDRSVersion() - if err != nil { - return err - } - if drsVersion != m.State.RollappParams.DrsVersion { - return fmt.Errorf("DRS version mismatch. rollapp param: %d binary used:%d", m.State.RollappParams.DrsVersion, drsVersion) - } - if da.Client(m.State.RollappParams.Da) != m.DAClient.GetClientType() { return fmt.Errorf("da client mismatch. rollapp param: %s da configured: %s", m.State.RollappParams.Da, m.DAClient.GetClientType()) } diff --git a/types/state.go b/types/state.go index a02a8355e..aa96bc985 100644 --- a/types/state.go +++ b/types/state.go @@ -14,6 +14,8 @@ import ( "github.com/dymensionxyz/dymint/types/pb/dymint" ) +const rollappparams_modulename = "rollappparams" + // State contains information about current state of the blockchain. type State struct { Version tmstate.Version @@ -105,9 +107,9 @@ func (s *State) SetRollappParamsFromGenesis(appState json.RawMessage) error { if err != nil { return err } - params, ok := objmap["rollappparams"] + params, ok := objmap[rollappparams_modulename] if !ok { - return fmt.Errorf("rollappparams not defined in genesis") + return fmt.Errorf("module not defined in genesis: %s", rollappparams_modulename) } var rollappParams RollappParams