Skip to content

Commit

Permalink
Use bigints when calculating staking bound amount
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Jun 12, 2023
1 parent a9e9d75 commit ab443bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const debug = require("debug")("zombie::chain-spec");
const JSONStream = require("JSONStream");

// track 1st staking as default;
let stakingBond: number | undefined;
let stakingBond: bigint | undefined;

export type KeyType = "session" | "aura" | "grandpa";

Expand Down Expand Up @@ -73,7 +73,7 @@ export function clearAuthorities(specPath: string) {

// Clear staking
if (runtimeConfig?.staking) {
stakingBond = runtimeConfig.staking.stakers[0][2];
stakingBond = BigInt(runtimeConfig.staking.stakers[0][2]);
runtimeConfig.staking.stakers = [];
runtimeConfig.staking.invulnerables = [];
runtimeConfig.staking.validatorCount = 0;
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function addBalances(specPath: string, nodes: Node[]) {
const balanceToAdd = stakingBond
? node.validator && node.balance > stakingBond
? node.balance
: stakingBond! + 1
: stakingBond! + BigInt(1)
: node.balance;
runtimeConfig.balances.balances.push([stash_key, balanceToAdd]);

Expand Down Expand Up @@ -206,7 +206,7 @@ export async function addStaking(specPath: string, node: Node) {
runtimeConfig.staking.stakers.push([
sr_stash.address,
sr_stash.address,
stakingBond || 1000000000000,
stakingBond || BigInt(1000000000000),
"Validator",
]);

Expand Down Expand Up @@ -354,7 +354,7 @@ export async function generateNominators(
// create account
const nom = await generateKeyFromSeed(`nom-${i}`);
// add to balances
const balanceToAdd = stakingBond! + 1;
const balanceToAdd = stakingBond! + BigInt(1);
runtimeConfig.balances.balances.push([nom.address, balanceToAdd]);
// random nominations
const count = crypto.randomInt(maxForRandom) % maxNominations;
Expand Down
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export interface Node {
name: string;
key?: string;
accounts?: any;
balance?: number;
balance?: bigint;
command?: string;
commandWithArgs?: string;
fullCommand?: string;
Expand Down

0 comments on commit ab443bb

Please sign in to comment.