diff --git a/cmd/rollapp/setup/setup.go b/cmd/rollapp/setup/setup.go index cd2a8bf4..35dff9c6 100644 --- a/cmd/rollapp/setup/setup.go +++ b/cmd/rollapp/setup/setup.go @@ -179,6 +179,7 @@ RollApp's IRO time: %v`, pterm.Error.Println("failed to validate genesis: ", err) } err = genesis.ValidateGenesis( + localRollerConfig, localRollerConfig.RollappID, localRollerConfig.HubData, ) diff --git a/cmd/rollapp/start/start.go b/cmd/rollapp/start/start.go index e45b594d..49ce4788 100644 --- a/cmd/rollapp/start/start.go +++ b/cmd/rollapp/start/start.go @@ -19,6 +19,7 @@ import ( "github.com/dymensionxyz/roller/sequencer" "github.com/dymensionxyz/roller/utils/bash" "github.com/dymensionxyz/roller/utils/filesystem" + genesisutils "github.com/dymensionxyz/roller/utils/genesis" "github.com/dymensionxyz/roller/utils/healthagent" "github.com/dymensionxyz/roller/utils/logging" "github.com/dymensionxyz/roller/utils/migrations" @@ -68,6 +69,22 @@ Consider using 'services' if you want to run a 'systemd'(unix) or 'launchd'(mac) return } + isChecksumValid, err := genesisutils.CompareGenesisChecksum( + rollappConfig.Home, + rollappConfig.RollappID, + rollappConfig.HubData, + ) + + if !isChecksumValid { + pterm.Error.Println("genesis checksum mismatch") + return + } + + if err != nil { + pterm.Error.Println("failed to compare genesis checksum: ", err) + return + } + if rollappConfig.HubData.ID != consts.MockHubID { raUpgrade, err := upgrades.NewRollappUpgrade(string(rollappConfig.RollappVMType)) if err != nil { diff --git a/utils/genesis/genesis.go b/utils/genesis/genesis.go index aa78f8ae..ad057a15 100644 --- a/utils/genesis/genesis.go +++ b/utils/genesis/genesis.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -396,13 +397,27 @@ const ( ValidateGenesisURL = "https://genesis-validator.rollapp.network/validate-genesis" ) -func ValidateGenesis(raID string, hd consts.HubData) error { +func ValidateGenesis(raCfg roller.RollappConfig, raID string, hd consts.HubData) error { req := ValidateGenesisRequest{ RollappID: raID, SettlementChainID: hd.ID, SettlementNodeAddress: hd.RpcUrl, } + isChecksumValid, err := CompareGenesisChecksum( + raCfg.Home, + raID, + hd, + ) + + if !isChecksumValid { + return errors.New("genesis checksum mismatch") + } + + if err != nil { + return err + } + b, err := json.Marshal(req) if err != nil { return err