Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
small fixes to spec & http_server & Vagrantfile (#2859)
Browse files Browse the repository at this point in the history
* Vagrantfile: install dev_tools

Follow-up on tendermint/tendermint#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
  • Loading branch information
melekes authored and ebuchman committed Nov 16, 2018
1 parent d8ab850 commit e6a0d09
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

[[constraint]]
name = "google.golang.org/grpc"
version = "~1.13.0"
version = "^1.13.0"

[[constraint]]
name = "github.com/fortytw2/leaktest"
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 15 additions & 26 deletions docs/spec/blockchain/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -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 changes: 3 additions & 0 deletions rpc/lib/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 7 additions & 25 deletions rpc/lib/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions types/part_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -107,7 +106,6 @@ func TestPartSetHeaderSetValidateBasic(t *testing.T) {
}

func TestPartValidateBasic(t *testing.T) {

testCases := []struct {
testName string
malleatePart func(*Part)
Expand Down

0 comments on commit e6a0d09

Please sign in to comment.