Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sequence module - Closes #5606 #5630

Merged
merged 6 commits into from Aug 7, 2020

Conversation

ishantiw
Copy link
Member

@ishantiw ishantiw commented Aug 7, 2020

What was the problem?

This PR resolves #5606

How was it solved?

Source:

  • Implement beforeTransactionApply and afterTransactionApply of sequence module
  • Create SequenceModuleError
  • Add id in Transaction interface in base_modules to show in the SequenceModuleError

Tests:

  • Add tests related to when nonce is invalid
  • Add tests related to when nonce is valid

How was it tested?

Run npm run test test/unit/specs/modules/sequence/sequence_module.spec.ts under /framework

@ishantiw ishantiw self-assigned this Aug 7, 2020
@ishantiw ishantiw force-pushed the 5606_create_sequence_module branch from a72aefe to 76f206f Compare August 7, 2020 11:11
framework/src/modules/sequence/sequence_module.ts Outdated Show resolved Hide resolved

// Throw error when tx nonce is not equal to account nonce
if (tx.nonce !== senderAccount.sequence.nonce) {
throw new SequenceModuleError(
Copy link
Member

Choose a reason for hiding this comment

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

it should throw the NonceOutOfRange error to be handled specifically in the transaction pool

framework/src/errors.ts Outdated Show resolved Hide resolved
framework/src/modules/sequence/sequence_module.ts Outdated Show resolved Hide resolved

// Throw error when tx nonce is lower than the account nonce
if (tx.nonce < senderAccount.sequence.nonce) {
throw new NonceOutOfBoundsError(
Copy link
Member

Choose a reason for hiding this comment

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

This error should be different in order to check in transaction pool.
ie) in transaction pool, the lower nonce is rejected immediately, but higher nonce is accepted.

@ishantiw ishantiw force-pushed the 5606_create_sequence_module branch from 0486599 to 5851531 Compare August 7, 2020 13:02
@ishantiw ishantiw requested a review from shuse2 August 7, 2020 13:04
- Implement beforeTransactionApply and afterTransactionApply of sequence module
- Create SequenceModuleError
- Add id in Transaction interface in base_modules to show in the SequenceModuleError
- Add tests related to when nonce is invalid
- Add tests related to when nonce is valid
- Pass nonce under sequence prop inside Account type
- Use SequenceAccount type
- Account schema default values should have nonce
- Throw NonceOutOfBoundsError error
- Update unit tests
- Use generics for account.set
- Only need to use getOrDefault in transfer asset of recipient
@ishantiw ishantiw force-pushed the 5606_create_sequence_module branch from 5851531 to 21a1de6 Compare August 7, 2020 13:13
@shuse2 shuse2 merged commit 89b4bc6 into feature/on_chain_architecture Aug 7, 2020
@shuse2 shuse2 deleted the 5606_create_sequence_module branch August 7, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants