Skip to content
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): replace bech32 address with evm hex address for Createvalidator function #2122

Merged
merged 8 commits into from
Dec 5, 2023

Conversation

luchenqun
Copy link
Contributor

@luchenqun luchenqun commented Dec 4, 2023

Description

I changed the input parameter string memory validatorAddress in the precompiled contract function createValidator to address validatorAddress. For this input parameter, for example:
it was evmosvaloper1hajh6rhhkjqkwet6wqld3lgx8ur4y3khljfx82 before,
but now it is 0xbf657D0ef7b48167657A703Ed8Fd063F075246D7.
see more details #2076 , Of course, I have also updated the relevant unit tests.

Further Discussion

For the two input parameters delegatorAddress and validatorAddress in the createValidator function. I think we only need to keep the validatorAddress in it, because they are essentially the same address. More detailed information can be found in the cosmos sdk related code:
https://github.com/cosmos/cosmos-sdk/blob/e049998eb5f2582fe0bb5ab102f0de87b1466534/proto/cosmos/staking/v1beta1/tx.proto#L71-L75

https://github.com/evmos/cosmos-sdk/blob/ab1087a4131e5798ef3a21cefb362800498a67de/x/staking/types/msg.go#L99-L101

Therefore, I suggest that the createValidator function in the pre-compiled contract StakingI.sol be change from

    function createValidator(
        ......
        address delegatorAddress,
        string memory validatorAddress,
        ......
    ) external returns (bool success);

to

    function createValidator(
        ......
        address validatorAddress,
        ......
    ) external returns (bool success);

and for the event CreateValidator change from

    event CreateValidator(
        address indexed delegatorAddress,
        address indexed validatorAddress,
        ......
    );

to

    event CreateValidator(
        address indexed validatorAddress,
        ......
    );

@luchenqun luchenqun requested a review from a team as a code owner December 4, 2023 02:17
@luchenqun luchenqun requested review from MalteHerrmann and 0xstepit and removed request for a team December 4, 2023 02:17
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Merging #2122 (9e8d599) into main (f179530) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 87.50%.

❗ Current head 9e8d599 differs from pull request most recent head 68e84bf. Consider uploading reports for the commit 68e84bf to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2122   +/-   ##
=======================================
  Coverage   69.10%   69.10%           
=======================================
  Files         304      304           
  Lines       23737    23742    +5     
=======================================
+ Hits        16403    16408    +5     
  Misses       6433     6433           
  Partials      901      901           
Files Coverage Δ
precompiles/staking/types.go 87.33% <100.00%> (-0.12%) ⬇️
precompiles/staking/tx.go 88.37% <80.00%> (-0.05%) ⬇️
precompiles/staking/events.go 72.36% <81.25%> (+1.26%) ⬆️

Copy link
Contributor

@Vvaradinov Vvaradinov left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for this @luchenqun!

Copy link
Contributor

@MalteHerrmann MalteHerrmann left a comment

Choose a reason for hiding this comment

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

Looks good @luchenqun! Thanks a lot for the contribution. I do agree with adjusting the call signature to remove the delegatorAddress since it makes no sense to pass the same address twice.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
precompiles/staking/StakingI.sol Outdated Show resolved Hide resolved
@luchenqun
Copy link
Contributor Author

Looks good @luchenqun! Thanks a lot for the contribution. I do agree with adjusting the call signature to remove the delegatorAddress since it makes no sense to pass the same address twice.

Okay, I'll implement that feature later.

@luchenqun
Copy link
Contributor Author

@Vvaradinov @MalteHerrmann delegatorAddress has been removed and related tests have been updated. I am very happy that createValidator has finally been implemented relatively completely. Thank you for your review.

@CLAassistant
Copy link

CLAassistant commented Dec 5, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@MalteHerrmann MalteHerrmann left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @luchenqun 🙏

CHANGELOG.md Outdated Show resolved Hide resolved
precompiles/staking/events.go Show resolved Hide resolved
@MalteHerrmann MalteHerrmann enabled auto-merge (squash) December 5, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants