mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-20 06:52:30 +00:00
Merge branch 'master' into callum/add-evidence-doc
This commit is contained in:
@@ -1,24 +1,7 @@
|
||||
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
|
||||
v ✰ Thanks for creating a PR! ✰
|
||||
v Before smashing the submit button please review the checkboxes.
|
||||
v If a checkbox is n/a - please still include it but + a little note why
|
||||
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->
|
||||
|
||||
## Description
|
||||
|
||||
|
||||
<!-- Add a description of the changes that this PR introduces and the files that
|
||||
are the most critical to review.
|
||||
-->
|
||||
_Please add a description of the changes that this PR introduces and the files that
|
||||
are the most critical to review._
|
||||
|
||||
Closes: #XXX
|
||||
______
|
||||
|
||||
For contributor use:
|
||||
|
||||
- [ ] Wrote tests
|
||||
- [ ] Updated CHANGELOG_PENDING.md
|
||||
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
|
||||
- [ ] Updated relevant documentation (`docs/`) and code comments
|
||||
- [ ] Re-reviewed `Files changed` in the Github PR explorer
|
||||
- [ ] Applied Appropriate Labels
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
pullRequestOpened: >
|
||||
:wave: Thanks for creating a PR!
|
||||
|
||||
Before we can merge this PR, please make sure that all the following items have been
|
||||
checked off. If any of the checklist items are not applicable, please leave them but
|
||||
write a little note why.
|
||||
|
||||
- [ ] Wrote tests
|
||||
- [ ] Updated CHANGELOG_PENDING.md
|
||||
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
|
||||
- [ ] Updated relevant documentation (`docs/`) and code comments
|
||||
- [ ] Re-reviewed `Files changed` in the Github PR explorer
|
||||
- [ ] Applied Appropriate Labels
|
||||
|
||||
|
||||
Thank you for your contribution to Tendermint! :rocket:
|
||||
@@ -10,12 +10,17 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
|
||||
|
||||
- CLI/RPC/Config
|
||||
|
||||
- [evidence] \#4725 Remove `Pubkey` from DuplicateVoteEvidence
|
||||
|
||||
- Apps
|
||||
|
||||
- P2P Protocol
|
||||
|
||||
- Go API
|
||||
- [crypto] [\#4721](https://github.com/tendermint/tendermint/pull/4721) Remove `SimpleHashFromMap()` and `SimpleProofsFromMap()` (@erikgrinaker)
|
||||
|
||||
|
||||
- Blockchain Protocol
|
||||
### FEATURES:
|
||||
|
||||
- [evidence] [\#4532](https://github.com/tendermint/tendermint/pull/4532) Handle evidence from light clients (@melekes)
|
||||
@@ -23,5 +28,15 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
|
||||
|
||||
### IMPROVEMENTS:
|
||||
|
||||
- [abci/server] [\#4719](https://github.com/tendermint/tendermint/pull/4719) Print panic & stack trace to STDERR if logger is not set (@melekes)
|
||||
- [types] [\#4638](https://github.com/tendermint/tendermint/pull/4638) Implement `Header#ValidateBasic` (@alexanderbez)
|
||||
- [txindex] [\#4466](https://github.com/tendermint/tendermint/pull/4466) Allow to index an event at runtime (@favadi)
|
||||
- [evidence] [\#4722](https://github.com/tendermint/tendermint/pull/4722) Improved evidence db (@cmwaters)
|
||||
- [buildsystem] [\#4378](https://github.com/tendermint/tendermint/pull/4738) Replace build_c and install_c with TENDERMINT_BUILD_OPTIONS parsing. The following options are available:
|
||||
- nostrip: don't strip debugging symbols nor DWARF tables.
|
||||
- cleveldb: use cleveldb as db backend instead of goleveldb.
|
||||
- race: pass -race to go build and enable data race detection.
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
- [light] [\#4741](https://github.com/tendermint/tendermint/pull/4741) Correctly return `ErrSignedHeaderNotFound` and `ErrValidatorSetNotFound` on corresponding RPC errors (@erikgrinaker)
|
||||
|
||||
@@ -24,5 +24,5 @@ ENV GOPATH=/go/src
|
||||
RUN mkdir -p /tendermint
|
||||
WORKDIR /tendermint
|
||||
|
||||
CMD ["/usr/bin/make", "build_c"]
|
||||
CMD ["/usr/bin/make", "build", "TENDERMINT_BUILD_OPTIONS=cleveldb"]
|
||||
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
PACKAGES=$(shell go list ./...)
|
||||
OUTPUT?=build/tendermint
|
||||
|
||||
BUILD_TAGS?='tendermint'
|
||||
LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD` -s -w
|
||||
BUILD_TAGS?=tendermint
|
||||
LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`
|
||||
BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
|
||||
HTTPS_GIT := https://github.com/tendermint/tendermint.git
|
||||
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf
|
||||
CGO_ENABLED ?= 0
|
||||
|
||||
# handle nostrip
|
||||
ifeq (,$(findstring nostrip,$(TENDERMINT_BUILD_OPTIONS)))
|
||||
BUILD_FLAGS += -trimpath
|
||||
LD_FLAGS += -s -w
|
||||
endif
|
||||
|
||||
# handle race
|
||||
ifeq (race,$(findstring race,$(TENDERMINT_BUILD_OPTIONS)))
|
||||
CGO_ENABLED=1
|
||||
BUILD_FLAGS += -race
|
||||
endif
|
||||
|
||||
# handle cleveldb
|
||||
ifeq (cleveldb,$(findstring cleveldb,$(TENDERMINT_BUILD_OPTIONS)))
|
||||
CGO_ENABLED=1
|
||||
BUILD_TAGS += cleveldb
|
||||
endif
|
||||
|
||||
# allow users to pass additional flags via the conventional LDFLAGS variable
|
||||
LD_FLAGS += $(LDFLAGS)
|
||||
|
||||
all: check build test install
|
||||
.PHONY: all
|
||||
@@ -19,25 +41,13 @@ include tests.mk
|
||||
###############################################################################
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/
|
||||
CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/
|
||||
.PHONY: build
|
||||
|
||||
build_c:
|
||||
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" -o $(OUTPUT) ./cmd/tendermint/
|
||||
.PHONY: build_c
|
||||
|
||||
build_race:
|
||||
CGO_ENABLED=1 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint
|
||||
.PHONY: build_race
|
||||
|
||||
install:
|
||||
CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
|
||||
CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
|
||||
.PHONY: install
|
||||
|
||||
install_c:
|
||||
CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" ./cmd/tendermint
|
||||
.PHONY: install_c
|
||||
|
||||
###############################################################################
|
||||
### Protobuf ###
|
||||
###############################################################################
|
||||
@@ -197,9 +207,9 @@ build-docker-localnode:
|
||||
@cd networks/local && make
|
||||
.PHONY: build-docker-localnode
|
||||
|
||||
# Runs `make build_c` from within an Amazon Linux (v2)-based Docker build
|
||||
# container in order to build an Amazon Linux-compatible binary. Produces a
|
||||
# compatible binary at ./build/tendermint
|
||||
# Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon
|
||||
# Linux (v2)-based Docker build container in order to build an Amazon
|
||||
# Linux-compatible binary. Produces a compatible binary at ./build/tendermint
|
||||
build_c-amazonlinux:
|
||||
$(MAKE) -C ./DOCKER build_amazonlinux_buildimage
|
||||
docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux
|
||||
|
||||
@@ -9,13 +9,13 @@ Or [Blockchain](<https://en.wikipedia.org/wiki/Blockchain_(database)>), for shor
|
||||
[](https://github.com/tendermint/tendermint/releases/latest)
|
||||
[](https://godoc.org/github.com/tendermint/tendermint)
|
||||
[](https://github.com/moovweb/gvm)
|
||||
[](https://discord.gg/AzefAFd)
|
||||
[](https://discord.gg/AzefAFd)
|
||||
[](https://github.com/tendermint/tendermint/blob/master/LICENSE)
|
||||
[](https://github.com/tendermint/tendermint)
|
||||
|
||||
| Branch | Tests | Coverage |
|
||||
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| master | [](https://circleci.com/gh/tendermint/tendermint/tree/master) | [](https://codecov.io/gh/tendermint/tendermint) |
|
||||
| Branch | Tests | Coverage |
|
||||
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
||||
| master | [](https://circleci.com/gh/tendermint/tendermint/tree/master) <br />  | [](https://codecov.io/gh/tendermint/tendermint) |
|
||||
|
||||
Tendermint Core is Byzantine Fault Tolerant (BFT) middleware that takes a state transition machine - written in any programming language -
|
||||
and securely replicates it on many machines.
|
||||
@@ -125,9 +125,9 @@ For more information on upgrading, see [UPGRADING.md](./UPGRADING.md).
|
||||
|
||||
### Supported Versions
|
||||
|
||||
Because we are a small core team, we only ship patch updates, including security updates,
|
||||
to the most recent minor release and the second-most recent minor release. Consequently,
|
||||
we strongly recommend keeping Tendermint up-to-date. Upgrading instructions can be found
|
||||
Because we are a small core team, we only ship patch updates, including security updates,
|
||||
to the most recent minor release and the second-most recent minor release. Consequently,
|
||||
we strongly recommend keeping Tendermint up-to-date. Upgrading instructions can be found
|
||||
in [UPGRADING.md](./UPGRADING.md).
|
||||
|
||||
## Resources
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/abci/example/code"
|
||||
"github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
@@ -99,9 +98,11 @@ func (app *Application) DeliverTx(req types.RequestDeliverTx) types.ResponseDeli
|
||||
events := []types.Event{
|
||||
{
|
||||
Type: "app",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []types.EventAttribute{
|
||||
{Key: []byte("creator"), Value: []byte("Cosmoshi Netowoko")},
|
||||
{Key: []byte("key"), Value: key},
|
||||
{Key: []byte("index_key"), Value: []byte("index is working"), Index: true},
|
||||
{Key: []byte("noindex_key"), Value: []byte("index is working"), Index: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -34,25 +34,24 @@ func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) service.Se
|
||||
return s
|
||||
}
|
||||
|
||||
// OnStart starts the gRPC service
|
||||
// OnStart starts the gRPC service.
|
||||
func (s *GRPCServer) OnStart() error {
|
||||
if err := s.BaseService.OnStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
ln, err := net.Listen(s.proto, s.addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
|
||||
|
||||
s.listener = ln
|
||||
s.server = grpc.NewServer()
|
||||
types.RegisterABCIApplicationServer(s.server, s.app)
|
||||
|
||||
s.Logger.Info("Listening", "proto", s.proto, "addr", s.addr)
|
||||
go s.server.Serve(s.listener)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnStop stops the gRPC server
|
||||
// OnStop stops the gRPC server.
|
||||
func (s *GRPCServer) OnStop() {
|
||||
s.BaseService.OnStop()
|
||||
s.server.Stop()
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/tendermint/tendermint/abci/types"
|
||||
tmlog "github.com/tendermint/tendermint/libs/log"
|
||||
tmnet "github.com/tendermint/tendermint/libs/net"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
)
|
||||
@@ -16,6 +19,7 @@ import (
|
||||
|
||||
type SocketServer struct {
|
||||
service.BaseService
|
||||
isLoggerSet bool
|
||||
|
||||
proto string
|
||||
addr string
|
||||
@@ -42,21 +46,24 @@ func NewSocketServer(protoAddr string, app types.Application) service.Service {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SocketServer) SetLogger(l tmlog.Logger) {
|
||||
s.BaseService.SetLogger(l)
|
||||
s.isLoggerSet = true
|
||||
}
|
||||
|
||||
func (s *SocketServer) OnStart() error {
|
||||
if err := s.BaseService.OnStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
ln, err := net.Listen(s.proto, s.addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.listener = ln
|
||||
go s.acceptConnectionsRoutine()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SocketServer) OnStop() {
|
||||
s.BaseService.OnStop()
|
||||
if err := s.listener.Close(); err != nil {
|
||||
s.Logger.Error("Error closing listener", "err", err)
|
||||
}
|
||||
@@ -105,7 +112,7 @@ func (s *SocketServer) acceptConnectionsRoutine() {
|
||||
if !s.IsRunning() {
|
||||
return // Ignore error from listener closing.
|
||||
}
|
||||
s.Logger.Error("Failed to accept connection: " + err.Error())
|
||||
s.Logger.Error("Failed to accept connection", "err", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -132,15 +139,15 @@ func (s *SocketServer) waitForClose(closeConn chan error, connID int) {
|
||||
case err == io.EOF:
|
||||
s.Logger.Error("Connection was closed by client")
|
||||
case err != nil:
|
||||
s.Logger.Error("Connection error", "error", err)
|
||||
s.Logger.Error("Connection error", "err", err)
|
||||
default:
|
||||
// never happens
|
||||
s.Logger.Error("Connection was closed.")
|
||||
s.Logger.Error("Connection was closed")
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
if err := s.rmConn(connID); err != nil {
|
||||
s.Logger.Error("Error in closing connection", "error", err)
|
||||
s.Logger.Error("Error closing connection", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +160,14 @@ func (s *SocketServer) handleRequests(closeConn chan error, conn io.Reader, resp
|
||||
// make sure to recover from any app-related panics to allow proper socket cleanup
|
||||
r := recover()
|
||||
if r != nil {
|
||||
closeConn <- fmt.Errorf("recovered from panic: %v", r)
|
||||
const size = 64 << 10
|
||||
buf := make([]byte, size)
|
||||
buf = buf[:runtime.Stack(buf, false)]
|
||||
err := fmt.Errorf("recovered from panic: %v\n%s", r, buf)
|
||||
if !s.isLoggerSet {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
closeConn <- err
|
||||
s.appMtx.Unlock()
|
||||
}
|
||||
}()
|
||||
@@ -166,7 +180,7 @@ func (s *SocketServer) handleRequests(closeConn chan error, conn io.Reader, resp
|
||||
if err == io.EOF {
|
||||
closeConn <- err
|
||||
} else {
|
||||
closeConn <- fmt.Errorf("error reading message: %v", err)
|
||||
closeConn <- fmt.Errorf("error reading message: %w", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -223,13 +237,13 @@ func (s *SocketServer) handleResponses(closeConn chan error, conn io.Writer, res
|
||||
var res = <-responses
|
||||
err := types.WriteMessage(res, bufWriter)
|
||||
if err != nil {
|
||||
closeConn <- fmt.Errorf("error writing message: %v", err.Error())
|
||||
closeConn <- fmt.Errorf("error writing message: %w", err)
|
||||
return
|
||||
}
|
||||
if _, ok := res.Value.(*types.Response_Flush); ok {
|
||||
err = bufWriter.Flush()
|
||||
if err != nil {
|
||||
closeConn <- fmt.Errorf("error flushing write buffer: %v", err.Error())
|
||||
closeConn <- fmt.Errorf("error flushing write buffer: %w", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
)
|
||||
|
||||
func TestMarshalJSON(t *testing.T) {
|
||||
@@ -24,7 +22,7 @@ func TestMarshalJSON(t *testing.T) {
|
||||
Events: []Event{
|
||||
{
|
||||
Type: "testEvent",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []EventAttribute{
|
||||
{Key: []byte("pho"), Value: []byte("bo")},
|
||||
},
|
||||
},
|
||||
@@ -91,7 +89,7 @@ func TestWriteReadMessage2(t *testing.T) {
|
||||
Events: []Event{
|
||||
{
|
||||
Type: "testEvent",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []EventAttribute{
|
||||
{Key: []byte("abc"), Value: []byte("def")},
|
||||
},
|
||||
},
|
||||
|
||||
+568
-235
File diff suppressed because it is too large
Load Diff
+10
-3
@@ -6,7 +6,6 @@ option go_package = "github.com/tendermint/tendermint/abci/types";
|
||||
// https://github.com/gogo/protobuf/blob/master/extensions.md
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "crypto/merkle/merkle.proto";
|
||||
import "libs/kv/types.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
@@ -247,10 +246,18 @@ message LastCommitInfo {
|
||||
repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
|
||||
// EventAttribute represents an event to the indexing service.
|
||||
message EventAttribute {
|
||||
bytes key = 1;
|
||||
bytes value = 2;
|
||||
bool index = 3;
|
||||
}
|
||||
|
||||
message Event {
|
||||
string type = 1;
|
||||
repeated tendermint.libs.kv.Pair attributes = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
|
||||
repeated EventAttribute attributes = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
+124
-1
@@ -13,7 +13,6 @@ import (
|
||||
_ "github.com/golang/protobuf/ptypes/duration"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
_ "github.com/tendermint/tendermint/crypto/merkle"
|
||||
_ "github.com/tendermint/tendermint/libs/kv"
|
||||
math "math"
|
||||
math_rand "math/rand"
|
||||
testing "testing"
|
||||
@@ -1706,6 +1705,62 @@ func TestLastCommitInfoMarshalTo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventAttributeProto(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, false)
|
||||
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
||||
if err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
msg := &EventAttribute{}
|
||||
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
littlefuzz := make([]byte, len(dAtA))
|
||||
copy(littlefuzz, dAtA)
|
||||
for i := range dAtA {
|
||||
dAtA[i] = byte(popr.Intn(256))
|
||||
}
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
||||
}
|
||||
if len(littlefuzz) > 0 {
|
||||
fuzzamount := 100
|
||||
for i := 0; i < fuzzamount; i++ {
|
||||
littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256))
|
||||
littlefuzz = append(littlefuzz, byte(popr.Intn(256)))
|
||||
}
|
||||
// shouldn't panic
|
||||
_ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventAttributeMarshalTo(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, false)
|
||||
size := p.Size()
|
||||
dAtA := make([]byte, size)
|
||||
for i := range dAtA {
|
||||
dAtA[i] = byte(popr.Intn(256))
|
||||
}
|
||||
_, err := p.MarshalTo(dAtA)
|
||||
if err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
msg := &EventAttribute{}
|
||||
if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
for i := range dAtA {
|
||||
dAtA[i] = byte(popr.Intn(256))
|
||||
}
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventProto(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
@@ -2806,6 +2861,24 @@ func TestLastCommitInfoJSON(t *testing.T) {
|
||||
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
||||
}
|
||||
}
|
||||
func TestEventAttributeJSON(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, true)
|
||||
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
|
||||
jsondata, err := marshaler.MarshalToString(p)
|
||||
if err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
msg := &EventAttribute{}
|
||||
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
|
||||
if err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
|
||||
}
|
||||
}
|
||||
func TestEventJSON(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
@@ -3826,6 +3899,34 @@ func TestLastCommitInfoProtoCompactText(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventAttributeProtoText(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, true)
|
||||
dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p)
|
||||
msg := &EventAttribute{}
|
||||
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventAttributeProtoCompactText(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, true)
|
||||
dAtA := github_com_gogo_protobuf_proto.CompactTextString(p)
|
||||
msg := &EventAttribute{}
|
||||
if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
if !p.Equal(msg) {
|
||||
t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventProtoText(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
@@ -4766,6 +4867,28 @@ func TestLastCommitInfoSize(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventAttributeSize(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
p := NewPopulatedEventAttribute(popr, true)
|
||||
size2 := github_com_gogo_protobuf_proto.Size(p)
|
||||
dAtA, err := github_com_gogo_protobuf_proto.Marshal(p)
|
||||
if err != nil {
|
||||
t.Fatalf("seed = %d, err = %v", seed, err)
|
||||
}
|
||||
size := p.Size()
|
||||
if len(dAtA) != size {
|
||||
t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA))
|
||||
}
|
||||
if size2 != size {
|
||||
t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2)
|
||||
}
|
||||
size3 := github_com_gogo_protobuf_proto.Size(p)
|
||||
if size3 != size {
|
||||
t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventSize(t *testing.T) {
|
||||
seed := time.Now().UnixNano()
|
||||
popr := math_rand.New(math_rand.NewSource(seed))
|
||||
|
||||
@@ -204,7 +204,7 @@ type mockEvidencePool struct {
|
||||
|
||||
func newMockEvidencePool(val []byte) *mockEvidencePool {
|
||||
return &mockEvidencePool{
|
||||
ev: []types.Evidence{types.NewMockEvidence(1, time.Now().UTC(), 1, val)},
|
||||
ev: []types.Evidence{types.NewMockEvidence(1, time.Now().UTC(), val)},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
package merkle
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
)
|
||||
|
||||
// Merkle tree from a map.
|
||||
// Leaves are `hash(key) | hash(value)`.
|
||||
// Leaves are sorted before Merkle hashing.
|
||||
type simpleMap struct {
|
||||
kvs kv.Pairs
|
||||
sorted bool
|
||||
}
|
||||
|
||||
func newSimpleMap() *simpleMap {
|
||||
return &simpleMap{
|
||||
kvs: nil,
|
||||
sorted: false,
|
||||
}
|
||||
}
|
||||
|
||||
// Set creates a kv pair of the key and the hash of the value,
|
||||
// and then appends it to simpleMap's kv pairs.
|
||||
func (sm *simpleMap) Set(key string, value []byte) {
|
||||
sm.sorted = false
|
||||
|
||||
// The value is hashed, so you can
|
||||
// check for equality with a cached value (say)
|
||||
// and make a determination to fetch or not.
|
||||
vhash := tmhash.Sum(value)
|
||||
|
||||
sm.kvs = append(sm.kvs, kv.Pair{
|
||||
Key: []byte(key),
|
||||
Value: vhash,
|
||||
})
|
||||
}
|
||||
|
||||
// Hash Merkle root hash of items sorted by key
|
||||
// (UNSTABLE: and by value too if duplicate key).
|
||||
func (sm *simpleMap) Hash() []byte {
|
||||
sm.Sort()
|
||||
return hashKVPairs(sm.kvs)
|
||||
}
|
||||
|
||||
func (sm *simpleMap) Sort() {
|
||||
if sm.sorted {
|
||||
return
|
||||
}
|
||||
sm.kvs.Sort()
|
||||
sm.sorted = true
|
||||
}
|
||||
|
||||
// Returns a copy of sorted KVPairs.
|
||||
// NOTE these contain the hashed key and value.
|
||||
func (sm *simpleMap) KVPairs() kv.Pairs {
|
||||
sm.Sort()
|
||||
kvs := make(kv.Pairs, len(sm.kvs))
|
||||
copy(kvs, sm.kvs)
|
||||
return kvs
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
// A local extension to KVPair that can be hashed.
|
||||
// Key and value are length prefixed and concatenated,
|
||||
// then hashed.
|
||||
type KVPair kv.Pair
|
||||
|
||||
// Bytes returns key || value, with both the
|
||||
// key and value length prefixed.
|
||||
func (kv KVPair) Bytes() []byte {
|
||||
var b bytes.Buffer
|
||||
err := amino.EncodeByteSlice(&b, kv.Key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = amino.EncodeByteSlice(&b, kv.Value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
func hashKVPairs(kvs kv.Pairs) []byte {
|
||||
kvsH := make([][]byte, len(kvs))
|
||||
for i, kvp := range kvs {
|
||||
kvsH[i] = KVPair(kvp).Bytes()
|
||||
}
|
||||
return SimpleHashFromByteSlices(kvsH)
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package merkle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSimpleMap(t *testing.T) {
|
||||
tests := []struct {
|
||||
keys []string
|
||||
values []string // each string gets converted to []byte in test
|
||||
want string
|
||||
}{
|
||||
{[]string{"key1"}, []string{"value1"}, "a44d3cc7daba1a4600b00a2434b30f8b970652169810d6dfa9fb1793a2189324"},
|
||||
{[]string{"key1"}, []string{"value2"}, "0638e99b3445caec9d95c05e1a3fc1487b4ddec6a952ff337080360b0dcc078c"},
|
||||
// swap order with 2 keys
|
||||
{
|
||||
[]string{"key1", "key2"},
|
||||
[]string{"value1", "value2"},
|
||||
"8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3",
|
||||
},
|
||||
{
|
||||
[]string{"key2", "key1"},
|
||||
[]string{"value2", "value1"},
|
||||
"8fd19b19e7bb3f2b3ee0574027d8a5a4cec370464ea2db2fbfa5c7d35bb0cff3",
|
||||
},
|
||||
// swap order with 3 keys
|
||||
{
|
||||
[]string{"key1", "key2", "key3"},
|
||||
[]string{"value1", "value2", "value3"},
|
||||
"1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc",
|
||||
},
|
||||
{
|
||||
[]string{"key1", "key3", "key2"},
|
||||
[]string{"value1", "value3", "value2"},
|
||||
"1dd674ec6782a0d586a903c9c63326a41cbe56b3bba33ed6ff5b527af6efb3dc",
|
||||
},
|
||||
}
|
||||
for i, tc := range tests {
|
||||
db := newSimpleMap()
|
||||
for i := 0; i < len(tc.keys); i++ {
|
||||
db.Set(tc.keys[i], []byte(tc.values[i]))
|
||||
}
|
||||
got := db.Hash()
|
||||
assert.Equal(t, tc.want, fmt.Sprintf("%x", got), "Hash didn't match on tc %d", i)
|
||||
}
|
||||
}
|
||||
@@ -47,31 +47,6 @@ func SimpleProofsFromByteSlices(items [][]byte) (rootHash []byte, proofs []*Simp
|
||||
return
|
||||
}
|
||||
|
||||
// SimpleProofsFromMap generates proofs from a map. The keys/values of the map will be used as the keys/values
|
||||
// in the underlying key-value pairs.
|
||||
// The keys are sorted before the proofs are computed.
|
||||
func SimpleProofsFromMap(m map[string][]byte) (rootHash []byte, proofs map[string]*SimpleProof, keys []string) {
|
||||
sm := newSimpleMap()
|
||||
for k, v := range m {
|
||||
sm.Set(k, v)
|
||||
}
|
||||
sm.Sort()
|
||||
kvs := sm.kvs
|
||||
kvsBytes := make([][]byte, len(kvs))
|
||||
for i, kvp := range kvs {
|
||||
kvsBytes[i] = KVPair(kvp).Bytes()
|
||||
}
|
||||
|
||||
rootHash, proofList := SimpleProofsFromByteSlices(kvsBytes)
|
||||
proofs = make(map[string]*SimpleProof)
|
||||
keys = make([]string, len(proofList))
|
||||
for i, kvp := range kvs {
|
||||
proofs[string(kvp.Key)] = proofList[i]
|
||||
keys[i] = string(kvp.Key)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Verify that the SimpleProof proves the root hash.
|
||||
// Check sp.Index/sp.Total manually if needed
|
||||
func (sp *SimpleProof) Verify(rootHash []byte, leaf []byte) error {
|
||||
|
||||
@@ -91,18 +91,6 @@ func SimpleHashFromByteSlicesIterative(input [][]byte) []byte {
|
||||
}
|
||||
}
|
||||
|
||||
// SimpleHashFromMap computes a Merkle tree from sorted map.
|
||||
// Like calling SimpleHashFromHashers with
|
||||
// `item = []byte(Hash(key) | Hash(value))`,
|
||||
// sorted by `item`.
|
||||
func SimpleHashFromMap(m map[string][]byte) []byte {
|
||||
sm := newSimpleMap()
|
||||
for k, v := range m {
|
||||
sm.Set(k, v)
|
||||
}
|
||||
return sm.Hash()
|
||||
}
|
||||
|
||||
// getSplitPoint returns the largest power of 2 less than length
|
||||
func getSplitPoint(length int) int {
|
||||
if length < 1 {
|
||||
|
||||
@@ -76,10 +76,11 @@ func (app *KVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.Resul
|
||||
events := []abci.Event{
|
||||
{
|
||||
Type: "transfer",
|
||||
Attributes: kv.Pairs{
|
||||
kv.Pair{Key: []byte("sender"), Value: []byte("Bob")},
|
||||
kv.Pair{Key: []byte("recipient"), Value: []byte("Alice")},
|
||||
kv.Pair{Key: []byte("balance"), Value: []byte("100")},
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("sender"), Value: []byte("Bob")},
|
||||
{Key: []byte("recipient"), Value: []byte("Alice")},
|
||||
{Key: []byte("balance"), Value: []byte("100")},
|
||||
{Key: []byte("note"), Value: []byte("nothing"), Index: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -98,6 +99,9 @@ Note, there are a few predefined event types:
|
||||
|
||||
Tendermint will throw a warning if you try to use any of the above keys.
|
||||
|
||||
The index will be added if the `Index` field of attribute is set to true. In above example, querying
|
||||
using `transfer.note` will work.
|
||||
|
||||
## Querying Transactions
|
||||
|
||||
You can query the transaction results by calling `/tx_search` RPC endpoint:
|
||||
|
||||
@@ -119,13 +119,13 @@ db_backend = "cleveldb"
|
||||
To install Tendermint, run:
|
||||
|
||||
```
|
||||
CGO_LDFLAGS="-lsnappy" make install_c
|
||||
CGO_LDFLAGS="-lsnappy" make install TENDERMINT_BUILD_OPTIONS=cleveldb
|
||||
```
|
||||
|
||||
or run:
|
||||
|
||||
```
|
||||
CGO_LDFLAGS="-lsnappy" make build_c
|
||||
CGO_LDFLAGS="-lsnappy" make build TENDERMINT_BUILD_OPTIONS=cleveldb
|
||||
```
|
||||
|
||||
which puts the binary in `./build`.
|
||||
|
||||
@@ -10,7 +10,7 @@ By default, Tendermint uses the `syndtr/goleveldb` package for its in-process
|
||||
key-value database. Unfortunately, this implementation of LevelDB seems to suffer under heavy load (see
|
||||
[#226](https://github.com/syndtr/goleveldb/issues/226)). It may be best to
|
||||
install the real C-implementation of LevelDB and compile Tendermint to use
|
||||
that using `make build_c`. See the [install instructions](../introduction/install.md) for details.
|
||||
that using `make build TENDERMINT_BUILD_OPTIONS=cleveldb`. See the [install instructions](../introduction/install.md) for details.
|
||||
|
||||
Tendermint keeps multiple distinct databases in the `$TMROOT/data`:
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ErrInvalidEvidence returns when evidence failed to validate
|
||||
type ErrInvalidEvidence struct {
|
||||
Reason error
|
||||
}
|
||||
|
||||
func (e ErrInvalidEvidence) Error() string {
|
||||
return fmt.Sprintf("evidence is not valid: %v ", e.Reason)
|
||||
}
|
||||
|
||||
// ErrEvidenceAlreadyStored indicates that the evidence has already been stored in the evidence db
|
||||
type ErrEvidenceAlreadyStored struct{}
|
||||
|
||||
func (e ErrEvidenceAlreadyStored) Error() string {
|
||||
return "evidence is already stored"
|
||||
}
|
||||
+182
-56
@@ -14,12 +14,17 @@ import (
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// Pool maintains a pool of valid evidence in an Store.
|
||||
const (
|
||||
baseKeyCommitted = byte(0x00) // committed evidence
|
||||
baseKeyPending = byte(0x01) // pending evidence
|
||||
)
|
||||
|
||||
// Pool maintains a pool of valid evidence to be broadcasted and committed
|
||||
type Pool struct {
|
||||
logger log.Logger
|
||||
|
||||
store *Store
|
||||
evidenceList *clist.CList // concurrent linked-list of evidence
|
||||
evidenceStore dbm.DB
|
||||
evidenceList *clist.CList // concurrent linked-list of evidence
|
||||
|
||||
// needed to load validators to verify evidence
|
||||
stateDB dbm.DB
|
||||
@@ -41,7 +46,6 @@ type valToLastHeightMap map[string]int64
|
||||
|
||||
func NewPool(stateDB, evidenceDB dbm.DB, blockStore *store.BlockStore) (*Pool, error) {
|
||||
var (
|
||||
store = NewStore(evidenceDB)
|
||||
state = sm.LoadState(stateDB)
|
||||
)
|
||||
|
||||
@@ -50,49 +54,44 @@ func NewPool(stateDB, evidenceDB dbm.DB, blockStore *store.BlockStore) (*Pool, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Pool{
|
||||
pool := &Pool{
|
||||
stateDB: stateDB,
|
||||
blockStore: blockStore,
|
||||
state: state,
|
||||
logger: log.NewNopLogger(),
|
||||
store: store,
|
||||
evidenceStore: evidenceDB,
|
||||
evidenceList: clist.New(),
|
||||
valToLastHeight: valToLastHeight,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// if pending evidence already in db, in event of prior failure, then load it back to the evidenceList
|
||||
evList, err := pool.listEvidence(baseKeyPending, -1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, ev := range evList {
|
||||
if pool.IsExpired(ev) {
|
||||
pool.removePendingEvidence(ev)
|
||||
continue
|
||||
}
|
||||
pool.evidenceList.PushBack(ev)
|
||||
}
|
||||
|
||||
return pool, nil
|
||||
}
|
||||
|
||||
func (evpool *Pool) EvidenceFront() *clist.CElement {
|
||||
return evpool.evidenceList.Front()
|
||||
}
|
||||
|
||||
func (evpool *Pool) EvidenceWaitChan() <-chan struct{} {
|
||||
return evpool.evidenceList.WaitChan()
|
||||
}
|
||||
|
||||
// SetLogger sets the Logger.
|
||||
func (evpool *Pool) SetLogger(l log.Logger) {
|
||||
evpool.logger = l
|
||||
}
|
||||
|
||||
// PriorityEvidence returns the priority evidence.
|
||||
func (evpool *Pool) PriorityEvidence() []types.Evidence {
|
||||
return evpool.store.PriorityEvidence()
|
||||
}
|
||||
|
||||
// PendingEvidence returns up to maxNum uncommitted evidence.
|
||||
// If maxNum is -1, all evidence is returned.
|
||||
// PendingEvidence is used primarily as part of block proposal and returns up to maxNum of uncommitted evidence.
|
||||
// If maxNum is -1, all evidence is returned. Pending evidence is prioritised based on time.
|
||||
func (evpool *Pool) PendingEvidence(maxNum int64) []types.Evidence {
|
||||
return evpool.store.PendingEvidence(maxNum)
|
||||
evidence, err := evpool.listEvidence(baseKeyPending, maxNum)
|
||||
if err != nil {
|
||||
evpool.logger.Error("Unable to retrieve pending evidence", "err", err)
|
||||
}
|
||||
return evidence
|
||||
}
|
||||
|
||||
// State returns the current state of the evpool.
|
||||
func (evpool *Pool) State() sm.State {
|
||||
evpool.mtx.Lock()
|
||||
defer evpool.mtx.Unlock()
|
||||
return evpool.state
|
||||
}
|
||||
|
||||
// Update loads the latest
|
||||
// Update uses the latest block to update the state, the ValToLastHeight map for evidence expiration
|
||||
// and to mark committed evidence
|
||||
func (evpool *Pool) Update(block *types.Block, state sm.State) {
|
||||
// sanity check
|
||||
if state.LastBlockHeight != block.Height {
|
||||
@@ -146,8 +145,8 @@ func (evpool *Pool) AddEvidence(evidence types.Evidence) error {
|
||||
}
|
||||
|
||||
for _, ev := range evList {
|
||||
if evpool.store.Has(evidence) {
|
||||
return ErrEvidenceAlreadyStored{}
|
||||
if evpool.Has(ev) {
|
||||
continue
|
||||
}
|
||||
|
||||
// For lunatic validator evidence, a header needs to be fetched.
|
||||
@@ -165,17 +164,12 @@ func (evpool *Pool) AddEvidence(evidence types.Evidence) error {
|
||||
return fmt.Errorf("failed to verify %v: %w", ev, err)
|
||||
}
|
||||
|
||||
// 2) Compute priority.
|
||||
_, val := valSet.GetByAddress(ev.Address())
|
||||
priority := val.VotingPower
|
||||
|
||||
// 3) Save to store.
|
||||
_, err := evpool.store.AddNewEvidence(ev, priority)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add new evidence %v: %w", ev, err)
|
||||
// 2) Save to store.
|
||||
if err := evpool.addPendingEvidence(ev); err != nil {
|
||||
return fmt.Errorf("database error: %v", err)
|
||||
}
|
||||
|
||||
// 4) Add evidence to clist.
|
||||
// 3) Add evidence to clist.
|
||||
evpool.evidenceList.PushBack(ev)
|
||||
|
||||
evpool.logger.Info("Verified new evidence of byzantine behaviour", "evidence", ev)
|
||||
@@ -190,20 +184,77 @@ func (evpool *Pool) MarkEvidenceAsCommitted(height int64, lastBlockTime time.Tim
|
||||
// make a map of committed evidence to remove from the clist
|
||||
blockEvidenceMap := make(map[string]struct{})
|
||||
for _, ev := range evidence {
|
||||
evpool.store.MarkEvidenceAsCommitted(ev)
|
||||
blockEvidenceMap[evMapKey(ev)] = struct{}{}
|
||||
// As the evidence is stored in the block store we only need to record the height that it was saved at.
|
||||
key := keyCommitted(ev)
|
||||
evBytes := cdc.MustMarshalBinaryBare(height)
|
||||
if err := evpool.evidenceStore.Set(key, evBytes); err != nil {
|
||||
evpool.logger.Error("Unable to add committed evidence", "err", err)
|
||||
// if we can't move evidence to committed then don't remove the evidence from pending
|
||||
continue
|
||||
}
|
||||
// if pending, remove from that bucket, remember not all evidence has been seen before
|
||||
if evpool.IsPending(ev) {
|
||||
evpool.removePendingEvidence(ev)
|
||||
blockEvidenceMap[evMapKey(ev)] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// remove committed evidence from the clist
|
||||
evidenceParams := evpool.State().ConsensusParams.Evidence
|
||||
evpool.removeEvidence(height, lastBlockTime, evidenceParams, blockEvidenceMap)
|
||||
if len(blockEvidenceMap) != 0 {
|
||||
evidenceParams := evpool.State().ConsensusParams.Evidence
|
||||
evpool.removeEvidenceFromList(height, lastBlockTime, evidenceParams, blockEvidenceMap)
|
||||
}
|
||||
}
|
||||
|
||||
// IsCommitted returns true if we have already seen this exact evidence and it
|
||||
// is already marked as committed.
|
||||
// Has checks whether the evidence exists either pending or already committed
|
||||
func (evpool *Pool) Has(evidence types.Evidence) bool {
|
||||
return evpool.IsPending(evidence) || evpool.IsCommitted(evidence)
|
||||
}
|
||||
|
||||
// IsExpired checks whether evidence is past the maximum age where it can be used
|
||||
func (evpool *Pool) IsExpired(evidence types.Evidence) bool {
|
||||
var (
|
||||
params = evpool.State().ConsensusParams.Evidence
|
||||
ageDuration = evpool.State().LastBlockTime.Sub(evidence.Time())
|
||||
ageNumBlocks = evpool.State().LastBlockHeight - evidence.Height()
|
||||
)
|
||||
return ageNumBlocks > params.MaxAgeNumBlocks &&
|
||||
ageDuration > params.MaxAgeDuration
|
||||
}
|
||||
|
||||
// IsCommitted returns true if we have already seen this exact evidence and it is already marked as committed.
|
||||
func (evpool *Pool) IsCommitted(evidence types.Evidence) bool {
|
||||
ei := evpool.store.getInfo(evidence)
|
||||
return ei.Evidence != nil && ei.Committed
|
||||
key := keyCommitted(evidence)
|
||||
ok, err := evpool.evidenceStore.Has(key)
|
||||
if err != nil {
|
||||
evpool.logger.Error("Unable to find committed evidence", "err", err)
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
// Checks whether the evidence is already pending. DB errors are passed to the logger.
|
||||
func (evpool *Pool) IsPending(evidence types.Evidence) bool {
|
||||
key := keyPending(evidence)
|
||||
ok, err := evpool.evidenceStore.Has(key)
|
||||
if err != nil {
|
||||
evpool.logger.Error("Unable to find pending evidence", "err", err)
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
// EvidenceFront goes to the first evidence in the clist
|
||||
func (evpool *Pool) EvidenceFront() *clist.CElement {
|
||||
return evpool.evidenceList.Front()
|
||||
}
|
||||
|
||||
// EvidenceWaitChan is a channel that closes once the first evidence in the list is there. i.e Front is not nil
|
||||
func (evpool *Pool) EvidenceWaitChan() <-chan struct{} {
|
||||
return evpool.evidenceList.WaitChan()
|
||||
}
|
||||
|
||||
// SetLogger sets the Logger.
|
||||
func (evpool *Pool) SetLogger(l log.Logger) {
|
||||
evpool.logger = l
|
||||
}
|
||||
|
||||
// ValidatorLastHeight returns the last height of the validator w/ the
|
||||
@@ -218,7 +269,56 @@ func (evpool *Pool) ValidatorLastHeight(address []byte) int64 {
|
||||
return h
|
||||
}
|
||||
|
||||
func (evpool *Pool) removeEvidence(
|
||||
// State returns the current state of the evpool.
|
||||
func (evpool *Pool) State() sm.State {
|
||||
evpool.mtx.Lock()
|
||||
defer evpool.mtx.Unlock()
|
||||
return evpool.state
|
||||
}
|
||||
|
||||
func (evpool *Pool) addPendingEvidence(evidence types.Evidence) error {
|
||||
evBytes := cdc.MustMarshalBinaryBare(evidence)
|
||||
key := keyPending(evidence)
|
||||
return evpool.evidenceStore.Set(key, evBytes)
|
||||
}
|
||||
|
||||
func (evpool *Pool) removePendingEvidence(evidence types.Evidence) {
|
||||
key := keyPending(evidence)
|
||||
if err := evpool.evidenceStore.Delete(key); err != nil {
|
||||
evpool.logger.Error("Unable to delete pending evidence", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// listEvidence lists up to maxNum pieces of evidence for the given prefix key.
|
||||
// It is wrapped by PriorityEvidence and PendingEvidence for convenience.
|
||||
// If maxNum is -1, there's no cap on the size of returned evidence.
|
||||
func (evpool *Pool) listEvidence(prefixKey byte, maxNum int64) ([]types.Evidence, error) {
|
||||
var count int64
|
||||
var evidence []types.Evidence
|
||||
iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{prefixKey})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("database error: %v", err)
|
||||
}
|
||||
defer iter.Close()
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
val := iter.Value()
|
||||
|
||||
if count == maxNum {
|
||||
return evidence, nil
|
||||
}
|
||||
count++
|
||||
|
||||
var ev types.Evidence
|
||||
err := cdc.UnmarshalBinaryBare(val, &ev)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
evidence = append(evidence, ev)
|
||||
}
|
||||
return evidence, nil
|
||||
}
|
||||
|
||||
func (evpool *Pool) removeEvidenceFromList(
|
||||
height int64,
|
||||
lastBlockTime time.Time,
|
||||
params types.EvidenceParams,
|
||||
@@ -324,3 +424,29 @@ func buildValToLastHeightMap(state sm.State, stateDB dbm.DB, blockStore *store.B
|
||||
|
||||
return valToLastHeight, nil
|
||||
}
|
||||
|
||||
// big endian padded hex
|
||||
func bE(h int64) string {
|
||||
return fmt.Sprintf("%0.16X", h)
|
||||
}
|
||||
|
||||
func keyCommitted(evidence types.Evidence) []byte {
|
||||
return append([]byte{baseKeyCommitted}, keySuffix(evidence)...)
|
||||
}
|
||||
|
||||
func keyPending(evidence types.Evidence) []byte {
|
||||
return append([]byte{baseKeyPending}, keySuffix(evidence)...)
|
||||
}
|
||||
|
||||
func keySuffix(evidence types.Evidence) []byte {
|
||||
return []byte(fmt.Sprintf("%s/%X", bE(evidence.Height()), evidence.Hash()))
|
||||
}
|
||||
|
||||
// ErrInvalidEvidence returns when evidence failed to validate
|
||||
type ErrInvalidEvidence struct {
|
||||
Reason error
|
||||
}
|
||||
|
||||
func (e ErrInvalidEvidence) Error() string {
|
||||
return fmt.Sprintf("evidence is not valid: %v ", e.Reason)
|
||||
}
|
||||
|
||||
+49
-9
@@ -33,8 +33,8 @@ func TestEvidencePool(t *testing.T) {
|
||||
blockStore = initializeBlockStore(blockStoreDB, sm.LoadState(stateDB), valAddr)
|
||||
evidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
goodEvidence = types.NewMockEvidence(height, time.Now(), 0, valAddr)
|
||||
badEvidence = types.NewMockEvidence(1, evidenceTime, 0, valAddr)
|
||||
goodEvidence = types.NewMockEvidence(height, time.Now(), valAddr)
|
||||
badEvidence = types.NewMockEvidence(1, evidenceTime, valAddr)
|
||||
)
|
||||
|
||||
pool, err := NewPool(stateDB, evidenceDB, blockStore)
|
||||
@@ -45,6 +45,8 @@ func TestEvidencePool(t *testing.T) {
|
||||
if assert.Error(t, err) {
|
||||
assert.Contains(t, err.Error(), "is too old; min height is 32 and evidence can not be older than")
|
||||
}
|
||||
assert.False(t, pool.IsPending(badEvidence))
|
||||
assert.True(t, pool.IsExpired(badEvidence))
|
||||
|
||||
// good evidence
|
||||
evAdded := make(chan struct{})
|
||||
@@ -59,18 +61,18 @@ func TestEvidencePool(t *testing.T) {
|
||||
select {
|
||||
case <-evAdded:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("evidence was not added after 5s")
|
||||
t.Fatal("evidence was not added to list after 5s")
|
||||
}
|
||||
|
||||
assert.Equal(t, 1, pool.evidenceList.Len())
|
||||
|
||||
// if we send it again, it shouldnt add and return an error
|
||||
err = pool.AddEvidence(goodEvidence)
|
||||
assert.Error(t, err)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, pool.evidenceList.Len())
|
||||
}
|
||||
|
||||
func TestEvidencePoolIsCommitted(t *testing.T) {
|
||||
func TestProposingAndCommittingEvidence(t *testing.T) {
|
||||
var (
|
||||
valAddr = []byte("validator_address")
|
||||
height = int64(1)
|
||||
@@ -79,22 +81,31 @@ func TestEvidencePoolIsCommitted(t *testing.T) {
|
||||
evidenceDB = dbm.NewMemDB()
|
||||
blockStoreDB = dbm.NewMemDB()
|
||||
blockStore = initializeBlockStore(blockStoreDB, sm.LoadState(stateDB), valAddr)
|
||||
evidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
pool, err := NewPool(stateDB, evidenceDB, blockStore)
|
||||
require.NoError(t, err)
|
||||
|
||||
// evidence not seen yet:
|
||||
evidence := types.NewMockEvidence(height, time.Now(), 0, valAddr)
|
||||
evidence := types.NewMockEvidence(height, evidenceTime, valAddr)
|
||||
assert.False(t, pool.IsCommitted(evidence))
|
||||
|
||||
// evidence seen but not yet committed:
|
||||
assert.NoError(t, pool.AddEvidence(evidence))
|
||||
assert.False(t, pool.IsCommitted(evidence))
|
||||
|
||||
// test evidence is proposed
|
||||
proposedEvidence := pool.PendingEvidence(-1)
|
||||
assert.Equal(t, proposedEvidence[0], evidence)
|
||||
|
||||
// evidence seen and committed:
|
||||
pool.MarkEvidenceAsCommitted(height, lastBlockTime, []types.Evidence{evidence})
|
||||
pool.MarkEvidenceAsCommitted(height, lastBlockTime, proposedEvidence)
|
||||
assert.True(t, pool.IsCommitted(evidence))
|
||||
assert.False(t, pool.IsPending(evidence))
|
||||
assert.Equal(t, 0, pool.evidenceList.Len())
|
||||
|
||||
// evidence should
|
||||
}
|
||||
|
||||
func TestEvidencePoolAddEvidence(t *testing.T) {
|
||||
@@ -127,7 +138,7 @@ func TestEvidencePoolAddEvidence(t *testing.T) {
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.evDescription, func(t *testing.T) {
|
||||
ev := types.NewMockEvidence(tc.evHeight, tc.evTime, 0, valAddr)
|
||||
ev := types.NewMockEvidence(tc.evHeight, tc.evTime, valAddr)
|
||||
err := pool.AddEvidence(ev)
|
||||
if tc.expErr {
|
||||
assert.Error(t, err)
|
||||
@@ -152,7 +163,7 @@ func TestEvidencePoolUpdate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// create new block (no need to save it to blockStore)
|
||||
evidence := types.NewMockEvidence(height, time.Now(), 0, valAddr)
|
||||
evidence := types.NewMockEvidence(height, time.Now(), valAddr)
|
||||
lastCommit := makeCommit(height, valAddr)
|
||||
block := types.MakeBlock(height+1, []types.Tx{}, lastCommit, []types.Evidence{evidence})
|
||||
// update state (partially)
|
||||
@@ -184,6 +195,35 @@ func TestEvidencePoolNewPool(t *testing.T) {
|
||||
assert.EqualValues(t, 0, pool.ValidatorLastHeight([]byte("non-existent-validator")))
|
||||
}
|
||||
|
||||
func TestRecoverPendingEvidence(t *testing.T) {
|
||||
var (
|
||||
valAddr = []byte("val1")
|
||||
height = int64(30)
|
||||
stateDB = initializeValidatorState(valAddr, height)
|
||||
evidenceDB = dbm.NewMemDB()
|
||||
blockStoreDB = dbm.NewMemDB()
|
||||
state = sm.LoadState(stateDB)
|
||||
blockStore = initializeBlockStore(blockStoreDB, state, valAddr)
|
||||
evidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
goodEvidence = types.NewMockEvidence(height, time.Now(), valAddr)
|
||||
expiredEvidence = types.NewMockEvidence(int64(1), evidenceTime, valAddr)
|
||||
)
|
||||
|
||||
// load good evidence
|
||||
goodKey := keyPending(goodEvidence)
|
||||
goodEvidenceBytes := cdc.MustMarshalBinaryBare(goodEvidence)
|
||||
_ = evidenceDB.Set(goodKey, goodEvidenceBytes)
|
||||
|
||||
// load expired evidence
|
||||
expiredKey := keyPending(expiredEvidence)
|
||||
expiredEvidenceBytes := cdc.MustMarshalBinaryBare(expiredEvidence)
|
||||
_ = evidenceDB.Set(expiredKey, expiredEvidenceBytes)
|
||||
pool, err := NewPool(stateDB, evidenceDB, blockStore)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, pool.evidenceList.Len())
|
||||
assert.True(t, pool.IsPending(goodEvidence))
|
||||
}
|
||||
|
||||
func initializeValidatorState(valAddr []byte, height int64) dbm.DB {
|
||||
stateDB := dbm.NewMemDB()
|
||||
|
||||
|
||||
@@ -88,8 +88,6 @@ func (evR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
|
||||
// punish peer
|
||||
evR.Switch.StopPeerForError(src, err)
|
||||
return
|
||||
case ErrEvidenceAlreadyStored:
|
||||
evR.Logger.Debug("Evidence already exists", "evidence", msg.Evidence)
|
||||
case nil:
|
||||
default:
|
||||
evR.Logger.Error("Evidence has not been added", "evidence", msg.Evidence, "err", err)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
@@ -116,7 +115,7 @@ func _waitForEvidence(
|
||||
func sendEvidence(t *testing.T, evpool *Pool, valAddr []byte, n int) types.EvidenceList {
|
||||
evList := make([]types.Evidence, n)
|
||||
for i := 0; i < n; i++ {
|
||||
ev := types.NewMockEvidence(int64(i+1), time.Now().UTC(), 0, valAddr)
|
||||
ev := types.NewMockEvidence(int64(i+1), time.Now().UTC(), valAddr)
|
||||
err := evpool.AddEvidence(ev)
|
||||
require.NoError(t, err)
|
||||
evList[i] = ev
|
||||
@@ -214,7 +213,7 @@ func TestListMessageValidationBasic(t *testing.T) {
|
||||
{"Good ListMessage", func(evList *ListMessage) {}, false},
|
||||
{"Invalid ListMessage", func(evList *ListMessage) {
|
||||
evList.Evidence = append(evList.Evidence,
|
||||
&types.DuplicateVoteEvidence{PubKey: secp256k1.GenPrivKey().PubKey()})
|
||||
&types.DuplicateVoteEvidence{})
|
||||
}, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
@@ -225,7 +224,7 @@ func TestListMessageValidationBasic(t *testing.T) {
|
||||
valAddr := []byte("myval")
|
||||
evListMsg.Evidence = make([]types.Evidence, n)
|
||||
for i := 0; i < n; i++ {
|
||||
evListMsg.Evidence[i] = types.NewMockEvidence(int64(i+1), time.Now(), 0, valAddr)
|
||||
evListMsg.Evidence[i] = types.NewMockEvidence(int64(i+1), time.Now(), valAddr)
|
||||
}
|
||||
tc.malleateEvListMsg(evListMsg)
|
||||
assert.Equal(t, tc.expectErr, evListMsg.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
/*
|
||||
Requirements:
|
||||
- Valid new evidence must be persisted immediately and never forgotten
|
||||
- Uncommitted evidence must be continuously broadcast
|
||||
- Uncommitted evidence has a partial order, the evidence's priority
|
||||
|
||||
Impl:
|
||||
- First commit atomically in outqueue, pending, lookup.
|
||||
- Once broadcast, remove from outqueue. No need to sync
|
||||
- Once committed, atomically remove from pending and update lookup.
|
||||
|
||||
Schema for indexing evidence (note you need both height and hash to find a piece of evidence):
|
||||
|
||||
"evidence-lookup"/<evidence-height>/<evidence-hash> -> Info
|
||||
"evidence-outqueue"/<priority>/<evidence-height>/<evidence-hash> -> Info
|
||||
"evidence-pending"/<evidence-height>/<evidence-hash> -> Info
|
||||
*/
|
||||
|
||||
type Info struct {
|
||||
Committed bool
|
||||
Priority int64
|
||||
Evidence types.Evidence
|
||||
}
|
||||
|
||||
const (
|
||||
baseKeyLookup = "evidence-lookup" // all evidence
|
||||
baseKeyOutqueue = "evidence-outqueue" // not-yet broadcast
|
||||
baseKeyPending = "evidence-pending" // broadcast but not committed
|
||||
)
|
||||
|
||||
func keyLookup(evidence types.Evidence) []byte {
|
||||
return keyLookupFromHeightAndHash(evidence.Height(), evidence.Hash())
|
||||
}
|
||||
|
||||
// big endian padded hex
|
||||
func bE(h int64) string {
|
||||
return fmt.Sprintf("%0.16X", h)
|
||||
}
|
||||
|
||||
func keyLookupFromHeightAndHash(height int64, hash []byte) []byte {
|
||||
return _key("%s/%s/%X", baseKeyLookup, bE(height), hash)
|
||||
}
|
||||
|
||||
func keyOutqueue(evidence types.Evidence, priority int64) []byte {
|
||||
return _key("%s/%s/%s/%X", baseKeyOutqueue, bE(priority), bE(evidence.Height()), evidence.Hash())
|
||||
}
|
||||
|
||||
func keyPending(evidence types.Evidence) []byte {
|
||||
return _key("%s/%s/%X", baseKeyPending, bE(evidence.Height()), evidence.Hash())
|
||||
}
|
||||
|
||||
func _key(format string, o ...interface{}) []byte {
|
||||
return []byte(fmt.Sprintf(format, o...))
|
||||
}
|
||||
|
||||
// Store is a store of all the evidence we've seen, including
|
||||
// evidence that has been committed, evidence that has been verified but not broadcast,
|
||||
// and evidence that has been broadcast but not yet committed.
|
||||
type Store struct {
|
||||
db dbm.DB
|
||||
}
|
||||
|
||||
func NewStore(db dbm.DB) *Store {
|
||||
return &Store{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
// PriorityEvidence returns the evidence from the outqueue, sorted by highest priority.
|
||||
func (store *Store) PriorityEvidence() (evidence []types.Evidence) {
|
||||
// reverse the order so highest priority is first
|
||||
l := store.listEvidence(baseKeyOutqueue, -1)
|
||||
for i, j := 0, len(l)-1; i < j; i, j = i+1, j-1 {
|
||||
l[i], l[j] = l[j], l[i]
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
// PendingEvidence returns up to maxNum known, uncommitted evidence.
|
||||
// If maxNum is -1, all evidence is returned.
|
||||
func (store *Store) PendingEvidence(maxNum int64) (evidence []types.Evidence) {
|
||||
return store.listEvidence(baseKeyPending, maxNum)
|
||||
}
|
||||
|
||||
// listEvidence lists up to maxNum pieces of evidence for the given prefix key.
|
||||
// It is wrapped by PriorityEvidence and PendingEvidence for convenience.
|
||||
// If maxNum is -1, there's no cap on the size of returned evidence.
|
||||
func (store *Store) listEvidence(prefixKey string, maxNum int64) (evidence []types.Evidence) {
|
||||
var count int64
|
||||
iter, err := dbm.IteratePrefix(store.db, []byte(prefixKey))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer iter.Close()
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
val := iter.Value()
|
||||
|
||||
if count == maxNum {
|
||||
return evidence
|
||||
}
|
||||
count++
|
||||
|
||||
var ei Info
|
||||
err := cdc.UnmarshalBinaryBare(val, &ei)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
evidence = append(evidence, ei.Evidence)
|
||||
}
|
||||
return evidence
|
||||
}
|
||||
|
||||
// GetInfo fetches the Info with the given height and hash.
|
||||
// If not found, ei.Evidence is nil.
|
||||
func (store *Store) GetInfo(height int64, hash []byte) Info {
|
||||
key := keyLookupFromHeightAndHash(height, hash)
|
||||
val, err := store.db.Get(key)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(val) == 0 {
|
||||
return Info{}
|
||||
}
|
||||
var ei Info
|
||||
err = cdc.UnmarshalBinaryBare(val, &ei)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ei
|
||||
}
|
||||
|
||||
// Has checks if the evidence is already stored
|
||||
func (store *Store) Has(evidence types.Evidence) bool {
|
||||
key := keyLookup(evidence)
|
||||
ok, _ := store.db.Has(key)
|
||||
return ok
|
||||
}
|
||||
|
||||
// AddNewEvidence adds the given evidence to the database.
|
||||
// It returns false if the evidence is already stored.
|
||||
func (store *Store) AddNewEvidence(evidence types.Evidence, priority int64) (bool, error) {
|
||||
// check if we already have seen it
|
||||
if store.Has(evidence) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
ei := Info{
|
||||
Committed: false,
|
||||
Priority: priority,
|
||||
Evidence: evidence,
|
||||
}
|
||||
eiBytes := cdc.MustMarshalBinaryBare(ei)
|
||||
|
||||
// add it to the store
|
||||
var err error
|
||||
key := keyOutqueue(evidence, priority)
|
||||
if err = store.db.Set(key, eiBytes); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
key = keyPending(evidence)
|
||||
if err = store.db.Set(key, eiBytes); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
key = keyLookup(evidence)
|
||||
if err = store.db.SetSync(key, eiBytes); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// MarkEvidenceAsBroadcasted removes evidence from Outqueue.
|
||||
func (store *Store) MarkEvidenceAsBroadcasted(evidence types.Evidence) {
|
||||
ei := store.getInfo(evidence)
|
||||
if ei.Evidence == nil {
|
||||
// nothing to do; we did not store the evidence yet (AddNewEvidence):
|
||||
return
|
||||
}
|
||||
// remove from the outqueue
|
||||
key := keyOutqueue(evidence, ei.Priority)
|
||||
store.db.Delete(key)
|
||||
}
|
||||
|
||||
// MarkEvidenceAsCommitted removes evidence from pending and outqueue and sets the state to committed.
|
||||
func (store *Store) MarkEvidenceAsCommitted(evidence types.Evidence) {
|
||||
// if its committed, its been broadcast
|
||||
store.MarkEvidenceAsBroadcasted(evidence)
|
||||
|
||||
pendingKey := keyPending(evidence)
|
||||
store.db.Delete(pendingKey)
|
||||
|
||||
// committed Info doens't need priority
|
||||
ei := Info{
|
||||
Committed: true,
|
||||
Evidence: evidence,
|
||||
Priority: 0,
|
||||
}
|
||||
|
||||
lookupKey := keyLookup(evidence)
|
||||
store.db.SetSync(lookupKey, cdc.MustMarshalBinaryBare(ei))
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// utils
|
||||
|
||||
// getInfo is convenience for calling GetInfo if we have the full evidence.
|
||||
func (store *Store) getInfo(evidence types.Evidence) Info {
|
||||
return store.GetInfo(evidence.Height(), evidence.Hash())
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
func TestStoreAddDuplicate(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
store := NewStore(db)
|
||||
|
||||
priority := int64(10)
|
||||
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
|
||||
|
||||
added, err := store.AddNewEvidence(ev, priority)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, added)
|
||||
|
||||
// cant add twice
|
||||
added, err = store.AddNewEvidence(ev, priority)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, added)
|
||||
}
|
||||
|
||||
func TestStoreCommitDuplicate(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
store := NewStore(db)
|
||||
|
||||
priority := int64(10)
|
||||
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
|
||||
|
||||
store.MarkEvidenceAsCommitted(ev)
|
||||
|
||||
added, err := store.AddNewEvidence(ev, priority)
|
||||
require.NoError(t, err)
|
||||
assert.False(t, added)
|
||||
}
|
||||
|
||||
func TestStoreMark(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
store := NewStore(db)
|
||||
|
||||
// before we do anything, priority/pending are empty
|
||||
priorityEv := store.PriorityEvidence()
|
||||
pendingEv := store.PendingEvidence(-1)
|
||||
assert.Equal(t, 0, len(priorityEv))
|
||||
assert.Equal(t, 0, len(pendingEv))
|
||||
|
||||
priority := int64(10)
|
||||
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
|
||||
|
||||
added, err := store.AddNewEvidence(ev, priority)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, added)
|
||||
|
||||
// get the evidence. verify. should be uncommitted
|
||||
ei := store.GetInfo(ev.Height(), ev.Hash())
|
||||
assert.Equal(t, ev, ei.Evidence)
|
||||
assert.Equal(t, priority, ei.Priority)
|
||||
assert.False(t, ei.Committed)
|
||||
|
||||
// new evidence should be returns in priority/pending
|
||||
priorityEv = store.PriorityEvidence()
|
||||
pendingEv = store.PendingEvidence(-1)
|
||||
assert.Equal(t, 1, len(priorityEv))
|
||||
assert.Equal(t, 1, len(pendingEv))
|
||||
|
||||
// priority is now empty
|
||||
store.MarkEvidenceAsBroadcasted(ev)
|
||||
priorityEv = store.PriorityEvidence()
|
||||
pendingEv = store.PendingEvidence(-1)
|
||||
assert.Equal(t, 0, len(priorityEv))
|
||||
assert.Equal(t, 1, len(pendingEv))
|
||||
|
||||
// priority and pending are now empty
|
||||
store.MarkEvidenceAsCommitted(ev)
|
||||
priorityEv = store.PriorityEvidence()
|
||||
pendingEv = store.PendingEvidence(-1)
|
||||
assert.Equal(t, 0, len(priorityEv))
|
||||
assert.Equal(t, 0, len(pendingEv))
|
||||
|
||||
// evidence should show committed
|
||||
newPriority := int64(0)
|
||||
ei = store.GetInfo(ev.Height(), ev.Hash())
|
||||
assert.Equal(t, ev, ei.Evidence)
|
||||
assert.Equal(t, newPriority, ei.Priority)
|
||||
assert.True(t, ei.Committed)
|
||||
}
|
||||
|
||||
func TestStorePriority(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
store := NewStore(db)
|
||||
|
||||
// sorted by priority and then height
|
||||
cases := []struct {
|
||||
ev types.MockEvidence
|
||||
priority int64
|
||||
}{
|
||||
{types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1")), 17},
|
||||
{types.NewMockEvidence(5, time.Now().UTC(), 2, []byte("val2")), 15},
|
||||
{types.NewMockEvidence(10, time.Now().UTC(), 2, []byte("val2")), 13},
|
||||
{types.NewMockEvidence(100, time.Now().UTC(), 2, []byte("val2")), 11},
|
||||
{types.NewMockEvidence(90, time.Now().UTC(), 2, []byte("val2")), 11},
|
||||
{types.NewMockEvidence(80, time.Now().UTC(), 2, []byte("val2")), 11},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
added, err := store.AddNewEvidence(c.ev, c.priority)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, added)
|
||||
}
|
||||
|
||||
evList := store.PriorityEvidence()
|
||||
for i, ev := range evList {
|
||||
assert.Equal(t, ev, cases[i].ev)
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,5 @@ require (
|
||||
github.com/tendermint/tm-db v0.5.1
|
||||
golang.org/x/crypto v0.0.0-20200406173513-056763e48d71
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
|
||||
google.golang.org/grpc v1.28.1
|
||||
google.golang.org/grpc v1.29.1
|
||||
)
|
||||
|
||||
@@ -563,8 +563,10 @@ google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k=
|
||||
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.0 h1:2pJjwYOdkZ9HlN4sWRYBg9ttH5bCOlsueaM+b/oYjwo=
|
||||
google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
||||
+1
-1
@@ -17,6 +17,6 @@ option (gogoproto.testgen_all) = true;
|
||||
// Abstract types
|
||||
|
||||
message Pair {
|
||||
bytes key = 1;
|
||||
bytes key = 1;
|
||||
bytes value = 2;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,15 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
lerr "github.com/tendermint/tendermint/lite/errors"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func TestBaseCert(t *testing.T) {
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
t.SkipNow()
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
keys := genPrivKeys(4)
|
||||
@@ -41,8 +45,14 @@ func TestBaseCert(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
sh := tc.keys.GenSignedHeader(chainID, tc.height, nil, tc.vals, tc.vals,
|
||||
[]byte("foo"), []byte("params"), []byte("results"), tc.first, tc.last)
|
||||
sh := tc.keys.GenSignedHeader(
|
||||
chainID, tc.height, nil, tc.vals, tc.vals,
|
||||
tmhash.Sum([]byte("foo")),
|
||||
tmhash.Sum([]byte("params")),
|
||||
tmhash.Sum([]byte("results")),
|
||||
tc.first, tc.last,
|
||||
)
|
||||
|
||||
err := cert.Verify(sh)
|
||||
if tc.proper {
|
||||
assert.Nil(err, "%+v", err)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
log "github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -70,8 +71,10 @@ func TestInquirerValidPath(t *testing.T) {
|
||||
err := source.SaveFullCommit(fcz[i])
|
||||
require.Nil(err)
|
||||
}
|
||||
err = cert.Verify(sh)
|
||||
assert.Nil(err, "%+v", err)
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// err = cert.Verify(sh)
|
||||
// assert.Nil(err, "%+v", err)
|
||||
}
|
||||
|
||||
func TestDynamicVerify(t *testing.T) {
|
||||
@@ -118,24 +121,27 @@ func TestDynamicVerify(t *testing.T) {
|
||||
ver.SetLogger(log.TestingLogger())
|
||||
|
||||
// fetch the latest from the source
|
||||
latestFC, err := source.LatestFullCommit(chainID, 1, maxHeight)
|
||||
_, err = source.LatestFullCommit(chainID, 1, maxHeight)
|
||||
require.NoError(t, err)
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// try to update to the latest
|
||||
err = ver.Verify(latestFC.SignedHeader)
|
||||
require.NoError(t, err)
|
||||
|
||||
// err = ver.Verify(latestFC.SignedHeader)
|
||||
// require.NoError(t, err)
|
||||
}
|
||||
|
||||
func makeFullCommit(height int64, keys privKeys, vals, nextVals *types.ValidatorSet, chainID string) FullCommit {
|
||||
height++
|
||||
consHash := []byte("special-params")
|
||||
appHash := []byte(fmt.Sprintf("h=%d", height))
|
||||
resHash := []byte(fmt.Sprintf("res=%d", height))
|
||||
|
||||
consHash := tmhash.Sum([]byte("special-params"))
|
||||
appHash := tmhash.Sum([]byte(fmt.Sprintf("h=%d", height)))
|
||||
resHash := tmhash.Sum([]byte(fmt.Sprintf("res=%d", height)))
|
||||
|
||||
return keys.GenFullCommit(
|
||||
chainID, height, nil,
|
||||
vals, nextVals,
|
||||
appHash, consHash, resHash, 0, len(keys))
|
||||
appHash, consHash, resHash, 0, len(keys),
|
||||
)
|
||||
}
|
||||
|
||||
func TestInquirerVerifyHistorical(t *testing.T) {
|
||||
@@ -183,10 +189,13 @@ func TestInquirerVerifyHistorical(t *testing.T) {
|
||||
// Souce doesn't have fcz[9] so cert.LastTrustedHeight wont' change.
|
||||
err = source.SaveFullCommit(fcz[7])
|
||||
require.Nil(err, "%+v", err)
|
||||
sh := fcz[8].SignedHeader
|
||||
err = cert.Verify(sh)
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(fcz[7].Height(), cert.LastTrustedHeight())
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// sh := fcz[8].SignedHeader
|
||||
// err = cert.Verify(sh)
|
||||
// require.Nil(err, "%+v", err)
|
||||
// assert.Equal(fcz[7].Height(), cert.LastTrustedHeight())
|
||||
|
||||
commit, err := trust.LatestFullCommit(chainID, fcz[8].Height(), fcz[8].Height())
|
||||
require.NotNil(err, "%+v", err)
|
||||
assert.Equal(commit, (FullCommit{}))
|
||||
@@ -194,13 +203,17 @@ func TestInquirerVerifyHistorical(t *testing.T) {
|
||||
// With fcz[9] Verify will update last trusted height.
|
||||
err = source.SaveFullCommit(fcz[9])
|
||||
require.Nil(err, "%+v", err)
|
||||
sh = fcz[8].SignedHeader
|
||||
err = cert.Verify(sh)
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(fcz[8].Height(), cert.LastTrustedHeight())
|
||||
commit, err = trust.LatestFullCommit(chainID, fcz[8].Height(), fcz[8].Height())
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(commit.Height(), fcz[8].Height())
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// sh = fcz[8].SignedHeader
|
||||
// err = cert.Verify(sh)
|
||||
// require.Nil(err, "%+v", err)
|
||||
// assert.Equal(fcz[8].Height(), cert.LastTrustedHeight())
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// commit, err = trust.LatestFullCommit(chainID, fcz[8].Height(), fcz[8].Height())
|
||||
// require.Nil(err, "%+v", err)
|
||||
// assert.Equal(commit.Height(), fcz[8].Height())
|
||||
|
||||
// Add access to all full commits via untrusted source.
|
||||
for i := 0; i < count; i++ {
|
||||
@@ -208,17 +221,19 @@ func TestInquirerVerifyHistorical(t *testing.T) {
|
||||
require.Nil(err)
|
||||
}
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// Try to check an unknown seed in the past.
|
||||
sh = fcz[3].SignedHeader
|
||||
err = cert.Verify(sh)
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(fcz[8].Height(), cert.LastTrustedHeight())
|
||||
// sh = fcz[3].SignedHeader
|
||||
// err = cert.Verify(sh)
|
||||
// require.Nil(err, "%+v", err)
|
||||
// assert.Equal(fcz[8].Height(), cert.LastTrustedHeight())
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// Jump all the way forward again.
|
||||
sh = fcz[count-1].SignedHeader
|
||||
err = cert.Verify(sh)
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(fcz[9].Height(), cert.LastTrustedHeight())
|
||||
// sh = fcz[count-1].SignedHeader
|
||||
// err = cert.Verify(sh)
|
||||
// require.Nil(err, "%+v", err)
|
||||
// assert.Equal(fcz[9].Height(), cert.LastTrustedHeight())
|
||||
}
|
||||
|
||||
func TestConcurrencyInquirerVerify(t *testing.T) {
|
||||
@@ -266,6 +281,7 @@ func TestConcurrencyInquirerVerify(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
count = 100
|
||||
errList := make([]error, count)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
wg.Add(1)
|
||||
go func(index int) {
|
||||
@@ -273,8 +289,11 @@ func TestConcurrencyInquirerVerify(t *testing.T) {
|
||||
defer wg.Done()
|
||||
}(i)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
for _, err := range errList {
|
||||
require.Nil(err)
|
||||
}
|
||||
|
||||
// TODO: Requires proposer address to be set in header.
|
||||
// for _, err := range errList {
|
||||
// require.Nil(err)
|
||||
// }
|
||||
}
|
||||
|
||||
+22
-22
@@ -27,13 +27,13 @@ var (
|
||||
vals = keys.ToValidators(20, 10)
|
||||
bTime, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
|
||||
h1 = keys.GenSignedHeader(chainID, 1, bTime, nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
// 3/3 signed
|
||||
h2 = keys.GenSignedHeaderLastBlockID(chainID, 2, bTime.Add(30*time.Minute), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys), types.BlockID{Hash: h1.Hash()})
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys), types.BlockID{Hash: h1.Hash()})
|
||||
// 3/3 signed
|
||||
h3 = keys.GenSignedHeaderLastBlockID(chainID, 3, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys), types.BlockID{Hash: h2.Hash()})
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys), types.BlockID{Hash: h2.Hash()})
|
||||
trustPeriod = 4 * time.Hour
|
||||
trustOptions = lite.TrustOptions{
|
||||
Period: 4 * time.Hour,
|
||||
@@ -85,7 +85,7 @@ func TestClient_SequentialVerification(t *testing.T) {
|
||||
map[int64]*types.SignedHeader{
|
||||
// different header
|
||||
1: keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
},
|
||||
map[int64]*types.ValidatorSet{
|
||||
1: vals,
|
||||
@@ -100,10 +100,10 @@ func TestClient_SequentialVerification(t *testing.T) {
|
||||
1: h1,
|
||||
// interim header (1/3 signed)
|
||||
2: keys.GenSignedHeader(chainID, 2, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), len(keys)-1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), len(keys)-1, len(keys)),
|
||||
// last header (3/3 signed)
|
||||
3: keys.GenSignedHeader(chainID, 3, bTime.Add(2*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
},
|
||||
valSet,
|
||||
false,
|
||||
@@ -116,10 +116,10 @@ func TestClient_SequentialVerification(t *testing.T) {
|
||||
1: h1,
|
||||
// interim header (3/3 signed)
|
||||
2: keys.GenSignedHeader(chainID, 2, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
// last header (1/3 signed)
|
||||
3: keys.GenSignedHeader(chainID, 3, bTime.Add(2*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), len(keys)-1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), len(keys)-1, len(keys)),
|
||||
},
|
||||
valSet,
|
||||
false,
|
||||
@@ -209,7 +209,7 @@ func TestClient_SkippingVerification(t *testing.T) {
|
||||
// trusted header
|
||||
1: h1,
|
||||
3: transitKeys.GenSignedHeader(chainID, 3, bTime.Add(2*time.Hour), nil, transitVals, transitVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(transitKeys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(transitKeys)),
|
||||
},
|
||||
map[int64]*types.ValidatorSet{
|
||||
1: vals,
|
||||
@@ -226,10 +226,10 @@ func TestClient_SkippingVerification(t *testing.T) {
|
||||
1: h1,
|
||||
// interim header (3/3 signed)
|
||||
2: keys.GenSignedHeader(chainID, 2, bTime.Add(1*time.Hour), nil, vals, newVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
// last header (0/4 of the original val set signed)
|
||||
3: newKeys.GenSignedHeader(chainID, 3, bTime.Add(2*time.Hour), nil, newVals, newVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(newKeys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(newKeys)),
|
||||
},
|
||||
map[int64]*types.ValidatorSet{
|
||||
1: vals,
|
||||
@@ -246,10 +246,10 @@ func TestClient_SkippingVerification(t *testing.T) {
|
||||
1: h1,
|
||||
// last header (0/4 of the original val set signed)
|
||||
2: keys.GenSignedHeader(chainID, 2, bTime.Add(1*time.Hour), nil, vals, newVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, 0),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, 0),
|
||||
// last header (0/4 of the original val set signed)
|
||||
3: newKeys.GenSignedHeader(chainID, 3, bTime.Add(2*time.Hour), nil, newVals, newVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(newKeys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(newKeys)),
|
||||
},
|
||||
map[int64]*types.ValidatorSet{
|
||||
1: vals,
|
||||
@@ -362,7 +362,7 @@ func TestClientRestoresTrustedHeaderAfterStartup1(t *testing.T) {
|
||||
|
||||
// header1 != header
|
||||
header1 := keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
|
||||
primary := mockp.New(
|
||||
chainID,
|
||||
@@ -447,10 +447,10 @@ func TestClientRestoresTrustedHeaderAfterStartup2(t *testing.T) {
|
||||
|
||||
// header1 != header
|
||||
diffHeader1 := keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
|
||||
diffHeader2 := keys.GenSignedHeader(chainID, 2, bTime.Add(2*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
|
||||
primary := mockp.New(
|
||||
chainID,
|
||||
@@ -541,10 +541,10 @@ func TestClientRestoresTrustedHeaderAfterStartup3(t *testing.T) {
|
||||
|
||||
// header1 != header
|
||||
header1 := keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
|
||||
header2 := keys.GenSignedHeader(chainID, 2, bTime.Add(2*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
err = trustedStore.SaveSignedHeaderAndValidatorSet(header2, vals)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -748,7 +748,7 @@ func TestClient_BackwardsVerification(t *testing.T) {
|
||||
map[int64]*types.SignedHeader{
|
||||
1: h1,
|
||||
2: keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
3: h3,
|
||||
},
|
||||
valSet,
|
||||
@@ -761,7 +761,7 @@ func TestClient_BackwardsVerification(t *testing.T) {
|
||||
map[int64]*types.SignedHeader{
|
||||
1: h1,
|
||||
2: keys.GenSignedHeader(chainID, 2, bTime.Add(30*time.Minute), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
3: h3,
|
||||
},
|
||||
valSet,
|
||||
@@ -841,7 +841,7 @@ func TestClientRemovesWitnessIfItSendsUsIncorrectHeader(t *testing.T) {
|
||||
map[int64]*types.SignedHeader{
|
||||
1: h1,
|
||||
2: keys.GenSignedHeaderLastBlockID(chainID, 2, bTime.Add(30*time.Minute), nil, vals, vals,
|
||||
[]byte("app_hash2"), []byte("cons_hash"), []byte("results_hash"),
|
||||
hash("app_hash2"), hash("cons_hash"), hash("results_hash"),
|
||||
len(keys), len(keys), types.BlockID{Hash: h1.Hash()}),
|
||||
},
|
||||
map[int64]*types.ValidatorSet{
|
||||
@@ -913,7 +913,7 @@ func TestClientTrustedValidatorSet(t *testing.T) {
|
||||
func TestClientReportsConflictingHeadersEvidence(t *testing.T) {
|
||||
// fullNode2 sends us different header
|
||||
altH2 := keys.GenSignedHeaderLastBlockID(chainID, 2, bTime.Add(30*time.Minute), nil, vals, vals,
|
||||
[]byte("app_hash2"), []byte("cons_hash"), []byte("results_hash"),
|
||||
hash("app_hash2"), hash("cons_hash"), hash("results_hash"),
|
||||
0, len(keys), types.BlockID{Hash: h1.Hash()})
|
||||
fullNode2 := mockp.New(
|
||||
chainID,
|
||||
|
||||
+10
-4
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
@@ -134,6 +135,7 @@ func genHeader(chainID string, height int64, bTime time.Time, txs types.Txs,
|
||||
AppHash: appHash,
|
||||
ConsensusHash: consHash,
|
||||
LastResultsHash: resHash,
|
||||
ProposerAddress: valset.Validators[0].Address,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +196,8 @@ func GenMockNode(
|
||||
|
||||
// genesis header and vals
|
||||
lastHeader := keys.GenSignedHeader(chainID, 1, bTime.Add(1*time.Minute), nil,
|
||||
keys.ToValidators(2, 2), newKeys.ToValidators(2, 2), []byte("app_hash"), []byte("cons_hash"),
|
||||
[]byte("results_hash"), 0, len(keys))
|
||||
keys.ToValidators(2, 2), newKeys.ToValidators(2, 2), hash("app_hash"), hash("cons_hash"),
|
||||
hash("results_hash"), 0, len(keys))
|
||||
currentHeader := lastHeader
|
||||
headers[1] = currentHeader
|
||||
valset[1] = keys.ToValidators(2, 2)
|
||||
@@ -208,8 +210,8 @@ func GenMockNode(
|
||||
newKeys = keys.ChangeKeys(valVariationInt)
|
||||
currentHeader = keys.GenSignedHeaderLastBlockID(chainID, height, bTime.Add(time.Duration(height)*time.Minute),
|
||||
nil,
|
||||
keys.ToValidators(2, 2), newKeys.ToValidators(2, 2), []byte("app_hash"), []byte("cons_hash"),
|
||||
[]byte("results_hash"), 0, len(keys), types.BlockID{Hash: lastHeader.Hash()})
|
||||
keys.ToValidators(2, 2), newKeys.ToValidators(2, 2), hash("app_hash"), hash("cons_hash"),
|
||||
hash("results_hash"), 0, len(keys), types.BlockID{Hash: lastHeader.Hash()})
|
||||
headers[height] = currentHeader
|
||||
valset[height] = keys.ToValidators(2, 2)
|
||||
lastHeader = currentHeader
|
||||
@@ -218,3 +220,7 @@ func GenMockNode(
|
||||
|
||||
return chainID, headers, valset
|
||||
}
|
||||
|
||||
func hash(s string) []byte {
|
||||
return tmhash.Sum([]byte(s))
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package http
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/lite2/provider"
|
||||
@@ -11,6 +12,9 @@ import (
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// This is very brittle, see: https://github.com/tendermint/tendermint/issues/4740
|
||||
var regexpMissingHeight = regexp.MustCompile(`height \d+ (must be less than or equal to|is not available)`)
|
||||
|
||||
// http provider uses an RPC client to obtain the necessary information.
|
||||
type http struct {
|
||||
chainID string
|
||||
@@ -62,7 +66,7 @@ func (p *http) SignedHeader(height int64) (*types.SignedHeader, error) {
|
||||
commit, err := p.client.Commit(h)
|
||||
if err != nil {
|
||||
// TODO: standartise errors on the RPC side
|
||||
if strings.Contains(err.Error(), "height must be less than or equal") {
|
||||
if regexpMissingHeight.MatchString(err.Error()) {
|
||||
return nil, provider.ErrSignedHeaderNotFound
|
||||
}
|
||||
return nil, err
|
||||
@@ -92,7 +96,7 @@ func (p *http) ValidatorSet(height int64) (*types.ValidatorSet, error) {
|
||||
res, err := p.client.Validators(h, 0, maxPerPage)
|
||||
if err != nil {
|
||||
// TODO: standartise errors on the RPC side
|
||||
if strings.Contains(err.Error(), "height must be less than or equal") {
|
||||
if regexpMissingHeight.MatchString(err.Error()) {
|
||||
return nil, provider.ErrValidatorSetNotFound
|
||||
}
|
||||
return nil, err
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/tendermint/abci/example/kvstore"
|
||||
"github.com/tendermint/tendermint/lite2/provider"
|
||||
"github.com/tendermint/tendermint/lite2/provider/http"
|
||||
litehttp "github.com/tendermint/tendermint/lite2/provider/http"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
@@ -33,6 +34,7 @@ func TestNewProvider(t *testing.T) {
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
app := kvstore.NewApplication()
|
||||
app.RetainBlocks = 5
|
||||
node := rpctest.StartTendermint(app)
|
||||
|
||||
code := m.Run()
|
||||
@@ -73,8 +75,25 @@ func TestProvider(t *testing.T) {
|
||||
assert.Nil(t, sh.ValidateBasic(chainID))
|
||||
|
||||
// historical queries now work :)
|
||||
lower := sh.Height - 5
|
||||
lower := sh.Height - 3
|
||||
sh, err = p.SignedHeader(lower)
|
||||
assert.Nil(t, err, "%+v", err)
|
||||
assert.Equal(t, lower, sh.Height)
|
||||
|
||||
// fetching missing heights (both future and pruned) should return appropriate errors
|
||||
_, err = p.SignedHeader(1000)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, provider.ErrSignedHeaderNotFound, err)
|
||||
|
||||
_, err = p.ValidatorSet(1000)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, provider.ErrValidatorSetNotFound, err)
|
||||
|
||||
_, err = p.SignedHeader(1)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, provider.ErrSignedHeaderNotFound, err)
|
||||
|
||||
_, err = p.ValidatorSet(1)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, provider.ErrValidatorSetNotFound, err)
|
||||
}
|
||||
|
||||
+19
-19
@@ -29,7 +29,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
vals = keys.ToValidators(20, 10)
|
||||
bTime, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
|
||||
header = keys.GenSignedHeader(chainID, lastHeight, bTime, nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
@@ -52,7 +52,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// different chainID -> error
|
||||
1: {
|
||||
keys.GenSignedHeader("different-chainID", nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -62,7 +62,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// new header's time is before old header's time -> error
|
||||
2: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(-1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -72,7 +72,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// new header's time is from the future -> error
|
||||
3: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(3*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -83,7 +83,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
4: {
|
||||
keys.GenSignedHeader(chainID, nextHeight,
|
||||
bTime.Add(2*time.Hour).Add(maxClockDrift).Add(-1*time.Millisecond), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -93,7 +93,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// 3/3 signed -> no error
|
||||
5: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -103,7 +103,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// 2/3 signed -> no error
|
||||
6: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 1, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -113,7 +113,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// 1/3 signed -> error
|
||||
7: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), len(keys)-1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), len(keys)-1, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -123,7 +123,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// vals does not match with what we have -> error
|
||||
8: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, keys.ToValidators(10, 1), vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
keys.ToValidators(10, 1),
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -133,7 +133,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// vals are inconsistent with newHeader -> error
|
||||
9: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
keys.ToValidators(10, 1),
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -143,7 +143,7 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
|
||||
// old header has expired -> error
|
||||
10: {
|
||||
keys.GenSignedHeader(chainID, nextHeight, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
keys.ToValidators(10, 1),
|
||||
1 * time.Hour,
|
||||
bTime.Add(1 * time.Hour),
|
||||
@@ -181,7 +181,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
vals = keys.ToValidators(20, 10)
|
||||
bTime, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
|
||||
header = keys.GenSignedHeader(chainID, lastHeight, bTime, nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
|
||||
// 30, 40, 50
|
||||
twoThirds = keys[1:]
|
||||
@@ -207,7 +207,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 3/3 new vals signed, 3/3 old vals present -> no error
|
||||
0: {
|
||||
keys.GenSignedHeader(chainID, 3, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -217,7 +217,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 2/3 new vals signed, 3/3 old vals present -> no error
|
||||
1: {
|
||||
keys.GenSignedHeader(chainID, 4, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 1, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -227,7 +227,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 1/3 new vals signed, 3/3 old vals present -> error
|
||||
2: {
|
||||
keys.GenSignedHeader(chainID, 5, bTime.Add(1*time.Hour), nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), len(keys)-1, len(keys)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), len(keys)-1, len(keys)),
|
||||
vals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -237,7 +237,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 3/3 new vals signed, 2/3 old vals present -> no error
|
||||
3: {
|
||||
twoThirds.GenSignedHeader(chainID, 5, bTime.Add(1*time.Hour), nil, twoThirdsVals, twoThirdsVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(twoThirds)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(twoThirds)),
|
||||
twoThirdsVals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -247,7 +247,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 3/3 new vals signed, 1/3 old vals present -> no error
|
||||
4: {
|
||||
oneThird.GenSignedHeader(chainID, 5, bTime.Add(1*time.Hour), nil, oneThirdVals, oneThirdVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(oneThird)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(oneThird)),
|
||||
oneThirdVals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -257,7 +257,7 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
|
||||
// 3/3 new vals signed, less than 1/3 old vals present -> error
|
||||
5: {
|
||||
lessThanOneThird.GenSignedHeader(chainID, 5, bTime.Add(1*time.Hour), nil, lessThanOneThirdVals, lessThanOneThirdVals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(lessThanOneThird)),
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(lessThanOneThird)),
|
||||
lessThanOneThirdVals,
|
||||
3 * time.Hour,
|
||||
bTime.Add(2 * time.Hour),
|
||||
@@ -297,7 +297,7 @@ func TestVerifyReturnsErrorIfTrustLevelIsInvalid(t *testing.T) {
|
||||
vals = keys.ToValidators(20, 10)
|
||||
bTime, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
|
||||
header = keys.GenSignedHeader(chainID, lastHeight, bTime, nil, vals, vals,
|
||||
[]byte("app_hash"), []byte("cons_hash"), []byte("results_hash"), 0, len(keys))
|
||||
hash("app_hash"), hash("cons_hash"), hash("results_hash"), 0, len(keys))
|
||||
)
|
||||
|
||||
err := lite.Verify(chainID, header, vals, header, vals, 2*time.Hour, time.Now(), maxClockDrift,
|
||||
|
||||
@@ -0,0 +1,593 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/crypto/keys/types.proto
|
||||
|
||||
package keys
|
||||
|
||||
import (
|
||||
bytes "bytes"
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type PublicKey struct {
|
||||
// Types that are valid to be assigned to Sum:
|
||||
// *PublicKey_Ed25519
|
||||
Sum isPublicKey_Sum `protobuf_oneof:"sum"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PublicKey) Reset() { *m = PublicKey{} }
|
||||
func (m *PublicKey) String() string { return proto.CompactTextString(m) }
|
||||
func (*PublicKey) ProtoMessage() {}
|
||||
func (*PublicKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_943d79b57ec0188f, []int{0}
|
||||
}
|
||||
func (m *PublicKey) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PublicKey.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PublicKey.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PublicKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PublicKey.Merge(m, src)
|
||||
}
|
||||
func (m *PublicKey) XXX_Size() int {
|
||||
return xxx_messageInfo_PublicKey.Size(m)
|
||||
}
|
||||
func (m *PublicKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PublicKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PublicKey proto.InternalMessageInfo
|
||||
|
||||
type isPublicKey_Sum interface {
|
||||
isPublicKey_Sum()
|
||||
Equal(interface{}) bool
|
||||
Compare(interface{}) int
|
||||
}
|
||||
|
||||
type PublicKey_Ed25519 struct {
|
||||
Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"`
|
||||
}
|
||||
|
||||
func (*PublicKey_Ed25519) isPublicKey_Sum() {}
|
||||
|
||||
func (m *PublicKey) GetSum() isPublicKey_Sum {
|
||||
if m != nil {
|
||||
return m.Sum
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PublicKey) GetEd25519() []byte {
|
||||
if x, ok := m.GetSum().(*PublicKey_Ed25519); ok {
|
||||
return x.Ed25519
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*PublicKey) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*PublicKey_Ed25519)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING PrivateKey is used for internal purposes only
|
||||
type PrivateKey struct {
|
||||
// Types that are valid to be assigned to Sum:
|
||||
// *PrivateKey_Ed25519
|
||||
Sum isPrivateKey_Sum `protobuf_oneof:"sum"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PrivateKey) Reset() { *m = PrivateKey{} }
|
||||
func (m *PrivateKey) String() string { return proto.CompactTextString(m) }
|
||||
func (*PrivateKey) ProtoMessage() {}
|
||||
func (*PrivateKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_943d79b57ec0188f, []int{1}
|
||||
}
|
||||
func (m *PrivateKey) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PrivateKey.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PrivateKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PrivateKey.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PrivateKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PrivateKey.Merge(m, src)
|
||||
}
|
||||
func (m *PrivateKey) XXX_Size() int {
|
||||
return xxx_messageInfo_PrivateKey.Size(m)
|
||||
}
|
||||
func (m *PrivateKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PrivateKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PrivateKey proto.InternalMessageInfo
|
||||
|
||||
type isPrivateKey_Sum interface {
|
||||
isPrivateKey_Sum()
|
||||
Equal(interface{}) bool
|
||||
Compare(interface{}) int
|
||||
}
|
||||
|
||||
type PrivateKey_Ed25519 struct {
|
||||
Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"`
|
||||
}
|
||||
|
||||
func (*PrivateKey_Ed25519) isPrivateKey_Sum() {}
|
||||
|
||||
func (m *PrivateKey) GetSum() isPrivateKey_Sum {
|
||||
if m != nil {
|
||||
return m.Sum
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PrivateKey) GetEd25519() []byte {
|
||||
if x, ok := m.GetSum().(*PrivateKey_Ed25519); ok {
|
||||
return x.Ed25519
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*PrivateKey) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*PrivateKey_Ed25519)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PublicKey)(nil), "tendermint.proto.crypto.keys.PublicKey")
|
||||
proto.RegisterType((*PrivateKey)(nil), "tendermint.proto.crypto.keys.PrivateKey")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/crypto/keys/types.proto", fileDescriptor_943d79b57ec0188f) }
|
||||
|
||||
var fileDescriptor_943d79b57ec0188f = []byte{
|
||||
// 190 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0xcf, 0x4e, 0xad, 0x2c, 0xd6, 0x2f, 0xa9,
|
||||
0x2c, 0x48, 0x2d, 0xd6, 0x03, 0x8b, 0x0b, 0xc9, 0x94, 0xa4, 0xe6, 0xa5, 0xa4, 0x16, 0xe5, 0x66,
|
||||
0xe6, 0x95, 0x40, 0x44, 0xf4, 0x20, 0x2a, 0xf5, 0x40, 0x2a, 0xa5, 0xd4, 0x4a, 0x32, 0x32, 0x8b,
|
||||
0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0x21, 0x06, 0xa5, 0xe7, 0xa7, 0xe7, 0x23, 0x58,
|
||||
0x10, 0x3d, 0x4a, 0x7a, 0x5c, 0x9c, 0x01, 0xa5, 0x49, 0x39, 0x99, 0xc9, 0xde, 0xa9, 0x95, 0x42,
|
||||
0x52, 0x5c, 0xec, 0xa9, 0x29, 0x46, 0xa6, 0xa6, 0x86, 0x96, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c,
|
||||
0x1e, 0x0c, 0x41, 0x30, 0x01, 0x27, 0x56, 0x2e, 0xe6, 0xe2, 0xd2, 0x5c, 0x25, 0x7d, 0x2e, 0xae,
|
||||
0x80, 0xa2, 0xcc, 0xb2, 0xc4, 0x92, 0x54, 0xe2, 0x34, 0x38, 0x39, 0xfc, 0x78, 0x28, 0xc7, 0xb8,
|
||||
0xe2, 0x91, 0x1c, 0xe3, 0x8a, 0xc7, 0x72, 0x8c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49,
|
||||
0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x08, 0xf7, 0x23, 0x33, 0x31, 0x3c, 0x9d, 0xc4, 0x06, 0x16, 0x32,
|
||||
0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x99, 0x5e, 0xad, 0xbd, 0x10, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *PublicKey) Compare(that interface{}) int {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
that1, ok := that.(*PublicKey)
|
||||
if !ok {
|
||||
that2, ok := that.(PublicKey)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
} else if this == nil {
|
||||
return -1
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return 1
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return -1
|
||||
} else {
|
||||
thisType := -1
|
||||
switch this.Sum.(type) {
|
||||
case *PublicKey_Ed25519:
|
||||
thisType = 0
|
||||
default:
|
||||
panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Sum))
|
||||
}
|
||||
that1Type := -1
|
||||
switch that1.Sum.(type) {
|
||||
case *PublicKey_Ed25519:
|
||||
that1Type = 0
|
||||
default:
|
||||
panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.Sum))
|
||||
}
|
||||
if thisType == that1Type {
|
||||
if c := this.Sum.Compare(that1.Sum); c != 0 {
|
||||
return c
|
||||
}
|
||||
} else if thisType < that1Type {
|
||||
return -1
|
||||
} else if thisType > that1Type {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
|
||||
return c
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (this *PublicKey_Ed25519) Compare(that interface{}) int {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
that1, ok := that.(*PublicKey_Ed25519)
|
||||
if !ok {
|
||||
that2, ok := that.(PublicKey_Ed25519)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
} else if this == nil {
|
||||
return -1
|
||||
}
|
||||
if c := bytes.Compare(this.Ed25519, that1.Ed25519); c != 0 {
|
||||
return c
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (this *PrivateKey) Compare(that interface{}) int {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
that1, ok := that.(*PrivateKey)
|
||||
if !ok {
|
||||
that2, ok := that.(PrivateKey)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
} else if this == nil {
|
||||
return -1
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return 1
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return -1
|
||||
} else {
|
||||
thisType := -1
|
||||
switch this.Sum.(type) {
|
||||
case *PrivateKey_Ed25519:
|
||||
thisType = 0
|
||||
default:
|
||||
panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Sum))
|
||||
}
|
||||
that1Type := -1
|
||||
switch that1.Sum.(type) {
|
||||
case *PrivateKey_Ed25519:
|
||||
that1Type = 0
|
||||
default:
|
||||
panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.Sum))
|
||||
}
|
||||
if thisType == that1Type {
|
||||
if c := this.Sum.Compare(that1.Sum); c != 0 {
|
||||
return c
|
||||
}
|
||||
} else if thisType < that1Type {
|
||||
return -1
|
||||
} else if thisType > that1Type {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
|
||||
return c
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (this *PrivateKey_Ed25519) Compare(that interface{}) int {
|
||||
if that == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
that1, ok := that.(*PrivateKey_Ed25519)
|
||||
if !ok {
|
||||
that2, ok := that.(PrivateKey_Ed25519)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
if this == nil {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
} else if this == nil {
|
||||
return -1
|
||||
}
|
||||
if c := bytes.Compare(this.Ed25519, that1.Ed25519); c != 0 {
|
||||
return c
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (this *PublicKey) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*PublicKey)
|
||||
if !ok {
|
||||
that2, ok := that.(PublicKey)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return false
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return false
|
||||
} else if !this.Sum.Equal(that1.Sum) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *PublicKey_Ed25519) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*PublicKey_Ed25519)
|
||||
if !ok {
|
||||
that2, ok := that.(PublicKey_Ed25519)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.Ed25519, that1.Ed25519) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *PrivateKey) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*PrivateKey)
|
||||
if !ok {
|
||||
that2, ok := that.(PrivateKey)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return false
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return false
|
||||
} else if !this.Sum.Equal(that1.Sum) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *PrivateKey_Ed25519) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*PrivateKey_Ed25519)
|
||||
if !ok {
|
||||
that2, ok := that.(PrivateKey_Ed25519)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.Ed25519, that1.Ed25519) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func NewPopulatedPublicKey(r randyTypes, easy bool) *PublicKey {
|
||||
this := &PublicKey{}
|
||||
oneofNumber_Sum := []int32{1}[r.Intn(1)]
|
||||
switch oneofNumber_Sum {
|
||||
case 1:
|
||||
this.Sum = NewPopulatedPublicKey_Ed25519(r, easy)
|
||||
}
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedTypes(r, 2)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
func NewPopulatedPublicKey_Ed25519(r randyTypes, easy bool) *PublicKey_Ed25519 {
|
||||
this := &PublicKey_Ed25519{}
|
||||
v1 := r.Intn(100)
|
||||
this.Ed25519 = make([]byte, v1)
|
||||
for i := 0; i < v1; i++ {
|
||||
this.Ed25519[i] = byte(r.Intn(256))
|
||||
}
|
||||
return this
|
||||
}
|
||||
func NewPopulatedPrivateKey(r randyTypes, easy bool) *PrivateKey {
|
||||
this := &PrivateKey{}
|
||||
oneofNumber_Sum := []int32{1}[r.Intn(1)]
|
||||
switch oneofNumber_Sum {
|
||||
case 1:
|
||||
this.Sum = NewPopulatedPrivateKey_Ed25519(r, easy)
|
||||
}
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedTypes(r, 2)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
func NewPopulatedPrivateKey_Ed25519(r randyTypes, easy bool) *PrivateKey_Ed25519 {
|
||||
this := &PrivateKey_Ed25519{}
|
||||
v2 := r.Intn(100)
|
||||
this.Ed25519 = make([]byte, v2)
|
||||
for i := 0; i < v2; i++ {
|
||||
this.Ed25519[i] = byte(r.Intn(256))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
type randyTypes interface {
|
||||
Float32() float32
|
||||
Float64() float64
|
||||
Int63() int64
|
||||
Int31() int32
|
||||
Uint32() uint32
|
||||
Intn(n int) int
|
||||
}
|
||||
|
||||
func randUTF8RuneTypes(r randyTypes) rune {
|
||||
ru := r.Intn(62)
|
||||
if ru < 10 {
|
||||
return rune(ru + 48)
|
||||
} else if ru < 36 {
|
||||
return rune(ru + 55)
|
||||
}
|
||||
return rune(ru + 61)
|
||||
}
|
||||
func randStringTypes(r randyTypes) string {
|
||||
v3 := r.Intn(100)
|
||||
tmps := make([]rune, v3)
|
||||
for i := 0; i < v3; i++ {
|
||||
tmps[i] = randUTF8RuneTypes(r)
|
||||
}
|
||||
return string(tmps)
|
||||
}
|
||||
func randUnrecognizedTypes(r randyTypes, maxFieldNumber int) (dAtA []byte) {
|
||||
l := r.Intn(5)
|
||||
for i := 0; i < l; i++ {
|
||||
wire := r.Intn(4)
|
||||
if wire == 3 {
|
||||
wire = 5
|
||||
}
|
||||
fieldNumber := maxFieldNumber + r.Intn(100)
|
||||
dAtA = randFieldTypes(dAtA, r, fieldNumber, wire)
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func randFieldTypes(dAtA []byte, r randyTypes, fieldNumber int, wire int) []byte {
|
||||
key := uint32(fieldNumber)<<3 | uint32(wire)
|
||||
switch wire {
|
||||
case 0:
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(key))
|
||||
v4 := r.Int63()
|
||||
if r.Intn(2) == 0 {
|
||||
v4 *= -1
|
||||
}
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(v4))
|
||||
case 1:
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
case 2:
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(key))
|
||||
ll := r.Intn(100)
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(ll))
|
||||
for j := 0; j < ll; j++ {
|
||||
dAtA = append(dAtA, byte(r.Intn(256)))
|
||||
}
|
||||
default:
|
||||
dAtA = encodeVarintPopulateTypes(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func encodeVarintPopulateTypes(dAtA []byte, v uint64) []byte {
|
||||
for v >= 1<<7 {
|
||||
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
|
||||
v >>= 7
|
||||
}
|
||||
dAtA = append(dAtA, uint8(v))
|
||||
return dAtA
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.crypto.keys;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/crypto/keys";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.equal_all) = true;
|
||||
option (gogoproto.compare_all) = true;
|
||||
option (gogoproto.populate_all) = true;
|
||||
|
||||
message PublicKey {
|
||||
oneof sum {
|
||||
bytes ed25519 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING PrivateKey is used for internal purposes only
|
||||
message PrivateKey {
|
||||
oneof sum {
|
||||
bytes ed25519 = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/evidence/msgs.proto
|
||||
|
||||
package evidence
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
types "github.com/tendermint/tendermint/proto/types"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type List struct {
|
||||
Evidence []types.Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *List) Reset() { *m = List{} }
|
||||
func (m *List) String() string { return proto.CompactTextString(m) }
|
||||
func (*List) ProtoMessage() {}
|
||||
func (*List) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_df8322769b0bd7d6, []int{0}
|
||||
}
|
||||
func (m *List) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_List.Unmarshal(m, b)
|
||||
}
|
||||
func (m *List) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_List.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *List) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_List.Merge(m, src)
|
||||
}
|
||||
func (m *List) XXX_Size() int {
|
||||
return xxx_messageInfo_List.Size(m)
|
||||
}
|
||||
func (m *List) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_List.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_List proto.InternalMessageInfo
|
||||
|
||||
func (m *List) GetEvidence() []types.Evidence {
|
||||
if m != nil {
|
||||
return m.Evidence
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
Committed bool `protobuf:"varint,1,opt,name=committed,proto3" json:"committed,omitempty"`
|
||||
Priority int64 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"`
|
||||
Evidence types.Evidence `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Info) Reset() { *m = Info{} }
|
||||
func (m *Info) String() string { return proto.CompactTextString(m) }
|
||||
func (*Info) ProtoMessage() {}
|
||||
func (*Info) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_df8322769b0bd7d6, []int{1}
|
||||
}
|
||||
func (m *Info) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Info.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Info.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Info) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Info.Merge(m, src)
|
||||
}
|
||||
func (m *Info) XXX_Size() int {
|
||||
return xxx_messageInfo_Info.Size(m)
|
||||
}
|
||||
func (m *Info) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Info.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Info proto.InternalMessageInfo
|
||||
|
||||
func (m *Info) GetCommitted() bool {
|
||||
if m != nil {
|
||||
return m.Committed
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *Info) GetPriority() int64 {
|
||||
if m != nil {
|
||||
return m.Priority
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Info) GetEvidence() types.Evidence {
|
||||
if m != nil {
|
||||
return m.Evidence
|
||||
}
|
||||
return types.Evidence{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*List)(nil), "tendermint.proto.evidence.List")
|
||||
proto.RegisterType((*Info)(nil), "tendermint.proto.evidence.Info")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/evidence/msgs.proto", fileDescriptor_df8322769b0bd7d6) }
|
||||
|
||||
var fileDescriptor_df8322769b0bd7d6 = []byte{
|
||||
// 228 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0x4f, 0x2d, 0xcb, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0xcf, 0x2d, 0x4e, 0x2f, 0xd6,
|
||||
0x03, 0x8b, 0x09, 0x49, 0x96, 0xa4, 0xe6, 0xa5, 0xa4, 0x16, 0xe5, 0x66, 0xe6, 0x95, 0x40, 0x44,
|
||||
0xf4, 0x60, 0xaa, 0xa4, 0xd4, 0x4a, 0x32, 0x32, 0x8b, 0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a,
|
||||
0xf5, 0x21, 0x26, 0xa4, 0xe7, 0xa7, 0xe7, 0x23, 0x58, 0x10, 0x0d, 0x52, 0x52, 0x10, 0x91, 0x92,
|
||||
0xca, 0x82, 0xd4, 0x62, 0xb8, 0x1d, 0x10, 0x39, 0x25, 0x2f, 0x2e, 0x16, 0x9f, 0xcc, 0xe2, 0x12,
|
||||
0x21, 0x27, 0x2e, 0x0e, 0x98, 0x8c, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x82, 0x1e, 0x86,
|
||||
0xcd, 0x60, 0x13, 0xf4, 0x5c, 0xa1, 0xea, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xeb,
|
||||
0x53, 0x6a, 0x61, 0xe4, 0x62, 0xf1, 0xcc, 0x4b, 0xcb, 0x17, 0x92, 0xe1, 0xe2, 0x4c, 0xce, 0xcf,
|
||||
0xcd, 0xcd, 0x2c, 0x29, 0x49, 0x4d, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x08, 0x42, 0x08, 0x08,
|
||||
0x49, 0x71, 0x71, 0x14, 0x14, 0x65, 0xe6, 0x17, 0x65, 0x96, 0x54, 0x4a, 0x30, 0x29, 0x30, 0x6a,
|
||||
0x30, 0x07, 0xc1, 0xf9, 0x28, 0xce, 0x60, 0x56, 0x60, 0x24, 0xc7, 0x19, 0x4e, 0x86, 0x51, 0xfa,
|
||||
0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x08, 0xdd, 0xc8, 0x4c, 0xd4,
|
||||
0xf0, 0x4e, 0x62, 0x03, 0xf3, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x66, 0x20, 0x26,
|
||||
0x88, 0x01, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.evidence;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/evidence";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "proto/types/evidence.proto";
|
||||
|
||||
message List {
|
||||
repeated tendermint.proto.types.Evidence evidence = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message Info {
|
||||
bool committed = 1;
|
||||
int64 priority = 2;
|
||||
tendermint.proto.types.Evidence evidence = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/libs/bits/types.proto
|
||||
|
||||
package bits
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type BitArray struct {
|
||||
Bits int64 `protobuf:"varint,1,opt,name=bits,proto3" json:"bits,omitempty"`
|
||||
Elems []uint64 `protobuf:"varint,2,rep,packed,name=elems,proto3" json:"elems,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BitArray) Reset() { *m = BitArray{} }
|
||||
func (m *BitArray) String() string { return proto.CompactTextString(m) }
|
||||
func (*BitArray) ProtoMessage() {}
|
||||
func (*BitArray) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3f1fbe70d7999e09, []int{0}
|
||||
}
|
||||
func (m *BitArray) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BitArray.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BitArray) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BitArray.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BitArray) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BitArray.Merge(m, src)
|
||||
}
|
||||
func (m *BitArray) XXX_Size() int {
|
||||
return xxx_messageInfo_BitArray.Size(m)
|
||||
}
|
||||
func (m *BitArray) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BitArray.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BitArray proto.InternalMessageInfo
|
||||
|
||||
func (m *BitArray) GetBits() int64 {
|
||||
if m != nil {
|
||||
return m.Bits
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BitArray) GetElems() []uint64 {
|
||||
if m != nil {
|
||||
return m.Elems
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*BitArray)(nil), "tendermint.proto.libs.bits.BitArray")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/libs/bits/types.proto", fileDescriptor_3f1fbe70d7999e09) }
|
||||
|
||||
var fileDescriptor_3f1fbe70d7999e09 = []byte{
|
||||
// 140 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0xcf, 0xc9, 0x4c, 0x2a, 0xd6, 0x4f, 0xca, 0x2c, 0x29, 0xd6, 0x2f, 0xa9, 0x2c, 0x48,
|
||||
0x2d, 0xd6, 0x03, 0x8b, 0x0a, 0x49, 0x95, 0xa4, 0xe6, 0xa5, 0xa4, 0x16, 0xe5, 0x66, 0xe6, 0x95,
|
||||
0x40, 0x44, 0xf4, 0x40, 0xea, 0xf4, 0x40, 0xea, 0x94, 0x4c, 0xb8, 0x38, 0x9c, 0x32, 0x4b, 0x1c,
|
||||
0x8b, 0x8a, 0x12, 0x2b, 0x85, 0x84, 0xb8, 0x58, 0x40, 0x62, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc,
|
||||
0x41, 0x60, 0xb6, 0x90, 0x08, 0x17, 0x6b, 0x6a, 0x4e, 0x6a, 0x6e, 0xb1, 0x04, 0x93, 0x02, 0xb3,
|
||||
0x06, 0x4b, 0x10, 0x84, 0xe3, 0x64, 0x14, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97,
|
||||
0x9c, 0x9f, 0xab, 0x8f, 0x30, 0x1e, 0x99, 0x89, 0xe6, 0xa2, 0x24, 0x36, 0xb0, 0x80, 0x31, 0x20,
|
||||
0x00, 0x00, 0xff, 0xff, 0x49, 0xc4, 0x52, 0x81, 0xab, 0x00, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.libs.bits;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/libs/bits";
|
||||
|
||||
message BitArray {
|
||||
int64 bits = 1;
|
||||
repeated uint64 elems = 2;
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/state/types.proto
|
||||
|
||||
package state
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
types "github.com/tendermint/tendermint/abci/types"
|
||||
types1 "github.com/tendermint/tendermint/proto/types"
|
||||
version "github.com/tendermint/tendermint/proto/version"
|
||||
math "math"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// ABCIResponses retains the responses
|
||||
// of the various ABCI calls during block processing.
|
||||
// It is persisted to disk for each height before calling Commit.
|
||||
type ABCIResponses struct {
|
||||
DeliverTxs []*types.ResponseDeliverTx `protobuf:"bytes,1,rep,name=deliver_txs,json=deliverTxs,proto3" json:"deliver_txs,omitempty"`
|
||||
EndBlock *types.ResponseEndBlock `protobuf:"bytes,2,opt,name=end_block,json=endBlock,proto3" json:"end_block,omitempty"`
|
||||
BeginBlock *types.ResponseBeginBlock `protobuf:"bytes,3,opt,name=begin_block,json=beginBlock,proto3" json:"begin_block,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ABCIResponses) Reset() { *m = ABCIResponses{} }
|
||||
func (m *ABCIResponses) String() string { return proto.CompactTextString(m) }
|
||||
func (*ABCIResponses) ProtoMessage() {}
|
||||
func (*ABCIResponses) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_00e69fef8162ea9b, []int{0}
|
||||
}
|
||||
func (m *ABCIResponses) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ABCIResponses.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ABCIResponses) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ABCIResponses.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ABCIResponses) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ABCIResponses.Merge(m, src)
|
||||
}
|
||||
func (m *ABCIResponses) XXX_Size() int {
|
||||
return xxx_messageInfo_ABCIResponses.Size(m)
|
||||
}
|
||||
func (m *ABCIResponses) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ABCIResponses.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ABCIResponses proto.InternalMessageInfo
|
||||
|
||||
func (m *ABCIResponses) GetDeliverTxs() []*types.ResponseDeliverTx {
|
||||
if m != nil {
|
||||
return m.DeliverTxs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ABCIResponses) GetEndBlock() *types.ResponseEndBlock {
|
||||
if m != nil {
|
||||
return m.EndBlock
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ABCIResponses) GetBeginBlock() *types.ResponseBeginBlock {
|
||||
if m != nil {
|
||||
return m.BeginBlock
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidatorsInfo represents the latest validator set, or the last height it changed
|
||||
type ValidatorsInfo struct {
|
||||
ValidatorSet *types1.ValidatorSet `protobuf:"bytes,1,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty"`
|
||||
LastHeightChanged int64 `protobuf:"varint,2,opt,name=last_height_changed,json=lastHeightChanged,proto3" json:"last_height_changed,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ValidatorsInfo) Reset() { *m = ValidatorsInfo{} }
|
||||
func (m *ValidatorsInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*ValidatorsInfo) ProtoMessage() {}
|
||||
func (*ValidatorsInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_00e69fef8162ea9b, []int{1}
|
||||
}
|
||||
func (m *ValidatorsInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ValidatorsInfo.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ValidatorsInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ValidatorsInfo.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ValidatorsInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ValidatorsInfo.Merge(m, src)
|
||||
}
|
||||
func (m *ValidatorsInfo) XXX_Size() int {
|
||||
return xxx_messageInfo_ValidatorsInfo.Size(m)
|
||||
}
|
||||
func (m *ValidatorsInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ValidatorsInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ValidatorsInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *ValidatorsInfo) GetValidatorSet() *types1.ValidatorSet {
|
||||
if m != nil {
|
||||
return m.ValidatorSet
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ValidatorsInfo) GetLastHeightChanged() int64 {
|
||||
if m != nil {
|
||||
return m.LastHeightChanged
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ConsensusParamsInfo represents the latest consensus params, or the last height it changed
|
||||
type ConsensusParamsInfo struct {
|
||||
ConsensusParams types1.ConsensusParams `protobuf:"bytes,1,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"`
|
||||
LastHeightChanged int64 `protobuf:"varint,2,opt,name=last_height_changed,json=lastHeightChanged,proto3" json:"last_height_changed,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ConsensusParamsInfo) Reset() { *m = ConsensusParamsInfo{} }
|
||||
func (m *ConsensusParamsInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*ConsensusParamsInfo) ProtoMessage() {}
|
||||
func (*ConsensusParamsInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_00e69fef8162ea9b, []int{2}
|
||||
}
|
||||
func (m *ConsensusParamsInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ConsensusParamsInfo.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ConsensusParamsInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ConsensusParamsInfo.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ConsensusParamsInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ConsensusParamsInfo.Merge(m, src)
|
||||
}
|
||||
func (m *ConsensusParamsInfo) XXX_Size() int {
|
||||
return xxx_messageInfo_ConsensusParamsInfo.Size(m)
|
||||
}
|
||||
func (m *ConsensusParamsInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ConsensusParamsInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ConsensusParamsInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *ConsensusParamsInfo) GetConsensusParams() types1.ConsensusParams {
|
||||
if m != nil {
|
||||
return m.ConsensusParams
|
||||
}
|
||||
return types1.ConsensusParams{}
|
||||
}
|
||||
|
||||
func (m *ConsensusParamsInfo) GetLastHeightChanged() int64 {
|
||||
if m != nil {
|
||||
return m.LastHeightChanged
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Version struct {
|
||||
Consensus version.Consensus `protobuf:"bytes,1,opt,name=consensus,proto3" json:"consensus"`
|
||||
Software string `protobuf:"bytes,2,opt,name=software,proto3" json:"software,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Version) Reset() { *m = Version{} }
|
||||
func (m *Version) String() string { return proto.CompactTextString(m) }
|
||||
func (*Version) ProtoMessage() {}
|
||||
func (*Version) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_00e69fef8162ea9b, []int{3}
|
||||
}
|
||||
func (m *Version) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Version.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Version.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Version) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Version.Merge(m, src)
|
||||
}
|
||||
func (m *Version) XXX_Size() int {
|
||||
return xxx_messageInfo_Version.Size(m)
|
||||
}
|
||||
func (m *Version) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Version.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Version proto.InternalMessageInfo
|
||||
|
||||
func (m *Version) GetConsensus() version.Consensus {
|
||||
if m != nil {
|
||||
return m.Consensus
|
||||
}
|
||||
return version.Consensus{}
|
||||
}
|
||||
|
||||
func (m *Version) GetSoftware() string {
|
||||
if m != nil {
|
||||
return m.Software
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type State struct {
|
||||
Version Version `protobuf:"bytes,1,opt,name=version,proto3" json:"version"`
|
||||
// immutable
|
||||
ChainID string `protobuf:"bytes,2,opt,name=chain_Id,json=chainId,proto3" json:"chain_Id,omitempty"`
|
||||
// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist)
|
||||
LastBlockHeight int64 `protobuf:"varint,3,opt,name=last_block_height,json=lastBlockHeight,proto3" json:"last_block_height,omitempty"`
|
||||
LastBlockID types1.BlockID `protobuf:"bytes,4,opt,name=last_block_id,json=lastBlockId,proto3" json:"last_block_id"`
|
||||
LastBlockTime time.Time `protobuf:"bytes,5,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time"`
|
||||
// LastValidators is used to validate block.LastCommit.
|
||||
// Validators are persisted to the database separately every time they change,
|
||||
// so we can query for historical validator sets.
|
||||
// Note that if s.LastBlockHeight causes a valset change,
|
||||
// we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1
|
||||
// Extra +1 due to nextValSet delay.
|
||||
NextValidators *types1.ValidatorSet `protobuf:"bytes,6,opt,name=next_validators,json=nextValidators,proto3" json:"next_validators,omitempty"`
|
||||
Validators *types1.ValidatorSet `protobuf:"bytes,7,opt,name=validators,proto3" json:"validators,omitempty"`
|
||||
LastValidators *types1.ValidatorSet `protobuf:"bytes,8,opt,name=last_validators,json=lastValidators,proto3" json:"last_validators,omitempty"`
|
||||
LastHeightValidatorsChanged int64 `protobuf:"varint,9,opt,name=last_height_validators_changed,json=lastHeightValidatorsChanged,proto3" json:"last_height_validators_changed,omitempty"`
|
||||
// Consensus parameters used for validating blocks.
|
||||
// Changes returned by EndBlock and updated after Commit.
|
||||
ConsensusParams types1.ConsensusParams `protobuf:"bytes,10,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"`
|
||||
LastHeightConsensusParamsChanged int64 `protobuf:"varint,11,opt,name=last_height_consensus_params_changed,json=lastHeightConsensusParamsChanged,proto3" json:"last_height_consensus_params_changed,omitempty"`
|
||||
// Merkle root of the results from executing prev block
|
||||
LastResultsHash []byte `protobuf:"bytes,12,opt,name=LastResultsHash,proto3" json:"LastResultsHash,omitempty"`
|
||||
// the latest AppHash we've received from calling abci.Commit()
|
||||
AppHash []byte `protobuf:"bytes,13,opt,name=AppHash,proto3" json:"AppHash,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *State) Reset() { *m = State{} }
|
||||
func (m *State) String() string { return proto.CompactTextString(m) }
|
||||
func (*State) ProtoMessage() {}
|
||||
func (*State) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_00e69fef8162ea9b, []int{4}
|
||||
}
|
||||
func (m *State) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_State.Unmarshal(m, b)
|
||||
}
|
||||
func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_State.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *State) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_State.Merge(m, src)
|
||||
}
|
||||
func (m *State) XXX_Size() int {
|
||||
return xxx_messageInfo_State.Size(m)
|
||||
}
|
||||
func (m *State) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_State.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_State proto.InternalMessageInfo
|
||||
|
||||
func (m *State) GetVersion() Version {
|
||||
if m != nil {
|
||||
return m.Version
|
||||
}
|
||||
return Version{}
|
||||
}
|
||||
|
||||
func (m *State) GetChainID() string {
|
||||
if m != nil {
|
||||
return m.ChainID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *State) GetLastBlockHeight() int64 {
|
||||
if m != nil {
|
||||
return m.LastBlockHeight
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *State) GetLastBlockID() types1.BlockID {
|
||||
if m != nil {
|
||||
return m.LastBlockID
|
||||
}
|
||||
return types1.BlockID{}
|
||||
}
|
||||
|
||||
func (m *State) GetLastBlockTime() time.Time {
|
||||
if m != nil {
|
||||
return m.LastBlockTime
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (m *State) GetNextValidators() *types1.ValidatorSet {
|
||||
if m != nil {
|
||||
return m.NextValidators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetValidators() *types1.ValidatorSet {
|
||||
if m != nil {
|
||||
return m.Validators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetLastValidators() *types1.ValidatorSet {
|
||||
if m != nil {
|
||||
return m.LastValidators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetLastHeightValidatorsChanged() int64 {
|
||||
if m != nil {
|
||||
return m.LastHeightValidatorsChanged
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *State) GetConsensusParams() types1.ConsensusParams {
|
||||
if m != nil {
|
||||
return m.ConsensusParams
|
||||
}
|
||||
return types1.ConsensusParams{}
|
||||
}
|
||||
|
||||
func (m *State) GetLastHeightConsensusParamsChanged() int64 {
|
||||
if m != nil {
|
||||
return m.LastHeightConsensusParamsChanged
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *State) GetLastResultsHash() []byte {
|
||||
if m != nil {
|
||||
return m.LastResultsHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetAppHash() []byte {
|
||||
if m != nil {
|
||||
return m.AppHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ABCIResponses)(nil), "tendermint.proto.state.ABCIResponses")
|
||||
proto.RegisterType((*ValidatorsInfo)(nil), "tendermint.proto.state.ValidatorsInfo")
|
||||
proto.RegisterType((*ConsensusParamsInfo)(nil), "tendermint.proto.state.ConsensusParamsInfo")
|
||||
proto.RegisterType((*Version)(nil), "tendermint.proto.state.Version")
|
||||
proto.RegisterType((*State)(nil), "tendermint.proto.state.State")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/state/types.proto", fileDescriptor_00e69fef8162ea9b) }
|
||||
|
||||
var fileDescriptor_00e69fef8162ea9b = []byte{
|
||||
// 722 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x5d, 0x6a, 0xdb, 0x40,
|
||||
0x10, 0xae, 0xea, 0x24, 0xb6, 0x47, 0x71, 0xdc, 0x6e, 0x20, 0x15, 0x0e, 0xd4, 0xc6, 0x0d, 0x89,
|
||||
0x5b, 0x8a, 0x0c, 0xe9, 0x01, 0x4a, 0x64, 0x97, 0x46, 0x25, 0x2d, 0x45, 0x09, 0x21, 0xf4, 0x45,
|
||||
0xc8, 0xd6, 0x46, 0x12, 0xb5, 0x25, 0xa1, 0x5d, 0xbb, 0xc9, 0x19, 0xfa, 0xd2, 0x1b, 0xf4, 0x3a,
|
||||
0xbd, 0x43, 0x21, 0x85, 0x3c, 0xf7, 0x10, 0x65, 0x7f, 0x24, 0x6d, 0x9c, 0x84, 0x60, 0xe8, 0x93,
|
||||
0x57, 0x33, 0xf3, 0x7d, 0xf3, 0xcd, 0xee, 0x37, 0x18, 0x9e, 0xa5, 0x59, 0x42, 0x93, 0x3e, 0xa1,
|
||||
0x1e, 0xc5, 0x7d, 0x7a, 0x99, 0x62, 0x62, 0xf2, 0x08, 0xda, 0xa2, 0x38, 0xf6, 0x71, 0x36, 0x8d,
|
||||
0x62, 0x2a, 0x22, 0x26, 0xaf, 0x69, 0xed, 0xd2, 0x30, 0xca, 0x7c, 0x37, 0xf5, 0x32, 0x7a, 0xd9,
|
||||
0x17, 0xe0, 0x20, 0x09, 0x92, 0xf2, 0x24, 0xaa, 0x5b, 0x5b, 0xde, 0x68, 0x1c, 0x09, 0x46, 0x95,
|
||||
0xb7, 0x25, 0x1b, 0xde, 0x4e, 0x6c, 0xab, 0x89, 0xb9, 0x37, 0x89, 0x7c, 0x8f, 0x26, 0x99, 0x4c,
|
||||
0x1a, 0x6a, 0x32, 0xf5, 0x32, 0x6f, 0xba, 0x00, 0x9b, 0xe3, 0x8c, 0x44, 0x49, 0x9c, 0xff, 0xca,
|
||||
0x64, 0x3b, 0x48, 0x92, 0x60, 0x82, 0x85, 0xce, 0xd1, 0xec, 0xbc, 0x4f, 0xa3, 0x29, 0x26, 0xd4,
|
||||
0x9b, 0xa6, 0xa2, 0xa0, 0xfb, 0x57, 0x83, 0xc6, 0x81, 0x35, 0xb0, 0x1d, 0x4c, 0xd2, 0x24, 0x26,
|
||||
0x98, 0x20, 0x1b, 0x74, 0x1f, 0x4f, 0xa2, 0x39, 0xce, 0x5c, 0x7a, 0x41, 0x0c, 0xad, 0x53, 0xe9,
|
||||
0xe9, 0xfb, 0x3d, 0x53, 0xb9, 0x0d, 0x36, 0x98, 0x29, 0x94, 0xe7, 0xb0, 0xa1, 0x40, 0x9c, 0x5c,
|
||||
0x38, 0xe0, 0xe7, 0x47, 0x82, 0x86, 0x50, 0xc7, 0xb1, 0xef, 0x8e, 0x26, 0xc9, 0xf8, 0xab, 0xf1,
|
||||
0xb8, 0xa3, 0xf5, 0xf4, 0xfd, 0xbd, 0x07, 0x88, 0xde, 0xc5, 0xbe, 0xc5, 0xca, 0x9d, 0x1a, 0x96,
|
||||
0x27, 0xf4, 0x01, 0xf4, 0x11, 0x0e, 0xa2, 0x58, 0xf2, 0x54, 0x38, 0xcf, 0xcb, 0x07, 0x78, 0x2c,
|
||||
0x86, 0x10, 0x4c, 0x30, 0x2a, 0xce, 0xdd, 0xef, 0x1a, 0x6c, 0x9c, 0xe6, 0x57, 0x4b, 0xec, 0xf8,
|
||||
0x3c, 0x41, 0x36, 0x34, 0x8a, 0xcb, 0x76, 0x09, 0xa6, 0x86, 0xc6, 0x1b, 0xec, 0x98, 0xb7, 0xde,
|
||||
0x5f, 0x74, 0x28, 0xe0, 0xc7, 0x98, 0x3a, 0xeb, 0x73, 0xe5, 0x0b, 0x99, 0xb0, 0x39, 0xf1, 0x08,
|
||||
0x75, 0x43, 0x1c, 0x05, 0x21, 0x75, 0xc7, 0xa1, 0x17, 0x07, 0xd8, 0xe7, 0x93, 0x57, 0x9c, 0xa7,
|
||||
0x2c, 0x75, 0xc8, 0x33, 0x03, 0x91, 0xe8, 0xfe, 0xd4, 0x60, 0x73, 0xc0, 0xd4, 0xc6, 0x64, 0x46,
|
||||
0x3e, 0xf3, 0x47, 0xe5, 0x92, 0xce, 0xe0, 0xc9, 0x38, 0x0f, 0xbb, 0xe2, 0xb1, 0xa5, 0xaa, 0xbd,
|
||||
0xfb, 0x54, 0x2d, 0xd0, 0x58, 0x2b, 0xbf, 0xae, 0xda, 0x8f, 0x9c, 0xe6, 0xf8, 0x66, 0x78, 0x69,
|
||||
0x85, 0x31, 0x54, 0x4f, 0x85, 0xa1, 0xd0, 0x7b, 0xa8, 0x17, 0x6c, 0x52, 0xcd, 0x8b, 0xdb, 0x6a,
|
||||
0x72, 0xfb, 0x15, 0x7a, 0xa4, 0x92, 0x12, 0x8b, 0x5a, 0x50, 0x23, 0xc9, 0x39, 0xfd, 0xe6, 0x65,
|
||||
0x98, 0x37, 0xae, 0x3b, 0xc5, 0x77, 0xf7, 0xf7, 0x1a, 0xac, 0x1e, 0xb3, 0x35, 0x43, 0x6f, 0xa1,
|
||||
0x2a, 0xb9, 0x64, 0xb3, 0xb6, 0x79, 0xf7, 0x42, 0x9a, 0x52, 0xa0, 0x6c, 0x94, 0xa3, 0xd0, 0x2e,
|
||||
0xd4, 0xc6, 0xa1, 0x17, 0xc5, 0xae, 0x2d, 0xe6, 0xab, 0x5b, 0xfa, 0xf5, 0x55, 0xbb, 0x3a, 0x60,
|
||||
0x31, 0x7b, 0xe8, 0x54, 0x79, 0xd2, 0xf6, 0xd1, 0x2b, 0xe0, 0x73, 0x0b, 0x77, 0xc9, 0x8b, 0xe1,
|
||||
0x26, 0xab, 0x38, 0x4d, 0x96, 0xe0, 0xc6, 0x11, 0xb7, 0x82, 0xce, 0xa0, 0xa1, 0xd4, 0x46, 0xbe,
|
||||
0xb1, 0x72, 0x9f, 0x34, 0xf1, 0x2a, 0x1c, 0x6b, 0x0f, 0xad, 0x4d, 0x26, 0xed, 0xfa, 0xaa, 0xad,
|
||||
0x1f, 0xe5, 0x84, 0xf6, 0xd0, 0xd1, 0x0b, 0x76, 0xdb, 0x47, 0x47, 0xd0, 0x54, 0x98, 0xd9, 0x96,
|
||||
0x1a, 0xab, 0x9c, 0xbb, 0x65, 0x8a, 0x15, 0x36, 0xf3, 0x15, 0x36, 0x4f, 0xf2, 0x15, 0xb6, 0x6a,
|
||||
0x8c, 0xf6, 0xc7, 0x9f, 0xb6, 0xe6, 0x34, 0x0a, 0x2e, 0x96, 0x45, 0x1f, 0xa1, 0x19, 0xe3, 0x0b,
|
||||
0xea, 0x16, 0xee, 0x24, 0xc6, 0xda, 0x12, 0xae, 0xde, 0x60, 0xe0, 0x72, 0x4d, 0xd0, 0x10, 0x40,
|
||||
0x61, 0xaa, 0x2e, 0xc1, 0xa4, 0xe0, 0x98, 0x28, 0x3e, 0xa2, 0x42, 0x55, 0x5b, 0x46, 0x14, 0x03,
|
||||
0x2b, 0xa2, 0x06, 0xf0, 0x5c, 0xb5, 0x72, 0xc9, 0x5a, 0xb8, 0xba, 0xce, 0x1f, 0x71, 0xbb, 0x74,
|
||||
0x75, 0x89, 0x96, 0xfe, 0xbe, 0x73, 0xd3, 0xe0, 0xbf, 0x6c, 0xda, 0x27, 0xd8, 0xb9, 0xb1, 0x69,
|
||||
0x0b, 0x5d, 0x0a, 0x91, 0x3a, 0x17, 0xd9, 0x51, 0x56, 0xef, 0x26, 0x51, 0xae, 0xb4, 0x07, 0x4d,
|
||||
0x66, 0x1e, 0x07, 0x93, 0xd9, 0x84, 0x92, 0x43, 0x8f, 0x84, 0xc6, 0x7a, 0x47, 0xeb, 0xad, 0x3b,
|
||||
0x8b, 0x61, 0x64, 0x40, 0xf5, 0x20, 0x4d, 0x79, 0x45, 0x83, 0x57, 0xe4, 0x9f, 0x96, 0xf9, 0xe5,
|
||||
0x75, 0x10, 0xd1, 0x70, 0x36, 0x32, 0xc7, 0xc9, 0xb4, 0x5f, 0xce, 0xa7, 0x1e, 0x95, 0xbf, 0xc3,
|
||||
0xd1, 0x1a, 0xff, 0x78, 0xf3, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x78, 0x53, 0xd2, 0x08, 0x24, 0x07,
|
||||
0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.state;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/state";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "abci/types/types.proto";
|
||||
import "proto/types/types.proto";
|
||||
import "proto/types/validator.proto";
|
||||
import "proto/types/params.proto";
|
||||
import "proto/version/version.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
// ABCIResponses retains the responses
|
||||
// of the various ABCI calls during block processing.
|
||||
// It is persisted to disk for each height before calling Commit.
|
||||
message ABCIResponses {
|
||||
repeated tendermint.abci.types.ResponseDeliverTx deliver_txs = 1;
|
||||
tendermint.abci.types.ResponseEndBlock end_block = 2;
|
||||
tendermint.abci.types.ResponseBeginBlock begin_block = 3;
|
||||
}
|
||||
|
||||
// ValidatorsInfo represents the latest validator set, or the last height it changed
|
||||
message ValidatorsInfo {
|
||||
tendermint.proto.types.ValidatorSet validator_set = 1;
|
||||
int64 last_height_changed = 2;
|
||||
}
|
||||
|
||||
// ConsensusParamsInfo represents the latest consensus params, or the last height it changed
|
||||
message ConsensusParamsInfo {
|
||||
tendermint.proto.types.ConsensusParams consensus_params = 1 [(gogoproto.nullable) = false];
|
||||
int64 last_height_changed = 2;
|
||||
}
|
||||
|
||||
message Version {
|
||||
tendermint.proto.version.Consensus consensus = 1 [(gogoproto.nullable) = false];
|
||||
string software = 2;
|
||||
}
|
||||
|
||||
message State {
|
||||
Version version = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// immutable
|
||||
string chain_Id = 2 [(gogoproto.customname) = "ChainID"];
|
||||
|
||||
// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist)
|
||||
int64 last_block_height = 3;
|
||||
tendermint.proto.types.BlockID last_block_id = 4
|
||||
[(gogoproto.nullable) = false, (gogoproto.customname) = "LastBlockID"];
|
||||
google.protobuf.Timestamp last_block_time = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
|
||||
// LastValidators is used to validate block.LastCommit.
|
||||
// Validators are persisted to the database separately every time they change,
|
||||
// so we can query for historical validator sets.
|
||||
// Note that if s.LastBlockHeight causes a valset change,
|
||||
// we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1
|
||||
// Extra +1 due to nextValSet delay.
|
||||
tendermint.proto.types.ValidatorSet next_validators = 6;
|
||||
tendermint.proto.types.ValidatorSet validators = 7;
|
||||
tendermint.proto.types.ValidatorSet last_validators = 8;
|
||||
int64 last_height_validators_changed = 9;
|
||||
|
||||
// Consensus parameters used for validating blocks.
|
||||
// Changes returned by EndBlock and updated after Commit.
|
||||
tendermint.proto.types.ConsensusParams consensus_params = 10 [(gogoproto.nullable) = false];
|
||||
int64 last_height_consensus_params_changed = 11;
|
||||
|
||||
// Merkle root of the results from executing prev block
|
||||
bytes LastResultsHash = 12;
|
||||
|
||||
// the latest AppHash we've received from calling abci.Commit()
|
||||
bytes AppHash = 13;
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/types/block.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Block struct {
|
||||
Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"`
|
||||
Data Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data"`
|
||||
Evidence EvidenceData `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence"`
|
||||
LastCommit *Commit `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Block) Reset() { *m = Block{} }
|
||||
func (m *Block) String() string { return proto.CompactTextString(m) }
|
||||
func (*Block) ProtoMessage() {}
|
||||
func (*Block) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3aa007336dea920d, []int{0}
|
||||
}
|
||||
func (m *Block) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Block.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Block.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Block) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Block.Merge(m, src)
|
||||
}
|
||||
func (m *Block) XXX_Size() int {
|
||||
return xxx_messageInfo_Block.Size(m)
|
||||
}
|
||||
func (m *Block) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Block.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Block proto.InternalMessageInfo
|
||||
|
||||
func (m *Block) GetHeader() Header {
|
||||
if m != nil {
|
||||
return m.Header
|
||||
}
|
||||
return Header{}
|
||||
}
|
||||
|
||||
func (m *Block) GetData() Data {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return Data{}
|
||||
}
|
||||
|
||||
func (m *Block) GetEvidence() EvidenceData {
|
||||
if m != nil {
|
||||
return m.Evidence
|
||||
}
|
||||
return EvidenceData{}
|
||||
}
|
||||
|
||||
func (m *Block) GetLastCommit() *Commit {
|
||||
if m != nil {
|
||||
return m.LastCommit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Block)(nil), "tendermint.proto.types.Block")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/types/block.proto", fileDescriptor_3aa007336dea920d) }
|
||||
|
||||
var fileDescriptor_3aa007336dea920d = []byte{
|
||||
// 248 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0xd6, 0x03, 0x8b,
|
||||
0x08, 0x89, 0x95, 0xa4, 0xe6, 0xa5, 0xa4, 0x16, 0xe5, 0x66, 0xe6, 0x95, 0x40, 0x44, 0xf4, 0xc0,
|
||||
0x6a, 0xa4, 0xd4, 0x4a, 0x32, 0x32, 0x8b, 0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0x21,
|
||||
0x9a, 0xd3, 0xf3, 0xd3, 0xf3, 0x11, 0x2c, 0x88, 0x6a, 0x29, 0x14, 0x83, 0xc1, 0x24, 0x54, 0x42,
|
||||
0x0a, 0x59, 0x22, 0xb5, 0x2c, 0x33, 0x25, 0x35, 0x2f, 0x39, 0x15, 0x22, 0xa7, 0xd4, 0xc6, 0xc4,
|
||||
0xc5, 0xea, 0x04, 0x72, 0x84, 0x90, 0x0d, 0x17, 0x5b, 0x46, 0x6a, 0x62, 0x4a, 0x6a, 0x91, 0x04,
|
||||
0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x9c, 0x1e, 0x76, 0xf7, 0xe8, 0x79, 0x80, 0x55, 0x39, 0xb1,
|
||||
0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0xd5, 0x23, 0x64, 0xc6, 0xc5, 0x92, 0x92, 0x58, 0x92, 0x28,
|
||||
0xc1, 0x04, 0xd6, 0x2b, 0x83, 0x4b, 0xaf, 0x4b, 0x62, 0x49, 0x22, 0x54, 0x27, 0x58, 0xbd, 0x90,
|
||||
0x1b, 0x17, 0x07, 0xcc, 0x45, 0x12, 0xcc, 0x60, 0xbd, 0x2a, 0xb8, 0xf4, 0xba, 0x42, 0xd5, 0x21,
|
||||
0x99, 0x01, 0xd7, 0x2b, 0x64, 0xcf, 0xc5, 0x9d, 0x93, 0x58, 0x5c, 0x12, 0x9f, 0x9c, 0x9f, 0x9b,
|
||||
0x9b, 0x59, 0x22, 0xc1, 0x82, 0xdf, 0x0b, 0xce, 0x60, 0x55, 0x41, 0x5c, 0x20, 0x2d, 0x10, 0xb6,
|
||||
0x93, 0x5e, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x42,
|
||||
0x1f, 0x32, 0x13, 0x29, 0x1c, 0x93, 0xd8, 0xc0, 0x1c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||
0x46, 0x9a, 0x1b, 0xf7, 0xcf, 0x01, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.types;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "proto/types/types.proto";
|
||||
import "proto/types/evidence.proto";
|
||||
|
||||
message Block {
|
||||
Header header = 1 [(gogoproto.nullable) = false];
|
||||
Data data = 2 [(gogoproto.nullable) = false];
|
||||
tendermint.proto.types.EvidenceData evidence = 3 [(gogoproto.nullable) = false];
|
||||
Commit last_commit = 4;
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/types/evidence.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
math "math"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// DuplicateVoteEvidence contains evidence a validator signed two conflicting
|
||||
// votes.
|
||||
type DuplicateVoteEvidence struct {
|
||||
VoteA *Vote `protobuf:"bytes,1,opt,name=vote_a,json=voteA,proto3" json:"vote_a,omitempty"`
|
||||
VoteB *Vote `protobuf:"bytes,2,opt,name=vote_b,json=voteB,proto3" json:"vote_b,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DuplicateVoteEvidence) Reset() { *m = DuplicateVoteEvidence{} }
|
||||
func (m *DuplicateVoteEvidence) String() string { return proto.CompactTextString(m) }
|
||||
func (*DuplicateVoteEvidence) ProtoMessage() {}
|
||||
func (*DuplicateVoteEvidence) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_86495eef24aeacc0, []int{0}
|
||||
}
|
||||
func (m *DuplicateVoteEvidence) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DuplicateVoteEvidence.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DuplicateVoteEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DuplicateVoteEvidence.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DuplicateVoteEvidence) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DuplicateVoteEvidence.Merge(m, src)
|
||||
}
|
||||
func (m *DuplicateVoteEvidence) XXX_Size() int {
|
||||
return xxx_messageInfo_DuplicateVoteEvidence.Size(m)
|
||||
}
|
||||
func (m *DuplicateVoteEvidence) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DuplicateVoteEvidence.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DuplicateVoteEvidence proto.InternalMessageInfo
|
||||
|
||||
func (m *DuplicateVoteEvidence) GetVoteA() *Vote {
|
||||
if m != nil {
|
||||
return m.VoteA
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DuplicateVoteEvidence) GetVoteB() *Vote {
|
||||
if m != nil {
|
||||
return m.VoteB
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MockEvidence is used for testing pruposes
|
||||
type MockEvidence struct {
|
||||
EvidenceHeight int64 `protobuf:"varint,1,opt,name=evidence_height,json=evidenceHeight,proto3" json:"evidence_height,omitempty"`
|
||||
EvidenceTime time.Time `protobuf:"bytes,2,opt,name=evidence_time,json=evidenceTime,proto3,stdtime" json:"evidence_time"`
|
||||
EvidenceAddress []byte `protobuf:"bytes,3,opt,name=evidence_address,json=evidenceAddress,proto3" json:"evidence_address,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MockEvidence) Reset() { *m = MockEvidence{} }
|
||||
func (m *MockEvidence) String() string { return proto.CompactTextString(m) }
|
||||
func (*MockEvidence) ProtoMessage() {}
|
||||
func (*MockEvidence) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_86495eef24aeacc0, []int{1}
|
||||
}
|
||||
func (m *MockEvidence) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MockEvidence.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MockEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MockEvidence.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *MockEvidence) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MockEvidence.Merge(m, src)
|
||||
}
|
||||
func (m *MockEvidence) XXX_Size() int {
|
||||
return xxx_messageInfo_MockEvidence.Size(m)
|
||||
}
|
||||
func (m *MockEvidence) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MockEvidence.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MockEvidence proto.InternalMessageInfo
|
||||
|
||||
func (m *MockEvidence) GetEvidenceHeight() int64 {
|
||||
if m != nil {
|
||||
return m.EvidenceHeight
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MockEvidence) GetEvidenceTime() time.Time {
|
||||
if m != nil {
|
||||
return m.EvidenceTime
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (m *MockEvidence) GetEvidenceAddress() []byte {
|
||||
if m != nil {
|
||||
return m.EvidenceAddress
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Evidence struct {
|
||||
// Types that are valid to be assigned to Sum:
|
||||
// *Evidence_DuplicateVoteEvidence
|
||||
// *Evidence_MockEvidence
|
||||
Sum isEvidence_Sum `protobuf_oneof:"sum"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Evidence) Reset() { *m = Evidence{} }
|
||||
func (m *Evidence) String() string { return proto.CompactTextString(m) }
|
||||
func (*Evidence) ProtoMessage() {}
|
||||
func (*Evidence) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_86495eef24aeacc0, []int{2}
|
||||
}
|
||||
func (m *Evidence) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Evidence.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Evidence.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Evidence) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Evidence.Merge(m, src)
|
||||
}
|
||||
func (m *Evidence) XXX_Size() int {
|
||||
return xxx_messageInfo_Evidence.Size(m)
|
||||
}
|
||||
func (m *Evidence) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Evidence.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Evidence proto.InternalMessageInfo
|
||||
|
||||
type isEvidence_Sum interface {
|
||||
isEvidence_Sum()
|
||||
}
|
||||
|
||||
type Evidence_DuplicateVoteEvidence struct {
|
||||
DuplicateVoteEvidence *DuplicateVoteEvidence `protobuf:"bytes,1,opt,name=duplicate_vote_evidence,json=duplicateVoteEvidence,proto3,oneof" json:"duplicate_vote_evidence,omitempty"`
|
||||
}
|
||||
type Evidence_MockEvidence struct {
|
||||
MockEvidence *MockEvidence `protobuf:"bytes,2,opt,name=mock_evidence,json=mockEvidence,proto3,oneof" json:"mock_evidence,omitempty"`
|
||||
}
|
||||
|
||||
func (*Evidence_DuplicateVoteEvidence) isEvidence_Sum() {}
|
||||
func (*Evidence_MockEvidence) isEvidence_Sum() {}
|
||||
|
||||
func (m *Evidence) GetSum() isEvidence_Sum {
|
||||
if m != nil {
|
||||
return m.Sum
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Evidence) GetDuplicateVoteEvidence() *DuplicateVoteEvidence {
|
||||
if x, ok := m.GetSum().(*Evidence_DuplicateVoteEvidence); ok {
|
||||
return x.DuplicateVoteEvidence
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Evidence) GetMockEvidence() *MockEvidence {
|
||||
if x, ok := m.GetSum().(*Evidence_MockEvidence); ok {
|
||||
return x.MockEvidence
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*Evidence) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*Evidence_DuplicateVoteEvidence)(nil),
|
||||
(*Evidence_MockEvidence)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
// EvidenceData contains any evidence of malicious wrong-doing by validators
|
||||
type EvidenceData struct {
|
||||
Evidence []Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"`
|
||||
Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvidenceData) Reset() { *m = EvidenceData{} }
|
||||
func (m *EvidenceData) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvidenceData) ProtoMessage() {}
|
||||
func (*EvidenceData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_86495eef24aeacc0, []int{3}
|
||||
}
|
||||
func (m *EvidenceData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvidenceData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvidenceData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvidenceData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvidenceData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvidenceData.Merge(m, src)
|
||||
}
|
||||
func (m *EvidenceData) XXX_Size() int {
|
||||
return xxx_messageInfo_EvidenceData.Size(m)
|
||||
}
|
||||
func (m *EvidenceData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvidenceData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvidenceData proto.InternalMessageInfo
|
||||
|
||||
func (m *EvidenceData) GetEvidence() []Evidence {
|
||||
if m != nil {
|
||||
return m.Evidence
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *EvidenceData) GetHash() []byte {
|
||||
if m != nil {
|
||||
return m.Hash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*DuplicateVoteEvidence)(nil), "tendermint.proto.types.DuplicateVoteEvidence")
|
||||
proto.RegisterType((*MockEvidence)(nil), "tendermint.proto.types.MockEvidence")
|
||||
proto.RegisterType((*Evidence)(nil), "tendermint.proto.types.Evidence")
|
||||
proto.RegisterType((*EvidenceData)(nil), "tendermint.proto.types.EvidenceData")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/types/evidence.proto", fileDescriptor_86495eef24aeacc0) }
|
||||
|
||||
var fileDescriptor_86495eef24aeacc0 = []byte{
|
||||
// 404 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xd1, 0x6a, 0xe2, 0x40,
|
||||
0x14, 0x35, 0x1b, 0x15, 0x19, 0xe3, 0xee, 0x12, 0x70, 0x95, 0xb0, 0xa0, 0x84, 0x65, 0xd7, 0x85,
|
||||
0xdd, 0x09, 0xe8, 0x17, 0x18, 0x2c, 0x58, 0x4a, 0x5f, 0x86, 0xd2, 0x87, 0xbe, 0x84, 0x49, 0x32,
|
||||
0x26, 0x41, 0xe3, 0x84, 0x64, 0x22, 0xf8, 0xd8, 0x3f, 0xe8, 0x8f, 0xf4, 0x3b, 0xda, 0xaf, 0x68,
|
||||
0x7f, 0xa5, 0x64, 0x26, 0x33, 0xe6, 0x41, 0xa1, 0x2f, 0x72, 0xe7, 0xce, 0x39, 0x67, 0xce, 0x39,
|
||||
0x06, 0x58, 0x59, 0x4e, 0x19, 0x75, 0xd8, 0x31, 0x23, 0x85, 0x43, 0x0e, 0x49, 0x48, 0xf6, 0x01,
|
||||
0x81, 0x7c, 0x69, 0xfe, 0x60, 0x64, 0x1f, 0x92, 0x3c, 0x4d, 0xf6, 0x4c, 0x6c, 0x20, 0x87, 0x59,
|
||||
0xbf, 0x59, 0x9c, 0xe4, 0xa1, 0x97, 0xe1, 0x9c, 0x1d, 0x1d, 0xc1, 0x8f, 0x68, 0x44, 0x4f, 0x93,
|
||||
0x40, 0x5b, 0xa3, 0xa6, 0x36, 0xff, 0xad, 0x2f, 0x26, 0x11, 0xa5, 0xd1, 0x8e, 0x08, 0xae, 0x5f,
|
||||
0x6e, 0x1c, 0x96, 0xa4, 0xa4, 0x60, 0x38, 0xcd, 0x04, 0xc0, 0x7e, 0xd4, 0xc0, 0x70, 0x55, 0x66,
|
||||
0xbb, 0x24, 0xc0, 0x8c, 0xdc, 0x53, 0x46, 0xae, 0x6a, 0x67, 0xe6, 0x02, 0x74, 0x0f, 0x94, 0x11,
|
||||
0x0f, 0x8f, 0xb5, 0xa9, 0x36, 0xeb, 0xcf, 0x7f, 0xc2, 0xf3, 0x26, 0x61, 0xc5, 0x42, 0x9d, 0x0a,
|
||||
0xbb, 0x54, 0x24, 0x7f, 0xfc, 0xe5, 0xb3, 0x24, 0xd7, 0x7e, 0xd6, 0x80, 0x71, 0x4b, 0x83, 0xad,
|
||||
0x7a, 0xfa, 0x0f, 0xf8, 0x26, 0x0b, 0xf2, 0x62, 0x92, 0x44, 0x31, 0xe3, 0x1e, 0x74, 0xf4, 0x55,
|
||||
0xae, 0xd7, 0x7c, 0x6b, 0x5e, 0x83, 0x81, 0x02, 0x56, 0xc9, 0xea, 0x57, 0x2d, 0x28, 0x62, 0x43,
|
||||
0x19, 0x1b, 0xde, 0xc9, 0xd8, 0x6e, 0xef, 0xf5, 0x6d, 0xd2, 0x7a, 0x7a, 0x9f, 0x68, 0xc8, 0x90,
|
||||
0xd4, 0xea, 0xd2, 0xfc, 0x0b, 0xbe, 0x2b, 0x29, 0x1c, 0x86, 0x39, 0x29, 0x8a, 0xb1, 0x3e, 0xd5,
|
||||
0x66, 0x06, 0x52, 0x5e, 0x96, 0x62, 0x6d, 0xbf, 0x68, 0xa0, 0xa7, 0xbc, 0x46, 0x60, 0x14, 0xca,
|
||||
0xfe, 0x3c, 0x9e, 0x5d, 0xc2, 0xeb, 0xde, 0xfe, 0x5f, 0xaa, 0xe0, 0x6c, 0xed, 0xeb, 0x16, 0x1a,
|
||||
0x86, 0x67, 0xff, 0x8f, 0x1b, 0x30, 0x48, 0x69, 0xb0, 0x3d, 0xc9, 0x8b, 0xac, 0xbf, 0x2e, 0xc9,
|
||||
0x37, 0x1b, 0x5d, 0xb7, 0x90, 0x91, 0x36, 0xce, 0x6e, 0x07, 0xe8, 0x45, 0x99, 0xda, 0x1b, 0x60,
|
||||
0xc8, 0xd5, 0x0a, 0x33, 0x6c, 0xba, 0xa0, 0xd7, 0x70, 0xaf, 0xcf, 0xfa, 0xf3, 0xe9, 0x25, 0x79,
|
||||
0x25, 0xd5, 0xae, 0x0a, 0x45, 0x8a, 0x67, 0x9a, 0xa0, 0x1d, 0xe3, 0x22, 0xe6, 0xf6, 0x0c, 0xc4,
|
||||
0x67, 0x17, 0x3e, 0xfc, 0x8b, 0x12, 0x16, 0x97, 0x3e, 0x0c, 0x68, 0xea, 0x9c, 0x14, 0x9b, 0x63,
|
||||
0xe3, 0x13, 0xf6, 0xbb, 0xfc, 0xb0, 0xf8, 0x08, 0x00, 0x00, 0xff, 0xff, 0x08, 0xfc, 0xe8, 0x04,
|
||||
0x34, 0x03, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.types;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "proto/types/types.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
// DuplicateVoteEvidence contains evidence a validator signed two conflicting
|
||||
// votes.
|
||||
message DuplicateVoteEvidence {
|
||||
Vote vote_a = 1;
|
||||
Vote vote_b = 2;
|
||||
}
|
||||
|
||||
// MockEvidence is used for testing pruposes
|
||||
message MockEvidence {
|
||||
int64 evidence_height = 1;
|
||||
google.protobuf.Timestamp evidence_time = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes evidence_address = 3;
|
||||
}
|
||||
|
||||
message Evidence {
|
||||
oneof sum {
|
||||
DuplicateVoteEvidence duplicate_vote_evidence = 1;
|
||||
MockEvidence mock_evidence = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// EvidenceData contains any evidence of malicious wrong-doing by validators
|
||||
message EvidenceData {
|
||||
repeated Evidence evidence = 1 [(gogoproto.nullable) = false];
|
||||
bytes hash = 2;
|
||||
}
|
||||
@@ -0,0 +1,485 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/types/params.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
bytes "bytes"
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
||||
_ "github.com/golang/protobuf/ptypes/duration"
|
||||
math "math"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// ConsensusParams contains consensus critical parameters that determine the
|
||||
// validity of blocks.
|
||||
type ConsensusParams struct {
|
||||
Block BlockParams `protobuf:"bytes,1,opt,name=block,proto3" json:"block"`
|
||||
Evidence EvidenceParams `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence"`
|
||||
Validator ValidatorParams `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ConsensusParams) Reset() { *m = ConsensusParams{} }
|
||||
func (m *ConsensusParams) String() string { return proto.CompactTextString(m) }
|
||||
func (*ConsensusParams) ProtoMessage() {}
|
||||
func (*ConsensusParams) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_95a9f934fa6f056c, []int{0}
|
||||
}
|
||||
func (m *ConsensusParams) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ConsensusParams.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ConsensusParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ConsensusParams.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ConsensusParams) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ConsensusParams.Merge(m, src)
|
||||
}
|
||||
func (m *ConsensusParams) XXX_Size() int {
|
||||
return xxx_messageInfo_ConsensusParams.Size(m)
|
||||
}
|
||||
func (m *ConsensusParams) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ConsensusParams.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ConsensusParams proto.InternalMessageInfo
|
||||
|
||||
func (m *ConsensusParams) GetBlock() BlockParams {
|
||||
if m != nil {
|
||||
return m.Block
|
||||
}
|
||||
return BlockParams{}
|
||||
}
|
||||
|
||||
func (m *ConsensusParams) GetEvidence() EvidenceParams {
|
||||
if m != nil {
|
||||
return m.Evidence
|
||||
}
|
||||
return EvidenceParams{}
|
||||
}
|
||||
|
||||
func (m *ConsensusParams) GetValidator() ValidatorParams {
|
||||
if m != nil {
|
||||
return m.Validator
|
||||
}
|
||||
return ValidatorParams{}
|
||||
}
|
||||
|
||||
// BlockParams contains limits on the block size.
|
||||
type BlockParams struct {
|
||||
// Note: must be greater than 0
|
||||
MaxBytes int64 `protobuf:"varint,1,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"`
|
||||
// Note: must be greater or equal to -1
|
||||
MaxGas int64 `protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3" json:"max_gas,omitempty"`
|
||||
// Minimum time increment between consecutive blocks (in milliseconds)
|
||||
// Not exposed to the application.
|
||||
TimeIotaMs int64 `protobuf:"varint,3,opt,name=time_iota_ms,json=timeIotaMs,proto3" json:"time_iota_ms,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BlockParams) Reset() { *m = BlockParams{} }
|
||||
func (m *BlockParams) String() string { return proto.CompactTextString(m) }
|
||||
func (*BlockParams) ProtoMessage() {}
|
||||
func (*BlockParams) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_95a9f934fa6f056c, []int{1}
|
||||
}
|
||||
func (m *BlockParams) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BlockParams.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BlockParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BlockParams.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BlockParams) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BlockParams.Merge(m, src)
|
||||
}
|
||||
func (m *BlockParams) XXX_Size() int {
|
||||
return xxx_messageInfo_BlockParams.Size(m)
|
||||
}
|
||||
func (m *BlockParams) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BlockParams.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BlockParams proto.InternalMessageInfo
|
||||
|
||||
func (m *BlockParams) GetMaxBytes() int64 {
|
||||
if m != nil {
|
||||
return m.MaxBytes
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BlockParams) GetMaxGas() int64 {
|
||||
if m != nil {
|
||||
return m.MaxGas
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BlockParams) GetTimeIotaMs() int64 {
|
||||
if m != nil {
|
||||
return m.TimeIotaMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// EvidenceParams determine how we handle evidence of malfeasance.
|
||||
type EvidenceParams struct {
|
||||
// Note: must be greater than 0
|
||||
MaxAgeNumBlocks int64 `protobuf:"varint,1,opt,name=max_age_num_blocks,json=maxAgeNumBlocks,proto3" json:"max_age_num_blocks,omitempty"`
|
||||
MaxAgeDuration time.Duration `protobuf:"bytes,2,opt,name=max_age_duration,json=maxAgeDuration,proto3,stdduration" json:"max_age_duration"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EvidenceParams) Reset() { *m = EvidenceParams{} }
|
||||
func (m *EvidenceParams) String() string { return proto.CompactTextString(m) }
|
||||
func (*EvidenceParams) ProtoMessage() {}
|
||||
func (*EvidenceParams) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_95a9f934fa6f056c, []int{2}
|
||||
}
|
||||
func (m *EvidenceParams) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EvidenceParams.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EvidenceParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EvidenceParams.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EvidenceParams) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EvidenceParams.Merge(m, src)
|
||||
}
|
||||
func (m *EvidenceParams) XXX_Size() int {
|
||||
return xxx_messageInfo_EvidenceParams.Size(m)
|
||||
}
|
||||
func (m *EvidenceParams) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EvidenceParams.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EvidenceParams proto.InternalMessageInfo
|
||||
|
||||
func (m *EvidenceParams) GetMaxAgeNumBlocks() int64 {
|
||||
if m != nil {
|
||||
return m.MaxAgeNumBlocks
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *EvidenceParams) GetMaxAgeDuration() time.Duration {
|
||||
if m != nil {
|
||||
return m.MaxAgeDuration
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ValidatorParams restrict the public key types validators can use.
|
||||
// NOTE: uses ABCI pubkey naming, not Amino names.
|
||||
type ValidatorParams struct {
|
||||
PubKeyTypes []string `protobuf:"bytes,1,rep,name=pub_key_types,json=pubKeyTypes,proto3" json:"pub_key_types,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ValidatorParams) Reset() { *m = ValidatorParams{} }
|
||||
func (m *ValidatorParams) String() string { return proto.CompactTextString(m) }
|
||||
func (*ValidatorParams) ProtoMessage() {}
|
||||
func (*ValidatorParams) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_95a9f934fa6f056c, []int{3}
|
||||
}
|
||||
func (m *ValidatorParams) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ValidatorParams.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ValidatorParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ValidatorParams.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ValidatorParams) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ValidatorParams.Merge(m, src)
|
||||
}
|
||||
func (m *ValidatorParams) XXX_Size() int {
|
||||
return xxx_messageInfo_ValidatorParams.Size(m)
|
||||
}
|
||||
func (m *ValidatorParams) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ValidatorParams.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ValidatorParams proto.InternalMessageInfo
|
||||
|
||||
func (m *ValidatorParams) GetPubKeyTypes() []string {
|
||||
if m != nil {
|
||||
return m.PubKeyTypes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HashedParams is a subset of ConsensusParams.
|
||||
// It is amino encoded and hashed into
|
||||
// the Header.ConsensusHash.
|
||||
type HashedParams struct {
|
||||
BlockMaxBytes int64 `protobuf:"varint,1,opt,name=block_max_bytes,json=blockMaxBytes,proto3" json:"block_max_bytes,omitempty"`
|
||||
BlockMaxGas int64 `protobuf:"varint,2,opt,name=block_max_gas,json=blockMaxGas,proto3" json:"block_max_gas,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *HashedParams) Reset() { *m = HashedParams{} }
|
||||
func (m *HashedParams) String() string { return proto.CompactTextString(m) }
|
||||
func (*HashedParams) ProtoMessage() {}
|
||||
func (*HashedParams) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_95a9f934fa6f056c, []int{4}
|
||||
}
|
||||
func (m *HashedParams) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HashedParams.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HashedParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HashedParams.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *HashedParams) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HashedParams.Merge(m, src)
|
||||
}
|
||||
func (m *HashedParams) XXX_Size() int {
|
||||
return xxx_messageInfo_HashedParams.Size(m)
|
||||
}
|
||||
func (m *HashedParams) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HashedParams.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HashedParams proto.InternalMessageInfo
|
||||
|
||||
func (m *HashedParams) GetBlockMaxBytes() int64 {
|
||||
if m != nil {
|
||||
return m.BlockMaxBytes
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *HashedParams) GetBlockMaxGas() int64 {
|
||||
if m != nil {
|
||||
return m.BlockMaxGas
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ConsensusParams)(nil), "tendermint.proto.types.ConsensusParams")
|
||||
proto.RegisterType((*BlockParams)(nil), "tendermint.proto.types.BlockParams")
|
||||
proto.RegisterType((*EvidenceParams)(nil), "tendermint.proto.types.EvidenceParams")
|
||||
proto.RegisterType((*ValidatorParams)(nil), "tendermint.proto.types.ValidatorParams")
|
||||
proto.RegisterType((*HashedParams)(nil), "tendermint.proto.types.HashedParams")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/types/params.proto", fileDescriptor_95a9f934fa6f056c) }
|
||||
|
||||
var fileDescriptor_95a9f934fa6f056c = []byte{
|
||||
// 465 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0xd1, 0x6e, 0xd3, 0x30,
|
||||
0x14, 0x25, 0x04, 0x46, 0x7b, 0xbb, 0xae, 0xc8, 0x0f, 0x10, 0x86, 0x44, 0xab, 0x20, 0x95, 0x49,
|
||||
0x20, 0x47, 0x82, 0x37, 0x5e, 0x26, 0x02, 0x68, 0x43, 0x53, 0x11, 0x8a, 0x10, 0x0f, 0x7b, 0xb1,
|
||||
0x6e, 0x1a, 0x93, 0x46, 0xab, 0xe3, 0x28, 0x76, 0xa6, 0xe6, 0x47, 0x10, 0x8f, 0xfb, 0x0c, 0x3e,
|
||||
0x81, 0xaf, 0x80, 0x57, 0xf8, 0x0b, 0x14, 0xbb, 0x21, 0xed, 0xb4, 0xbe, 0xd9, 0xf7, 0x9e, 0x73,
|
||||
0x7c, 0xcf, 0xb9, 0x32, 0x78, 0x45, 0x29, 0xb5, 0x0c, 0x74, 0x5d, 0x70, 0x15, 0x14, 0x58, 0xa2,
|
||||
0x50, 0xd4, 0x94, 0xc8, 0x03, 0xcd, 0xf3, 0x84, 0x97, 0x22, 0xcb, 0xb5, 0xad, 0x50, 0x03, 0x3a,
|
||||
0x9c, 0xea, 0x45, 0x56, 0x26, 0xac, 0xc0, 0x52, 0xd7, 0x81, 0x65, 0xa7, 0x32, 0x95, 0xdd, 0xc9,
|
||||
0xa2, 0x0f, 0x9f, 0xa4, 0x52, 0xa6, 0x4b, 0x6e, 0x21, 0x71, 0xf5, 0x35, 0x48, 0xaa, 0x12, 0x75,
|
||||
0x26, 0x73, 0xdb, 0xf7, 0xff, 0x3a, 0x30, 0x7a, 0x2b, 0x73, 0xc5, 0x73, 0x55, 0xa9, 0x4f, 0xe6,
|
||||
0x65, 0x72, 0x0c, 0x77, 0xe3, 0xa5, 0x9c, 0x5f, 0x78, 0xce, 0xc4, 0x39, 0x1a, 0xbc, 0x7c, 0x4a,
|
||||
0x6f, 0x9e, 0x81, 0x86, 0x0d, 0xc8, 0x72, 0xc2, 0x3b, 0x3f, 0x7f, 0x8d, 0x6f, 0x45, 0x96, 0x47,
|
||||
0x4e, 0xa1, 0xc7, 0x2f, 0xb3, 0x84, 0xe7, 0x73, 0xee, 0xdd, 0x36, 0x1a, 0xd3, 0x5d, 0x1a, 0xef,
|
||||
0xd7, 0xb8, 0x2d, 0x99, 0xff, 0x6c, 0x72, 0x06, 0xfd, 0x4b, 0x5c, 0x66, 0x09, 0x6a, 0x59, 0x7a,
|
||||
0xae, 0x91, 0x7a, 0xb6, 0x4b, 0xea, 0x4b, 0x0b, 0xdc, 0xd2, 0xea, 0xf8, 0x3e, 0x87, 0xc1, 0xc6,
|
||||
0xc8, 0xe4, 0x31, 0xf4, 0x05, 0xae, 0x58, 0x5c, 0x6b, 0xae, 0x8c, 0x55, 0x37, 0xea, 0x09, 0x5c,
|
||||
0x85, 0xcd, 0x9d, 0x3c, 0x84, 0x7b, 0x4d, 0x33, 0x45, 0x65, 0x1c, 0xb8, 0xd1, 0x9e, 0xc0, 0xd5,
|
||||
0x09, 0x2a, 0x32, 0x81, 0x7d, 0x9d, 0x09, 0xce, 0x32, 0xa9, 0x91, 0x09, 0x65, 0x86, 0x72, 0x23,
|
||||
0x68, 0x6a, 0x1f, 0xa4, 0xc6, 0x99, 0xf2, 0xbf, 0x39, 0x70, 0xb0, 0x6d, 0x8b, 0x3c, 0x07, 0xd2,
|
||||
0xa8, 0x61, 0xca, 0x59, 0x5e, 0x09, 0x66, 0x52, 0x6a, 0xdf, 0x1c, 0x09, 0x5c, 0xbd, 0x49, 0xf9,
|
||||
0xc7, 0x4a, 0x98, 0xe1, 0x14, 0x99, 0xc1, 0xfd, 0x16, 0xdc, 0x2e, 0x6b, 0x9d, 0xe2, 0x23, 0x6a,
|
||||
0xb7, 0x49, 0xdb, 0x6d, 0xd2, 0x77, 0x6b, 0x40, 0xd8, 0x6b, 0xcc, 0x7e, 0xff, 0x3d, 0x76, 0xa2,
|
||||
0x03, 0xab, 0xd7, 0x76, 0x5e, 0xf7, 0x7e, 0x5c, 0x8d, 0x9d, 0x3f, 0x57, 0x63, 0xc7, 0x3f, 0x86,
|
||||
0xd1, 0xb5, 0x8c, 0x88, 0x0f, 0xc3, 0xa2, 0x8a, 0xd9, 0x05, 0xaf, 0x99, 0x09, 0xd1, 0x73, 0x26,
|
||||
0xee, 0x51, 0x3f, 0x1a, 0x14, 0x55, 0x7c, 0xc6, 0xeb, 0xcf, 0x4d, 0x69, 0x43, 0xe0, 0x1c, 0xf6,
|
||||
0x4f, 0x51, 0x2d, 0x78, 0xb2, 0x66, 0x4f, 0x61, 0x64, 0xac, 0xb0, 0xeb, 0x39, 0x0e, 0x4d, 0x79,
|
||||
0xd6, 0x86, 0xe9, 0xc3, 0xb0, 0xc3, 0x75, 0x91, 0x0e, 0x5a, 0xd4, 0x09, 0xaa, 0x90, 0x9e, 0xbf,
|
||||
0x48, 0x33, 0xbd, 0xa8, 0x62, 0x3a, 0x97, 0x22, 0xe8, 0x56, 0xbc, 0x79, 0xdc, 0xf8, 0x25, 0xf1,
|
||||
0x9e, 0xb9, 0xbc, 0xfa, 0x17, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xc9, 0x35, 0x8e, 0x3b, 0x03, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (this *EvidenceParams) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*EvidenceParams)
|
||||
if !ok {
|
||||
that2, ok := that.(EvidenceParams)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.MaxAgeNumBlocks != that1.MaxAgeNumBlocks {
|
||||
return false
|
||||
}
|
||||
if this.MaxAgeDuration != that1.MaxAgeDuration {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *ValidatorParams) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*ValidatorParams)
|
||||
if !ok {
|
||||
that2, ok := that.(ValidatorParams)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if len(this.PubKeyTypes) != len(that1.PubKeyTypes) {
|
||||
return false
|
||||
}
|
||||
for i := range this.PubKeyTypes {
|
||||
if this.PubKeyTypes[i] != that1.PubKeyTypes[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func NewPopulatedEvidenceParams(r randyParams, easy bool) *EvidenceParams {
|
||||
this := &EvidenceParams{}
|
||||
this.MaxAgeNumBlocks = int64(r.Int63())
|
||||
if r.Intn(2) == 0 {
|
||||
this.MaxAgeNumBlocks *= -1
|
||||
}
|
||||
v1 := github_com_gogo_protobuf_types.NewPopulatedStdDuration(r, easy)
|
||||
this.MaxAgeDuration = *v1
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedParams(r, 3)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
func NewPopulatedValidatorParams(r randyParams, easy bool) *ValidatorParams {
|
||||
this := &ValidatorParams{}
|
||||
v2 := r.Intn(10)
|
||||
this.PubKeyTypes = make([]string, v2)
|
||||
for i := 0; i < v2; i++ {
|
||||
this.PubKeyTypes[i] = string(randStringParams(r))
|
||||
}
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedParams(r, 2)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
type randyParams interface {
|
||||
Float32() float32
|
||||
Float64() float64
|
||||
Int63() int64
|
||||
Int31() int32
|
||||
Uint32() uint32
|
||||
Intn(n int) int
|
||||
}
|
||||
|
||||
func randUTF8RuneParams(r randyParams) rune {
|
||||
ru := r.Intn(62)
|
||||
if ru < 10 {
|
||||
return rune(ru + 48)
|
||||
} else if ru < 36 {
|
||||
return rune(ru + 55)
|
||||
}
|
||||
return rune(ru + 61)
|
||||
}
|
||||
func randStringParams(r randyParams) string {
|
||||
v3 := r.Intn(100)
|
||||
tmps := make([]rune, v3)
|
||||
for i := 0; i < v3; i++ {
|
||||
tmps[i] = randUTF8RuneParams(r)
|
||||
}
|
||||
return string(tmps)
|
||||
}
|
||||
func randUnrecognizedParams(r randyParams, maxFieldNumber int) (dAtA []byte) {
|
||||
l := r.Intn(5)
|
||||
for i := 0; i < l; i++ {
|
||||
wire := r.Intn(4)
|
||||
if wire == 3 {
|
||||
wire = 5
|
||||
}
|
||||
fieldNumber := maxFieldNumber + r.Intn(100)
|
||||
dAtA = randFieldParams(dAtA, r, fieldNumber, wire)
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func randFieldParams(dAtA []byte, r randyParams, fieldNumber int, wire int) []byte {
|
||||
key := uint32(fieldNumber)<<3 | uint32(wire)
|
||||
switch wire {
|
||||
case 0:
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
|
||||
v4 := r.Int63()
|
||||
if r.Intn(2) == 0 {
|
||||
v4 *= -1
|
||||
}
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(v4))
|
||||
case 1:
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
case 2:
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
|
||||
ll := r.Intn(100)
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(ll))
|
||||
for j := 0; j < ll; j++ {
|
||||
dAtA = append(dAtA, byte(r.Intn(256)))
|
||||
}
|
||||
default:
|
||||
dAtA = encodeVarintPopulateParams(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func encodeVarintPopulateParams(dAtA []byte, v uint64) []byte {
|
||||
for v >= 1<<7 {
|
||||
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
|
||||
v >>= 7
|
||||
}
|
||||
dAtA = append(dAtA, uint8(v))
|
||||
return dAtA
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.types;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
// ConsensusParams contains consensus critical parameters that determine the
|
||||
// validity of blocks.
|
||||
message ConsensusParams {
|
||||
BlockParams block = 1 [(gogoproto.nullable) = false];
|
||||
EvidenceParams evidence = 2 [(gogoproto.nullable) = false];
|
||||
ValidatorParams validator = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// BlockParams contains limits on the block size.
|
||||
message BlockParams {
|
||||
// Note: must be greater than 0
|
||||
int64 max_bytes = 1;
|
||||
// Note: must be greater or equal to -1
|
||||
int64 max_gas = 2;
|
||||
// Minimum time increment between consecutive blocks (in milliseconds)
|
||||
// Not exposed to the application.
|
||||
int64 time_iota_ms = 3;
|
||||
}
|
||||
|
||||
// EvidenceParams determine how we handle evidence of malfeasance.
|
||||
message EvidenceParams {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
// Note: must be greater than 0
|
||||
int64 max_age_num_blocks = 1;
|
||||
google.protobuf.Duration max_age_duration = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
|
||||
}
|
||||
|
||||
// ValidatorParams restrict the public key types validators can use.
|
||||
// NOTE: uses ABCI pubkey naming, not Amino names.
|
||||
message ValidatorParams {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
repeated string pub_key_types = 1;
|
||||
}
|
||||
|
||||
// HashedParams is a subset of ConsensusParams.
|
||||
// It is amino encoded and hashed into
|
||||
// the Header.ConsensusHash.
|
||||
message HashedParams {
|
||||
int64 block_max_bytes = 1;
|
||||
int64 block_max_gas = 2;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,140 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.types;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "proto/libs/bits/types.proto";
|
||||
import "proto/version/version.proto";
|
||||
|
||||
// BlockIdFlag indicates which BlcokID the signature is for
|
||||
enum BlockIDFlag {
|
||||
option (gogoproto.goproto_enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
BLOCKD_ID_FLAG_UNKNOWN = 0;
|
||||
BLOCK_ID_FLAG_ABSENT = 1 [(gogoproto.enumvalue_customname) = "BlockIDFlagAbsent"];
|
||||
BLOCK_ID_FLAG_COMMIT = 2 [(gogoproto.enumvalue_customname) = "BlockIDFlagCommit"];
|
||||
BLOCK_ID_FLAG_NIL = 3 [(gogoproto.enumvalue_customname) = "BlockIDFlagNil"];
|
||||
}
|
||||
|
||||
// SignedMsgType is a type of signed message in the consensus.
|
||||
enum SignedMsgType {
|
||||
option (gogoproto.goproto_enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
SIGNED_MSG_TYPE_UNKNOWN = 0;
|
||||
PREVOTE_TYPE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"];
|
||||
PRECOMMIT_TYPE = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"];
|
||||
PROPOSAL_TYPE = 3 [(gogoproto.enumvalue_customname) = "ProposalType"];
|
||||
}
|
||||
|
||||
// PartsetHeader
|
||||
message PartSetHeader {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint32 total = 1;
|
||||
bytes hash = 2;
|
||||
}
|
||||
|
||||
// BlockID
|
||||
message BlockID {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
bytes hash = 1;
|
||||
PartSetHeader parts_header = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
|
||||
// Header defines the structure of a Tendermint block header.
|
||||
message Header {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
// basic block info
|
||||
tendermint.proto.version.Consensus version = 1 [(gogoproto.nullable) = false];
|
||||
string chain_id = 2 [(gogoproto.customname) = "ChainID"];
|
||||
int64 height = 3;
|
||||
google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
|
||||
// prev block info
|
||||
BlockID last_block_id = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "LastBlockID"];
|
||||
|
||||
// hashes of block data
|
||||
bytes last_commit_hash = 6; // commit from validators from the last block
|
||||
bytes data_hash = 7; // transactions
|
||||
|
||||
// hashes from the app output from the prev block
|
||||
bytes validators_hash = 8; // validators for the current block
|
||||
bytes next_validators_hash = 9; // validators for the next block
|
||||
bytes consensus_hash = 10; // consensus params for current block
|
||||
bytes app_hash = 11; // state after txs from the previous block
|
||||
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
|
||||
|
||||
// consensus info
|
||||
bytes evidence_hash = 13; // evidence included in the block
|
||||
bytes proposer_address = 14; // original proposer of the block
|
||||
}
|
||||
|
||||
// Data contains the set of transactions included in the block
|
||||
message Data {
|
||||
// Txs that will be applied by state @ block.Height+1.
|
||||
// NOTE: not all txs here are valid. We're just agreeing on the order first.
|
||||
// This means that block.AppHash does not include these txs.
|
||||
repeated bytes txs = 1;
|
||||
// Volatile
|
||||
bytes hash = 2;
|
||||
}
|
||||
|
||||
// Vote represents a prevote, precommit, or commit vote from validators for
|
||||
// consensus.
|
||||
message Vote {
|
||||
SignedMsgType type = 1;
|
||||
int64 height = 2;
|
||||
int32 round = 3;
|
||||
BlockID block_id = 4
|
||||
[(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil.
|
||||
google.protobuf.Timestamp timestamp = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes validator_address = 6;
|
||||
uint32 validator_index = 7;
|
||||
bytes signature = 8;
|
||||
}
|
||||
|
||||
// Commit contains the evidence that a block was committed by a set of validators.
|
||||
message Commit {
|
||||
int64 height = 1;
|
||||
int32 round = 2;
|
||||
BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"];
|
||||
repeated CommitSig signatures = 4 [(gogoproto.nullable) = false];
|
||||
bytes hash = 5;
|
||||
tendermint.proto.libs.bits.BitArray bit_array = 6;
|
||||
}
|
||||
|
||||
// CommitSig is a part of the Vote included in a Commit.
|
||||
message CommitSig {
|
||||
BlockIDFlag block_id_flag = 1;
|
||||
bytes validator_address = 2;
|
||||
google.protobuf.Timestamp timestamp = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes signature = 4;
|
||||
}
|
||||
|
||||
message Proposal {
|
||||
SignedMsgType type = 1;
|
||||
int64 height = 2;
|
||||
int32 round = 3;
|
||||
int32 pol_round = 4;
|
||||
BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false];
|
||||
google.protobuf.Timestamp timestamp = 6
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
bytes signature = 7;
|
||||
}
|
||||
|
||||
message SignedHeader {
|
||||
Header header = 1;
|
||||
Commit commit = 2;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/types/validator.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
keys "github.com/tendermint/tendermint/proto/crypto/keys"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type ValidatorSet struct {
|
||||
Validators []*Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"`
|
||||
Proposer *Validator `protobuf:"bytes,2,opt,name=proposer,proto3" json:"proposer,omitempty"`
|
||||
TotalVotingPower int64 `protobuf:"varint,3,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ValidatorSet) Reset() { *m = ValidatorSet{} }
|
||||
func (m *ValidatorSet) String() string { return proto.CompactTextString(m) }
|
||||
func (*ValidatorSet) ProtoMessage() {}
|
||||
func (*ValidatorSet) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2e7c6b38c20e5406, []int{0}
|
||||
}
|
||||
func (m *ValidatorSet) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ValidatorSet.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ValidatorSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ValidatorSet.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ValidatorSet) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ValidatorSet.Merge(m, src)
|
||||
}
|
||||
func (m *ValidatorSet) XXX_Size() int {
|
||||
return xxx_messageInfo_ValidatorSet.Size(m)
|
||||
}
|
||||
func (m *ValidatorSet) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ValidatorSet.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ValidatorSet proto.InternalMessageInfo
|
||||
|
||||
func (m *ValidatorSet) GetValidators() []*Validator {
|
||||
if m != nil {
|
||||
return m.Validators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ValidatorSet) GetProposer() *Validator {
|
||||
if m != nil {
|
||||
return m.Proposer
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ValidatorSet) GetTotalVotingPower() int64 {
|
||||
if m != nil {
|
||||
return m.TotalVotingPower
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Validator struct {
|
||||
Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
|
||||
PubKey keys.PublicKey `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key"`
|
||||
VotingPower int64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"`
|
||||
ProposerPriority int64 `protobuf:"varint,4,opt,name=proposer_priority,json=proposerPriority,proto3" json:"proposer_priority,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Validator) Reset() { *m = Validator{} }
|
||||
func (m *Validator) String() string { return proto.CompactTextString(m) }
|
||||
func (*Validator) ProtoMessage() {}
|
||||
func (*Validator) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_2e7c6b38c20e5406, []int{1}
|
||||
}
|
||||
func (m *Validator) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Validator.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Validator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Validator.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Validator) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Validator.Merge(m, src)
|
||||
}
|
||||
func (m *Validator) XXX_Size() int {
|
||||
return xxx_messageInfo_Validator.Size(m)
|
||||
}
|
||||
func (m *Validator) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Validator.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Validator proto.InternalMessageInfo
|
||||
|
||||
func (m *Validator) GetAddress() []byte {
|
||||
if m != nil {
|
||||
return m.Address
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Validator) GetPubKey() keys.PublicKey {
|
||||
if m != nil {
|
||||
return m.PubKey
|
||||
}
|
||||
return keys.PublicKey{}
|
||||
}
|
||||
|
||||
func (m *Validator) GetVotingPower() int64 {
|
||||
if m != nil {
|
||||
return m.VotingPower
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Validator) GetProposerPriority() int64 {
|
||||
if m != nil {
|
||||
return m.ProposerPriority
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ValidatorSet)(nil), "tendermint.proto.types.ValidatorSet")
|
||||
proto.RegisterType((*Validator)(nil), "tendermint.proto.types.Validator")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/types/validator.proto", fileDescriptor_2e7c6b38c20e5406) }
|
||||
|
||||
var fileDescriptor_2e7c6b38c20e5406 = []byte{
|
||||
// 325 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbd, 0x4e, 0x02, 0x41,
|
||||
0x10, 0xc7, 0x5d, 0x21, 0xa0, 0x0b, 0x85, 0x6e, 0x61, 0x2e, 0x18, 0x23, 0x50, 0x28, 0x89, 0x64,
|
||||
0x2f, 0xd1, 0xda, 0x42, 0x0a, 0x1b, 0x1a, 0x72, 0x26, 0x14, 0x36, 0x97, 0x3b, 0x6e, 0x73, 0x6c,
|
||||
0xf8, 0x98, 0xcd, 0xdc, 0x1c, 0x66, 0x1f, 0x4e, 0x6b, 0x9f, 0xc2, 0x67, 0x31, 0xdc, 0x72, 0x07,
|
||||
0x89, 0x14, 0x76, 0x33, 0xff, 0xff, 0x7c, 0xfc, 0x76, 0xb2, 0xfc, 0xda, 0x20, 0x10, 0xf8, 0x64,
|
||||
0x8d, 0xca, 0xfc, 0x4d, 0xb4, 0xd4, 0x49, 0x44, 0x80, 0xb2, 0x50, 0xc5, 0x15, 0xa9, 0x75, 0xa2,
|
||||
0x70, 0xa5, 0xd7, 0xe4, 0x14, 0x59, 0xd4, 0x75, 0xee, 0x68, 0xae, 0x31, 0x09, 0x4d, 0x84, 0x64,
|
||||
0x7d, 0x37, 0x20, 0x85, 0x14, 0xf6, 0x91, 0xab, 0xee, 0xdc, 0x38, 0x65, 0x86, 0xd6, 0x10, 0xf8,
|
||||
0x0b, 0x65, 0x33, 0xb7, 0xc8, 0xd9, 0xfd, 0x2f, 0xc6, 0xdb, 0xd3, 0x72, 0xe5, 0x9b, 0x22, 0xf1,
|
||||
0xc2, 0x79, 0x85, 0x90, 0x79, 0xac, 0x5b, 0x1b, 0xb4, 0x1e, 0x7b, 0xf2, 0x38, 0x84, 0xac, 0x3a,
|
||||
0x83, 0x83, 0x26, 0xf1, 0xcc, 0xcf, 0x0c, 0x82, 0x81, 0x4c, 0xa1, 0x77, 0xda, 0x65, 0xff, 0x1b,
|
||||
0x50, 0xb5, 0x88, 0x21, 0x17, 0x04, 0x14, 0x2d, 0xc3, 0x0d, 0x90, 0x5e, 0xa7, 0xa1, 0x81, 0x0f,
|
||||
0x85, 0x5e, 0xad, 0xcb, 0x06, 0xb5, 0xe0, 0xa2, 0x70, 0xa6, 0x85, 0x31, 0xd9, 0xea, 0xfd, 0x4f,
|
||||
0xc6, 0xcf, 0xab, 0x29, 0xc2, 0xe3, 0xcd, 0x28, 0x49, 0x50, 0x65, 0x5b, 0x74, 0x36, 0x68, 0x07,
|
||||
0x65, 0x2a, 0x5e, 0x79, 0xd3, 0xe4, 0x71, 0xb8, 0x50, 0x76, 0xc7, 0x74, 0xff, 0x97, 0xc9, 0x1d,
|
||||
0x49, 0x6e, 0x8f, 0x24, 0x27, 0x79, 0xbc, 0xd4, 0xb3, 0xb1, 0xb2, 0xa3, 0xfa, 0xf7, 0xcf, 0xed,
|
||||
0x49, 0xd0, 0x30, 0x79, 0x3c, 0x56, 0x56, 0xf4, 0x78, 0xfb, 0x08, 0x57, 0x6b, 0xb3, 0x47, 0x12,
|
||||
0x0f, 0xfc, 0xb2, 0x7c, 0x4c, 0x68, 0x50, 0x03, 0x6a, 0xb2, 0x5e, 0xdd, 0xf1, 0x97, 0xc6, 0x64,
|
||||
0xa7, 0x8f, 0xe4, 0xfb, 0x30, 0xd5, 0x34, 0xcf, 0x63, 0x39, 0x83, 0x95, 0xbf, 0x47, 0x3a, 0x0c,
|
||||
0x0f, 0xfe, 0x47, 0xdc, 0x28, 0x92, 0xa7, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x28, 0xeb,
|
||||
0x40, 0x35, 0x02, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.types;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "proto/crypto/keys/types.proto";
|
||||
|
||||
message ValidatorSet {
|
||||
repeated Validator validators = 1;
|
||||
Validator proposer = 2;
|
||||
int64 total_voting_power = 3;
|
||||
}
|
||||
|
||||
message Validator {
|
||||
bytes address = 1;
|
||||
tendermint.proto.crypto.keys.PublicKey pub_key = 2 [(gogoproto.nullable) = false];
|
||||
int64 voting_power = 3;
|
||||
int64 proposer_priority = 4;
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: proto/version/version.proto
|
||||
|
||||
package version
|
||||
|
||||
import (
|
||||
bytes "bytes"
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// App includes the protocol and software version for the application.
|
||||
// This information is included in ResponseInfo. The App.Protocol can be
|
||||
// updated in ResponseEndBlock.
|
||||
type App struct {
|
||||
Protocol uint64 `protobuf:"varint,1,opt,name=protocol,proto3" json:"protocol,omitempty"`
|
||||
Software string `protobuf:"bytes,2,opt,name=software,proto3" json:"software,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *App) Reset() { *m = App{} }
|
||||
func (m *App) String() string { return proto.CompactTextString(m) }
|
||||
func (*App) ProtoMessage() {}
|
||||
func (*App) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_14aa2353622f11e1, []int{0}
|
||||
}
|
||||
func (m *App) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_App.Unmarshal(m, b)
|
||||
}
|
||||
func (m *App) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_App.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *App) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_App.Merge(m, src)
|
||||
}
|
||||
func (m *App) XXX_Size() int {
|
||||
return xxx_messageInfo_App.Size(m)
|
||||
}
|
||||
func (m *App) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_App.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_App proto.InternalMessageInfo
|
||||
|
||||
func (m *App) GetProtocol() uint64 {
|
||||
if m != nil {
|
||||
return m.Protocol
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *App) GetSoftware() string {
|
||||
if m != nil {
|
||||
return m.Software
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Consensus captures the consensus rules for processing a block in the blockchain,
|
||||
// including all blockchain data structures and the rules of the application's
|
||||
// state transition machine.
|
||||
type Consensus struct {
|
||||
Block uint64 `protobuf:"varint,1,opt,name=block,proto3" json:"block,omitempty"`
|
||||
App uint64 `protobuf:"varint,2,opt,name=app,proto3" json:"app,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Consensus) Reset() { *m = Consensus{} }
|
||||
func (m *Consensus) String() string { return proto.CompactTextString(m) }
|
||||
func (*Consensus) ProtoMessage() {}
|
||||
func (*Consensus) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_14aa2353622f11e1, []int{1}
|
||||
}
|
||||
func (m *Consensus) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Consensus.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Consensus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Consensus.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Consensus) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Consensus.Merge(m, src)
|
||||
}
|
||||
func (m *Consensus) XXX_Size() int {
|
||||
return xxx_messageInfo_Consensus.Size(m)
|
||||
}
|
||||
func (m *Consensus) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Consensus.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Consensus proto.InternalMessageInfo
|
||||
|
||||
func (m *Consensus) GetBlock() uint64 {
|
||||
if m != nil {
|
||||
return m.Block
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Consensus) GetApp() uint64 {
|
||||
if m != nil {
|
||||
return m.App
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*App)(nil), "tendermint.proto.version.App")
|
||||
proto.RegisterType((*Consensus)(nil), "tendermint.proto.version.Consensus")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/version/version.proto", fileDescriptor_14aa2353622f11e1) }
|
||||
|
||||
var fileDescriptor_14aa2353622f11e1 = []byte{
|
||||
// 203 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0x2f, 0x4b, 0x2d, 0x2a, 0xce, 0xcc, 0xcf, 0x83, 0xd1, 0x7a, 0x60, 0x51, 0x21, 0x89,
|
||||
0x92, 0xd4, 0xbc, 0x94, 0xd4, 0xa2, 0xdc, 0xcc, 0xbc, 0x12, 0x88, 0x88, 0x1e, 0x54, 0x5e, 0x4a,
|
||||
0xad, 0x24, 0x23, 0xb3, 0x28, 0x25, 0xbe, 0x20, 0xb1, 0xa8, 0xa4, 0x52, 0x1f, 0x62, 0x44, 0x7a,
|
||||
0x7e, 0x7a, 0x3e, 0x82, 0x05, 0x51, 0xaf, 0x64, 0xcb, 0xc5, 0xec, 0x58, 0x50, 0x20, 0x24, 0xc5,
|
||||
0xc5, 0x01, 0xe6, 0x27, 0xe7, 0xe7, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x04, 0xc1, 0xf9, 0x20,
|
||||
0xb9, 0xe2, 0xfc, 0xb4, 0x92, 0xf2, 0xc4, 0xa2, 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20,
|
||||
0x38, 0x5f, 0xc9, 0x96, 0x8b, 0xd3, 0x39, 0x3f, 0xaf, 0x38, 0x35, 0xaf, 0xb8, 0xb4, 0x58, 0x48,
|
||||
0x84, 0x8b, 0x35, 0x29, 0x27, 0x3f, 0x39, 0x1b, 0x6a, 0x02, 0x84, 0x23, 0x24, 0xc0, 0xc5, 0x9c,
|
||||
0x58, 0x50, 0x00, 0xd6, 0xc9, 0x12, 0x04, 0x62, 0x5a, 0x71, 0xec, 0x58, 0x20, 0xcf, 0xf8, 0x62,
|
||||
0x81, 0x3c, 0xa3, 0x93, 0x41, 0x94, 0x5e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e,
|
||||
0xae, 0x3e, 0xc2, 0x33, 0xc8, 0x4c, 0x14, 0xff, 0x27, 0xb1, 0x81, 0xb9, 0xc6, 0x80, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x20, 0x9f, 0x49, 0xf1, 0x17, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Consensus) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Consensus)
|
||||
if !ok {
|
||||
that2, ok := that.(Consensus)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Block != that1.Block {
|
||||
return false
|
||||
}
|
||||
if this.App != that1.App {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func NewPopulatedConsensus(r randyVersion, easy bool) *Consensus {
|
||||
this := &Consensus{}
|
||||
this.Block = uint64(uint64(r.Uint32()))
|
||||
this.App = uint64(uint64(r.Uint32()))
|
||||
if !easy && r.Intn(10) != 0 {
|
||||
this.XXX_unrecognized = randUnrecognizedVersion(r, 3)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
type randyVersion interface {
|
||||
Float32() float32
|
||||
Float64() float64
|
||||
Int63() int64
|
||||
Int31() int32
|
||||
Uint32() uint32
|
||||
Intn(n int) int
|
||||
}
|
||||
|
||||
func randUTF8RuneVersion(r randyVersion) rune {
|
||||
ru := r.Intn(62)
|
||||
if ru < 10 {
|
||||
return rune(ru + 48)
|
||||
} else if ru < 36 {
|
||||
return rune(ru + 55)
|
||||
}
|
||||
return rune(ru + 61)
|
||||
}
|
||||
func randStringVersion(r randyVersion) string {
|
||||
v1 := r.Intn(100)
|
||||
tmps := make([]rune, v1)
|
||||
for i := 0; i < v1; i++ {
|
||||
tmps[i] = randUTF8RuneVersion(r)
|
||||
}
|
||||
return string(tmps)
|
||||
}
|
||||
func randUnrecognizedVersion(r randyVersion, maxFieldNumber int) (dAtA []byte) {
|
||||
l := r.Intn(5)
|
||||
for i := 0; i < l; i++ {
|
||||
wire := r.Intn(4)
|
||||
if wire == 3 {
|
||||
wire = 5
|
||||
}
|
||||
fieldNumber := maxFieldNumber + r.Intn(100)
|
||||
dAtA = randFieldVersion(dAtA, r, fieldNumber, wire)
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func randFieldVersion(dAtA []byte, r randyVersion, fieldNumber int, wire int) []byte {
|
||||
key := uint32(fieldNumber)<<3 | uint32(wire)
|
||||
switch wire {
|
||||
case 0:
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(key))
|
||||
v2 := r.Int63()
|
||||
if r.Intn(2) == 0 {
|
||||
v2 *= -1
|
||||
}
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(v2))
|
||||
case 1:
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
case 2:
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(key))
|
||||
ll := r.Intn(100)
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(ll))
|
||||
for j := 0; j < ll; j++ {
|
||||
dAtA = append(dAtA, byte(r.Intn(256)))
|
||||
}
|
||||
default:
|
||||
dAtA = encodeVarintPopulateVersion(dAtA, uint64(key))
|
||||
dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
|
||||
}
|
||||
return dAtA
|
||||
}
|
||||
func encodeVarintPopulateVersion(dAtA []byte, v uint64) []byte {
|
||||
for v >= 1<<7 {
|
||||
dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
|
||||
v >>= 7
|
||||
}
|
||||
dAtA = append(dAtA, uint8(v))
|
||||
return dAtA
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
syntax = "proto3";
|
||||
package tendermint.proto.version;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/version";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
// App includes the protocol and software version for the application.
|
||||
// This information is included in ResponseInfo. The App.Protocol can be
|
||||
// updated in ResponseEndBlock.
|
||||
message App {
|
||||
uint64 protocol = 1;
|
||||
string software = 2;
|
||||
}
|
||||
|
||||
// Consensus captures the consensus rules for processing a block in the blockchain,
|
||||
// including all blockchain data structures and the rules of the application's
|
||||
// state transition machine.
|
||||
message Consensus {
|
||||
option (gogoproto.populate) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 block = 1;
|
||||
uint64 app = 2;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func newEvidence(t *testing.T, val *privval.FilePV,
|
||||
vote2.Signature, err = val.Key.PrivKey.Sign(vote2.SignBytes(chainID))
|
||||
require.NoError(t, err)
|
||||
|
||||
return types.NewDuplicateVoteEvidence(val.Key.PubKey, vote, vote2)
|
||||
return types.NewDuplicateVoteEvidence(vote, vote2)
|
||||
}
|
||||
|
||||
func makeEvidences(
|
||||
@@ -123,7 +123,7 @@ func TestBroadcastEvidence_DuplicateVoteEvidence(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
client.WaitForHeight(c, status.SyncInfo.LatestBlockHeight+2, nil)
|
||||
|
||||
ed25519pub := correct.PubKey.(ed25519.PubKeyEd25519)
|
||||
ed25519pub := pv.Key.PubKey.(ed25519.PubKeyEd25519)
|
||||
rawpub := ed25519pub[:]
|
||||
result2, err := c.ABCIQuery("/val", rawpub)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -493,6 +493,20 @@ func TestTxSearch(t *testing.T) {
|
||||
t.Fatal("expected a lot of transactions")
|
||||
}
|
||||
|
||||
// query using an index key
|
||||
result, err = c.TxSearch("app.index_key='index is working'", false, 1, 30, "asc")
|
||||
require.Nil(t, err)
|
||||
if len(result.Txs) == 0 {
|
||||
t.Fatal("expected a lot of transactions")
|
||||
}
|
||||
|
||||
// query using an noindex key
|
||||
result, err = c.TxSearch("app.noindex_key='index is working'", false, 1, 30, "asc")
|
||||
require.Nil(t, err)
|
||||
if len(result.Txs) != 0 {
|
||||
t.Fatal("expected no transaction")
|
||||
}
|
||||
|
||||
// query using a compositeKey (see kvstore application) and height
|
||||
result, err = c.TxSearch("app.creator='Cosmoshi Netowoko' AND tx.height<10000", true, 1, 30, "asc")
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -3,7 +3,6 @@ package core
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/evidence"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@@ -16,9 +15,8 @@ func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.Result
|
||||
return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err)
|
||||
}
|
||||
|
||||
err := evidencePool.AddEvidence(ev)
|
||||
if _, ok := err.(evidence.ErrEvidenceAlreadyStored); err == nil || ok {
|
||||
return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil
|
||||
if err := evidencePool.AddEvidence(ev); err != nil {
|
||||
return nil, fmt.Errorf("failed to add evidence: %w", err)
|
||||
}
|
||||
return nil, err
|
||||
return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil
|
||||
}
|
||||
|
||||
@@ -127,10 +127,10 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
|
||||
prevParts := types.PartSetHeader{}
|
||||
prevBlockID := types.BlockID{Hash: prevHash, PartsHeader: prevParts}
|
||||
|
||||
height1, idx1, val1 := int64(8), 0, state.Validators.Validators[0].Address
|
||||
height2, idx2, val2 := int64(3), 1, state.Validators.Validators[1].Address
|
||||
ev1 := types.NewMockEvidence(height1, time.Now(), idx1, val1)
|
||||
ev2 := types.NewMockEvidence(height2, time.Now(), idx2, val2)
|
||||
height1, val1 := int64(8), state.Validators.Validators[0].Address
|
||||
height2, val2 := int64(3), state.Validators.Validators[1].Address
|
||||
ev1 := types.NewMockEvidence(height1, time.Now(), val1)
|
||||
ev2 := types.NewMockEvidence(height2, time.Now(), val2)
|
||||
|
||||
now := tmtime.Now()
|
||||
valSet := state.Validators
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/libs/rand"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
@@ -136,8 +135,8 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
|
||||
{
|
||||
Data: []byte("Gotcha!"),
|
||||
Events: []abci.Event{
|
||||
{Type: "type1", Attributes: []kv.Pair{{Key: []byte("a"), Value: []byte("1")}}},
|
||||
{Type: "type2", Attributes: []kv.Pair{{Key: []byte("build"), Value: []byte("stuff")}}},
|
||||
{Type: "type1", Attributes: []abci.EventAttribute{{Key: []byte("a"), Value: []byte("1")}}},
|
||||
{Type: "type2", Attributes: []abci.EventAttribute{{Key: []byte("build"), Value: []byte("stuff")}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -153,7 +153,7 @@ func (txi *TxIndex) indexEvents(result *types.TxResult, hash []byte, store dbm.S
|
||||
}
|
||||
|
||||
compositeTag := fmt.Sprintf("%s.%s", event.Type, string(attr.Key))
|
||||
if txi.indexAllEvents || tmstring.StringInSlice(compositeTag, txi.compositeKeysToIndex) {
|
||||
if txi.indexAllEvents || tmstring.StringInSlice(compositeTag, txi.compositeKeysToIndex) || attr.GetIndex() {
|
||||
store.Set(keyForEvent(compositeTag, attr.Value, result), hash)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -33,7 +32,7 @@ func BenchmarkTxSearch(b *testing.B) {
|
||||
events := []abci.Event{
|
||||
{
|
||||
Type: "transfer",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("address"), Value: []byte(fmt.Sprintf("address_%d", i%100))},
|
||||
{Key: []byte("amount"), Value: []byte("50")},
|
||||
},
|
||||
|
||||
+13
-14
@@ -13,7 +13,6 @@ import (
|
||||
db "github.com/tendermint/tm-db"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
@@ -71,9 +70,9 @@ func TestTxSearch(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexEvents(allowedKeys))
|
||||
|
||||
txResult := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("owner"), Value: []byte("Ivan")}}},
|
||||
{Type: "", Attributes: []kv.Pair{{Key: []byte("not_allowed"), Value: []byte("Vlad")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("owner"), Value: []byte("Ivan")}}},
|
||||
{Type: "", Attributes: []abci.EventAttribute{{Key: []byte("not_allowed"), Value: []byte("Vlad")}}},
|
||||
})
|
||||
hash := txResult.Tx.Hash()
|
||||
|
||||
@@ -140,9 +139,9 @@ func TestTxSearchWithCancelation(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexEvents(allowedKeys))
|
||||
|
||||
txResult := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("owner"), Value: []byte("Ivan")}}},
|
||||
{Type: "", Attributes: []kv.Pair{{Key: []byte("not_allowed"), Value: []byte("Vlad")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("owner"), Value: []byte("Ivan")}}},
|
||||
{Type: "", Attributes: []abci.EventAttribute{{Key: []byte("not_allowed"), Value: []byte("Vlad")}}},
|
||||
})
|
||||
err := indexer.Index(txResult)
|
||||
require.NoError(t, err)
|
||||
@@ -160,7 +159,7 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
|
||||
// index tx using events indexing (composite key)
|
||||
txResult1 := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
})
|
||||
hash1 := txResult1.Tx.Hash()
|
||||
|
||||
@@ -231,8 +230,8 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexEvents(allowedKeys))
|
||||
|
||||
txResult := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("2")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("2")}}},
|
||||
})
|
||||
|
||||
err := indexer.Index(txResult)
|
||||
@@ -253,7 +252,7 @@ func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
|
||||
// indexed first, but bigger height (to test the order of transactions)
|
||||
txResult := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
})
|
||||
|
||||
txResult.Tx = types.Tx("Bob's account")
|
||||
@@ -264,7 +263,7 @@ func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
|
||||
// indexed second, but smaller height (to test the order of transactions)
|
||||
txResult2 := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("2")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("2")}}},
|
||||
})
|
||||
txResult2.Tx = types.Tx("Alice's account")
|
||||
txResult2.Height = 1
|
||||
@@ -275,7 +274,7 @@ func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
|
||||
// indexed third (to test the order of transactions)
|
||||
txResult3 := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number"), Value: []byte("3")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("3")}}},
|
||||
})
|
||||
txResult3.Tx = types.Tx("Jack's account")
|
||||
txResult3.Height = 1
|
||||
@@ -286,7 +285,7 @@ func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
// indexed fourth (to test we don't include txs with similar events)
|
||||
// https://github.com/tendermint/tendermint/issues/2908
|
||||
txResult4 := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []kv.Pair{{Key: []byte("number.id"), Value: []byte("1")}}},
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number.id"), Value: []byte("1")}}},
|
||||
})
|
||||
txResult4.Tx = types.Tx("Mike's account")
|
||||
txResult4.Height = 2
|
||||
|
||||
@@ -211,8 +211,7 @@ func TestValidateBlockEvidence(t *testing.T) {
|
||||
|
||||
for height := int64(1); height < validationTestsStopHeight; height++ {
|
||||
proposerAddr := state.Validators.GetProposer().Address
|
||||
proposerIdx, _ := state.Validators.GetByAddress(proposerAddr)
|
||||
goodEvidence := types.NewMockEvidence(height, time.Now(), proposerIdx, proposerAddr)
|
||||
goodEvidence := types.NewMockEvidence(height, time.Now(), proposerAddr)
|
||||
if height > 1 {
|
||||
/*
|
||||
A block with too much evidence fails
|
||||
@@ -265,7 +264,7 @@ func TestValidateFailBlockOnCommittedEvidence(t *testing.T) {
|
||||
// A block with a couple pieces of evidence passes.
|
||||
block := makeBlock(state, height)
|
||||
addr, _ := state.Validators.GetByIndex(0)
|
||||
alreadyCommittedEvidence := types.NewMockEvidence(height, time.Now(), 0, addr)
|
||||
alreadyCommittedEvidence := types.NewMockEvidence(height, time.Now(), addr)
|
||||
block.Evidence.Evidence = []types.Evidence{alreadyCommittedEvidence}
|
||||
block.EvidenceHash = block.Evidence.Hash()
|
||||
err := blockExec.ValidateBlock(state, block)
|
||||
|
||||
+74
-57
@@ -36,7 +36,8 @@ const (
|
||||
|
||||
// Block defines the atomic unit of a Tendermint blockchain.
|
||||
type Block struct {
|
||||
mtx sync.Mutex
|
||||
mtx sync.Mutex
|
||||
|
||||
Header `json:"header"`
|
||||
Data `json:"data"`
|
||||
Evidence EvidenceData `json:"evidence"`
|
||||
@@ -50,23 +51,12 @@ func (b *Block) ValidateBasic() error {
|
||||
if b == nil {
|
||||
return errors.New("nil block")
|
||||
}
|
||||
|
||||
b.mtx.Lock()
|
||||
defer b.mtx.Unlock()
|
||||
|
||||
if len(b.ChainID) > MaxChainIDLen {
|
||||
return fmt.Errorf("chainID is too long. Max is %d, got %d", MaxChainIDLen, len(b.ChainID))
|
||||
}
|
||||
|
||||
if b.Height < 0 {
|
||||
return errors.New("negative Header.Height")
|
||||
} else if b.Height == 0 {
|
||||
return errors.New("zero Header.Height")
|
||||
}
|
||||
|
||||
// NOTE: Timestamp validation is subtle and handled elsewhere.
|
||||
|
||||
if err := b.LastBlockID.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("wrong Header.LastBlockID: %v", err)
|
||||
if err := b.Header.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid header: %w", err)
|
||||
}
|
||||
|
||||
// Validate the last commit and its hash.
|
||||
@@ -78,9 +68,7 @@ func (b *Block) ValidateBasic() error {
|
||||
return fmt.Errorf("wrong LastCommit: %v", err)
|
||||
}
|
||||
}
|
||||
if err := ValidateHash(b.LastCommitHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.LastCommitHash: %v", err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(b.LastCommitHash, b.LastCommit.Hash()) {
|
||||
return fmt.Errorf("wrong Header.LastCommitHash. Expected %v, got %v",
|
||||
b.LastCommit.Hash(),
|
||||
@@ -88,12 +76,7 @@ func (b *Block) ValidateBasic() error {
|
||||
)
|
||||
}
|
||||
|
||||
// Validate the hash of the transactions.
|
||||
// NOTE: b.Data.Txs may be nil, but b.Data.Hash()
|
||||
// still works fine
|
||||
if err := ValidateHash(b.DataHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.DataHash: %v", err)
|
||||
}
|
||||
// NOTE: b.Data.Txs may be nil, but b.Data.Hash() still works fine.
|
||||
if !bytes.Equal(b.DataHash, b.Data.Hash()) {
|
||||
return fmt.Errorf(
|
||||
"wrong Header.DataHash. Expected %v, got %v",
|
||||
@@ -102,32 +85,13 @@ func (b *Block) ValidateBasic() error {
|
||||
)
|
||||
}
|
||||
|
||||
// Basic validation of hashes related to application data.
|
||||
// Will validate fully against state in state#ValidateBlock.
|
||||
if err := ValidateHash(b.ValidatorsHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.ValidatorsHash: %v", err)
|
||||
}
|
||||
if err := ValidateHash(b.NextValidatorsHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.NextValidatorsHash: %v", err)
|
||||
}
|
||||
if err := ValidateHash(b.ConsensusHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.ConsensusHash: %v", err)
|
||||
}
|
||||
// NOTE: AppHash is arbitrary length
|
||||
if err := ValidateHash(b.LastResultsHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.LastResultsHash: %v", err)
|
||||
}
|
||||
|
||||
// Validate evidence and its hash.
|
||||
if err := ValidateHash(b.EvidenceHash); err != nil {
|
||||
return fmt.Errorf("wrong Header.EvidenceHash: %v", err)
|
||||
}
|
||||
// NOTE: b.Evidence.Evidence may be nil, but we're just looping.
|
||||
for i, ev := range b.Evidence.Evidence {
|
||||
if err := ev.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid evidence (#%d): %v", i, err)
|
||||
}
|
||||
}
|
||||
|
||||
if !bytes.Equal(b.EvidenceHash, b.Evidence.Hash()) {
|
||||
return fmt.Errorf("wrong Header.EvidenceHash. Expected %v, got %v",
|
||||
b.EvidenceHash,
|
||||
@@ -135,11 +99,6 @@ func (b *Block) ValidateBasic() error {
|
||||
)
|
||||
}
|
||||
|
||||
if len(b.ProposerAddress) != crypto.AddressSize {
|
||||
return fmt.Errorf("expected len(Header.ProposerAddress) to be %d, got %d",
|
||||
crypto.AddressSize, len(b.ProposerAddress))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -368,6 +327,63 @@ func (h *Header) Populate(
|
||||
h.ProposerAddress = proposerAddress
|
||||
}
|
||||
|
||||
// ValidateBasic performs stateless validation on a Header returning an error
|
||||
// if any validation fails.
|
||||
//
|
||||
// NOTE: Timestamp validation is subtle and handled elsewhere.
|
||||
func (h Header) ValidateBasic() error {
|
||||
if len(h.ChainID) > MaxChainIDLen {
|
||||
return fmt.Errorf("chainID is too long; got: %d, max: %d", len(h.ChainID), MaxChainIDLen)
|
||||
}
|
||||
|
||||
if h.Height < 0 {
|
||||
return errors.New("negative Height")
|
||||
} else if h.Height == 0 {
|
||||
return errors.New("zero Height")
|
||||
}
|
||||
|
||||
if err := h.LastBlockID.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("wrong LastBlockID: %w", err)
|
||||
}
|
||||
|
||||
if err := ValidateHash(h.LastCommitHash); err != nil {
|
||||
return fmt.Errorf("wrong LastCommitHash: %v", err)
|
||||
}
|
||||
|
||||
if err := ValidateHash(h.DataHash); err != nil {
|
||||
return fmt.Errorf("wrong DataHash: %v", err)
|
||||
}
|
||||
|
||||
if err := ValidateHash(h.EvidenceHash); err != nil {
|
||||
return fmt.Errorf("wrong EvidenceHash: %v", err)
|
||||
}
|
||||
|
||||
if len(h.ProposerAddress) != crypto.AddressSize {
|
||||
return fmt.Errorf(
|
||||
"invalid ProposerAddress length; got: %d, expected: %d",
|
||||
len(h.ProposerAddress), crypto.AddressSize,
|
||||
)
|
||||
}
|
||||
|
||||
// Basic validation of hashes related to application data.
|
||||
// Will validate fully against state in state#ValidateBlock.
|
||||
if err := ValidateHash(h.ValidatorsHash); err != nil {
|
||||
return fmt.Errorf("wrong ValidatorsHash: %v", err)
|
||||
}
|
||||
if err := ValidateHash(h.NextValidatorsHash); err != nil {
|
||||
return fmt.Errorf("wrong NextValidatorsHash: %v", err)
|
||||
}
|
||||
if err := ValidateHash(h.ConsensusHash); err != nil {
|
||||
return fmt.Errorf("wrong ConsensusHash: %v", err)
|
||||
}
|
||||
// NOTE: AppHash is arbitrary length
|
||||
if err := ValidateHash(h.LastResultsHash); err != nil {
|
||||
return fmt.Errorf("wrong LastResultsHash: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Hash returns the hash of the header.
|
||||
// It computes a Merkle tree from the header fields
|
||||
// ordered as they appear in the Header.
|
||||
@@ -747,7 +763,8 @@ func (commit *Commit) StringIndented(indent string) string {
|
||||
// It is the basis of the lite client.
|
||||
type SignedHeader struct {
|
||||
*Header `json:"header"`
|
||||
Commit *Commit `json:"commit"`
|
||||
|
||||
Commit *Commit `json:"commit"`
|
||||
}
|
||||
|
||||
// ValidateBasic does basic consistency checks and makes sure the header
|
||||
@@ -761,21 +778,21 @@ func (sh SignedHeader) ValidateBasic(chainID string) error {
|
||||
return errors.New("missing header")
|
||||
}
|
||||
if sh.Commit == nil {
|
||||
return errors.New("missing commit (precommit votes)")
|
||||
return errors.New("missing commit")
|
||||
}
|
||||
|
||||
// if err := sh.Header.ValidateBasic(); err != nil {
|
||||
// return fmt.Errorf("header.ValidateBasic failed: %w", err)
|
||||
// }
|
||||
|
||||
if err := sh.Header.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid header: %w", err)
|
||||
}
|
||||
if err := sh.Commit.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("commit.ValidateBasic failed: %w", err)
|
||||
return fmt.Errorf("invalid commit: %w", err)
|
||||
}
|
||||
|
||||
// Make sure the header is consistent with the commit.
|
||||
if sh.ChainID != chainID {
|
||||
return fmt.Errorf("header belongs to another chain %q, not %q", sh.ChainID, chainID)
|
||||
}
|
||||
|
||||
// Make sure the header is consistent with the commit.
|
||||
if sh.Commit.Height != sh.Height {
|
||||
return fmt.Errorf("header and commit height mismatch: %d vs %d", sh.Height, sh.Commit.Height)
|
||||
}
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ func TestBlockAddEvidence(t *testing.T) {
|
||||
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
|
||||
require.NoError(t, err)
|
||||
|
||||
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
|
||||
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
|
||||
evList := []Evidence{ev}
|
||||
|
||||
block := MakeBlock(h, txs, commit, evList)
|
||||
@@ -60,7 +60,7 @@ func TestBlockValidateBasic(t *testing.T) {
|
||||
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
|
||||
require.NoError(t, err)
|
||||
|
||||
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
|
||||
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
|
||||
evList := []Evidence{ev}
|
||||
|
||||
testCases := []struct {
|
||||
@@ -123,7 +123,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) {
|
||||
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
|
||||
require.NoError(t, err)
|
||||
|
||||
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
|
||||
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
|
||||
evList := []Evidence{ev}
|
||||
|
||||
partSet := MakeBlock(h, []Tx{Tx("Hello World")}, commit, evList).MakePartSet(512)
|
||||
@@ -140,7 +140,7 @@ func TestBlockHashesTo(t *testing.T) {
|
||||
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
|
||||
require.NoError(t, err)
|
||||
|
||||
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
|
||||
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
|
||||
evList := []Evidence{ev}
|
||||
|
||||
block := MakeBlock(h, []Tx{Tx("Hello World")}, commit, evList)
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/kv"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
@@ -27,7 +26,7 @@ func TestEventBusPublishEventTx(t *testing.T) {
|
||||
result := abci.ResponseDeliverTx{
|
||||
Data: []byte("bar"),
|
||||
Events: []abci.Event{
|
||||
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -71,12 +70,12 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
|
||||
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
|
||||
resultBeginBlock := abci.ResponseBeginBlock{
|
||||
Events: []abci.Event{
|
||||
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
},
|
||||
}
|
||||
resultEndBlock := abci.ResponseEndBlock{
|
||||
Events: []abci.Event{
|
||||
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("foz"), Value: []byte("2")}}},
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
Events: []abci.Event{
|
||||
{
|
||||
Type: "transfer",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("sender"), Value: []byte("foo")},
|
||||
{Key: []byte("recipient"), Value: []byte("bar")},
|
||||
{Key: []byte("amount"), Value: []byte("5")},
|
||||
@@ -129,7 +128,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Type: "transfer",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("sender"), Value: []byte("baz")},
|
||||
{Key: []byte("recipient"), Value: []byte("cat")},
|
||||
{Key: []byte("amount"), Value: []byte("13")},
|
||||
@@ -137,7 +136,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Type: "withdraw.rewards",
|
||||
Attributes: []kv.Pair{
|
||||
Attributes: []abci.EventAttribute{
|
||||
{Key: []byte("address"), Value: []byte("bar")},
|
||||
{Key: []byte("source"), Value: []byte("iceman")},
|
||||
{Key: []byte("amount"), Value: []byte("33")},
|
||||
@@ -218,12 +217,12 @@ func TestEventBusPublishEventNewBlockHeader(t *testing.T) {
|
||||
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
|
||||
resultBeginBlock := abci.ResponseBeginBlock{
|
||||
Events: []abci.Event{
|
||||
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
|
||||
},
|
||||
}
|
||||
resultEndBlock := abci.ResponseEndBlock{
|
||||
Events: []abci.Event{
|
||||
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("foz"), Value: []byte("2")}}},
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+16
-22
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
const (
|
||||
// MaxEvidenceBytes is a maximum size of any evidence (including amino overhead).
|
||||
MaxEvidenceBytes int64 = 484
|
||||
MaxEvidenceBytes int64 = 444
|
||||
|
||||
// An invalid field in the header from LunaticValidatorEvidence.
|
||||
// Must be a function of the ABCI application state.
|
||||
@@ -117,16 +117,15 @@ func MaxEvidencePerBlock(blockMaxBytes int64) (int64, int64) {
|
||||
// DuplicateVoteEvidence contains evidence a validator signed two conflicting
|
||||
// votes.
|
||||
type DuplicateVoteEvidence struct {
|
||||
PubKey crypto.PubKey
|
||||
VoteA *Vote
|
||||
VoteB *Vote
|
||||
VoteA *Vote
|
||||
VoteB *Vote
|
||||
}
|
||||
|
||||
var _ Evidence = &DuplicateVoteEvidence{}
|
||||
|
||||
// NewDuplicateVoteEvidence creates DuplicateVoteEvidence with right ordering given
|
||||
// two conflicting votes. If one of the votes is nil, evidence returned is nil as well
|
||||
func NewDuplicateVoteEvidence(pubkey crypto.PubKey, vote1 *Vote, vote2 *Vote) *DuplicateVoteEvidence {
|
||||
func NewDuplicateVoteEvidence(vote1 *Vote, vote2 *Vote) *DuplicateVoteEvidence {
|
||||
var voteA, voteB *Vote
|
||||
if vote1 == nil || vote2 == nil {
|
||||
return nil
|
||||
@@ -139,9 +138,8 @@ func NewDuplicateVoteEvidence(pubkey crypto.PubKey, vote1 *Vote, vote2 *Vote) *D
|
||||
voteB = vote1
|
||||
}
|
||||
return &DuplicateVoteEvidence{
|
||||
PubKey: pubkey,
|
||||
VoteA: voteA,
|
||||
VoteB: voteB,
|
||||
VoteA: voteA,
|
||||
VoteB: voteB,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +161,7 @@ func (dve *DuplicateVoteEvidence) Time() time.Time {
|
||||
|
||||
// Address returns the address of the validator.
|
||||
func (dve *DuplicateVoteEvidence) Address() []byte {
|
||||
return dve.PubKey.Address()
|
||||
return dve.VoteA.ValidatorAddress
|
||||
}
|
||||
|
||||
// Hash returns the hash of the evidence.
|
||||
@@ -247,9 +245,6 @@ func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool {
|
||||
|
||||
// ValidateBasic performs basic validation.
|
||||
func (dve *DuplicateVoteEvidence) ValidateBasic() error {
|
||||
if len(dve.PubKey.Bytes()) == 0 {
|
||||
return errors.New("empty PubKey")
|
||||
}
|
||||
if dve.VoteA == nil || dve.VoteB == nil {
|
||||
return fmt.Errorf("one or both of the votes are empty %v, %v", dve.VoteA, dve.VoteB)
|
||||
}
|
||||
@@ -424,9 +419,8 @@ OUTER_LOOP:
|
||||
// immediately slashable (#F1).
|
||||
if ev.H1.Commit.Round == ev.H2.Commit.Round {
|
||||
evList = append(evList, &DuplicateVoteEvidence{
|
||||
PubKey: val.PubKey,
|
||||
VoteA: ev.H1.Commit.GetVote(i),
|
||||
VoteB: ev.H2.Commit.GetVote(j),
|
||||
VoteA: ev.H1.Commit.GetVote(i),
|
||||
VoteB: ev.H2.Commit.GetVote(j),
|
||||
})
|
||||
} else {
|
||||
// if H1.Round != H2.Round we need to run full detection procedure => not
|
||||
@@ -632,9 +626,9 @@ func (e PhantomValidatorEvidence) ValidateBasic() error {
|
||||
return errors.New("empty vote")
|
||||
}
|
||||
|
||||
// if err := e.Header.ValidateBasic(); err != nil {
|
||||
// return fmt.Errorf("invalid header: %v", err)
|
||||
// }
|
||||
if err := e.Header.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid header: %v", err)
|
||||
}
|
||||
|
||||
if err := e.Vote.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid signature: %v", err)
|
||||
@@ -735,9 +729,9 @@ func (e LunaticValidatorEvidence) ValidateBasic() error {
|
||||
return errors.New("empty vote")
|
||||
}
|
||||
|
||||
// if err := e.Header.ValidateBasic(); err != nil {
|
||||
// return fmt.Errorf("invalid header: %v", err)
|
||||
// }
|
||||
if err := e.Header.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid header: %v", err)
|
||||
}
|
||||
|
||||
if err := e.Vote.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("invalid signature: %v", err)
|
||||
@@ -957,7 +951,7 @@ type MockEvidence struct {
|
||||
var _ Evidence = &MockEvidence{}
|
||||
|
||||
// UNSTABLE
|
||||
func NewMockEvidence(height int64, eTime time.Time, idx int, address []byte) MockEvidence {
|
||||
func NewMockEvidence(height int64, eTime time.Time, address []byte) MockEvidence {
|
||||
return MockEvidence{
|
||||
EvidenceHeight: height,
|
||||
EvidenceTime: eTime,
|
||||
|
||||
+44
-12
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
)
|
||||
@@ -108,15 +107,49 @@ func TestMaxEvidenceBytes(t *testing.T) {
|
||||
blockID2 := makeBlockID(tmhash.Sum([]byte("blockhash2")), math.MaxInt64, tmhash.Sum([]byte("partshash")))
|
||||
const chainID = "mychain"
|
||||
ev := &DuplicateVoteEvidence{
|
||||
PubKey: secp256k1.GenPrivKey().PubKey(), // use secp because it's pubkey is longer
|
||||
VoteA: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID),
|
||||
VoteB: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
|
||||
VoteA: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID),
|
||||
VoteB: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
|
||||
}
|
||||
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(ev)
|
||||
require.NoError(t, err)
|
||||
//TODO: Add other types of evidence to test and set MaxEvidenceBytes accordingly
|
||||
|
||||
// evl := &LunaticValidatorEvidence{
|
||||
// Header: makeHeaderRandom(),
|
||||
// Vote: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
|
||||
|
||||
// InvalidHeaderField: "",
|
||||
// }
|
||||
|
||||
// evp := &PhantomValidatorEvidence{
|
||||
// Header: makeHeaderRandom(),
|
||||
// Vote: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
|
||||
|
||||
// LastHeightValidatorWasInSet: math.MaxInt64,
|
||||
// }
|
||||
|
||||
// signedHeader := SignedHeader{Header: makeHeaderRandom(), Commit: randCommit(time.Now())}
|
||||
// evc := &ConflictingHeadersEvidence{
|
||||
// H1: &signedHeader,
|
||||
// H2: &signedHeader,
|
||||
// }
|
||||
|
||||
testCases := []struct {
|
||||
testName string
|
||||
evidence Evidence
|
||||
}{
|
||||
{"DuplicateVote", ev},
|
||||
// {"LunaticValidatorEvidence", evl},
|
||||
// {"PhantomValidatorEvidence", evp},
|
||||
// {"ConflictingHeadersEvidence", evc},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(tt.evidence)
|
||||
require.NoError(t, err, tt.testName)
|
||||
|
||||
assert.LessOrEqual(t, MaxEvidenceBytes, int64(len(bz)), tt.testName)
|
||||
}
|
||||
|
||||
assert.EqualValues(t, MaxEvidenceBytes, len(bz))
|
||||
}
|
||||
|
||||
func randomDuplicatedVoteEvidence(t *testing.T) *DuplicateVoteEvidence {
|
||||
@@ -160,10 +193,9 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) {
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
pk := secp256k1.GenPrivKey().PubKey()
|
||||
vote1 := makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, 0x02, blockID)
|
||||
vote2 := makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, 0x02, blockID2)
|
||||
ev := NewDuplicateVoteEvidence(pk, vote1, vote2)
|
||||
ev := NewDuplicateVoteEvidence(vote1, vote2)
|
||||
tc.malleateEvidence(ev)
|
||||
assert.Equal(t, tc.expectErr, ev.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
})
|
||||
@@ -171,12 +203,12 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMockGoodEvidenceValidateBasic(t *testing.T) {
|
||||
goodEvidence := NewMockEvidence(int64(1), time.Now(), 1, []byte{1})
|
||||
goodEvidence := NewMockEvidence(int64(1), time.Now(), []byte{1})
|
||||
assert.Nil(t, goodEvidence.ValidateBasic())
|
||||
}
|
||||
|
||||
func TestMockBadEvidenceValidateBasic(t *testing.T) {
|
||||
badEvidence := NewMockEvidence(int64(1), time.Now(), 1, []byte{1})
|
||||
badEvidence := NewMockEvidence(int64(1), time.Now(), []byte{1})
|
||||
assert.Nil(t, badEvidence.ValidateBasic())
|
||||
}
|
||||
|
||||
@@ -368,6 +400,6 @@ func makeHeaderRandom() *Header {
|
||||
AppHash: crypto.CRandBytes(tmhash.Size),
|
||||
LastResultsHash: crypto.CRandBytes(tmhash.Size),
|
||||
EvidenceHash: crypto.CRandBytes(tmhash.Size),
|
||||
ProposerAddress: crypto.CRandBytes(tmhash.Size),
|
||||
ProposerAddress: crypto.CRandBytes(crypto.AddressSize),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,9 +136,8 @@ func TestABCIEvidence(t *testing.T) {
|
||||
pubKey, err := val.GetPubKey()
|
||||
require.NoError(t, err)
|
||||
ev := &DuplicateVoteEvidence{
|
||||
PubKey: pubKey,
|
||||
VoteA: makeVote(t, val, chainID, 0, 10, 2, 1, blockID),
|
||||
VoteB: makeVote(t, val, chainID, 0, 10, 2, 1, blockID2),
|
||||
VoteA: makeVote(t, val, chainID, 0, 10, 2, 1, blockID),
|
||||
VoteB: makeVote(t, val, chainID, 0, 10, 2, 1, blockID2),
|
||||
}
|
||||
abciEv := TM2PB.Evidence(
|
||||
ev,
|
||||
|
||||
+2
-2
@@ -31,12 +31,12 @@ type ErrVoteConflictingVotes struct {
|
||||
}
|
||||
|
||||
func (err *ErrVoteConflictingVotes) Error() string {
|
||||
return fmt.Sprintf("conflicting votes from validator %X", err.PubKey.Address())
|
||||
return fmt.Sprintf("conflicting votes from validator %X", err.VoteA.ValidatorAddress)
|
||||
}
|
||||
|
||||
func NewConflictingVoteError(val *Validator, vote1, vote2 *Vote) *ErrVoteConflictingVotes {
|
||||
return &ErrVoteConflictingVotes{
|
||||
NewDuplicateVoteEvidence(val.PubKey, vote1, vote2),
|
||||
NewDuplicateVoteEvidence(vote1, vote2),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user