Skip to content

Commit

Permalink
fix: handle the initial sequencer (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Sep 22, 2024
1 parent 43e31ff commit 780efb0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/rollapp/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ func Cmd() *cobra.Command {

switch nodeType {
case "sequencer":
canRegister, err := sequencerutils.CanSequencerBeRegisteredForRollapp(
raResponse.Rollapp.RollappId,
rollerData.HubData,
)
if err != nil {
pterm.Error.Println(
"failed to check whether a sequencer can be registered for rollapp: ",
err,
)
return
}

if !canRegister {
pterm.Error.Println("rollapp is not ready to register a sequencer")
return
}

pterm.Info.Println("getting the existing sequencer address ")
hubSeqKC := utils.KeyConfig{
Dir: consts.ConfigDirName.HubKeys,
Expand Down
22 changes: 22 additions & 0 deletions utils/sequencer/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ func Register(raCfg config.RollappConfig, desiredBond cosmossdktypes.Coin) error
return nil
}

func CanSequencerBeRegisteredForRollapp(raID string, hd consts.HubData) (bool, error) {
var raResponse rollapp.ShowRollappResponse

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / build

undefined: rollapp

Check failure on line 91 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / manual release

undefined: rollapp
cmd := rollapp.GetRollappCmd(raID, hd)

Check failure on line 92 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp) (typecheck)

Check failure on line 92 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp) (typecheck)

Check failure on line 92 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / lint

undefined: rollapp) (typecheck)

Check failure on line 92 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / build

undefined: rollapp

Check failure on line 92 in utils/sequencer/sequencer.go

View workflow job for this annotation

GitHub Actions / manual release

undefined: rollapp

out, err := bash.ExecCommandWithStdout(cmd)
if err != nil {
pterm.Error.Println("failed to get rollapp: ", err)
return false, err
}
err = json.Unmarshal(out.Bytes(), &raResponse)
if err != nil {
pterm.Error.Println("failed to unmarshal", err)
return false, err
}

if raResponse.Rollapp.InitialSequencer == "" {
return false, nil
}

return true, nil
}

func isValidSequencerMetadata(path string) (bool, error) {
f, err := os.Open(path)
if err != nil {
Expand Down

0 comments on commit 780efb0

Please sign in to comment.