ValidatorSetUpdates -> ValidatorUpdates

This commit is contained in:
Jae Kwon
2017-12-20 00:02:41 -08:00
parent 9a5b943e77
commit c14d3982ac
7 changed files with 663 additions and 669 deletions

View File

@@ -3,7 +3,7 @@
## 0.9.0 (TBD) ## 0.9.0 (TBD)
BREAKING CHANGES: BREAKING CHANGES:
- [types] ResponseEndBlock: renamed Diffs field to ValidatorSetUpdates - [types] ResponseEndBlock: renamed Diffs field to ValidatorUpdates
FEATURES: FEATURES:
- [types] ResponseEndBlock: added ConsensusParamUpdates - [types] ResponseEndBlock: added ConsensusParamUpdates

View File

@@ -2,13 +2,12 @@ GOTOOLS = \
github.com/mitchellh/gox \ github.com/mitchellh/gox \
github.com/Masterminds/glide \ github.com/Masterminds/glide \
github.com/alecthomas/gometalinter \ github.com/alecthomas/gometalinter \
github.com/ckaznocha/protoc-gen-lint \
github.com/gogo/protobuf/protoc-gen-gogo \ github.com/gogo/protobuf/protoc-gen-gogo \
github.com/gogo/protobuf/gogoproto github.com/gogo/protobuf/gogoproto
INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
all: install test all: protoc install test metalinter
PACKAGES=$(shell go list ./... | grep -v '/vendor/') PACKAGES=$(shell go list ./... | grep -v '/vendor/')
@@ -27,7 +26,7 @@ protoc:
## On "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory" ## On "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
## ldconfig (may require sudo) ## ldconfig (may require sudo)
## https://stackoverflow.com/a/25518702 ## https://stackoverflow.com/a/25518702
protoc $(INCLUDE) --gogo_out=plugins=grpc:. --lint_out=. types/*.proto protoc $(INCLUDE) --gogo_out=plugins=grpc:. types/*.proto
install: install:
@ go install ./cmd/... @ go install ./cmd/...
@@ -41,15 +40,13 @@ dist:
test: test:
@ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \; @ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
@ echo "==> Running linter"
@ make metalinter_test
@ echo "==> Running go test" @ echo "==> Running go test"
@ go test $(PACKAGES) @ go test $(PACKAGES)
test_race: test_race:
@ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \; @ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
@ echo "==> Running go test --race" @ echo "==> Running go test --race"
@go test -v -race $(PACKAGES) @ go test -v -race $(PACKAGES)
test_integrations: test_integrations:
@ bash test.sh @ bash test.sh
@@ -62,19 +59,18 @@ get_deps:
ensure_tools: ensure_tools:
go get -u -v $(GOTOOLS) go get -u -v $(GOTOOLS)
@gometalinter --install @ gometalinter --install
get_vendor_deps: ensure_tools get_vendor_deps: ensure_tools
@rm -rf vendor/ @rm -rf vendor/
@echo "--> Running glide install" @echo "--> Running glide install"
@ glide install @ glide install
metalinter: metalinter_all:
protoc $(INCLUDE) --lint_out=. types/*.proto
gometalinter --vendor --deadline=600s --enable-all --disable=lll ./... gometalinter --vendor --deadline=600s --enable-all --disable=lll ./...
metalinter_test: metalinter:
protoc $(INCLUDE) --lint_out=. types/*.proto @ echo "==> Running linter"
gometalinter --vendor --deadline=600s --disable-all \ gometalinter --vendor --deadline=600s --disable-all \
--enable=maligned \ --enable=maligned \
--enable=deadcode \ --enable=deadcode \

View File

@@ -185,7 +185,7 @@ Here, we describe the requests and responses as function arguments and return va
* __Arguments__: * __Arguments__:
* `Height (int64)`: The block height that ended * `Height (int64)`: The block height that ended
* __Returns__: * __Returns__:
* `ValidatorSetUpdates ([]Validator)`: Changes to validator set (set voting power to 0 to remove) * `ValidatorUpdates ([]Validator)`: Changes to validator set (set voting power to 0 to remove)
* `ConsensusParamUpdates (ConsensusParams)`: Changes to consensus-critical time/size parameters * `ConsensusParamUpdates (ConsensusParams)`: Changes to consensus-critical time/size parameters
* __Usage__:<br/> * __Usage__:<br/>
Signals the end of a block. Called prior to each Commit after all transactions. Validator set is updated with the result. Signals the end of a block. Called prior to each Commit after all transactions. Validator set is updated with the result.

View File

@@ -107,7 +107,7 @@ func TestPersistentDummyInfo(t *testing.T) {
} }
// add a validator, remove a validator, update a validator // add a validator, remove a validator, update a validator
func TestValSetUpdates(t *testing.T) { func TestValUpdates(t *testing.T) {
dir, err := ioutil.TempDir("/tmp", "abci-dummy-test") // TODO dir, err := ioutil.TempDir("/tmp", "abci-dummy-test") // TODO
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -188,7 +188,7 @@ func makeApplyBlock(t *testing.T, dummy types.Application, heightInt int, diff [
resEndBlock := dummy.EndBlock(types.RequestEndBlock{header.Height}) resEndBlock := dummy.EndBlock(types.RequestEndBlock{header.Height})
dummy.Commit() dummy.Commit()
valsEqual(t, diff, resEndBlock.ValidatorSetUpdates) valsEqual(t, diff, resEndBlock.ValidatorUpdates)
} }

View File

@@ -28,7 +28,7 @@ type PersistentDummyApplication struct {
app *DummyApplication app *DummyApplication
// validator set // validator set
valSetUpdates []*types.Validator ValUpdates []*types.Validator
logger log.Logger logger log.Logger
} }
@@ -71,7 +71,7 @@ func (app *PersistentDummyApplication) DeliverTx(tx []byte) types.ResponseDelive
// format is "val:pubkey/power" // format is "val:pubkey/power"
if isValidatorTx(tx) { if isValidatorTx(tx) {
// update validators in the merkle tree // update validators in the merkle tree
// and in app.valSetUpdates // and in app.ValUpdates
return app.execValidatorTx(tx) return app.execValidatorTx(tx)
} }
@@ -119,13 +119,13 @@ func (app *PersistentDummyApplication) InitChain(req types.RequestInitChain) typ
// Track the block hash and header information // Track the block hash and header information
func (app *PersistentDummyApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock { func (app *PersistentDummyApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock {
// reset valset changes // reset valset changes
app.valSetUpdates = make([]*types.Validator, 0) app.ValUpdates = make([]*types.Validator, 0)
return types.ResponseBeginBlock{} return types.ResponseBeginBlock{}
} }
// Update the validator set // Update the validator set
func (app *PersistentDummyApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock { func (app *PersistentDummyApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock {
return types.ResponseEndBlock{ValidatorSetUpdates: app.valSetUpdates} return types.ResponseEndBlock{ValidatorUpdates: app.ValUpdates}
} }
//--------------------------------------------- //---------------------------------------------
@@ -216,7 +216,7 @@ func (app *PersistentDummyApplication) updateValidator(v *types.Validator) types
} }
// we only update the changes array if we successfully updated the tree // we only update the changes array if we successfully updated the tree
app.valSetUpdates = append(app.valSetUpdates, v) app.ValUpdates = append(app.ValUpdates, v)
return types.ResponseDeliverTx{Code: code.CodeTypeOK} return types.ResponseDeliverTx{Code: code.CodeTypeOK}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -10,18 +10,18 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto";
// Request types // Request types
message Request { message Request {
oneof value{ oneof value {
RequestEcho echo = 1; RequestEcho echo = 2;
RequestFlush flush = 2; RequestFlush flush = 3;
RequestInfo info = 3; RequestInfo info = 4;
RequestSetOption set_option = 4; RequestSetOption set_option = 5;
RequestDeliverTx deliver_tx = 5; RequestInitChain init_chain = 6;
RequestCheckTx check_tx = 6; RequestQuery query = 7;
RequestCommit commit = 7; RequestBeginBlock begin_block = 8;
RequestQuery query = 8; RequestCheckTx check_tx = 9;
RequestInitChain init_chain = 9; RequestDeliverTx deliver_tx = 19;
RequestBeginBlock begin_block = 10;
RequestEndBlock end_block = 11; RequestEndBlock end_block = 11;
RequestCommit commit = 12;
} }
} }
@@ -36,17 +36,13 @@ message RequestInfo {
string version = 1; string version = 1;
} }
message RequestSetOption{ message RequestSetOption {
string key = 1; string key = 1;
string value = 2; string value = 2;
} }
message RequestDeliverTx{ message RequestInitChain {
bytes tx = 1; repeated Validator validators = 1;
}
message RequestCheckTx{
bytes tx = 1;
} }
message RequestQuery{ message RequestQuery{
@@ -56,46 +52,49 @@ message RequestQuery{
bool prove = 4; bool prove = 4;
} }
message RequestCommit{ message RequestBeginBlock {
}
message RequestInitChain{
repeated Validator validators = 1;
}
message RequestBeginBlock{
bytes hash = 1; bytes hash = 1;
Header header = 2; Header header = 2;
repeated int32 absent_validators = 3; repeated int32 absent_validators = 3;
repeated Evidence byzantine_validators = 4; repeated Evidence byzantine_validators = 4;
} }
message RequestCheckTx {
bytes tx = 1;
}
message RequestDeliverTx {
bytes tx = 1;
}
message RequestEndBlock{ message RequestEndBlock{
int64 height = 1; int64 height = 1;
} }
message RequestCommit {
}
//---------------------------------------- //----------------------------------------
// Response types // Response types
message Response { message Response {
oneof value{ oneof value {
ResponseException exception = 1; ResponseException exception = 1;
ResponseEcho echo = 2; ResponseEcho echo = 2;
ResponseFlush flush = 3; ResponseFlush flush = 3;
ResponseInfo info = 4; ResponseInfo info = 4;
ResponseSetOption set_option = 5; ResponseSetOption set_option = 5;
ResponseDeliverTx deliver_tx = 6; ResponseInitChain init_chain = 6;
ResponseCheckTx check_tx = 7; ResponseQuery query = 7;
ResponseCommit commit = 8; ResponseBeginBlock begin_block = 8;
ResponseQuery query = 9; ResponseCheckTx check_tx = 9;
ResponseInitChain init_chain = 10; ResponseDeliverTx deliver_tx = 10;
ResponseBeginBlock begin_block = 11; ResponseEndBlock end_block = 11;
ResponseEndBlock end_block = 12; ResponseCommit commit = 12;
} }
} }
message ResponseException{ message ResponseException {
string error = 1; string error = 1;
} }
@@ -103,7 +102,7 @@ message ResponseEcho {
string message = 1; string message = 1;
} }
message ResponseFlush{ message ResponseFlush {
} }
message ResponseInfo { message ResponseInfo {
@@ -113,81 +112,82 @@ message ResponseInfo {
bytes last_block_app_hash = 4; bytes last_block_app_hash = 4;
} }
message ResponseSetOption{ message ResponseSetOption {
uint32 code = 1; uint32 code = 1;
string log = 2; string log = 2;
} }
message ResponseDeliverTx{ message ResponseInitChain {
uint32 code = 1; }
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3; message ResponseQuery {
uint32 code = 1;
int64 index = 2;
bytes key = 3 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
bytes value = 4 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
bytes proof = 5 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
int64 height = 6;
string log = 7;
}
message ResponseBeginBlock {
}
message ResponseCheckTx {
uint32 code = 1;
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3;
int64 gas = 4;
int64 fee = 5;
}
message ResponseDeliverTx {
uint32 code = 1;
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3;
repeated KVPair tags = 4; repeated KVPair tags = 4;
} }
message ResponseCheckTx{ message ResponseEndBlock {
uint32 code = 1; repeated Validator validator_updates = 1;
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3;
int64 gas = 4;
int64 fee = 5;
}
message ResponseQuery{
uint32 code = 1;
int64 index = 2;
bytes key = 3 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
bytes value = 4 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
bytes proof = 5 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
int64 height = 6;
string log = 7;
}
message ResponseCommit{
uint32 code = 1;
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3;
}
message ResponseInitChain{
}
message ResponseBeginBlock{
}
message ResponseEndBlock{
repeated Validator validator_set_updates = 1;
ConsensusParams consensus_param_updates = 2; ConsensusParams consensus_param_updates = 2;
} }
message ResponseCommit {
uint32 code = 1;
bytes data = 2 [(gogoproto.customtype) = "github.com/tendermint/go-wire/data.Bytes", (gogoproto.nullable) = false];
string log = 3;
}
//----------------------------------------
// Misc.
// ConsensusParams contains all consensus-relevant parameters // ConsensusParams contains all consensus-relevant parameters
// that can be adjusted by the abci app // that can be adjusted by the abci app
message ConsensusParams{ message ConsensusParams {
BlockSize block_size = 1; BlockSize block_size = 1;
TxSize tx_size = 2; TxSize tx_size = 2;
BlockGossip block_gossip = 3; BlockGossip block_gossip = 3;
} }
// BlockSize contain limits on the block size. // BlockSize contain limits on the block size.
message BlockSize{ message BlockSize {
// NOTE: must not be 0 nor greater than 100MB int32 max_bytes = 1;
int32 max_bytes = 1; int32 max_txs = 2;
int32 max_txs = 2; int64 max_gas = 3;
int64 max_gas = 3;
} }
// TxSize contain limits on the tx size. // TxSize contain limits on the tx size.
message TxSize{ message TxSize{
int32 max_bytes = 1; int32 max_bytes = 1;
int64 max_gas = 2; int64 max_gas = 2;
} }
// BlockGossip determine consensus critical // BlockGossip determine consensus critical
// elements of how blocks are gossiped // elements of how blocks are gossiped
message BlockGossip{ message BlockGossip{
// Note: must not be 0 // Note: must not be 0
int32 block_part_size_bytes = 1; int32 block_part_size_bytes = 1;
} }
//---------------------------------------- //----------------------------------------