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

Implement genesis block creation and validation function in lisk-genesis - Closes #5277, #5386 #5421

Merged
merged 30 commits into from
Jun 17, 2020

Conversation

nazarhussain
Copy link
Contributor

What was the problem?

This PR resolves ##5277, resolved #5386

How was it solved?

Created new functions for creating and validating genesis block

How was it tested?

Run all tests for lisk-genesis

@nazarhussain nazarhussain self-assigned this Jun 10, 2020
elements/lisk-genesis/src/constants.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/create.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/schema.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/schema.ts Show resolved Hide resolved
@nazarhussain nazarhussain marked this pull request as ready for review June 15, 2020 13:47
@nazarhussain nazarhussain requested a review from shuse2 June 15, 2020 13:47
@shuse2 shuse2 requested a review from ishantiw June 15, 2020 19:45
framework/.tool-versions Outdated Show resolved Hide resolved
elements/lisk-genesis/test/validate.spec.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/test/validate.spec.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/create.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/constants.ts Outdated Show resolved Hide resolved

export type GenesisBlockHeaderWithoutId = Omit<GenesisBlockHeader, 'id'>;

export interface GenesisBlock {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, you can use Block<GenesisBlockHeaderAsset>

Copy link
Contributor Author

@nazarhussain nazarhussain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible, as we want genesis block to fixed type as an empty array. If used as Block we have to declare payload as an empty array of BaseTransaction

const transactionRoot = GB_TRANSACTION_ROOT;

const accounts: ReadonlyArray<GenesisAccountState> = params.accounts
.map(acc => new Account(acc))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to change this to instance here?

Copy link
Contributor Author

@nazarhussain nazarhussain Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, we have to specify full account type and also duplicate code to convert the partial account to a full account attributes. Then we have to add another dependency of lisk-transactions

elements/lisk-genesis/src/utils/merge_deep.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/schema.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/constants.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/utils/buffer_array.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/utils/buffer_array.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/utils/merge_deep.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
@nazarhussain nazarhussain requested review from ishantiw and shuse2 June 16, 2020 12:58
@nazarhussain
Copy link
Contributor Author

@shuse2 @ishantiw Interesting part of the code change to review will be https://github.com/LiskHQ/lisk-sdk/pull/5421/files#diff-a9077ad359351fde5b4b05d4551fce86

Copy link
Contributor

@ishantiw ishantiw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, very minor comment but approved from my end

elements/lisk-genesis/test/create.spec.ts Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
elements/lisk-genesis/src/validate.ts Outdated Show resolved Hide resolved
@nazarhussain nazarhussain requested a review from shuse2 June 17, 2020 07:56
@shuse2 shuse2 merged commit 8468c1a into development Jun 17, 2020
@shuse2 shuse2 deleted the 5277-create-genesis-block branch June 17, 2020 08:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement genesis block validation function in lisk-genesis
3 participants