Skip to content

Commit

Permalink
add additional pre-migration validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jan 27, 2021
1 parent 073a158 commit 5aaf6af
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chain/stmgr/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,18 @@ func (us UpgradeSchedule) Validate() error {
}

for _, m := range u.PreMigrations {
if m.When < 0 || m.NotAfter < 0 {
return xerrors.Errorf("pre-migration must specify non-negative epochs")
}
if m.When <= m.NotAfter {
return xerrors.Errorf("pre-migration cannot end before it starts: %d <= %d", m.When, m.NotAfter)
}
}
if !sort.SliceIsSorted(u.PreMigrations, func(i, j int) bool {
return u.PreMigrations[i].When < u.PreMigrations[j].When
}) {
return xerrors.Errorf("pre-migrations must be sorted by start epoch")
}
}

// Make sure the upgrade order makes sense.
Expand Down

0 comments on commit 5aaf6af

Please sign in to comment.