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

R4R: Additional gentx verfication #2971

Merged
merged 19 commits into from
Dec 4, 2018
Merged

R4R: Additional gentx verfication #2971

merged 19 commits into from
Dec 4, 2018

Conversation

jackzampolin
Copy link
Member

@jackzampolin jackzampolin commented Nov 30, 2018

Per @zmanian

This PR checks that when running gaiad gentx that the --from account:

  1. Exists in genesis
  2. Contains enough funds of type stakeTypes.DefaultBondDenom to stake them

Should it additionally check that the denomination of the funds is the correct type?
Are there any additional checks we should add here?

cc @alexanderbez @cwgoes @alessio

  • Wrote tests
  • Updated relevant documentation (docs/)
  • Added entries in PENDING.md with issue #
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@jackzampolin
Copy link
Member Author

CLI Tests failing are the result of this change. Still more work there and we should likely add tests for this functionality as well.

@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #2971 into develop will decrease coverage by 0.19%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           develop    #2971     +/-   ##
==========================================
- Coverage    55.72%   55.53%   -0.2%     
==========================================
  Files          120      120             
  Lines         8468     8494     +26     
==========================================
- Hits          4719     4717      -2     
- Misses        3427     3455     +28     
  Partials       322      322

@jackzampolin jackzampolin changed the title WIP: Additional gentx verfication R4R: Additional gentx verfication Dec 3, 2018
@jackzampolin
Copy link
Member Author

Ok so I have these tests passing locally with no problem, but the new functionality I added here (validation that the account you are gentxing exists in the genesis accounts array) is failing here. I've added some additional debugging to print the genesis before the failure and it shows that the account is in fact in the genesis file.

@cwgoes cwgoes mentioned this pull request Dec 3, 2018
4 tasks
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
@cwgoes
Copy link
Contributor

cwgoes commented Dec 3, 2018

The CLI tests also fail for me locally @jackzampolin, with the same error as on CI. I wonder if you have a different genesis.json which is not being automatically initialized correctly in the tests?

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Left some minor feedback. Most importantly I think @cwgoes comments should be addressed and then it could be ready for merge.

cmd/gaia/cli_test/cli_test.go Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

A few more tidbits ☕️

cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
cmd/gaia/init/gentx.go Outdated Show resolved Hide resolved
tests/util.go Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

CI passes and changes look reasonable. Thanks @jackzampolin. This should warrant another review or two though.

bondDenom := genesisState.StakeData.Params.BondDenom

// Check if the account is in genesis
for _, acc := range genesisState.Accounts {
Copy link
Contributor

Choose a reason for hiding this comment

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

The contents of this for loop should probably be broken out into a seperate function, or this whole containing function restructured to reduce indentation

return err
}

inGenesis := false
Copy link
Contributor

Choose a reason for hiding this comment

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

use of inGenesis is confusing - I don't intuitively know what this parameter is doing

}

if !inGenesis {
return fmt.Errorf(
Copy link
Contributor

Choose a reason for hiding this comment

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

We can eliminate use of inGenesis by just moving this error into the above loop (which should also probably get moved to it's own funcion per my previous comment)

@jackzampolin
Copy link
Member Author

Ok I've addressed all the PR comments and this should be good to go!

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

All previous comments were addressed, nothing to add from me. Furthermore, integration tests execution went down to 1m30s!!

@cwgoes cwgoes merged commit d8fbae6 into develop Dec 4, 2018
@cwgoes cwgoes deleted the jack/check-gentx branch December 4, 2018 09:57
mircea-c pushed a commit that referenced this pull request Dec 5, 2018
* Add check that account is in genesis and contains enough funds to gentx command

* Fix CLI tests and make them parallel

* Update makefile to take advantage of parallel tests

* Add path seperator back in

* Don
't check error on key delete

* Add debuggin printout for debugging remote test failures

* Update cmd/gaia/init/gentx.go

Co-Authored-By: jackzampolin <jack.zampolin@gmail.com>

* Update cmd/gaia/init/gentx.go

Co-Authored-By: jackzampolin <jack.zampolin@gmail.com>

* Change to bondDenom from the stake section in genesis

* Add PENDING.md

* Push changes

* Fix CI failure

* Address PR comments

* Fix broken gov tests

* Address PR comments

* Address PR comments
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.

5 participants