mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
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
This commit is contained in:
parent
d8ab8509de
commit
e6a0d098e8
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "google.golang.org/grpc"
|
name = "google.golang.org/grpc"
|
||||||
version = "~1.13.0"
|
version = "^1.13.0"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/fortytw2/leaktest"
|
name = "github.com/fortytw2/leaktest"
|
||||||
|
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@ -53,6 +53,6 @@ Vagrant.configure("2") do |config|
|
|||||||
|
|
||||||
# get all deps and tools, ready to install/test
|
# get all deps and tools, ready to install/test
|
||||||
su - vagrant -c 'source /home/vagrant/.bash_profile'
|
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
|
SHELL
|
||||||
end
|
end
|
||||||
|
@ -79,31 +79,25 @@ func TotalVotingPower(vals []Validators) int64{
|
|||||||
ConsensusParams define various limits for blockchain data structures.
|
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.
|
Like validator sets, they are set during genesis and can be updated by the application through ABCI.
|
||||||
|
|
||||||
```
|
```go
|
||||||
type ConsensusParams struct {
|
type ConsensusParams struct {
|
||||||
BlockSize
|
BlockSize
|
||||||
TxSize
|
Evidence
|
||||||
BlockGossip
|
Validator
|
||||||
EvidenceParams
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockSize struct {
|
type BlockSize struct {
|
||||||
MaxBytes int
|
MaxBytes int64
|
||||||
MaxGas int64
|
MaxGas int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type TxSize struct {
|
type Evidence struct {
|
||||||
MaxBytes int
|
|
||||||
MaxGas int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type BlockGossip struct {
|
|
||||||
BlockPartSizeBytes int
|
|
||||||
}
|
|
||||||
|
|
||||||
type EvidenceParams struct {
|
|
||||||
MaxAge int64
|
MaxAge int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Validator struct {
|
||||||
|
PubKeyTypes []string
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### BlockSize
|
#### BlockSize
|
||||||
@ -115,20 +109,15 @@ otherwise.
|
|||||||
Blocks should additionally be limited by the amount of "gas" consumed by the
|
Blocks should additionally be limited by the amount of "gas" consumed by the
|
||||||
transactions in the block, though this is not yet implemented.
|
transactions in the block, though this is not yet implemented.
|
||||||
|
|
||||||
#### TxSize
|
#### Evidence
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
For evidence in a block to be valid, it must satisfy:
|
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`.
|
||||||
|
@ -134,6 +134,9 @@ func setup() {
|
|||||||
wm.SetLogger(unixLogger)
|
wm.SetLogger(unixLogger)
|
||||||
mux2.HandleFunc(websocketEndpoint, wm.WebsocketHandler)
|
mux2.HandleFunc(websocketEndpoint, wm.WebsocketHandler)
|
||||||
listener2, err := server.Listen(unixAddr, server.Config{})
|
listener2, err := server.Listen(unixAddr, server.Config{})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
go server.StartHTTPServer(listener2, mux2, unixLogger)
|
go server.StartHTTPServer(listener2, mux2, unixLogger)
|
||||||
|
|
||||||
// wait for servers to start
|
// wait for servers to start
|
||||||
|
@ -33,12 +33,12 @@ const (
|
|||||||
// It wraps handler with RecoverAndLogHandler.
|
// It wraps handler with RecoverAndLogHandler.
|
||||||
// NOTE: This function blocks - you may want to call it in a go-routine.
|
// 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 {
|
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(
|
err := http.Serve(
|
||||||
listener,
|
listener,
|
||||||
RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger),
|
RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger),
|
||||||
)
|
)
|
||||||
logger.Info("RPC HTTP server stopped", "err", err)
|
logger.Info("RPC HTTP server stopped", "err", err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,25 +51,17 @@ func StartHTTPAndTLSServer(
|
|||||||
certFile, keyFile string,
|
certFile, keyFile string,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) error {
|
) error {
|
||||||
logger.Info(
|
logger.Info(fmt.Sprintf("Starting RPC HTTPS server on %s (cert: %q, key: %q)",
|
||||||
fmt.Sprintf(
|
listener.Addr(), certFile, keyFile))
|
||||||
"Starting RPC HTTPS server on %s (cert: %q, key: %q)",
|
err := http.ServeTLS(
|
||||||
listener.Addr(),
|
|
||||||
certFile,
|
|
||||||
keyFile,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
if err := http.ServeTLS(
|
|
||||||
listener,
|
listener,
|
||||||
RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger),
|
RecoverAndLogHandler(maxBytesHandler{h: handler, n: maxBodyBytes}, logger),
|
||||||
certFile,
|
certFile,
|
||||||
keyFile,
|
keyFile,
|
||||||
); err != nil {
|
)
|
||||||
logger.Error("RPC HTTPS server stopped", "err", err)
|
logger.Info("RPC HTTPS server stopped", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func WriteRPCResponseHTTPError(
|
func WriteRPCResponseHTTPError(
|
||||||
w http.ResponseWriter,
|
w http.ResponseWriter,
|
||||||
@ -170,16 +162,6 @@ func (h maxBytesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.h.ServeHTTP(w, r)
|
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.
|
// 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.
|
// 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) {
|
func Listen(addr string, config Config) (listener net.Listener, err error) {
|
||||||
|
@ -84,8 +84,7 @@ func TestWrongProof(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPartSetHeaderSetValidateBasic(t *testing.T) {
|
func TestPartSetHeaderValidateBasic(t *testing.T) {
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
testName string
|
testName string
|
||||||
malleatePartSetHeader func(*PartSetHeader)
|
malleatePartSetHeader func(*PartSetHeader)
|
||||||
@ -107,7 +106,6 @@ func TestPartSetHeaderSetValidateBasic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPartValidateBasic(t *testing.T) {
|
func TestPartValidateBasic(t *testing.T) {
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
testName string
|
testName string
|
||||||
malleatePart func(*Part)
|
malleatePart func(*Part)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user