Browse Source

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
pull/2869/head
Anton Kaliaev 6 years ago
committed by Ethan Buchman
parent
commit
e6a0d098e8
6 changed files with 28 additions and 56 deletions
  1. +1
    -1
      Gopkg.toml
  2. +1
    -1
      Vagrantfile
  3. +15
    -26
      docs/spec/blockchain/state.md
  4. +3
    -0
      rpc/lib/rpc_test.go
  5. +7
    -25
      rpc/lib/server/http_server.go
  6. +1
    -3
      types/part_set_test.go

+ 1
- 1
Gopkg.toml View File

@ -65,7 +65,7 @@
[[constraint]]
name = "google.golang.org/grpc"
version = "~1.13.0"
version = "^1.13.0"
[[constraint]]
name = "github.com/fortytw2/leaktest"


+ 1
- 1
Vagrantfile View File

@ -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

+ 15
- 26
docs/spec/blockchain/state.md View File

@ -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`.

+ 3
- 0
rpc/lib/rpc_test.go View File

@ -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


+ 7
- 25
rpc/lib/server/http_server.go View File

@ -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) {


+ 1
- 3
types/part_set_test.go View File

@ -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)


Loading…
Cancel
Save