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

validate candidate name #3705

Merged
merged 8 commits into from Dec 27, 2022
Merged

validate candidate name #3705

merged 8 commits into from Dec 27, 2022

Conversation

millken
Copy link
Contributor

@millken millken commented Dec 5, 2022

Description

validate candidate name

Fixes #3646

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@millken millken requested a review from a team as a code owner December 5, 2022 06:49
@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

Merging #3705 (eba4650) into master (263ff82) will decrease coverage by 0.35%.
The diff coverage is 80.12%.

@@            Coverage Diff             @@
##           master    #3705      +/-   ##
==========================================
- Coverage   74.47%   74.12%   -0.36%     
==========================================
  Files         269      291      +22     
  Lines       23925    24811     +886     
==========================================
+ Hits        17818    18390     +572     
- Misses       5174     5484     +310     
- Partials      933      937       +4     
Impacted Files Coverage Δ
action/actctx.go 90.62% <ø> (+6.25%) ⬆️
action/action.go 82.35% <ø> (ø)
action/action_deserializer.go 57.14% <ø> (ø)
action/candidate_update.go 88.88% <0.00%> (-4.14%) ⬇️
action/consignment_transfer.go 90.41% <ø> (ø)
action/const.go 100.00% <ø> (ø)
action/execution.go 83.78% <ø> (ø)
action/grantreward.go 68.57% <ø> (ø)
action/protocol/account/protocol.go 86.90% <ø> (ø)
action/protocol/account/transfer.go 84.61% <ø> (ø)
... and 267 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

if err := validator.ValidateCandidateNameForStake2(cr.Name()); err != nil {
return errors.Wrap(ErrInvalidCandidateName, err.Error())
if err := isValidCandidateName(cr.Name()); err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

  1. staking protocol can use this, delete isValidCandidateName inside \staking
  2. ioctl can use this

Copy link
Member

Choose a reason for hiding this comment

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

also add this to other staking action's SanityCheck()

@@ -111,6 +111,10 @@ func NewCandidateUpdate(
return nil, err
}
}

Copy link
Member

Choose a reason for hiding this comment

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

  1. remove empty line
  2. can you check if this would cause a potential different result in workingset.pickAndRunActions()? If yes, we need to gate the code by HF

Copy link
Member

Choose a reason for hiding this comment

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

also add the check to other staking actions as we discussed

Copy link
Contributor Author

@millken millken Dec 9, 2022

Choose a reason for hiding this comment

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

  1. remove empty line
  2. can you check if this would cause a potential different result in workingset.pickAndRunActions()? If yes, we need to gate the code by HF

No difference, invalidCandName actions both will be discarded

github.com/iotexproject/iotex-core/action.IsValidCandidateName (iotex-core/action/candidate_register.go:391)
github.com/iotexproject/iotex-core/action/protocol/staking.(*Protocol).validateCandidateRegister (iotex-core/action/protocol/staking/validations.go:65)
github.com/iotexproject/iotex-core/action/protocol/staking.(*Protocol).Validate (iotex-core/action/protocol/staking/protocol.go:459)
github.com/iotexproject/iotex-core/state/factory.(*workingSet).pickAndRunActions (iotex-core/state/factory/workingset.go:447)
github.com/iotexproject/iotex-core/state/factory.(*workingSet).CreateBuilder (iotex-core/state/factory/workingset.go:553)
github.com/iotexproject/iotex-core/state/factory.(*stateDB).NewBlockBuilder (iotex-core/state/factory/statedb.go:258)
github.com/iotexproject/iotex-core/state/factory.(*minter).NewBlockBuilder (iotex-core/state/factory/minter.go:30)
github.com/iotexproject/iotex-core/blockchain.(*blockchain).MintNewBlock (iotex-core/blockchain/blockchain.go:385)

@millken millken changed the title validate candidate name in CandidateRegister action validate candidate name Dec 9, 2022
@sonarcloud
Copy link

sonarcloud bot commented Dec 26, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.9% 3.9% Duplication

@dustinxie dustinxie merged commit 4d2ee17 into iotexproject:master Dec 27, 2022
envestcc added a commit that referenced this pull request Jan 12, 2023
* move IsValidCandidateName to action package (#3706)

* move IsValidCandidateName to action package

* move IsValidCandidateName to action package

* delete validations.go

* update tests

* delete ErrInvalidAmount in staking

* Remove stale comment "This is an alpha release and is not ...." in all files (#3713)

* remove stale comment

* remove stale comment

* remove nonce field (#3714)

Co-authored-by: dustinxie <dahuaxie@gmail.com>

* [evm] proper handle refundSnapshot and upgrade go-ethereum release (#3715)

* [ioctl] modify did command parameters (#3668)

* modify action.Read default parameters

* use constant

* use config.GasStation instead of config.API #3718 (#3721)

Co-authored-by: dustinxie <dahuaxie@gmail.com>

* [genesis] set Okhotsk to activate at 01-11-2023 12am UTC (#3720)

* [tests] add more cases for gas refund (#3707)

* add more cases for gas refund

* remove debug flag

Co-authored-by: dustinxie <dahuaxie@gmail.com>

* [api] web3 rewarding action (#3691)

* add rewarding execute action

* add rewarding execute test

* add commmet for public type

* add builder test

* complete web3 rewarding read

* complete web3 rewarding read test

* remove read api and receive create rewarding action enterance

* add test to rlp tx test

* change name

* revert fix amount bug for deposit cost bug

* change check error style

* add entrance for web3 rewarding

Co-authored-by: dustinxie <dahuaxie@gmail.com>

* update mockgen (#3733)

* [ioctl] use candidate.OperatorAddress to show probated delegates (#3727)

Co-authored-by: dustinxie <dahuaxie@gmail.com>

* [config] move config.Consensus to consensus package (#3735)

* [action] validate candidate name  (#3705)

* Update release.yaml

* [config] move config.Blocksync to blocksync package (#3736)

* move config.BlockSync to blocksync package

* remove def of BlockSync in config

* rename newBlockSyncer to newBlockSyncerForTest

* [ioctl] Build contract deploy command line into new ioctl (#3708)

* [ioctl] build contract deploy command line into new ioctl

* build unittest to cover the modification1~

* group iotex-core packages

* remove stale comments

Co-authored-by: huofei <68298506@qq.com>

* [ioctl] Build contract invoke command line into new ioctl (#3709)

* [ioctl] build contract invoke command line into new ioctl

* build unittest to cover the modification1~

* remove stale comments

Co-authored-by: huofei <68298506@qq.com>

* [github] Update codeowner (#3742)

* [ioctl] Build contract compile command line into new ioctl (#3676)

* [ioctl] build contract compile command line into new ioctl

Co-authored-by: huof6890 <68298506@qq.com>

* [config] move config.API to api package (#3739)

* move config.GasStation to gasstation package

* move config.API to api package

* make fields of testConfig  to be private

Co-authored-by: CoderZhi <thecoderzhi@gmail.com>

* complete web3 intergrity test (#3743)

* complete tests

* complete requires

* format

* init monitor message framework

* [ioctl/newcmd] fix node delegate run failed  (#3729)

* fix grpc error and show right datas

* check chainMeta.Epoch

* modify as currEpochNum

* init broadcast framework

* update broadcast framework

* update broadcast framework

* [ioctl] Build contract test bytecode command line into new ioctl (#3738)

* [ioctl] build contract test bytecode command line into new ioctl

* build unittest to cover the modification

* format

Co-authored-by: huofei <68298506@qq.com>

* [ioctl] Build contract prepare command line into new ioctl (#3737)

* [ioctl] build contract prepare command line into new ioctl

* build unittest to cover the modification

* fix commit

* update assert message

* update solc version

* update solc message version

* format

* brew install solidity

Co-authored-by: huofei <68298506@qq.com>

* add node package to handle node info manager

* update

* Update release.yaml

* Revert "adding .dockerignore file to fix git submodule builds (#3689)" (#3750)

This reverts commit c14dcca.

Co-authored-by: Jeremi [IoTeX] Rynkiewicz JRPC <63042547+jrynkiew@users.noreply.github.com>

* update docker build command (#3751)

* [actpool] Improve actqueue efficiency (#3377)

* opt actpool.Add()

* improve actqueue efficiency

* add node info request and response message

* remove delegate manager dependency

* add message sign

* add sign for node info message

* fix unittest error

* Update CODEOWNERS (#3754)

* [rewarding] add active web3 rewarding settings (#3740)

* add active web3 rewarding settings

* check active when encoding is web3

* check active with deposit action

* remove check logic to workingset

* add check in API module

* fix check validte web3 rewarding bug

Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>

* add unittest for node

* add pubkey in nodeinfo message

* fix compile error

* update go.mod

Co-authored-by: millken <millken@gmail.com>
Co-authored-by: huofei <68298506@qq.com>
Co-authored-by: dustinxie <dahuaxie@gmail.com>
Co-authored-by: Xueping Yang <xueping.yang@gmail.com>
Co-authored-by: xianhuawei <258022429@qq.com>
Co-authored-by: Jeremy Chou <lucky90322@gmail.com>
Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Jeremi [IoTeX] Rynkiewicz JRPC <63042547+jrynkiew@users.noreply.github.com>
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.

Register candidate with invalid name doesn't response error
3 participants