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

Added checkvalue function and testcase for AddVote api #1109

Merged
merged 4 commits into from
Jan 19, 2022

Conversation

mckim19
Copy link
Contributor

@mckim19 mckim19 commented Jan 11, 2022

Proposed changes

This PR implemented function to check the value of AddVote api and added test cases for AddVote function.

In the previous governance voting, voting was possible with a value that should not be applied.
Currently, if an api call is made for an invalid value as shown below, the call is blocked.

AS-IS
Screen Shot 2022-01-11 at 6 30 04 PM
Screen Shot 2022-01-12 at 2 17 12 PM

TO-BE
Screen Shot 2022-01-11 at 6 29 43 PM
Screen Shot 2022-01-12 at 2 17 24 PM

Closes #1107

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Comment on lines 173 to 182
if key == "istanbul.committeesize" && val == uint64(0) {
return false
}
if key == "reward.minimumstake" {
if v, ok := new(big.Int).SetString(val.(string), 10); ok {
if v.Cmp(common.Big0) <= 0 {
return false
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you check only for these 2 governance items?
Are other items good to go with no value-check in this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other items can be discussed and added if there are problems.

hqjang-pepper
hqjang-pepper previously approved these changes Jan 12, 2022
yoomee1313
yoomee1313 previously approved these changes Jan 13, 2022
governance/handler.go Outdated Show resolved Hide resolved
@mckim19 mckim19 dismissed stale reviews from yoomee1313 and hqjang-pepper via 947a75f January 13, 2022 13:57
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2022

Codecov Report

Merging #1109 (ee71e56) into dev (1775d07) will increase coverage by 0.04%.
The diff coverage is 50.00%.

❗ Current head ee71e56 differs from pull request most recent head 947a75f. Consider uploading reports for the commit 947a75f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1109      +/-   ##
==========================================
+ Coverage   61.30%   61.34%   +0.04%     
==========================================
  Files         478      478              
  Lines       62618    62620       +2     
==========================================
+ Hits        38386    38413      +27     
+ Misses      21512    21489      -23     
+ Partials     2720     2718       -2     
Impacted Files Coverage Δ
node/cn/api_backend.go 74.49% <0.00%> (-1.02%) ⬇️
params/protocol_params.go 87.09% <ø> (ø)
blockchain/evm.go 93.33% <100.00%> (ø)
blockchain/vm/runtime/runtime.go 72.72% <100.00%> (ø)
storage/statedb/node.go 79.09% <0.00%> (-1.82%) ⬇️
datasync/downloader/statesync.go 67.24% <0.00%> (-1.75%) ⬇️
networks/p2p/discover/discover_storage_simple.go 54.91% <0.00%> (-1.74%) ⬇️
networks/p2p/discover/table.go 77.58% <0.00%> (-1.73%) ⬇️
node/sc/subbridge.go 64.22% <0.00%> (-1.13%) ⬇️
networks/p2p/discover/discover_storage_kademlia.go 82.81% <0.00%> (-0.89%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1775d07...947a75f. Read the comment docs.

@mckim19 mckim19 merged commit 8ff01dd into klaytn:dev Jan 19, 2022
@jiseongnoh jiseongnoh added this to In progress in Consensus via automation Jan 20, 2022
@jiseongnoh jiseongnoh moved this from In progress to Done in Consensus Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

addVote api improvement - vote value validation logic improvement
5 participants