-
Notifications
You must be signed in to change notification settings - Fork 834
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
imp(staking): implement the EditValidator function for staking precompiled contract #2051
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2051 +/- ##
===========================================
- Coverage 70.45% 59.66% -10.79%
===========================================
Files 293 341 +48
Lines 22559 21676 -883
===========================================
- Hits 15893 12934 -2959
- Misses 5800 7693 +1893
- Partials 866 1049 +183
|
…or description to not change origin value
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.
Great work on this @luchenqun . Left some comments
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.
Hey @luchenqun lefts some additional comments. Please also address the changes @fedekunze requested on the string coversion
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.
thanks for the contribution @luchenqun!
Signed-off-by: Luke <luchenqun@qq.com>
Description
I have implemented the
editValidator
function in the #2030, and along with you the previously implementeddelegate
,undelegate
,redelegate
and related functions, the staking precompiled contract is only missing the finaleditValidator
. With previous experience, I spent about three hours complete theeditValidator
.Some Design Details
For the function
editValidator
defined in the StakingI.sol file, when the related values in thedescription
parameter are"[do-not-modify]"
string, the system will not changing the original values, the design comes from cosmos sdk, see https://github.com/evmos/cosmos-sdk/blob/v0.47.5-evmos/x/staking/client/cli/flags.go#L87-L91 and https://github.com/evmos/cosmos-sdk/blob/v0.47.5-evmos/x/staking/types/validator.go#L213-L241 . Since ths Solidity language does not have like thenil
value in the Go language. Therefore, when thecommissionRate
andminSelfDelegation
values are -1, the system keeps the original values unchanged.Why
commissionRate
andminSelfDelegation
not use the uint256 type and default to 0 without modifying the original value? Because the minimum value of commissionRate can be 0. If you think using -1 without modifying the original value is a reasonable design, I suggest that all subsequent related designs follow this principle.Testing
Step 1
Set up at least one validator node and check the original information of the validator.
Step 2
Connect to the validator node by Remix and call the
editValidator
method of the Staking precompiled contract with the following parameters:description
: [ "[do-not-modify]", "[do-not-modify]", "[do-not-modify]", "[do-not-modify]", "i want update my details" ]validatorAddress
: 0xbf657D0ef7b48167657A703Ed8Fd063F075246D7commissionRate
: -1minSelfDelegation
: 1000000Note: If you want to test modifying the
commissionRate
, you need to remove the restriction that it can only be changed once a day in cosmos sdk. For details see the code: https://github.com/evmos/cosmos-sdk/blob/v0.47.5-evmos/x/staking/types/commission.go#L86-L88Step 3
Verify if the modifications have taken effect
details
value in thedescription
has changed, while the others remain unchanged.commissionRate
value remains unchanged.minSelfDelegation
value has changed from 1 to 1000000.Query EVM transactions.
Query Cosmos transactions.