lastNonzeroSlash > submittedIn for chilled (#8518)

* lastNonzeroSlash > submittedIn for chilled

* Note on logic

* Cleanups
This commit is contained in:
Jaco 2022-12-12 07:44:07 +02:00 committed by GitHub
parent 61b7374156
commit 72b0f96176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -42,17 +42,17 @@ function expandOngoing (info: Referendum['info'], track?: PalletReferendaTrackIn
const { deciding, submitted } = ongoing;
if (deciding.isSome) {
const d = deciding.unwrap();
const { confirming, since } = deciding.unwrap();
if (d.confirming.isSome) {
// we are confirming (it details the actual end-block)
confirmEnd = d.confirming.unwrap(); // .add(track.confirmPeriod);
if (confirming.isSome) {
// we are confirming with the specific end block
confirmEnd = confirming.unwrap();
} else {
// we are still deciding
decideEnd = d.since.add(track.decisionPeriod);
// we are still deciding, start + length
decideEnd = since.add(track.decisionPeriod);
}
} else {
// we are still preparing
// we are still preparing, start + length
prepareEnd = submitted.add(track.preparePeriod);
}
}

View File

@ -31,7 +31,9 @@ function extractState (api: ApiPromise, stashId: string, slashes: Option<Slashin
const { lastNonzeroSlash } = slashes[index].unwrap();
return !lastNonzeroSlash.isZero() && lastNonzeroSlash.gte(submittedIn);
// to be chilled, we have a slash era and it is later than the submission era
// (if submitted in the same, the nomination will only take effect after the era)
return !lastNonzeroSlash.isZero() && lastNonzeroSlash.gt(submittedIn);
});
// all nominations that are oversubscribed