-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
c1f1618
to
6c9bc69
Compare
Codecov Report
@@ 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 |
Ready for review. Do not merge it before #1119 |
Oh - can we get a test for this ? |
x/stake/genesis.go
Outdated
@@ -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) { |
There was a problem hiding this comment.
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?
6c9bc69
to
d3dcd5c
Compare
d3dcd5c
to
7eb96db
Compare
7eb96db
to
a9e86ee
Compare
pass lint apply requests fix test
Sorry for the delay @mossid - this needs a rebase now. |
pass lint apply requests fix test fix abci dep
baseapp/baseapp.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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
x/stake/genesis.go
Outdated
) | ||
|
||
// 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
Found that
I'm changing |
a148093
to
df0079e
Compare
df0079e
to
bed8be3
Compare
bed8be3
to
9f12e67
Compare
pass lint apply requests fix test fix abci dep fix TestValidatorsQuery rm mistake file apply requests fix lint
Ready for review. |
There was a problem hiding this 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{}) |
There was a problem hiding this comment.
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?
x/stake/genesis.go
Outdated
@@ -41,7 +44,13 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) error | |||
} | |||
|
|||
keeper.UpdateBondedValidatorsFull(ctx) | |||
return nil | |||
|
|||
vals := keeper.GetAllValidators(ctx) |
There was a problem hiding this comment.
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
Also needs changelog entry and update to docs if applicable. |
@mossid There was some conflicting work done here and with share mechanism removal I think? Let's attempt to rebase here - Also |
9f12e67
to
323dbce
Compare
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
686df73
to
0469710
Compare
x/stake/keeper/key.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, thanks @mossid!
Closes: #959