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

Code improvements PoA module #1 #8945

Closed
Tracked by #7245
mitsuaki-u opened this issue Sep 8, 2023 · 0 comments
Closed
Tracked by #7245

Code improvements PoA module #1 #8945

mitsuaki-u opened this issue Sep 8, 2023 · 0 comments
Assignees
Milestone

Comments

@mitsuaki-u
Copy link
Contributor

Expected behavior

  1. Misspelled, unused constant . In poa/constants.ts , both
    LENGTH_PROOF_OF_POSSESSION and LENGTH_PROOF_OF_POSESSION are defined,
    both equaling 96. LENGTH_PROOF_OF_POSESSION is never used.

  2. Redundant, unused type . In poa/stores/snapshot.ts , the Validator type is
    defined but never used. It is identical to the ActiveValidator type, imported from
    poa/types.ts . ActiveValidator is used later in poa/stores/snapshot.ts .

  3. Hardcoded SUBSTORE_PREFIX constants . The LIP specifying the PoA module
    specifies four SUBSTORE_PREFIX constants. These constants are hardcoded in the
    implementation (in poa/module.ts , in the constructor of PoAModule ), rather than
    being defined as constants in poa/constants.ts .

  4. Constants are defined but hardcoded versions are used :
    a. In poa/module.ts , line 88, 'poa' is used instead of MODULE_NAME_POA .
    b. In poa/module.ts , line 216, /^[a-z0-9!@$&_.]+$/g is used instead of
    POA_VALIDATOR_NAME_REGEX . While the hardcoded value is slightly
    different from the constant (the hardcoded value includes a g for global at
    the end, while the constant does not), the effect will be the same.
    c. In poa/endpoint.ts , on lines 73 and 74, 20 is used instead of
    NUM_BYTES_ADDRESS .

  5. Inconsistent use of Buffer.from . Some code locations use Buffer.from(str,
    'utf-8') while other locations use Buffer.from(str) , leaving out the 'utf-8'
    argument. The effect is the same, since 'utf-8' is the default value of that
    argument

Actual behavior

See above

Steps to reproduce

Check PoA Module

Which version(s) does this affect? (Environment, OS, etc...)

v6.0.0

@mitsuaki-u mitsuaki-u self-assigned this Sep 11, 2023
@Madhulearn Madhulearn added this to the Sprint 104 milestone Sep 12, 2023
@ishantiw ishantiw changed the title Improvements to PoA module Code improvements PoA module #1 Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants