From e6a0d098e83c9c40742f80e914f80cdd0b134d13 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 16 Nov 2018 21:58:30 +0400 Subject: [PATCH] small fixes to spec & http_server & Vagrantfile (#2859) * Vagrantfile: install dev_tools Follow-up on https://github.com/tendermint/tendermint/pull/2824 * update consensus params spec * fix test name * rpc_test: panic if failed to start listener also - remove http_server#MustListen - align StartHTTPServer and StartHTTPAndTLSServer functions * dep: allow minor releases for grpc --- Gopkg.toml | 2 +- Vagrantfile | 2 +- docs/spec/blockchain/state.md | 41 +++++++++++++---------------------- rpc/lib/rpc_test.go | 3 +++ rpc/lib/server/http_server.go | 32 ++++++--------------------- types/part_set_test.go | 4 +--- 6 files changed, 28 insertions(+), 56 deletions(-) diff --git a/Gopkg.toml b/Gopkg.toml index cc5021c91..c5e625e9b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -65,7 +65,7 @@ [[constraint]] name = "google.golang.org/grpc" - version = "~1.13.0" + version = "^1.13.0" [[constraint]] name = "github.com/fortytw2/leaktest" diff --git a/Vagrantfile b/Vagrantfile index 320f3b1c3..f058d78e7 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -53,6 +53,6 @@ Vagrant.configure("2") do |config| # get all deps and tools, ready to install/test su - vagrant -c 'source /home/vagrant/.bash_profile' - su - vagrant -c 'cd /home/vagrant/go/src/github.com/tendermint/tendermint && make get_tools && make get_vendor_deps' + su - vagrant -c 'cd /home/vagrant/go/src/github.com/tendermint/tendermint && make get_tools && make get_dev_tools && make get_vendor_deps' SHELL end diff --git a/docs/spec/blockchain/state.md b/docs/spec/blockchain/state.md index 502f9d696..0a07890f8 100644 --- a/docs/spec/blockchain/state.md +++ b/docs/spec/blockchain/state.md @@ -79,30 +79,24 @@ func TotalVotingPower(vals []Validators) int64{ ConsensusParams define various limits for blockchain data structures. Like validator sets, they are set during genesis and can be updated by the application through ABCI. -``` +```go type ConsensusParams struct { BlockSize - TxSize - BlockGossip - EvidenceParams + Evidence + Validator } type BlockSize struct { - MaxBytes int + MaxBytes int64 MaxGas int64 } -type TxSize struct { - MaxBytes int - MaxGas int64 -} - -type BlockGossip struct { - BlockPartSizeBytes int +type Evidence struct { + MaxAge int64 } -type EvidenceParams struct { - MaxAge int64 +type Validator struct { + PubKeyTypes []string } ``` @@ -115,20 +109,15 @@ otherwise. Blocks should additionally be limited by the amount of "gas" consumed by the transactions in the block, though this is not yet implemented. -#### TxSize - -These parameters are not yet enforced and may disappear. See [issue -#2347](https://github.com/tendermint/tendermint/issues/2347). - -#### BlockGossip - -When gossipping blocks in the consensus, they are first split into parts. The -size of each part is `ConsensusParams.BlockGossip.BlockPartSizeBytes`. - -#### EvidenceParams +#### Evidence For evidence in a block to be valid, it must satisfy: ``` -block.Header.Height - evidence.Height < ConsensusParams.EvidenceParams.MaxAge +block.Header.Height - evidence.Height < ConsensusParams.Evidence.MaxAge ``` + +#### Validator + +Validators from genesis file and `ResponseEndBlock` must have pubkeys of type ∈ +`ConsensusParams.Validator.PubKeyTypes`. diff --git a/rpc/lib/rpc_test.go b/rpc/lib/rpc_test.go index 11b73ef19..794ab462c 100644 --- a/rpc/lib/rpc_test.go +++ b/rpc/lib/rpc_test.go @@ -134,6 +134,9 @@ func setup() { wm.SetLogger(unixLogger) mux2.HandleFunc(websocketEndpoint, wm.WebsocketHandler) listener2, err := server.Listen(unixAddr, server.Config{}) + if err != nil { + panic(err) + } go server.StartHTTPServer(listener2, mux2, unixLogger) // wait for servers to start diff --git a/rpc/lib/server/http_server.go b/rpc/lib/server/http_server.go index 3e7632e2f..a5f8692f9 100644 --- a/rpc/lib/server/http_server.go +++ b/rpc/lib/server/http_server.go @@ -33,12 +33,12 @@ const ( // It wraps handler with RecoverAndLogHandler. // NOTE: This function blocks - you may want to call it in a go-routine. func StartHTTPServer(listener net.Listener, handler http.Handler, logger log.Logger) error { + logger.Info(fmt.Sprintf("Starting RPC HTTP server on %s", listener.Addr())) err := http.Serve( listener, RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger), ) logger.Info("RPC HTTP server stopped", "err", err) - return err } @@ -51,24 +51,16 @@ func StartHTTPAndTLSServer( certFile, keyFile string, logger log.Logger, ) error { - logger.Info( - fmt.Sprintf( - "Starting RPC HTTPS server on %s (cert: %q, key: %q)", - listener.Addr(), - certFile, - keyFile, - ), - ) - if err := http.ServeTLS( + logger.Info(fmt.Sprintf("Starting RPC HTTPS server on %s (cert: %q, key: %q)", + listener.Addr(), certFile, keyFile)) + err := http.ServeTLS( listener, RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger), certFile, keyFile, - ); err != nil { - logger.Error("RPC HTTPS server stopped", "err", err) - return err - } - return nil + ) + logger.Info("RPC HTTPS server stopped", "err", err) + return err } func WriteRPCResponseHTTPError( @@ -170,16 +162,6 @@ func (h maxBytesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.h.ServeHTTP(w, r) } -// MustListen starts a new net.Listener on the given address. -// It panics in case of error. -func MustListen(addr string, config Config) net.Listener { - l, err := Listen(addr, config) - if err != nil { - panic(fmt.Errorf("Listen() failed: %v", err)) - } - return l -} - // Listen starts a new net.Listener on the given address. // It returns an error if the address is invalid or the call to Listen() fails. func Listen(addr string, config Config) (listener net.Listener, err error) { diff --git a/types/part_set_test.go b/types/part_set_test.go index e597088c6..daa2fa5c5 100644 --- a/types/part_set_test.go +++ b/types/part_set_test.go @@ -84,8 +84,7 @@ func TestWrongProof(t *testing.T) { } } -func TestPartSetHeaderSetValidateBasic(t *testing.T) { - +func TestPartSetHeaderValidateBasic(t *testing.T) { testCases := []struct { testName string malleatePartSetHeader func(*PartSetHeader) @@ -107,7 +106,6 @@ func TestPartSetHeaderSetValidateBasic(t *testing.T) { } func TestPartValidateBasic(t *testing.T) { - testCases := []struct { testName string malleatePart func(*Part)