Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update DPoS terminologies to PoS (#7803)
Browse files Browse the repository at this point in the history
### What was the problem?

This PR resolves #7672 

### How was it solved?

- Update DPoS terminologies to PoS
  - vote => stake
  - delegate => validator
  - DPoS => PoS
  - voter => staker

### How was it tested?

- All build/test should pass
- There should be no dpos related terminologies
  • Loading branch information
shuse2 authored Nov 21, 2022
1 parent 3899a74 commit dee896c
Show file tree
Hide file tree
Showing 312 changed files with 9,529 additions and 9,661 deletions.
2 changes: 1 addition & 1 deletion commander/src/bootstrapping/commands/endpoint/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class InvokeCommand extends BaseIPCClientCommand {
'endpoint:invoke {endpoint} {parameters}',
'endpoint:invoke --data-path --file',
`endpoint:invoke generator_getAllKeys`,
`endpoint:invoke consensus_getBFTParameters '{"height": 2}' -d ~/.lisk/dpos-mainchain --pretty`,
`endpoint:invoke consensus_getBFTParameters '{"height": 2}' -d ~/.lisk/pos-mainchain --pretty`,
`endpoint:invoke consensus_getBFTParameters -f ./input.json`,
];

Expand Down
2 changes: 1 addition & 1 deletion commander/src/bootstrapping/commands/generator/disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { BaseForgingCommand } from '../base_forging';

export abstract class DisableCommand extends BaseForgingCommand {
static description = 'Disable forging for given delegate address.';
static description = 'Disable forging for given validator address.';

static examples = [
'generator:disable lskycz7hvr8yfu74bcwxy2n4mopfmjancgdvxq8xz',
Expand Down
6 changes: 3 additions & 3 deletions commander/src/bootstrapping/commands/generator/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { BaseForgingCommand } from '../base_forging';

export abstract class EnableCommand extends BaseForgingCommand {
static description = 'Enable forging for given delegate address.';
static description = 'Enable forging for given validator address.';

static examples = [
'generator:enable lsk24cd35u4jdq8szo3pnsqe5dsxwrnazyqqqg5eu 100 100 10',
Expand All @@ -39,12 +39,12 @@ export abstract class EnableCommand extends BaseForgingCommand {
{
name: 'maxHeightGenerated',
required: true,
description: 'Delegates largest previously forged height.',
description: 'Validators largest previously forged height.',
},
{
name: 'maxHeightPrevoted',
required: true,
description: 'Delegates largest prevoted height for a block.',
description: 'Validators largest prevoted height for a block.',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as fs from 'fs-extra';
import * as Generator from 'yeoman-generator';
import { isHexString } from '@liskhq/lisk-validator';
import { Mnemonic } from '@liskhq/lisk-passphrase';
import { generateGenesisBlockDefaultDPoSAssets } from '../../../../utils/genesis_creation';
import { generateGenesisBlockDefaultPoSAssets } from '../../../../utils/genesis_creation';

interface InitPrompts {
name: string;
Expand Down Expand Up @@ -126,7 +126,7 @@ export default class InitGenerator extends Generator {
const { keys } = JSON.parse(
fs.readFileSync(`${this.destinationPath('config/default/dev-validators.json')}`, 'utf8'),
) as Record<string, unknown>;
const { genesisAssets } = generateGenesisBlockDefaultDPoSAssets({
const { genesisAssets } = generateGenesisBlockDefaultPoSAssets({
chainID: this.answers.chainID,
keysList: keys as never,
numberOfValidators: 101,
Expand Down
14 changes: 7 additions & 7 deletions commander/src/utils/genesis_creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import { Schema } from '@liskhq/lisk-codec';
import { address } from '@liskhq/lisk-cryptography';
import {
dposGenesisStoreSchema,
DPoSModule,
posGenesisStoreSchema,
PoSModule,
tokenGenesisStoreSchema,
TokenModule,
} from 'lisk-framework';
Expand Down Expand Up @@ -79,7 +79,7 @@ interface GenesisBlockDefaultAccountInput {
numberOfValidators: number;
}

export const generateGenesisBlockDefaultDPoSAssets = (input: GenesisBlockDefaultAccountInput) => {
export const generateGenesisBlockDefaultPoSAssets = (input: GenesisBlockDefaultAccountInput) => {
const localID = Buffer.from([0, 0, 0, 0]).toString('hex');
const tokenID = `${input.chainID}${localID}`;
input.keysList.sort((a, b) =>
Expand Down Expand Up @@ -109,7 +109,7 @@ export const generateGenesisBlockDefaultDPoSAssets = (input: GenesisBlockDefault
schema: tokenGenesisStoreSchema,
},
{
module: new DPoSModule().name,
module: new PoSModule().name,
data: {
validators: input.keysList.map((v, i) => ({
address: v.address,
Expand All @@ -125,13 +125,13 @@ export const generateGenesisBlockDefaultDPoSAssets = (input: GenesisBlockDefault
lastCommissionIncreaseHeight: 0,
sharingCoefficients: [],
})),
voters: [],
stakers: [],
genesisData: {
initRounds: 3,
initDelegates: input.keysList.slice(0, input.numberOfValidators).map(v => v.address),
initValidators: input.keysList.slice(0, input.numberOfValidators).map(v => v.address),
},
} as Record<string, unknown>,
schema: dposGenesisStoreSchema,
schema: posGenesisStoreSchema,
},
];

Expand Down
8 changes: 4 additions & 4 deletions commander/test/bootstrapping/commands/endpoint/invoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('endpoint:invoke command', () => {
[
'consensus_getBFTParameters',
'{"height": 2}',
'-d ~/.lisk/dpos-mainchain',
'-d ~/.lisk/pos-mainchain',
'-f ./input.json',
],
config,
Expand All @@ -58,15 +58,15 @@ describe('endpoint:invoke command', () => {
});

it('should call invoke with the provided action', async () => {
await InvokeCommand.run(['consensus_getBFTParameters', '-d ~/.lisk/dpos-mainchain'], config);
await InvokeCommand.run(['consensus_getBFTParameters', '-d ~/.lisk/pos-mainchain'], config);

expect(invokeMock).toBeCalledTimes(1);
expect(invokeMock).toBeCalledWith('consensus_getBFTParameters');
});

it('should call invoke the provided action with parameters if provided', async () => {
await InvokeCommand.run(
['consensus_getBFTParameters', '{"height": 2}', '-d ~/.lisk/dpos-mainchain'],
['consensus_getBFTParameters', '{"height": 2}', '-d ~/.lisk/pos-mainchain'],
config,
);

Expand All @@ -76,7 +76,7 @@ describe('endpoint:invoke command', () => {

it('should call printJSON with the result of client.invoke', async () => {
await InvokeCommand.run(
['consensus_getBFTParameters', '{"height": 2}', '-d ~/.lisk/dpos-mainchain'],
['consensus_getBFTParameters', '{"height": 2}', '-d ~/.lisk/pos-mainchain'],
config,
);

Expand Down
6 changes: 3 additions & 3 deletions commander/test/bootstrapping/commands/system/info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ describe('system:node-info command', () => {
distance: 3000000,
},
communityIdentifier: 'Lisk',
activeDelegates: 101,
standbyDelegates: 2,
activeValidators: 101,
standbyValidators: 2,
totalAmount: '10000000000000000',
delegateListRoundOffset: 2,
validatorListRoundOffset: 2,
},
};

Expand Down
44 changes: 16 additions & 28 deletions commander/test/bootstrapping/commands/transaction/create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as transactions from '@liskhq/lisk-transactions';

import * as appUtils from '../../../../src/utils/application';
import * as readerUtils from '../../../../src/utils/reader';
import { tokenTransferParamsSchema, dposVoteParamsSchema } from '../../../helpers/transactions';
import { tokenTransferParamsSchema, posVoteParamsSchema } from '../../../helpers/transactions';
import { CreateCommand } from '../../../../src/bootstrapping/commands/transaction/create';
import { getConfig } from '../../../helpers/config';
import { PromiseResolvedType } from '../../../../src/types';
Expand All @@ -32,9 +32,9 @@ describe('transaction:create command', () => {
const transferParams =
'{"tokenID": "0000000000000000","amount":100,"recipientAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","data":"send token", "accountInitializationFee": "5000000"}';
const voteParams =
'{"votes":[{"delegateAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":100},{"delegateAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":-50}]}';
'{"stakes":[{"validatorAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":100},{"validatorAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":-50}]}';
const unVoteParams =
'{"votes":[{"delegateAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":-50}]}';
'{"stakes":[{"validatorAddress":"lskqozpc4ftffaompmqwzd93dfj89g5uezqwhosg9","amount":-50}]}';
const { publicKey } = cryptography.legacy.getPrivateAndPublicKeyFromPassphrase(passphrase);
const senderPublicKey = publicKey.toString('hex');
const mockEncodedTransaction = Buffer.from('encoded transaction');
Expand Down Expand Up @@ -94,11 +94,11 @@ describe('transaction:create command', () => {
],
},
{
name: 'dpos',
name: 'pos',
commands: [
{
name: 'voteDelegate',
params: dposVoteParamsSchema,
name: 'stake',
params: posVoteParamsSchema,
},
],
},
Expand Down Expand Up @@ -338,12 +338,12 @@ describe('transaction:create command', () => {
});
});

describe(`transaction:create dpos voteDelegate 100000000 --params=${voteParams} --passphrase=${passphrase}`, () => {
describe(`transaction:create pos stake 100000000 --params=${voteParams} --passphrase=${passphrase}`, () => {
it('should return encoded transaction string in hex format with signature', async () => {
await CreateCommandExtended.run(
[
'dpos',
'voteDelegate',
'pos',
'stake',
'100000000',
'--offline',
`--params=${voteParams}`,
Expand All @@ -360,12 +360,12 @@ describe('transaction:create command', () => {
});
});

describe(`transaction:create dpos voteDelegate 100000000 --params=${unVoteParams} --passphrase=${passphrase}`, () => {
describe(`transaction:create pos stake 100000000 --params=${unVoteParams} --passphrase=${passphrase}`, () => {
it('should return encoded transaction string in hex format with signature', async () => {
await CreateCommandExtended.run(
[
'dpos',
'voteDelegate',
'pos',
'stake',
'100000000',
'--offline',
`--params=${unVoteParams}`,
Expand Down Expand Up @@ -600,16 +600,10 @@ describe('transaction:create command', () => {
});
});

describe(`transaction:create dpos voteDelegate 100000000 --params=${voteParams} --passphrase=${passphrase}`, () => {
describe(`transaction:create pos stake 100000000 --params=${voteParams} --passphrase=${passphrase}`, () => {
it('should return encoded transaction string in hex format with signature', async () => {
await CreateCommandExtended.run(
[
'dpos',
'voteDelegate',
'100000000',
`--params=${voteParams}`,
`--passphrase=${passphrase}`,
],
['pos', 'stake', '100000000', `--params=${voteParams}`, `--passphrase=${passphrase}`],
config,
);
expect(CreateCommandExtended.prototype.printJSON).toHaveBeenCalledTimes(1);
Expand All @@ -619,16 +613,10 @@ describe('transaction:create command', () => {
});
});

describe(`transaction:create dpos voteDelegate 100000000 --params=${unVoteParams} --passphrase=${passphrase}`, () => {
describe(`transaction:create pos stake 100000000 --params=${unVoteParams} --passphrase=${passphrase}`, () => {
it('should return encoded transaction string in hex format with signature', async () => {
await CreateCommandExtended.run(
[
'dpos',
'voteDelegate',
'100000000',
`--params=${unVoteParams}`,
`--passphrase=${passphrase}`,
],
['pos', 'stake', '100000000', `--params=${unVoteParams}`, `--passphrase=${passphrase}`],
config,
);
expect(CreateCommandExtended.prototype.printJSON).toHaveBeenCalledTimes(1);
Expand Down
22 changes: 11 additions & 11 deletions commander/test/bootstrapping/commands/transaction/prompt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import {
tokenTransferParamsSchema,
keysRegisterParamsSchema,
dposVoteParamsSchema,
posVoteParamsSchema,
} from '../../../helpers/transactions';

describe('prompt', () => {
Expand Down Expand Up @@ -81,28 +81,28 @@ describe('prompt', () => {

describe('transformNestedAsset', () => {
it('should transform result according to nested asset schema', () => {
const questions = prepareQuestions(dposVoteParamsSchema);
const transformedAsset = transformNestedAsset(dposVoteParamsSchema, [
{ votes: 'a,100' },
{ votes: 'b,300' },
const questions = prepareQuestions(posVoteParamsSchema);
const transformedAsset = transformNestedAsset(posVoteParamsSchema, [
{ stakes: 'a,100' },
{ stakes: 'b,300' },
]);

expect(questions).toEqual([
{
type: 'input',
name: 'votes',
message: 'Please enter: votes(delegateAddress, amount): ',
name: 'stakes',
message: 'Please enter: stakes(validatorAddress, amount): ',
},
{
type: 'confirm',
name: 'askAgain',
message: 'Want to enter another votes(delegateAddress, amount)',
message: 'Want to enter another stakes(validatorAddress, amount)',
},
]);
expect(transformedAsset).toEqual({
votes: [
{ delegateAddress: 'a', amount: 100 },
{ delegateAddress: 'b', amount: 300 },
stakes: [
{ validatorAddress: 'a', amount: 100 },
{ validatorAddress: 'b', amount: 300 },
],
});
});
Expand Down
20 changes: 10 additions & 10 deletions commander/test/helpers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ export const createFakeDefaultAccount = (account: any) => ({
optionalKeys: account?.keys?.optionalKeys ?? [],
numberOfSignatures: account?.keys?.numberOfSignatures ?? 0,
},
dpos: {
delegate: {
username: account?.dpos?.delegate?.username ?? '',
pomHeights: account?.dpos?.delegate?.pomHeights ?? [],
consecutiveMissedBlocks: account?.dpos?.delegate?.consecutiveMissedBlocks ?? 0,
lastForgedHeight: account?.dpos?.delegate?.lastForgedHeight ?? 0,
isBanned: account?.dpos?.delegate?.isBanned ?? false,
totalVotesReceived: account?.dpos?.delegate?.totalVotesReceived ?? BigInt(0),
pos: {
validator: {
username: account?.pos?.validator?.username ?? '',
pomHeights: account?.pos?.validator?.pomHeights ?? [],
consecutiveMissedBlocks: account?.pos?.validator?.consecutiveMissedBlocks ?? 0,
lastForgedHeight: account?.pos?.validator?.lastForgedHeight ?? 0,
isBanned: account?.pos?.validator?.isBanned ?? false,
totalStakeReceived: account?.pos?.validator?.totalStakeReceived ?? BigInt(0),
},
sentVotes: account?.dpos?.sentVotes ?? [],
unlocking: account?.dpos?.unlocking ?? [],
sentStakes: account?.pos?.sentStakes ?? [],
unlocking: account?.pos?.unlocking ?? [],
},
});

Expand Down
14 changes: 7 additions & 7 deletions commander/test/helpers/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { codec, Schema } from '@liskhq/lisk-codec';
import { utils } from '@liskhq/lisk-cryptography';
import { transactionSchema } from 'lisk-framework';
import {
dposVoteParamsSchema,
posVoteParamsSchema,
registerMultisignatureParamsSchema,
tokenTransferParamsSchema,
} from './transactions';
Expand All @@ -40,9 +40,9 @@ export const mockCommands: CommandInfo[] = [
schema: registerMultisignatureParamsSchema,
},
{
module: 'dpos',
command: 'voteDelegate',
schema: dposVoteParamsSchema,
module: 'pos',
command: 'stake',
schema: posVoteParamsSchema,
},
];

Expand Down Expand Up @@ -99,12 +99,12 @@ export const createIPCClientMock = (
},
{
id: utils.intToBuffer(13, 4).toString('hex'),
name: 'dpos',
name: 'pos',
commands: [
{
id: utils.intToBuffer(1, 4).toString('hex'),
name: 'voteDelegate',
params: dposVoteParamsSchema,
name: 'stake',
params: posVoteParamsSchema,
},
],
},
Expand Down
Loading

0 comments on commit dee896c

Please sign in to comment.