Skip to content

Commit

Permalink
feat(upgrade): move drs check to begin blocker to allow time-based up…
Browse files Browse the repository at this point in the history
…grades (#1272)
  • Loading branch information
srene authored Dec 10, 2024
1 parent 7de4e89 commit b7f6555
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
7 changes: 0 additions & 7 deletions block/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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())
}
Expand Down
6 changes: 4 additions & 2 deletions types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7f6555

Please sign in to comment.