diff --git a/CHANGELOG.md b/CHANGELOG.md index c3de2157..97c3dfb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,20 @@ # Changelog -## 0.19.10 +## 0.20.0 + +*June 6th, 2018* + +BREAKING CHANGES + +- [abci] Upgrade to + [v0.11.0](https://github.com/tendermint/abci/blob/master/CHANGELOG.md#0110) + +NOTE: this release does not break any blockchain data structures or +protocols other than the ABCI messages between Tendermint and the application. + +Applications that upgrade for ABCI v0.11.0 should be able to continue running Tendermint +v0.20.0 on blockchains created with v0.19.X -*TBD* ## 0.19.9 diff --git a/Gopkg.lock b/Gopkg.lock index 20ae605a..f21e3842 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -238,8 +238,8 @@ "server", "types" ] - revision = "7cf66f570e2f47b286985e2d688b0a400c028e4c" - version = "v0.11.0-rc6" + revision = "ebee2fe114020aa49c70bbbae50b7079fc7e7b90" + version = "v0.11.0" [[projects]] branch = "master" @@ -313,7 +313,7 @@ branch = "master" name = "golang.org/x/sys" packages = ["unix"] - revision = "c11f84a56e43e20a78cee75a7c034031ecf57d1f" + revision = "9527bec2660bd847c050fda93a0f0c6dee0800bb" [[projects]] name = "golang.org/x/text" @@ -374,6 +374,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "132980da98fc92b6c0dd988df07316a340f5fc91ee77593cf984ade4e3e5fd62" + inputs-digest = "ae6792578b0664708339f4c05e020687d6b799ad6f8282394b919de69e403d1f" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index f95fb296..77a6af9b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -71,7 +71,7 @@ [[constraint]] name = "github.com/tendermint/abci" - version = "~0.11.0-rc6" + version = "~0.11.0" [[constraint]] name = "github.com/tendermint/go-crypto" diff --git a/consensus/replay.go b/consensus/replay.go index b30a1f15..c0c300b3 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -267,17 +267,31 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight // If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain if appBlockHeight == 0 { validators := types.TM2PB.Validators(state.Validators) + csParams := types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams) req := abci.RequestInitChain{ Time: h.genDoc.GenesisTime.Unix(), // TODO ChainId: h.genDoc.ChainID, - ConsensusParams: types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams), + ConsensusParams: csParams, Validators: validators, AppStateBytes: h.genDoc.AppStateJSON, } - _, err := proxyApp.Consensus().InitChainSync(req) + res, err := proxyApp.Consensus().InitChainSync(req) if err != nil { return nil, err } + + // update the state + if len(res.Validators) > 0 { + vals, err := types.PB2TM.Validators(res.Validators) + if err != nil { + return nil, err + } + state.Validators = types.NewValidatorSet(vals) + } + if res.ConsensusParams != nil { + // TODO + } + sm.SaveState(h.stateDB, state) } // First handle edge cases and constraints on the storeBlockHeight diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 2836110c..725568ed 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/abci/example/kvstore" @@ -634,3 +635,53 @@ func (bs *mockBlockStore) LoadBlockCommit(height int64) *types.Commit { func (bs *mockBlockStore) LoadSeenCommit(height int64) *types.Commit { return bs.commits[height-1] } + +//---------------------------------------- + +func TestInitChainUpdateValidators(t *testing.T) { + val, _ := types.RandValidator(true, 10) + vals := types.NewValidatorSet([]*types.Validator{val}) + app := &initChainApp{vals: types.TM2PB.Validators(vals)} + clientCreator := proxy.NewLocalClientCreator(app) + + config := ResetConfig("proxy_test_") + privVal := privval.LoadFilePV(config.PrivValidatorFile()) + stateDB, state, store := stateAndStore(config, privVal.GetPubKey()) + + oldValAddr := state.Validators.Validators[0].Address + + // now start the app using the handshake - it should sync + genDoc, _ := sm.MakeGenesisDocFromFile(config.GenesisFile()) + handshaker := NewHandshaker(stateDB, state, store, genDoc) + proxyApp := proxy.NewAppConns(clientCreator, handshaker) + if err := proxyApp.Start(); err != nil { + t.Fatalf("Error starting proxy app connections: %v", err) + } + defer proxyApp.Stop() + + // reload the state, check the validator set was updated + state = sm.LoadState(stateDB) + + newValAddr := state.Validators.Validators[0].Address + expectValAddr := val.Address + assert.NotEqual(t, oldValAddr, newValAddr) + assert.Equal(t, newValAddr, expectValAddr) +} + +func newInitChainApp(vals []abci.Validator) *initChainApp { + return &initChainApp{ + vals: vals, + } +} + +// returns the vals on InitChain +type initChainApp struct { + abci.BaseApplication + vals []abci.Validator +} + +func (ica *initChainApp) InitChain(req abci.RequestInitChain) abci.ResponseInitChain { + return abci.ResponseInitChain{ + Validators: ica.vals, + } +} diff --git a/types/protobuf.go b/types/protobuf.go index d1b0ae7f..730c6005 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -167,3 +167,19 @@ func (pb2tm) PubKey(pubKey abci.PubKey) (crypto.PubKey, error) { return nil, fmt.Errorf("Unknown pubkey type %v", pubKey.Type) } } + +func (pb2tm) Validators(vals []abci.Validator) ([]*Validator, error) { + tmVals := make([]*Validator, len(vals)) + for i, v := range vals { + pub, err := PB2TM.PubKey(v.PubKey) + if err != nil { + return nil, err + } + tmVals[i] = &Validator{ + Address: v.Address, + PubKey: pub, + VotingPower: v.Power, + } + } + return tmVals, nil +} diff --git a/version/version.go b/version/version.go index 1296657d..2c9c88c0 100644 --- a/version/version.go +++ b/version/version.go @@ -3,14 +3,14 @@ package version // Version components const ( Maj = "0" - Min = "19" - Fix = "10" + Min = "20" + Fix = "0" ) var ( // Version is the current version of Tendermint // Must be a string because scripts like dist.sh read this file. - Version = "0.19.10-dev" + Version = "0.20.0-dev" // GitCommit is the current HEAD set using ldflags. GitCommit string