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(upgrade): move drs check to begin blocker to allow time-based upgrades #1272

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
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
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where it's gonna be validated now?
if the DRS changed in the rollapp params (through the RDK)
where it's validated against local version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its validated in the begin blocker function of the app dymensionxyz/rollapp-evm#393. this way it allows using a different version when upgrade is required, but if using wrong version it will fail in begin blocker

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
Loading