From 5aaf6afae89a0fc1fbd4dbb7bd76de15223356e4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 27 Jan 2021 12:24:48 -0800 Subject: [PATCH] add additional pre-migration validations --- chain/stmgr/forks.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index d7f138c2832..7a8473fc26a 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -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.