Skip to content

Commit

Permalink
Merge pull request #2700 from w3f/will-v3.1.3
Browse files Browse the repository at this point in the history
Adjust shouldNominate
  • Loading branch information
wpank authored Mar 5, 2024
2 parents 581013c + 30bcaa2 commit 59ac1da
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
5 changes: 4 additions & 1 deletion packages/common/src/nominator/nominator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,15 @@ export default class Nominator extends EventEmitter {
const isBonded = await this.chaindata.isBonded(stash);
const [bonded, err] = await this.chaindata.getDenomBondedAmount(stash);
const proxyTxs = await queries.getAccountDelayedTx(this.bondedAddress);
const lastNominationEra =
await this.chaindata.getNominatorLastNominationEra(stash);
this.lastEraNomination = lastNominationEra;

const currentEra = (await this.chaindata.getCurrentEra()) || 0;
this._shouldNominate =
isBonded &&
bonded > 50 &&
currentEra - this.lastEraNomination >= 1 &&
currentEra - lastNominationEra >= 1 &&
proxyTxs.length == 0;
return this._shouldNominate;
}
Expand Down
14 changes: 0 additions & 14 deletions packages/common/src/scorekeeper/Nominating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ export const doNominations = async (
return null;
}

// Update nominator status to start nominations
for (const nom of nominatorGroups) {
const shouldNominate = await nom.shouldNominate();
if (!shouldNominate) {
const nominatorStatus: NominatorStatus = {
state: "Nominating",
status: `Doing Nominations.....`,
updated: Date.now(),
stale: false,
};
await nom.updateNominatorStatus(nominatorStatus);
}
}

// The list of all valid Validators to nominate
const allTargets = candidates.map((c) => {
return { stash: c.stash };
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const API = {
CurrentValidatorSet: "/validators/current",
Validators: "/validators",
Validator: "/validator/:address",
//TODO: add to swagger
ValidatorsNumActiveEras: "/validators/activeeras/:address",
ValidatorsBeefyStats: "/validators/beefy",
ValidatorsBeefyDummy: "/validators/beefy/dummy",
Expand Down
12 changes: 6 additions & 6 deletions packages/scorekeeper-status-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const App = () => {
{renderStatusIcon(
job.status,
job.progress !== undefined
? job.progress.toFixed(1)
? job.progress?.toFixed(1)
: undefined,
)}
</div>
Expand All @@ -391,7 +391,7 @@ const App = () => {
<div
className="progressBar"
style={{
width: `${job.progress !== undefined ? job.progress.toFixed(1) : 0}%`,
width: `${job.progress !== undefined ? job.progress?.toFixed(1) : 0}%`,
}}
></div>
</div>
Expand All @@ -405,7 +405,7 @@ const App = () => {
border: `1px solid linear-gradient(to right, rgba(255, 0, 0, 0.1) ${job.progress}%, rgba(255, 255, 0, 0.1) ${job.progress}%, rgba(0, 255, 0, 0.1) ${job.progress}%)`,
}}
>
{job.progress !== undefined ? job.progress.toFixed(1) : 0}%
{job.progress !== undefined ? job.progress?.toFixed(1) : 0}%
</span>
</p>
{job.iteration && (
Expand Down Expand Up @@ -504,7 +504,7 @@ const App = () => {
<p>
<FiDollarSign className="icon" /> Bonded Amount:{" "}
{new Intl.NumberFormat().format(
nominator.bondedAmount.toFixed(2),
nominator.bondedAmount?.toFixed(2),
)}{" "}
{currentEndpoint.includes("kusama") ? "KSM" : "DOT"}
</p>
Expand Down Expand Up @@ -576,8 +576,8 @@ const App = () => {
theme="polkadot"
/>
{target.name
? `[${target.score.toFixed(0)}] ${target.name}`
: `[${target.score.toFixed(0)}] ${truncateAddress(target.stash)}`}{" "}
? `[${target.score?.toFixed(0)}] ${target.name}`
: `[${target.score?.toFixed(0)}] ${truncateAddress(target.stash)}`}{" "}
{target.kyc && (
<FiCheckCircle
style={{ color: "green", marginLeft: "5px" }}
Expand Down

0 comments on commit 59ac1da

Please sign in to comment.