Skip to content

Commit

Permalink
feature: support custom balance allocation to nodes (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavmsra authored Oct 23, 2023
1 parent 0b5088e commit c2c0338
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export async function main(): Promise<void> {
default: false,
describe: "Include quorum-dev-quickstart test accounts",
},
genesisNodeAllocation: {
type: "string",
demandOption: true,
default: "1000000000000000000000000000",
describe: "Balance allocated to each nodes",
},
alloc: {
type: "string",
demandOption: true,
Expand Down Expand Up @@ -181,6 +187,7 @@ export async function main(): Promise<void> {
quickstartDevAccounts: args.quickstartDevAccounts,
noOutputTimestamp: args.noOutputTimestamp,
prefundedAccounts: args.alloc,
genesisNodeAllocation: args.genesisNodeAllocation,
};
} else {
const qr = new QuestionRenderer(rootQuestion);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/genesisGenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function createBesuGenesis(
}
node.forEach((account) => {
besu.alloc[account.ethAccount.address] = {
balance: "1000000000000000000000000000",
balance: quorumConfig.genesisNodeAllocation,
};
});

Expand Down Expand Up @@ -153,7 +153,7 @@ export function createGoQuorumGenesis(
}
node.forEach((account) => {
goquorum.alloc[account.ethAccount.address] = {
balance: "1000000000000000000000000000",
balance: quorumConfig.genesisNodeAllocation,
};
});

Expand Down
6 changes: 6 additions & 0 deletions src/questions/commonQs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export const quickstartDevAccountsQuestion: QuestionTree = {
prompt: "Include quorum-dev-quickstart test accounts: [y/N]",
};

export const genesisNodeAllocationQuestion: QuestionTree = {
name: "genesisNodeAllocation",
prompt:
"Balance allocated to each nodes: (default 1000000000000000000000000000)",
};

export const prefundedAccountsQuestion: QuestionTree = {
name: "prefundedAccounts",
prompt:
Expand Down
12 changes: 11 additions & 1 deletion src/questions/qbftQs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@ _prefundedAccountsQuestion.transformerValidator = allocStringValidator(
"{}"
);

const _genesisNodeAllocationQuestion: QuestionTree = Object.assign(
{},
commonQs.genesisNodeAllocationQuestion
);
_genesisNodeAllocationQuestion.transformerValidator = stringValidator(
_genesisNodeAllocationQuestion,
_prefundedAccountsQuestion,
"1000000000000000000000000000"
);


const _quickstartDevAccountsQuestion: QuestionTree = Object.assign(
{},
commonQs.quickstartDevAccountsQuestion
);
_quickstartDevAccountsQuestion.transformerValidator = getYesNoValidator(
_quickstartDevAccountsQuestion,
_prefundedAccountsQuestion,
_genesisNodeAllocationQuestion,
"n"
);

Expand Down
1 change: 1 addition & 0 deletions src/types/quorumConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export type QuorumConfig = {
quickstartDevAccounts: boolean;
noOutputTimestamp: boolean;
prefundedAccounts: string;
genesisNodeAllocation: string;
};
1 change: 1 addition & 0 deletions tests/lib/testConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const TEST_QUORUM_CONFIG: QuorumConfig = {
quickstartDevAccounts: false,
noOutputTimestamp: false,
prefundedAccounts: "{}",
genesisNodeAllocation: "100",
};

export const TEST_NODE = {
Expand Down

0 comments on commit c2c0338

Please sign in to comment.