-
Notifications
You must be signed in to change notification settings - Fork 23
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
M-01 token conversion #621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, just one suggestion
@@ -58,6 +58,11 @@ Proof-of-Authority Validator management is provided via `PoAValidatorManager`, w | |||
|
|||
Proof-of-Stake Validator management is provided by the abstract contract `PoSValidatorManager`, which has two concrete implementations: `NativeTokenStakingManager` and `ERC20TokenStakingManager`. In addition to basic Validator management provided in `ValidatorManager`, `PoSValidatorManager` supports uptime-based Validation rewards, as well as Delegation to a Validator. This [state transition diagram](./StateTransition.md) illustrates the relationship between Validators and Delegators. | |||
|
|||
> [!NOTE] | |||
> The `weightToValueFactor` fields of the `PoSValidatorManagerSettings` passed to `PoSValidatorManager`'s `initialize` function sets the factor used to convert between the value transferred to the contract as stake, and the weight that the Validator is registered with on the P-Chain. This involves integer division, which may result in loss of precision. When selecting `weightToValueFactor`, it's important to make the following considerations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> The `weightToValueFactor` fields of the `PoSValidatorManagerSettings` passed to `PoSValidatorManager`'s `initialize` function sets the factor used to convert between the value transferred to the contract as stake, and the weight that the Validator is registered with on the P-Chain. This involves integer division, which may result in loss of precision. When selecting `weightToValueFactor`, it's important to make the following considerations: | |
> The `weightToValueFactor` fields of the `PoSValidatorManagerSettings` passed to `PoSValidatorManager`'s `initialize` function sets the factor used to convert between the weight that the Validator is registered with on the P-Chain, and the value transferred to the contract as stake. This involves integer division, which may result in loss of precision. When selecting `weightToValueFactor`, it's important to make the following considerations: |
We may want to note here that weight
on the P-Chain is represented as a uint64
, so the weightToValueFactor
should be set with that in mind to ensure that the weight value will not overflow. We may even want to add a require
statement when registering a validator that the weight is <= UINT64_MAX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Added documentation, a check against UINT64_MAX
, and a test.
Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Adding an example in the README about possible issues with conversion might help clarify any possible misunderstandings.
@@ -58,6 +58,12 @@ Proof-of-Authority Validator management is provided via `PoAValidatorManager`, w | |||
|
|||
Proof-of-Stake Validator management is provided by the abstract contract `PoSValidatorManager`, which has two concrete implementations: `NativeTokenStakingManager` and `ERC20TokenStakingManager`. In addition to basic Validator management provided in `ValidatorManager`, `PoSValidatorManager` supports uptime-based Validation rewards, as well as Delegation to a Validator. This [state transition diagram](./StateTransition.md) illustrates the relationship between Validators and Delegators. | |||
|
|||
> [!NOTE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: It may be helpful to include an example that illustrates the first 2 considerations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added examples
Why this should be merged
Parameterizes weight to value conversion factor.
How this works
How this was tested
CI, new unit tests
How is this documented
Documents gotchas when selecting the conversion factor