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

Update framework use the new schema - Closes #5378 #5382

Merged
merged 13 commits into from
Jun 4, 2020

Conversation

shuse2
Copy link
Collaborator

@shuse2 shuse2 commented Jun 3, 2020

What was the problem?

This PR resolves #5378

How was it solved?

  • Update all the usages of the old block and account format
  • Update to use base64 for external communication and logs
  • Integrate all the library changes

How was it tested?

  • All the test cases are updated
  • Application should run after restarting the database

@shuse2 shuse2 self-assigned this Jun 3, 2020
@shuse2 shuse2 requested review from ManuGowda and nazarhussain June 3, 2020 07:02
elements/lisk-chain/src/chain.ts Outdated Show resolved Hide resolved
// Validate block header
const errors = validator.validate(blockHeaderSchema, block.header);
if (errors.length) {
throw new Error(errors[0].message);
Copy link
Contributor

Choose a reason for hiding this comment

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

On development branch introduced a new error LiskValidationError which contains an attribute errors. We should start using it in such cases.

throw new Error(errors);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is returning the error array, so i dont think this works

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that LiskValidationError accepts array of errors. So all good to throw it. The message will be generated automatically something

Lisk validation failed and found 2 errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah you mean parse it to the error, but I think if it just return the particular error instead of asking it to handle here, it would be better.
but I do agree we should use the single error everywhere and we should fix it.

Copy link
Contributor

@nazarhussain nazarhussain Jun 4, 2020

Choose a reason for hiding this comment

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

@shuse2 Just for reference can you create an issue to remove all usages of throwing errors like throw new Error(errors[0].message) So we can fix it.

elements/lisk-chain/src/utils/buffer_map.ts Show resolved Hide resolved
elements/lisk-transactions/src/base_transaction.ts Outdated Show resolved Hide resolved
elements/lisk-transactions/src/base_transaction.ts Outdated Show resolved Hide resolved
elements/lisk-transactions/src/types.ts Show resolved Hide resolved
elements/lisk-validator/src/validation.ts Outdated Show resolved Hide resolved
framework/src/application/logger/logger.ts Show resolved Hide resolved
framework/src/application/node/account.ts Show resolved Hide resolved
framework/src/application/node/block_processor_v2.ts Outdated Show resolved Hide resolved
@shuse2 shuse2 requested a review from nazarhussain June 3, 2020 14:38
// Validate block header
const errors = validator.validate(blockHeaderSchema, block.header);
if (errors.length) {
throw new Error(errors[0].message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that LiskValidationError accepts array of errors. So all good to throw it. The message will be generated automatically something

Lisk validation failed and found 2 errors.

elements/lisk-validator/src/formats.ts Outdated Show resolved Hide resolved
framework/src/application/node/account.ts Show resolved Hide resolved
@shuse2 shuse2 requested a review from nazarhussain June 4, 2020 09:43
@sridharmeganathan sridharmeganathan linked an issue Jun 4, 2020 that may be closed by this pull request
Copy link
Contributor

@ManuGowda ManuGowda left a comment

Choose a reason for hiding this comment

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

Summary:

  • event name typos
  • interface reuse
  • hex vs base64 usages

@@ -173,7 +175,7 @@ export class Chain {
private readonly blocksVerify: BlocksVerify;
private readonly _networkIdentifier: Buffer;
private readonly blockRewardArgs: BlockRewardOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

since we are refactoring, can we rename these private properties to follow _?

framework/src/application/node/block_processor_v2.ts Outdated Show resolved Hide resolved
framework/src/application/node/block_processor_v2.ts Outdated Show resolved Hide resolved
framework/src/application/node/forger/forger.ts Outdated Show resolved Hide resolved
framework/src/application/node/node.ts Outdated Show resolved Hide resolved
@@ -30,6 +31,10 @@ const forkStatusList = [
ForkStatus.DISCARD,
];

export const EVENT_PROCESSOR_SYNC_REQUIRED = 'EVENT_PROCESSOR_SYNC_REQUIRED';
Copy link
Contributor

Choose a reason for hiding this comment

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

PROCESSOR_SYNC_REQUIRED, at places we use the value without event_, maybe we should use one format.

framework/src/application/node/processor/processor.ts Outdated Show resolved Hide resolved
@shuse2 shuse2 merged commit 702dd4e into feature/update_to_use_codec Jun 4, 2020
@shuse2 shuse2 deleted the 5378-update_framework_use_codec branch June 4, 2020 14:19
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.

Update framework transport to return and receive encoded data
3 participants