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

Add missing configurable config params #8854

Merged
merged 13 commits into from
Aug 19, 2023

Conversation

bobanm
Copy link
Contributor

@bobanm bobanm commented Aug 15, 2023

What was the problem?

This PR resolves #8753

How was it solved?

Replaced config literals with constants:

  • MAX_TRANSACTIONS_SIZE
  • BFT_BATCH_SIZE
  • FACTOR_MINIMUM_REWARD_ACTIVE_VALIDATORS
  • MIN_FEE_PER_BYTE
  • MAX_BLOCK_HEIGHT_ZERO_FEE_PER_BYTE
  • FACTOR_SELF_STAKES
  • FAIL_SAFE_MISSED_BLOCKS
  • FAIL_SAFE_INACTIVE_WINDOW
  • MAX_BFT_WEIGHT_CAP
  • USE_INVALID_BLS_KEY

Added a default value in defaultConfig and updated code not to directly import the constant, but get it from config:

  • NUMBER_ACTIVE_VALIDATORS
  • NUMBER_STANDBY_VALIDATORS
  • MAX_LENGTH_NAME
  • MAX_NUMBER_PENDING_UNLOCKS
  • BASE_STAKE_AMOUNT
  • LOCKING_PERIOD_SELF_STAKING
  • WEIGHT_SCALE_FACTOR
  • PUNISHMENT_PERIOD
  • PUNISHMENT_WINDOW_STAKING
  • PUNISHMENT_WINDOW_SELF_STAKING
  • LOCKING_PERIOD_SELF_STAKING

Added as default value in defaultConfig, added config property, and updated code not to directly import the constant, but get it from config:

  • LOCKING_PERIOD_STAKING
  • REPORT_MISBEHAVIOR_REWARD
  • REPORT_MISBEHAVIOR_LIMIT_BANNED
  • MAX_NUMBER_OF_SIGNATURES

Added comment about different name:

  • MAX_COMMISSION_INCREASE_RATE

Renamed constant and added a comment about different name:

  • MAX_LENGTH_REVEALS

Renamed constant to align with LIP and property name:

  • USER_SUBSTORE_INITIALIZATION_FEE => USER_ACCOUNT_INITIALIZATION_FEE
  • ESCROW_SUBSTORE_INITIALIZATION_FEE => ESCROW_ACCOUNT_INITIALIZATION_FEE
  • TRANSACTION_MAX_PARAMS_SIZE => MAX_PARAMS_SIZE

Updated constant value to match LIP:

  • MAX_ASSET_DATA_SIZE_BYTES

Updated PoS util functions to get param value from config as arguments, instead of importing constants.

  • isCurrentlyPunished()
  • getWaitTime()
  • getPunishTime()
  • hasWaited()
  • isPunished()
  • getPunishmentPeriod()

BONUS: Changed factorSelfStakes to number and removed all castings of it to BigInt 😎

How was it tested?

All tests pass 👌🏻
Example app runs 🏃🏻

@bobanm bobanm requested review from shuse2 and gkoumout August 15, 2023 16:04
@bobanm bobanm self-assigned this Aug 15, 2023
elements/lisk-chain/src/constants.ts Outdated Show resolved Hide resolved
framework/src/constants.ts Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Merging #8854 (9f219be) into release/6.0.0 (72ce6b3) will increase coverage by 0.01%.
The diff coverage is 96.42%.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release/6.0.0    #8854      +/-   ##
=================================================
+ Coverage          83.57%   83.59%   +0.01%     
=================================================
  Files                601      601              
  Lines              22486    22521      +35     
  Branches            3322     3324       +2     
=================================================
+ Hits               18793    18826      +33     
- Misses              3693     3695       +2     
Files Changed Coverage Δ
framework/src/modules/auth/schemas.ts 100.00% <ø> (ø)
framework/src/modules/pos/schemas.ts 100.00% <ø> (ø)
...work/src/modules/pos/stores/eligible_validators.ts 100.00% <ø> (ø)
framework/src/modules/reward/constants.ts 100.00% <ø> (ø)
framework/src/modules/reward/module.ts 93.75% <ø> (ø)
framework/src/schema/application_config_schema.ts 100.00% <ø> (ø)
elements/lisk-chain/src/transaction.ts 69.09% <66.66%> (ø)
framework/src/modules/pos/utils.ts 84.89% <85.71%> (-0.30%) ⬇️
elements/lisk-chain/src/constants.ts 100.00% <100.00%> (ø)
framework/src/constants.ts 100.00% <100.00%> (ø)
... and 16 more

... and 1 file with indirect coverage changes

Copy link

@gkoumout gkoumout left a comment

Choose a reason for hiding this comment

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

Very good job! I tried to check as carefully as possible, caught just few minor inconsistencies.

framework/src/modules/reward/constants.ts Show resolved Hide resolved
framework/src/modules/random/constants.ts Show resolved Hide resolved
export const defaultConfig = {
minFeePerByte: 1000,
maxBlockHeightZeroFeePerByte: 0,
minFeePerByte: MIN_FEE_PER_BYTE,

Choose a reason for hiding this comment

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

I am not 100% sure those values are intended as part of default configuration, perhaps we should check this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the specs. Let me know if they are outdated.

Choose a reason for hiding this comment

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

Those are the mainchain values. Mainchain configuration is set in LIP 63. For sidechains built with SDK, I think the values should be given dynamically at creation time, same as TOKEN_ID_FEE. Using current status, we define minFee to a default value without knowing which token it corresponds to, whic is a bit funny.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are just some default values because we need some meaningful defaults, which users are supposed to override with their custom config?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gkoumout you mean to force user to set this value in the config for the sidechain?

Choose a reason for hiding this comment

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

@ishantiw @bobanm Yes, this is what I meant

lockingPeriodSelfStaking: number;
reportMisbehaviorReward: bigint;
reportMisbehaviorLimitBanned: number;
weightScaleFactor: bigint;
}

Choose a reason for hiding this comment

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

Comment about line 33: round length is not configurable anymore..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Round Length is no longer a directly configurable param, but a derived param. It is calculated based on number of configured validators.

So it is still part of the config.

Choose a reason for hiding this comment

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

ok sounds good, just wanted to make sure.

framework/test/unit/modules/pos/module.spec.ts Outdated Show resolved Hide resolved
framework/test/unit/modules/pos/commands/stake.spec.ts Outdated Show resolved Hide resolved
framework/test/unit/modules/pos/commands/unlock.spec.ts Outdated Show resolved Hide resolved
@bobanm bobanm requested a review from gkoumout August 17, 2023 15:59
Copy link
Collaborator

@shuse2 shuse2 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, one minor problem i see

framework/test/unit/modules/pos/method.spec.ts Outdated Show resolved Hide resolved
@bobanm bobanm requested a review from shuse2 August 18, 2023 13:03
Copy link

@gkoumout gkoumout left a comment

Choose a reason for hiding this comment

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

Some minor leftover comments.

elements/lisk-chain/src/constants.ts Show resolved Hide resolved
framework/src/modules/auth/constants.ts Show resolved Hide resolved
export const defaultConfig = {
minFeePerByte: 1000,
maxBlockHeightZeroFeePerByte: 0,
minFeePerByte: MIN_FEE_PER_BYTE,

Choose a reason for hiding this comment

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

Those are the mainchain values. Mainchain configuration is set in LIP 63. For sidechains built with SDK, I think the values should be given dynamically at creation time, same as TOKEN_ID_FEE. Using current status, we define minFee to a default value without knowing which token it corresponds to, whic is a bit funny.

framework/src/modules/pos/endpoint.ts Outdated Show resolved Hide resolved
lockingPeriodSelfStaking: number;
reportMisbehaviorReward: bigint;
reportMisbehaviorLimitBanned: number;
weightScaleFactor: bigint;
}

Choose a reason for hiding this comment

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

ok sounds good, just wanted to make sure.

framework/src/modules/auth/module.ts Outdated Show resolved Hide resolved
@bobanm bobanm requested review from shuse2 and gkoumout August 18, 2023 14:10
export const defaultConfig = {
minFeePerByte: 1000,
maxBlockHeightZeroFeePerByte: 0,
minFeePerByte: MIN_FEE_PER_BYTE,
Copy link
Contributor

Choose a reason for hiding this comment

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

@gkoumout you mean to force user to set this value in the config for the sidechain?

@shuse2 shuse2 merged commit 21c8668 into release/6.0.0 Aug 19, 2023
10 checks passed
@shuse2 shuse2 deleted the 8753-add-missing-configurable-config-params branch August 19, 2023 10:07
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.

4 participants