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

Initialization of POS chain #1373

Merged
merged 4 commits into from
Jul 19, 2018
Merged

Initialization of POS chain #1373

merged 4 commits into from
Jul 19, 2018

Conversation

mossid
Copy link
Contributor

@mossid mossid commented Jun 25, 2018

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md
  • Updated Gaia/Examples
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Closes: #959

@mossid mossid requested a review from ebuchman as a code owner June 25, 2018 23:54
mossid added a commit that referenced this pull request Jun 25, 2018
@codecov
Copy link

codecov bot commented Jun 26, 2018

Codecov Report

Merging #1373 into develop will decrease coverage by 0.04%.
The diff coverage is 70.58%.

@@             Coverage Diff             @@
##           develop    #1373      +/-   ##
===========================================
- Coverage     64.2%   64.16%   -0.05%     
===========================================
  Files          115      115              
  Lines         6834     6837       +3     
===========================================
- Hits          4388     4387       -1     
- Misses        2192     2196       +4     
  Partials       254      254

@mossid
Copy link
Contributor Author

mossid commented Jun 26, 2018

Ready for review. Do not merge it before #1119

ebuchman
ebuchman previously approved these changes Jun 26, 2018
@ebuchman
Copy link
Member

Oh - can we get a test for this ?

@@ -32,7 +33,7 @@ func DefaultGenesisState() GenesisState {
}

// InitGenesis - store genesis parameters
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) (vals []abci.Validator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to use a named return var when we're not using that actual named variable?

mossid added a commit that referenced this pull request Jun 27, 2018
pass lint

apply requests

fix test
@cwgoes cwgoes mentioned this pull request Jun 30, 2018
@cwgoes cwgoes changed the base branch from develop to unstable July 3, 2018 21:12
@cwgoes
Copy link
Contributor

cwgoes commented Jul 4, 2018

Sorry for the delay @mossid - this needs a rebase now.

@cwgoes cwgoes changed the base branch from unstable to develop July 4, 2018 19:26
mossid added a commit that referenced this pull request Jul 4, 2018
pass lint

apply requests

fix test

fix abci dep
@@ -296,7 +296,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
if app.initChainer == nil {
return
}
app.initChainer(app.deliverState.ctx, req) // no error
res = app.initChainer(app.deliverState.ctx, req) // no error
Copy link
Contributor

Choose a reason for hiding this comment

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

delete the comment // no error? why do we even have that here

)

// InitGenesis sets the pool and parameters for the provided keeper and
// initializes the IntraTxCounter. For each validator in data, it sets that
// validator in the keeper along with manually setting the indexes. In
// addition, it also sets any delegations found in data. Finally, it updates
// the bonded validators.
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) {
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res []abci.Validator) {
Copy link
Contributor

Choose a reason for hiding this comment

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

function comment should be updated to reflect these changes.

If I understand this correctly we want to pass back the abci validators so that we do not need to have the validators twice in the genesis file? Tendermint will just read the validators from response init chain?

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

Cool - I guess tendermint is already ready to take in the validator set directly from response of init chain?

If so, as a part of this PR, we should update the Genesis file creation to nolonger write the abci validators to the config file here:https://github.com/cosmos/cosmos-sdk/blob/develop/server/init.go#L132

@ebuchman ebuchman changed the base branch from develop to master July 11, 2018 00:28
@mossid
Copy link
Contributor Author

mossid commented Jul 13, 2018

Found that TestValidatorsQuery was failing, the reason was:

  1. It calls InitializeTestLCD with nValidators=2
  2. The function allocates 10 power to the first validator(who runs the node) and 1 power to the rest so it supposed to be run normally without the rest of the validators.
  3. But new InitChain now returns a new validator set, which is called by GaiaAppGenState, which allocates equal power to the all validators(https://github.com/cosmos/cosmos-sdk/blob/master/cmd/gaia/app/genesis.go#L175)
  4. So only 50% of voting power available, node not starts, test fails.

I'm changing TestValidatorsQuery to use only one validator, but I think we should change the equal validator power allocating part, at least for the test codes.

mossid added a commit that referenced this pull request Jul 13, 2018
pass lint

apply requests

fix test

fix abci dep

fix TestValidatorsQuery

rm mistake file

apply requests

fix lint
@mossid
Copy link
Contributor Author

mossid commented Jul 13, 2018

Ready for review.

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Is Tendermint ready for this? Mostly LGTM; req'd two changes.

@@ -359,25 +359,20 @@ func TestTxs(t *testing.T) {
}

func TestValidatorsQuery(t *testing.T) {
cleanup, pks, port := InitializeTestLCD(t, 2, []sdk.AccAddress{})
cleanup, pks, port := InitializeTestLCD(t, 1, []sdk.AccAddress{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we initialize with 2 validators?

@@ -41,7 +44,13 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) error
}

keeper.UpdateBondedValidatorsFull(ctx)
return nil

vals := keeper.GetAllValidators(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

We want all the bonded validators, not all validators - I think you want GetValidatorsBonded - there may be more than 100 genesis validator candidates

@cwgoes
Copy link
Contributor

cwgoes commented Jul 13, 2018

Also needs changelog entry and update to docs if applicable.

@rigelrozanski
Copy link
Contributor

@mossid There was some conflicting work done here and with share mechanism removal I think? Let's attempt to rebase here - Also TestValidatorsQuery bug could maybe be separated into a mini PR for fast merge to split up the fixes within this PR. Otherwise I'd like to try to merge this in soon, as soon as rebased - lookin' good

@rigelrozanski
Copy link
Contributor

Can we add a test to this PR which ensures that if there > MaxValidators in the genesis file only the top 100 make it into Tendermint as outlined by #1710

pass lint

apply requests

fix test

fix abci dep

fix TestValidatorsQuery

rm mistake file

apply requests

fix lint

in progress

apply requests
@@ -85,12 +84,18 @@ func getValidatorPowerRank(validator types.Validator, pool types.Pool) []byte {
counterBytes := make([]byte, 2)
binary.BigEndian.PutUint16(counterBytes, ^uint16(validator.BondIntraTxCounter)) // invert counter (first txns have priority)

return append(append(append(append(
lenBytes := make([]byte, binary.MaxVarintLen64)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead merge #1724 to fix this.

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

utACK, thanks @mossid!

@cwgoes cwgoes dismissed rigelrozanski’s stale review July 19, 2018 06:29

Test has been added.

@cwgoes cwgoes merged commit aa52541 into develop Jul 19, 2018
@cwgoes cwgoes deleted the joon/959-pos-init branch July 19, 2018 06:39
@ebuchman
Copy link
Member

Note tendermint/tendermint#2015

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