This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What was the problem? This PR resolves #7717 ### How was it solved? - Add new dynamic reward module using reward module - Update genesis block for example app - Add small refactor to reward module to be usable from dynamic reward module - Add new DPoS method which is required by dynamic reward module - #7715 should add the implementation for `updateSharedRewards` ### How was it tested? - Add unit tests for all the cases
- Loading branch information
Showing
21 changed files
with
996 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright © 2021 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
import { defaultConfig as rewardDefaultConfig } from '../reward/constants'; | ||
|
||
export const EMPTY_BYTES = Buffer.alloc(0); | ||
|
||
export const defaultConfig = { | ||
...rewardDefaultConfig, | ||
factorMinimumRewardActiveDelegates: 1000, | ||
}; | ||
|
||
export const DECIMAL_PERCENT_FACTOR = BigInt(10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright © 2021 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
import { RewardEndpoint } from '../reward/endpoint'; | ||
|
||
export class DynamicRewardEndpoint extends RewardEndpoint {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright © 2021 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
export { DynamicRewardModule } from './module'; | ||
export { DynamicRewardMethod } from './method'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright © 2021 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
import { ImmutableMethodContext } from '../../state_machine'; | ||
import { BaseMethod } from '../base_method'; | ||
import { calculateDefaultReward } from '../reward/calculate_reward'; | ||
import { ModuleConfig } from './types'; | ||
|
||
export interface MethodInitArgs { | ||
config: ModuleConfig; | ||
} | ||
|
||
export class DynamicRewardMethod extends BaseMethod { | ||
private _config!: ModuleConfig; | ||
|
||
public init(args: MethodInitArgs) { | ||
this._config = args.config; | ||
} | ||
|
||
public getDefaultRewardAtHeight(_context: ImmutableMethodContext, height: number): bigint { | ||
return calculateDefaultReward(this._config, height); | ||
} | ||
} |
Oops, something went wrong.