mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-22 23:21:30 +00:00
state: proto migration (#4951)
This commit is contained in:
@@ -31,6 +31,8 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
|
||||
- multisig: type `PubKeyMultisigThreshold` is now `PubKey`
|
||||
- [light] \#4946 Rename `lite2` pkg to `light`, the lite cmd has also been renamed to `light`. Remove `lite` implementation.
|
||||
- [rpc] \#4937 Return an error when `page` pagination param is 0 in `/validators`, `tx_search` (@melekes)
|
||||
- [state] \#4679 `TxResult` is a Protobuf type defined in `abci` types directory
|
||||
- [state] \#4679 `state` reactor migration to Protobuf encoding
|
||||
- [evidence] \#4959 Add json tags to `DuplicateVoteEvidence`
|
||||
|
||||
- Apps
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
stateKey = []byte("stateKey")
|
||||
kvPairPrefixKey = []byte("kvPairKey:")
|
||||
|
||||
ProtocolVersion version.Protocol = 0x1
|
||||
ProtocolVersion uint64 = 0x1
|
||||
)
|
||||
|
||||
type State struct {
|
||||
@@ -76,7 +76,7 @@ func (app *Application) Info(req types.RequestInfo) (resInfo types.ResponseInfo)
|
||||
return types.ResponseInfo{
|
||||
Data: fmt.Sprintf("{\"size\":%v}", app.state.Size),
|
||||
Version: version.ABCIVersion,
|
||||
AppVersion: ProtocolVersion.Uint64(),
|
||||
AppVersion: ProtocolVersion,
|
||||
LastBlockHeight: app.state.Height,
|
||||
LastBlockAppHash: app.state.AppHash,
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/tendermint/tendermint/abci/example/code"
|
||||
abciserver "github.com/tendermint/tendermint/abci/server"
|
||||
"github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -103,7 +104,7 @@ func TestPersistentKVStoreInfo(t *testing.T) {
|
||||
// make and apply block
|
||||
height = int64(1)
|
||||
hash := []byte("foo")
|
||||
header := types.Header{
|
||||
header := tmproto.Header{
|
||||
Height: height,
|
||||
}
|
||||
kvstore.BeginBlock(types.RequestBeginBlock{Hash: hash, Header: header})
|
||||
@@ -193,7 +194,7 @@ func makeApplyBlock(
|
||||
// make and apply block
|
||||
height := int64(heightInt)
|
||||
hash := []byte("foo")
|
||||
header := types.Header{
|
||||
header := tmproto.Header{
|
||||
Height: height,
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ func TestClientServer(t *testing.T) {
|
||||
// set up socket app
|
||||
kvstore := NewApplication()
|
||||
client, server, err := makeSocketClientServer(kvstore, "kvstore-socket")
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
defer server.Stop()
|
||||
defer client.Stop()
|
||||
|
||||
@@ -282,7 +283,7 @@ func TestClientServer(t *testing.T) {
|
||||
// set up grpc app
|
||||
kvstore = NewApplication()
|
||||
gclient, gserver, err := makeGRPCClientServer(kvstore, "kvstore-grpc")
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
defer gserver.Stop()
|
||||
defer gclient.Stop()
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
tmproto "github.com/tendermint/tendermint/proto/types"
|
||||
)
|
||||
|
||||
func TestMarshalJSON(t *testing.T) {
|
||||
@@ -53,13 +55,13 @@ func TestWriteReadMessageSimple(t *testing.T) {
|
||||
err = ReadMessage(buf, msg)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, c, msg)
|
||||
assert.True(t, proto.Equal(c, msg))
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriteReadMessage(t *testing.T) {
|
||||
cases := []proto.Message{
|
||||
&Header{
|
||||
&tmproto.Header{
|
||||
Height: 4,
|
||||
ChainID: "test",
|
||||
},
|
||||
@@ -71,11 +73,11 @@ func TestWriteReadMessage(t *testing.T) {
|
||||
err := WriteMessage(c, buf)
|
||||
assert.Nil(t, err)
|
||||
|
||||
msg := new(Header)
|
||||
msg := new(tmproto.Header)
|
||||
err = ReadMessage(buf, msg)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, c, msg)
|
||||
assert.True(t, proto.Equal(c, msg))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +109,6 @@ func TestWriteReadMessage2(t *testing.T) {
|
||||
err = ReadMessage(buf, msg)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, c, msg)
|
||||
assert.True(t, proto.Equal(c, msg))
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ option go_package = "github.com/tendermint/tendermint/abci/types";
|
||||
// For more information on gogo.proto, see:
|
||||
// https://github.com/gogo/protobuf/blob/master/extensions.md
|
||||
import "crypto/merkle/merkle.proto";
|
||||
import "proto/types/types.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
@@ -77,7 +78,7 @@ message RequestQuery {
|
||||
|
||||
message RequestBeginBlock {
|
||||
bytes hash = 1;
|
||||
Header header = 2 [(gogoproto.nullable) = false];
|
||||
tendermint.proto.types.Header header = 2 [(gogoproto.nullable) = false];
|
||||
LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
|
||||
repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
@@ -326,41 +327,19 @@ message Event {
|
||||
(gogoproto.jsontag) = "attributes,omitempty"];
|
||||
}
|
||||
|
||||
// TxResult contains results of executing the transaction.
|
||||
//
|
||||
// One usage is indexing transaction results.
|
||||
message TxResult {
|
||||
int64 height = 1;
|
||||
uint32 Index = 2;
|
||||
bytes tx = 3;
|
||||
ResponseDeliverTx result = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Blockchain Types
|
||||
|
||||
message Header {
|
||||
// basic block info
|
||||
Version 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];
|
||||
|
||||
// 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 tx results from prev block
|
||||
|
||||
// consensus info
|
||||
bytes evidence_hash = 13; // evidence included in the block
|
||||
bytes proposer_address = 14; // original proposer of the block
|
||||
}
|
||||
|
||||
message Version {
|
||||
uint64 Block = 1;
|
||||
uint64 App = 2;
|
||||
}
|
||||
|
||||
message BlockID {
|
||||
bytes hash = 1;
|
||||
PartSetHeader parts_header = 2 [(gogoproto.nullable) = false];
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
var crc32c = crc32.MakeTable(crc32.Castagnoli)
|
||||
@@ -259,8 +258,8 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
|
||||
)
|
||||
|
||||
// Set AppVersion on the state.
|
||||
if h.initialState.Version.Consensus.App != version.Protocol(res.AppVersion) {
|
||||
h.initialState.Version.Consensus.App = version.Protocol(res.AppVersion)
|
||||
if h.initialState.Version.Consensus.App != res.AppVersion {
|
||||
h.initialState.Version.Consensus.App = res.AppVersion
|
||||
sm.SaveState(h.stateDB, h.initialState)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -1086,7 +1085,7 @@ func readPieceFromWAL(msg *TimedWALMessage) interface{} {
|
||||
func stateAndStore(
|
||||
config *cfg.Config,
|
||||
pubKey crypto.PubKey,
|
||||
appVersion version.Protocol) (dbm.DB, sm.State, *mockBlockStore) {
|
||||
appVersion uint64) (dbm.DB, sm.State, *mockBlockStore) {
|
||||
stateDB := dbm.NewMemDB()
|
||||
state, _ := sm.MakeGenesisStateFromFile(config.GenesisFile())
|
||||
state.Version.Consensus.App = appVersion
|
||||
|
||||
2
go.mod
2
go.mod
@@ -11,7 +11,7 @@ require (
|
||||
github.com/go-kit/kit v0.10.0
|
||||
github.com/go-logfmt/logfmt v0.5.0
|
||||
github.com/gogo/protobuf v1.3.1
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/golang/protobuf v1.4.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/gtank/merlin v0.1.1
|
||||
github.com/libp2p/go-buffer-pool v0.0.2
|
||||
|
||||
5
go.sum
5
go.sum
@@ -160,14 +160,13 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
@@ -652,8 +651,6 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/tendermint/tendermint/store"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
func TestNodeStartStop(t *testing.T) {
|
||||
@@ -120,7 +119,7 @@ func TestNodeSetAppVersion(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// default config uses the kvstore app
|
||||
var appVersion version.Protocol = kvstore.ProtocolVersion
|
||||
var appVersion uint64 = kvstore.ProtocolVersion
|
||||
|
||||
// check version is set in state
|
||||
state := sm.LoadState(n.stateDB)
|
||||
|
||||
@@ -44,9 +44,9 @@ type nodeInfoTransport interface {
|
||||
|
||||
// ProtocolVersion contains the protocol versions for the software.
|
||||
type ProtocolVersion struct {
|
||||
P2P version.Protocol `json:"p2p"`
|
||||
Block version.Protocol `json:"block"`
|
||||
App version.Protocol `json:"app"`
|
||||
P2P uint64 `json:"p2p"`
|
||||
Block uint64 `json:"block"`
|
||||
App uint64 `json:"app"`
|
||||
}
|
||||
|
||||
// defaultProtocolVersion populates the Block and P2P versions using
|
||||
@@ -58,7 +58,7 @@ var defaultProtocolVersion = NewProtocolVersion(
|
||||
)
|
||||
|
||||
// NewProtocolVersion returns a fully populated ProtocolVersion.
|
||||
func NewProtocolVersion(p2p, block, app version.Protocol) ProtocolVersion {
|
||||
func NewProtocolVersion(p2p, block, app uint64) ProtocolVersion {
|
||||
return ProtocolVersion{
|
||||
P2P: p2p,
|
||||
Block: block,
|
||||
|
||||
@@ -5,8 +5,11 @@ package merkle
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@@ -37,16 +40,25 @@ func (*SimpleProof) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_57e39eefdaf7ae96, []int{0}
|
||||
}
|
||||
func (m *SimpleProof) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SimpleProof.Unmarshal(m, b)
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SimpleProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SimpleProof.Marshal(b, m, deterministic)
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SimpleProof.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SimpleProof) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SimpleProof.Merge(m, src)
|
||||
}
|
||||
func (m *SimpleProof) XXX_Size() int {
|
||||
return xxx_messageInfo_SimpleProof.Size(m)
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SimpleProof) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SimpleProof.DiscardUnknown(m)
|
||||
@@ -89,17 +101,361 @@ func init() {
|
||||
func init() { proto.RegisterFile("proto/crypto/merkle/types.proto", fileDescriptor_57e39eefdaf7ae96) }
|
||||
|
||||
var fileDescriptor_57e39eefdaf7ae96 = []byte{
|
||||
// 188 bytes of a gzipped FileDescriptorProto
|
||||
// 225 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0xd7, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0xca, 0xce, 0x49, 0xd5,
|
||||
0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x03, 0xcb, 0x08, 0xc9, 0x95, 0xa4, 0xe6, 0xa5, 0xa4, 0x16,
|
||||
0xe5, 0x66, 0xe6, 0x95, 0x40, 0x44, 0xf4, 0x20, 0x6a, 0xf5, 0x20, 0x6a, 0x95, 0x72, 0xb8, 0xb8,
|
||||
0x83, 0x33, 0x73, 0x0b, 0x72, 0x52, 0x03, 0x8a, 0xf2, 0xf3, 0xd3, 0x84, 0x44, 0xb8, 0x58, 0x4b,
|
||||
0xf2, 0x4b, 0x12, 0x73, 0x24, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0x20, 0x1c, 0x90, 0x68, 0x66,
|
||||
0x5e, 0x4a, 0x6a, 0x85, 0x04, 0x13, 0x44, 0x14, 0xcc, 0x11, 0x92, 0xe6, 0xe2, 0xcc, 0x49, 0x4d,
|
||||
0x4c, 0x8b, 0xcf, 0x48, 0x2c, 0xce, 0x90, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x09, 0xe2, 0x00, 0x09,
|
||||
0x78, 0x24, 0x16, 0x67, 0x80, 0xb4, 0x24, 0x96, 0xe6, 0x95, 0x14, 0x4b, 0xb0, 0x28, 0x30, 0x6b,
|
||||
0xf0, 0x04, 0x41, 0x38, 0x4e, 0x66, 0x51, 0x26, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9,
|
||||
0xf9, 0xb9, 0xfa, 0x08, 0xa7, 0x21, 0x33, 0xb1, 0xf8, 0x28, 0x89, 0x0d, 0x2c, 0x68, 0x0c, 0x08,
|
||||
0x00, 0x00, 0xff, 0xff, 0x4f, 0x08, 0x9a, 0xf1, 0xef, 0x00, 0x00, 0x00,
|
||||
0xe5, 0x66, 0xe6, 0x95, 0x40, 0x44, 0xf4, 0x20, 0x6a, 0xf5, 0x20, 0x6a, 0xa5, 0xd4, 0x4a, 0x32,
|
||||
0x32, 0x8b, 0x52, 0xe2, 0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0x21, 0x86, 0xa5, 0xe7, 0xa7, 0xe7,
|
||||
0x23, 0x58, 0x10, 0x5d, 0x4a, 0x39, 0x5c, 0xdc, 0xc1, 0x99, 0xb9, 0x05, 0x39, 0xa9, 0x01, 0x45,
|
||||
0xf9, 0xf9, 0x69, 0x42, 0x22, 0x5c, 0xac, 0x25, 0xf9, 0x25, 0x89, 0x39, 0x12, 0x8c, 0x0a, 0x8c,
|
||||
0x1a, 0xcc, 0x41, 0x10, 0x0e, 0x48, 0x34, 0x33, 0x2f, 0x25, 0xb5, 0x42, 0x82, 0x09, 0x22, 0x0a,
|
||||
0xe6, 0x08, 0x49, 0x73, 0x71, 0xe6, 0xa4, 0x26, 0xa6, 0xc5, 0x67, 0x24, 0x16, 0x67, 0x48, 0x30,
|
||||
0x2b, 0x30, 0x6a, 0xf0, 0x04, 0x71, 0x80, 0x04, 0x3c, 0x12, 0x8b, 0x33, 0x40, 0x5a, 0x12, 0x4b,
|
||||
0xf3, 0x4a, 0x8a, 0x25, 0x58, 0x14, 0x98, 0x35, 0x78, 0x82, 0x20, 0x1c, 0x27, 0xa7, 0x13, 0x8f,
|
||||
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0xca, 0x24, 0x3d, 0xb3, 0x24,
|
||||
0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe1, 0x1d, 0x64, 0x26, 0x96, 0x50, 0x48, 0x62,
|
||||
0x03, 0x0b, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x90, 0x2f, 0xe5, 0x58, 0x23, 0x01, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (m *SimpleProof) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SimpleProof) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SimpleProof) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.XXX_unrecognized != nil {
|
||||
i -= len(m.XXX_unrecognized)
|
||||
copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
if len(m.Aunts) > 0 {
|
||||
for iNdEx := len(m.Aunts) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Aunts[iNdEx])
|
||||
copy(dAtA[i:], m.Aunts[iNdEx])
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.Aunts[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.LeafHash) > 0 {
|
||||
i -= len(m.LeafHash)
|
||||
copy(dAtA[i:], m.LeafHash)
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.LeafHash)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if m.Index != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Index))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
}
|
||||
if m.Total != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Total))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTypes(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTypes(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *SimpleProof) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Total != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Total))
|
||||
}
|
||||
if m.Index != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Index))
|
||||
}
|
||||
l = len(m.LeafHash)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
if len(m.Aunts) > 0 {
|
||||
for _, b := range m.Aunts {
|
||||
l = len(b)
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTypes(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozTypes(x uint64) (n int) {
|
||||
return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *SimpleProof) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: SimpleProof: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SimpleProof: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType)
|
||||
}
|
||||
m.Total = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Total |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
|
||||
}
|
||||
m.Index = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Index |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field LeafHash", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.LeafHash = append(m.LeafHash[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.LeafHash == nil {
|
||||
m.LeafHash = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Aunts", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Aunts = append(m.Aunts, make([]byte, postIndex-iNdEx))
|
||||
copy(m.Aunts[len(m.Aunts)-1], dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTypes(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTypes(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTypes
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTypes
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTypes
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
|
||||
@@ -3,6 +3,12 @@ package tendermint.proto.crypto.merkle;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/crypto/merkle";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.marshaler_all) = true;
|
||||
option (gogoproto.unmarshaler_all) = true;
|
||||
option (gogoproto.sizer_all) = true;
|
||||
|
||||
message SimpleProof {
|
||||
int64 total = 1;
|
||||
int64 index = 2;
|
||||
|
||||
@@ -5,12 +5,17 @@ package bits
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
golang_proto "github.com/golang/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = golang_proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
@@ -35,16 +40,25 @@ 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)
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *BitArray) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BitArray.Marshal(b, m, deterministic)
|
||||
if deterministic {
|
||||
return xxx_messageInfo_BitArray.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
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)
|
||||
return m.Size()
|
||||
}
|
||||
func (m *BitArray) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BitArray.DiscardUnknown(m)
|
||||
@@ -68,19 +82,349 @@ func (m *BitArray) GetElems() []uint64 {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*BitArray)(nil), "tendermint.proto.libs.bits.BitArray")
|
||||
golang_proto.RegisterType((*BitArray)(nil), "tendermint.proto.libs.bits.BitArray")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/libs/bits/types.proto", fileDescriptor_3f1fbe70d7999e09) }
|
||||
func init() {
|
||||
golang_proto.RegisterFile("proto/libs/bits/types.proto", fileDescriptor_3f1fbe70d7999e09)
|
||||
}
|
||||
|
||||
var fileDescriptor_3f1fbe70d7999e09 = []byte{
|
||||
// 140 bytes of a gzipped FileDescriptorProto
|
||||
// 182 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,
|
||||
0x40, 0x44, 0xf4, 0x40, 0xea, 0xf4, 0x40, 0xea, 0xa4, 0xd4, 0x4a, 0x32, 0x32, 0x8b, 0x52, 0xe2,
|
||||
0x0b, 0x12, 0x8b, 0x4a, 0x2a, 0xf5, 0x21, 0x86, 0xa4, 0xe7, 0xa7, 0xe7, 0x23, 0x58, 0x10, 0x1d,
|
||||
0x4a, 0x26, 0x5c, 0x1c, 0x4e, 0x99, 0x25, 0x8e, 0x45, 0x45, 0x89, 0x95, 0x42, 0x42, 0x5c, 0x2c,
|
||||
0x20, 0xbd, 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, 0xe4, 0x74, 0xe2,
|
||||
0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x1e, 0x78, 0x2c, 0xc7, 0x18,
|
||||
0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0x70, 0x16, 0x32,
|
||||
0x13, 0xcd, 0x27, 0x49, 0x6c, 0x60, 0x01, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xed,
|
||||
0xf8, 0x61, 0xe3, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *BitArray) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *BitArray) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *BitArray) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.XXX_unrecognized != nil {
|
||||
i -= len(m.XXX_unrecognized)
|
||||
copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
if len(m.Elems) > 0 {
|
||||
dAtA2 := make([]byte, len(m.Elems)*10)
|
||||
var j1 int
|
||||
for _, num := range m.Elems {
|
||||
for num >= 1<<7 {
|
||||
dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80)
|
||||
num >>= 7
|
||||
j1++
|
||||
}
|
||||
dAtA2[j1] = uint8(num)
|
||||
j1++
|
||||
}
|
||||
i -= j1
|
||||
copy(dAtA[i:], dAtA2[:j1])
|
||||
i = encodeVarintTypes(dAtA, i, uint64(j1))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.Bits != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Bits))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTypes(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTypes(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *BitArray) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Bits != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Bits))
|
||||
}
|
||||
if len(m.Elems) > 0 {
|
||||
l = 0
|
||||
for _, e := range m.Elems {
|
||||
l += sovTypes(uint64(e))
|
||||
}
|
||||
n += 1 + sovTypes(uint64(l)) + l
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTypes(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozTypes(x uint64) (n int) {
|
||||
return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *BitArray) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: BitArray: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: BitArray: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType)
|
||||
}
|
||||
m.Bits = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Bits |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType == 0 {
|
||||
var v uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.Elems = append(m.Elems, v)
|
||||
} else if wireType == 2 {
|
||||
var packedLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
packedLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if packedLen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + packedLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
var elementCount int
|
||||
var count int
|
||||
for _, integer := range dAtA[iNdEx:postIndex] {
|
||||
if integer < 128 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
elementCount = count
|
||||
if elementCount != 0 && len(m.Elems) == 0 {
|
||||
m.Elems = make([]uint64, 0, elementCount)
|
||||
}
|
||||
for iNdEx < postIndex {
|
||||
var v uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.Elems = append(m.Elems, v)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Elems", wireType)
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTypes(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTypes(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTypes
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTypes
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTypes
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
|
||||
@@ -3,6 +3,13 @@ package tendermint.proto.libs.bits;
|
||||
|
||||
option go_package = "github.com/tendermint/tendermint/proto/libs/bits";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.marshaler_all) = true;
|
||||
option (gogoproto.unmarshaler_all) = true;
|
||||
option (gogoproto.sizer_all) = true;
|
||||
option (gogoproto.goproto_registration) = true;
|
||||
|
||||
message BitArray {
|
||||
int64 bits = 1;
|
||||
repeated uint64 elems = 2;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,11 @@ import "proto/libs/bits/types.proto";
|
||||
import "proto/crypto/merkle/types.proto";
|
||||
import "proto/version/version.proto";
|
||||
|
||||
option (gogoproto.marshaler_all) = true;
|
||||
option (gogoproto.unmarshaler_all) = true;
|
||||
option (gogoproto.sizer_all) = true;
|
||||
option (gogoproto.goproto_registration) = true;
|
||||
|
||||
// BlockIdFlag indicates which BlcokID the signature is for
|
||||
enum BlockIDFlag {
|
||||
option (gogoproto.goproto_enum_stringer) = false;
|
||||
@@ -60,7 +65,7 @@ message Header {
|
||||
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"];
|
||||
BlockID last_block_id = 5 [(gogoproto.nullable) = false];
|
||||
|
||||
// hashes of block data
|
||||
bytes last_commit_hash = 6; // commit from validators from the last block
|
||||
|
||||
@@ -8,11 +8,15 @@ import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
golang_proto "github.com/golang/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = golang_proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
@@ -40,16 +44,25 @@ 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)
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *App) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_App.Marshal(b, m, deterministic)
|
||||
if deterministic {
|
||||
return xxx_messageInfo_App.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
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)
|
||||
return m.Size()
|
||||
}
|
||||
func (m *App) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_App.DiscardUnknown(m)
|
||||
@@ -89,16 +102,25 @@ 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)
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Consensus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Consensus.Marshal(b, m, deterministic)
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Consensus.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
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)
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Consensus) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Consensus.DiscardUnknown(m)
|
||||
@@ -122,13 +144,18 @@ func (m *Consensus) GetApp() uint64 {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*App)(nil), "tendermint.proto.version.App")
|
||||
golang_proto.RegisterType((*App)(nil), "tendermint.proto.version.App")
|
||||
proto.RegisterType((*Consensus)(nil), "tendermint.proto.version.Consensus")
|
||||
golang_proto.RegisterType((*Consensus)(nil), "tendermint.proto.version.Consensus")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("proto/version/version.proto", fileDescriptor_14aa2353622f11e1) }
|
||||
func init() {
|
||||
golang_proto.RegisterFile("proto/version/version.proto", fileDescriptor_14aa2353622f11e1)
|
||||
}
|
||||
|
||||
var fileDescriptor_14aa2353622f11e1 = []byte{
|
||||
// 198 bytes of a gzipped FileDescriptorProto
|
||||
// 216 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,
|
||||
@@ -138,10 +165,11 @@ var fileDescriptor_14aa2353622f11e1 = []byte{
|
||||
0xb9, 0xe2, 0xfc, 0xb4, 0x92, 0xf2, 0xc4, 0xa2, 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20,
|
||||
0x38, 0x5f, 0xc9, 0x92, 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, 0xb1, 0xbc, 0x58, 0x20, 0xcf, 0xe8, 0x64,
|
||||
0x10, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xf0, 0x08,
|
||||
0x32, 0x13, 0xc5, 0xef, 0x49, 0x6c, 0x60, 0xae, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xa6, 0xd3,
|
||||
0x5b, 0xf2, 0x13, 0x01, 0x00, 0x00,
|
||||
0x58, 0x50, 0x00, 0xd6, 0xc9, 0x12, 0x04, 0x62, 0x5a, 0xb1, 0xbc, 0x58, 0x20, 0xcf, 0xe8, 0xe4,
|
||||
0x70, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x1e, 0x78, 0x2c,
|
||||
0xc7, 0x18, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xf0,
|
||||
0x18, 0x32, 0x13, 0x25, 0x2c, 0x92, 0xd8, 0xc0, 0x5c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||
0xe4, 0xc8, 0xb4, 0x99, 0x23, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *Consensus) Equal(that interface{}) bool {
|
||||
@@ -174,3 +202,414 @@ func (this *Consensus) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *App) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *App) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *App) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.XXX_unrecognized != nil {
|
||||
i -= len(m.XXX_unrecognized)
|
||||
copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
if len(m.Software) > 0 {
|
||||
i -= len(m.Software)
|
||||
copy(dAtA[i:], m.Software)
|
||||
i = encodeVarintVersion(dAtA, i, uint64(len(m.Software)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.Protocol != 0 {
|
||||
i = encodeVarintVersion(dAtA, i, uint64(m.Protocol))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Consensus) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Consensus) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Consensus) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.XXX_unrecognized != nil {
|
||||
i -= len(m.XXX_unrecognized)
|
||||
copy(dAtA[i:], m.XXX_unrecognized)
|
||||
}
|
||||
if m.App != 0 {
|
||||
i = encodeVarintVersion(dAtA, i, uint64(m.App))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
}
|
||||
if m.Block != 0 {
|
||||
i = encodeVarintVersion(dAtA, i, uint64(m.Block))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintVersion(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovVersion(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *App) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Protocol != 0 {
|
||||
n += 1 + sovVersion(uint64(m.Protocol))
|
||||
}
|
||||
l = len(m.Software)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovVersion(uint64(l))
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Consensus) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Block != 0 {
|
||||
n += 1 + sovVersion(uint64(m.Block))
|
||||
}
|
||||
if m.App != 0 {
|
||||
n += 1 + sovVersion(uint64(m.App))
|
||||
}
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovVersion(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozVersion(x uint64) (n int) {
|
||||
return sovVersion(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *App) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: App: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: App: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Protocol", wireType)
|
||||
}
|
||||
m.Protocol = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Protocol |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Software", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Software = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipVersion(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Consensus) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Consensus: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Consensus: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType)
|
||||
}
|
||||
m.Block = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Block |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field App", wireType)
|
||||
}
|
||||
m.App = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.App |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipVersion(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthVersion
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipVersion(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowVersion
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthVersion
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupVersion
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthVersion
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthVersion = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowVersion = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupVersion = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
|
||||
@@ -5,6 +5,11 @@ option go_package = "github.com/tendermint/tendermint/proto/version";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.marshaler_all) = true;
|
||||
option (gogoproto.unmarshaler_all) = true;
|
||||
option (gogoproto.sizer_all) = true;
|
||||
option (gogoproto.goproto_registration) = true;
|
||||
|
||||
// App includes the protocol and software version for the application.
|
||||
// This information is included in ResponseInfo. The App.Protocol can be
|
||||
// updated in ResponseEndBlock.
|
||||
@@ -17,7 +22,7 @@ message App {
|
||||
// including all blockchain data structures and the rules of the application's
|
||||
// state transition machine.
|
||||
message Consensus {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 block = 1;
|
||||
uint64 app = 2;
|
||||
|
||||
@@ -10,6 +10,6 @@ import (
|
||||
// It contains only compile-time version information.
|
||||
var RequestInfo = abci.RequestInfo{
|
||||
Version: version.Version,
|
||||
BlockVersion: version.BlockProtocol.Uint64(),
|
||||
P2PVersion: version.P2PProtocol.Uint64(),
|
||||
BlockVersion: version.BlockProtocol,
|
||||
P2PVersion: version.P2PProtocol,
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func TxSearch(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPageP
|
||||
}
|
||||
|
||||
apiResults = append(apiResults, &ctypes.ResultTx{
|
||||
Hash: r.Tx.Hash(),
|
||||
Hash: types.Tx(r.Tx).Hash(),
|
||||
Height: r.Height,
|
||||
Index: r.Index,
|
||||
TxResult: r.Result,
|
||||
|
||||
@@ -226,27 +226,27 @@ func init() { golang_proto.RegisterFile("rpc/grpc/types.proto", fileDescriptor_1
|
||||
|
||||
var fileDescriptor_15f63baabf91876a = []byte{
|
||||
// 330 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4f, 0x4b, 0xc3, 0x30,
|
||||
0x18, 0xc6, 0xc9, 0x10, 0xff, 0xbc, 0x9b, 0x3b, 0x64, 0x22, 0xd2, 0x43, 0x99, 0x43, 0xe6, 0x4e,
|
||||
0x29, 0xcc, 0xa3, 0xa7, 0xcd, 0x81, 0x88, 0x97, 0x51, 0x76, 0xf2, 0x32, 0xbb, 0x34, 0xb4, 0x41,
|
||||
0xd7, 0xc4, 0x34, 0x93, 0xee, 0xe3, 0xf8, 0x41, 0x04, 0x8f, 0x1e, 0xfd, 0x08, 0x52, 0xbf, 0x88,
|
||||
0xa4, 0x5d, 0x6d, 0x0e, 0x3a, 0x2f, 0xe5, 0x69, 0x78, 0x9e, 0x1f, 0xcf, 0xfb, 0x26, 0x70, 0xa4,
|
||||
0x24, 0xf5, 0x22, 0xf3, 0xd1, 0x6b, 0xc9, 0x52, 0x22, 0x95, 0xd0, 0x02, 0x77, 0x34, 0x4b, 0x42,
|
||||
0xa6, 0x96, 0x3c, 0xd1, 0x44, 0x49, 0x4a, 0x8c, 0xc1, 0xe9, 0xeb, 0x98, 0xab, 0x70, 0x2e, 0x03,
|
||||
0xa5, 0xd7, 0x5e, 0xe1, 0xf3, 0x22, 0x11, 0x89, 0x5a, 0x95, 0x61, 0xe7, 0x38, 0x58, 0x50, 0x5e,
|
||||
0xe2, 0x6c, 0x68, 0xef, 0x10, 0x9a, 0x3e, 0x7b, 0x5a, 0xb1, 0x54, 0x4f, 0x79, 0x12, 0xf5, 0xce,
|
||||
0x00, 0x6f, 0x7e, 0xc7, 0x4a, 0x04, 0x21, 0x0d, 0x52, 0x3d, 0xcb, 0x70, 0x1b, 0x1a, 0x3a, 0x3b,
|
||||
0x41, 0x5d, 0x34, 0x68, 0xf9, 0x0d, 0x9d, 0xf5, 0xda, 0xd0, 0xf2, 0x59, 0x2a, 0x45, 0x92, 0xb2,
|
||||
0x22, 0xf5, 0x82, 0xa0, 0x53, 0x1d, 0xd8, 0xb9, 0x11, 0xec, 0xd3, 0x98, 0xd1, 0x87, 0xf9, 0x26,
|
||||
0xdd, 0x1c, 0xf6, 0x89, 0x35, 0x84, 0xa9, 0x44, 0xca, 0x32, 0x55, 0xfa, 0xca, 0xd8, 0x67, 0x99,
|
||||
0xbf, 0x47, 0x4b, 0x81, 0xaf, 0x01, 0x42, 0xf6, 0xc8, 0x9f, 0x99, 0x32, 0x90, 0x46, 0x01, 0x19,
|
||||
0xfc, 0x03, 0x99, 0x94, 0x81, 0x59, 0xe6, 0x1f, 0x84, 0x95, 0x1c, 0xbe, 0x22, 0x68, 0xfd, 0x74,
|
||||
0x1b, 0x4d, 0x6f, 0xf0, 0x2d, 0xec, 0x98, 0xf2, 0xb8, 0x4b, 0x7e, 0xd9, 0x2b, 0xb1, 0x96, 0xe2,
|
||||
0x9c, 0xfe, 0xe1, 0xa8, 0x37, 0x80, 0xef, 0xa1, 0x69, 0x0f, 0x7e, 0xbe, 0x8d, 0x69, 0x19, 0x9d,
|
||||
0xc1, 0x56, 0xb4, 0xe5, 0x1c, 0x4f, 0xde, 0x73, 0x17, 0x7d, 0xe4, 0x2e, 0xfa, 0xcc, 0x5d, 0xf4,
|
||||
0xf6, 0xe5, 0xa2, 0xbb, 0x61, 0xc4, 0x75, 0xbc, 0x5a, 0x10, 0x2a, 0x96, 0x5e, 0x4d, 0xb1, 0x65,
|
||||
0xf5, 0x8c, 0x2e, 0xa9, 0x50, 0xcc, 0x88, 0xc5, 0x6e, 0x71, 0xeb, 0x17, 0xdf, 0x01, 0x00, 0x00,
|
||||
0xff, 0xff, 0x67, 0x85, 0x6c, 0xf2, 0x62, 0x02, 0x00, 0x00,
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x4a, 0xc3, 0x40,
|
||||
0x14, 0x85, 0x99, 0x22, 0xfe, 0xdc, 0xd6, 0x2e, 0xa6, 0x22, 0x92, 0x45, 0xa8, 0x45, 0x6a, 0x57,
|
||||
0x13, 0xa8, 0x4b, 0x57, 0xad, 0x05, 0x11, 0x37, 0x25, 0x74, 0xe5, 0xa6, 0xa6, 0x93, 0x21, 0x19,
|
||||
0xb4, 0x99, 0x71, 0x32, 0x95, 0xf4, 0x71, 0x7c, 0x10, 0xc1, 0xa5, 0x4b, 0x1f, 0x41, 0xe2, 0x8b,
|
||||
0xc8, 0x24, 0x8d, 0x99, 0x85, 0xd6, 0x4d, 0x38, 0xb9, 0x7c, 0xe7, 0x70, 0xee, 0x4d, 0xe0, 0x48,
|
||||
0x49, 0xea, 0x45, 0xe6, 0xa1, 0xd7, 0x92, 0xa5, 0x44, 0x2a, 0xa1, 0x05, 0xee, 0x68, 0x96, 0x84,
|
||||
0x4c, 0x2d, 0x79, 0xa2, 0x89, 0x92, 0x94, 0x18, 0xc0, 0x39, 0x0e, 0x16, 0x94, 0x97, 0x98, 0x0d,
|
||||
0x3b, 0x7d, 0x1d, 0x73, 0x15, 0xce, 0x65, 0xa0, 0xf4, 0xda, 0x2b, 0x46, 0x5e, 0x24, 0x22, 0x51,
|
||||
0xab, 0x92, 0xeb, 0x1d, 0x42, 0xd3, 0x67, 0x4f, 0x2b, 0x96, 0xea, 0x29, 0x4f, 0xa2, 0xde, 0x19,
|
||||
0xe0, 0xcd, 0xeb, 0x58, 0x89, 0x20, 0xa4, 0x41, 0xaa, 0x67, 0x19, 0x6e, 0x43, 0x43, 0x67, 0x27,
|
||||
0xa8, 0x8b, 0x06, 0x2d, 0xbf, 0xa1, 0xb3, 0x5e, 0x1b, 0x5a, 0x3e, 0x4b, 0xa5, 0x48, 0x52, 0x56,
|
||||
0xb8, 0x5e, 0x10, 0x74, 0xaa, 0x81, 0xed, 0x1b, 0xc1, 0x3e, 0x8d, 0x19, 0x7d, 0x98, 0x6f, 0xdc,
|
||||
0xcd, 0x61, 0x9f, 0x58, 0x4b, 0x98, 0xea, 0xa4, 0x2c, 0x5d, 0xb9, 0xaf, 0x0c, 0x3e, 0xcb, 0xfc,
|
||||
0x3d, 0x5a, 0x0a, 0x7c, 0x0d, 0x10, 0xb2, 0x47, 0xfe, 0xcc, 0x94, 0x09, 0x69, 0x14, 0x21, 0x83,
|
||||
0x7f, 0x42, 0x26, 0xa5, 0x61, 0x96, 0xf9, 0x07, 0x61, 0x25, 0x87, 0xaf, 0x08, 0x5a, 0x3f, 0xdd,
|
||||
0x46, 0xd3, 0x1b, 0x7c, 0x0b, 0x3b, 0xa6, 0x3c, 0xee, 0x92, 0x5f, 0xee, 0x4a, 0xac, 0xa3, 0x38,
|
||||
0xa7, 0x7f, 0x10, 0xf5, 0x05, 0xf0, 0x3d, 0x34, 0xed, 0xc5, 0xcf, 0xb7, 0x65, 0x5a, 0xa0, 0x33,
|
||||
0xd8, 0x1a, 0x6d, 0x91, 0xe3, 0xc9, 0x7b, 0xee, 0xa2, 0x8f, 0xdc, 0x45, 0x9f, 0xb9, 0x8b, 0xde,
|
||||
0xbe, 0x5c, 0x74, 0x37, 0x8c, 0xb8, 0x8e, 0x57, 0x0b, 0x42, 0xc5, 0xd2, 0xab, 0x53, 0x6c, 0x59,
|
||||
0xfd, 0x46, 0x97, 0x54, 0x28, 0x66, 0xc4, 0x62, 0xb7, 0xf8, 0xea, 0x17, 0xdf, 0x01, 0x00, 0x00,
|
||||
0xff, 0xff, 0x21, 0xfc, 0xde, 0xc4, 0x62, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
@@ -2,8 +2,8 @@ syntax = "proto3";
|
||||
package tendermint.rpc.grpc;
|
||||
option go_package = "github.com/tendermint/tendermint/rpc/grpc;coregrpc";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "abci/types/types.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.marshaler_all) = true;
|
||||
option (gogoproto.unmarshaler_all) = true;
|
||||
@@ -11,9 +11,6 @@ option (gogoproto.sizer_all) = true;
|
||||
option (gogoproto.goproto_registration) = true;
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Message types
|
||||
|
||||
//----------------------------------------
|
||||
// Request types
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -279,9 +280,13 @@ func execBlockOnProxyApp(
|
||||
|
||||
// Begin block
|
||||
var err error
|
||||
pbh := block.Header.ToProto()
|
||||
if pbh == nil {
|
||||
return nil, errors.New("nil header")
|
||||
}
|
||||
abciResponses.BeginBlock, err = proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
|
||||
Hash: block.Hash(),
|
||||
Header: types.TM2PB.Header(&block.Header),
|
||||
Header: *pbh,
|
||||
LastCommitInfo: commitInfo,
|
||||
ByzantineValidators: byzVals,
|
||||
})
|
||||
@@ -466,7 +471,7 @@ func fireEvents(
|
||||
})
|
||||
|
||||
for i, tx := range block.Data.Txs {
|
||||
eventBus.PublishEventTx(types.EventDataTx{TxResult: types.TxResult{
|
||||
eventBus.PublishEventTx(types.EventDataTx{TxResult: abci.TxResult{
|
||||
Height: block.Height,
|
||||
Index: uint32(i),
|
||||
Tx: tx,
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
tmversion "github.com/tendermint/tendermint/proto/version"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
@@ -23,7 +24,7 @@ var (
|
||||
// and the software version to support upgrades to the format of
|
||||
// the State as stored on disk.
|
||||
type Version struct {
|
||||
Consensus version.Consensus
|
||||
Consensus tmversion.Consensus
|
||||
Software string
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ type Version struct {
|
||||
// The Consensus.App version will be set during the Handshake, once
|
||||
// we hear from the app what protocol version it is running.
|
||||
var InitStateVersion = Version{
|
||||
Consensus: version.Consensus{
|
||||
Consensus: tmversion.Consensus{
|
||||
Block: version.BlockProtocol,
|
||||
App: 0,
|
||||
},
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// TxIndexer interface defines methods to index and search transactions.
|
||||
@@ -15,14 +15,14 @@ type TxIndexer interface {
|
||||
AddBatch(b *Batch) error
|
||||
|
||||
// Index analyzes, indexes and stores a single transaction.
|
||||
Index(result *types.TxResult) error
|
||||
Index(result *abci.TxResult) error
|
||||
|
||||
// Get returns the transaction specified by hash or nil if the transaction is not indexed
|
||||
// or stored.
|
||||
Get(hash []byte) (*types.TxResult, error)
|
||||
Get(hash []byte) (*abci.TxResult, error)
|
||||
|
||||
// Search allows you to query for transactions.
|
||||
Search(ctx context.Context, q *query.Query) ([]*types.TxResult, error)
|
||||
Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error)
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@@ -31,18 +31,18 @@ type TxIndexer interface {
|
||||
// Batch groups together multiple Index operations to be performed at the same time.
|
||||
// NOTE: Batch is NOT thread-safe and must not be modified after starting its execution.
|
||||
type Batch struct {
|
||||
Ops []*types.TxResult
|
||||
Ops []*abci.TxResult
|
||||
}
|
||||
|
||||
// NewBatch creates a new Batch.
|
||||
func NewBatch(n int64) *Batch {
|
||||
return &Batch{
|
||||
Ops: make([]*types.TxResult, n),
|
||||
Ops: make([]*abci.TxResult, n),
|
||||
}
|
||||
}
|
||||
|
||||
// Add or update an entry for the given result.Index.
|
||||
func (b *Batch) Add(result *types.TxResult) error {
|
||||
func (b *Batch) Add(result *abci.TxResult) error {
|
||||
b.Ops[result.Index] = result
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) {
|
||||
Header: types.Header{Height: 1},
|
||||
NumTxs: int64(2),
|
||||
})
|
||||
txResult1 := &types.TxResult{
|
||||
txResult1 := &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: uint32(0),
|
||||
Tx: types.Tx("foo"),
|
||||
Result: abci.ResponseDeliverTx{Code: 0},
|
||||
}
|
||||
eventBus.PublishEventTx(types.EventDataTx{TxResult: *txResult1})
|
||||
txResult2 := &types.TxResult{
|
||||
txResult2 := &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: uint32(1),
|
||||
Tx: types.Tx("bar"),
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
amino "github.com/tendermint/go-amino"
|
||||
)
|
||||
|
||||
var cdc = amino.NewCodec()
|
||||
|
||||
func init() {
|
||||
}
|
||||
@@ -9,8 +9,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
tmstring "github.com/tendermint/tendermint/libs/strings"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
@@ -55,7 +57,7 @@ func IndexAllEvents() func(*TxIndex) {
|
||||
|
||||
// Get gets transaction from the TxIndex storage and returns it or nil if the
|
||||
// transaction is not found.
|
||||
func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
|
||||
func (txi *TxIndex) Get(hash []byte) (*abci.TxResult, error) {
|
||||
if len(hash) == 0 {
|
||||
return nil, txindex.ErrorEmptyHash
|
||||
}
|
||||
@@ -68,8 +70,8 @@ func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
txResult := new(types.TxResult)
|
||||
err = cdc.UnmarshalBinaryBare(rawBytes, &txResult)
|
||||
txResult := new(abci.TxResult)
|
||||
err = proto.Unmarshal(rawBytes, txResult)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading TxResult: %v", err)
|
||||
}
|
||||
@@ -86,7 +88,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
defer storeBatch.Close()
|
||||
|
||||
for _, result := range b.Ops {
|
||||
hash := result.Tx.Hash()
|
||||
hash := types.Tx(result.Tx).Hash()
|
||||
|
||||
// index tx by events
|
||||
txi.indexEvents(result, hash, storeBatch)
|
||||
@@ -97,7 +99,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
}
|
||||
|
||||
// index tx by hash
|
||||
rawBytes, err := cdc.MarshalBinaryBare(result)
|
||||
rawBytes, err := proto.Marshal(result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -112,11 +114,11 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
// that indexed from the tx's events is a composite of the event type and the
|
||||
// respective attribute's key delimited by a "." (eg. "account.number").
|
||||
// Any event with an empty type is not indexed.
|
||||
func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
func (txi *TxIndex) Index(result *abci.TxResult) error {
|
||||
b := txi.store.NewBatch()
|
||||
defer b.Close()
|
||||
|
||||
hash := result.Tx.Hash()
|
||||
hash := types.Tx(result.Tx).Hash()
|
||||
|
||||
// index tx by events
|
||||
txi.indexEvents(result, hash, b)
|
||||
@@ -127,7 +129,7 @@ func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
}
|
||||
|
||||
// index tx by hash
|
||||
rawBytes, err := cdc.MarshalBinaryBare(result)
|
||||
rawBytes, err := proto.Marshal(result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -138,7 +140,7 @@ func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (txi *TxIndex) indexEvents(result *types.TxResult, hash []byte, store dbm.SetDeleter) {
|
||||
func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store dbm.SetDeleter) {
|
||||
for _, event := range result.Result.Events {
|
||||
// only index events with a non-empty type
|
||||
if len(event.Type) == 0 {
|
||||
@@ -169,11 +171,11 @@ func (txi *TxIndex) indexEvents(result *types.TxResult, hash []byte, store dbm.S
|
||||
//
|
||||
// Search will exit early and return any result fetched so far,
|
||||
// when a message is received on the context chan.
|
||||
func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*types.TxResult, error) {
|
||||
func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error) {
|
||||
// Potentially exit early.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
results := make([]*types.TxResult, 0)
|
||||
results := make([]*abci.TxResult, 0)
|
||||
return results, nil
|
||||
default:
|
||||
}
|
||||
@@ -195,11 +197,11 @@ func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*types.TxResu
|
||||
res, err := txi.Get(hash)
|
||||
switch {
|
||||
case err != nil:
|
||||
return []*types.TxResult{}, fmt.Errorf("error while retrieving the result: %w", err)
|
||||
return []*abci.TxResult{}, fmt.Errorf("error while retrieving the result: %w", err)
|
||||
case res == nil:
|
||||
return []*types.TxResult{}, nil
|
||||
return []*abci.TxResult{}, nil
|
||||
default:
|
||||
return []*types.TxResult{res}, nil
|
||||
return []*abci.TxResult{res}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +254,7 @@ func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*types.TxResu
|
||||
}
|
||||
}
|
||||
|
||||
results := make([]*types.TxResult, 0, len(filteredHashes))
|
||||
results := make([]*abci.TxResult, 0, len(filteredHashes))
|
||||
for _, h := range filteredHashes {
|
||||
res, err := txi.Get(h)
|
||||
if err != nil {
|
||||
@@ -593,7 +595,7 @@ func extractValueFromKey(key []byte) string {
|
||||
return parts[1]
|
||||
}
|
||||
|
||||
func keyForEvent(key string, value []byte, result *types.TxResult) []byte {
|
||||
func keyForEvent(key string, value []byte, result *abci.TxResult) []byte {
|
||||
return []byte(fmt.Sprintf("%s/%s/%d/%d",
|
||||
key,
|
||||
value,
|
||||
@@ -602,7 +604,7 @@ func keyForEvent(key string, value []byte, result *types.TxResult) []byte {
|
||||
))
|
||||
}
|
||||
|
||||
func keyForHeight(result *types.TxResult) []byte {
|
||||
func keyForHeight(result *abci.TxResult) []byte {
|
||||
return []byte(fmt.Sprintf("%s/%d/%d/%d",
|
||||
types.TxHeightKey,
|
||||
result.Height,
|
||||
|
||||
@@ -44,7 +44,7 @@ func BenchmarkTxSearch(b *testing.B) {
|
||||
b.Errorf("failed produce random bytes: %s", err)
|
||||
}
|
||||
|
||||
txResult := &types.TxResult{
|
||||
txResult := &abci.TxResult{
|
||||
Height: int64(i),
|
||||
Index: 0,
|
||||
Tx: types.Tx(string(txBz)),
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -23,7 +24,7 @@ func TestTxIndex(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB())
|
||||
|
||||
tx := types.Tx("HELLO WORLD")
|
||||
txResult := &types.TxResult{
|
||||
txResult := &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
@@ -43,10 +44,10 @@ func TestTxIndex(t *testing.T) {
|
||||
|
||||
loadedTxResult, err := indexer.Get(hash)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, txResult, loadedTxResult)
|
||||
assert.True(t, proto.Equal(txResult, loadedTxResult))
|
||||
|
||||
tx2 := types.Tx("BYE BYE WORLD")
|
||||
txResult2 := &types.TxResult{
|
||||
txResult2 := &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx2,
|
||||
@@ -62,7 +63,7 @@ func TestTxIndex(t *testing.T) {
|
||||
|
||||
loadedTxResult2, err := indexer.Get(hash2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, txResult2, loadedTxResult2)
|
||||
assert.True(t, proto.Equal(txResult2, loadedTxResult2))
|
||||
}
|
||||
|
||||
func TestTxSearch(t *testing.T) {
|
||||
@@ -74,7 +75,7 @@ func TestTxSearch(t *testing.T) {
|
||||
{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()
|
||||
hash := types.Tx(txResult.Tx).Hash()
|
||||
|
||||
err := indexer.Index(txResult)
|
||||
require.NoError(t, err)
|
||||
@@ -128,7 +129,9 @@ func TestTxSearch(t *testing.T) {
|
||||
|
||||
assert.Len(t, results, tc.resultsLength)
|
||||
if tc.resultsLength > 0 {
|
||||
assert.Equal(t, []*types.TxResult{txResult}, results)
|
||||
for _, txr := range results {
|
||||
assert.True(t, proto.Equal(txResult, txr))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -161,7 +164,7 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
txResult1 := txResultWithEvents([]abci.Event{
|
||||
{Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1")}}},
|
||||
})
|
||||
hash1 := txResult1.Tx.Hash()
|
||||
hash1 := types.Tx(txResult1.Tx).Hash()
|
||||
|
||||
err := indexer.Index(txResult1)
|
||||
require.NoError(t, err)
|
||||
@@ -170,10 +173,10 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
txResult2 := txResultWithEvents(nil)
|
||||
txResult2.Tx = types.Tx("HELLO WORLD 2")
|
||||
|
||||
hash2 := txResult2.Tx.Hash()
|
||||
hash2 := types.Tx(txResult2.Tx).Hash()
|
||||
b := indexer.store.NewBatch()
|
||||
|
||||
rawBytes, err := cdc.MarshalBinaryBare(txResult2)
|
||||
rawBytes, err := proto.Marshal(txResult2)
|
||||
require.NoError(t, err)
|
||||
|
||||
depKey := []byte(fmt.Sprintf("%s/%s/%d/%d",
|
||||
@@ -190,27 +193,27 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
q string
|
||||
results []*types.TxResult
|
||||
results []*abci.TxResult
|
||||
}{
|
||||
// search by hash
|
||||
{fmt.Sprintf("tx.hash = '%X'", hash1), []*types.TxResult{txResult1}},
|
||||
{fmt.Sprintf("tx.hash = '%X'", hash1), []*abci.TxResult{txResult1}},
|
||||
// search by hash
|
||||
{fmt.Sprintf("tx.hash = '%X'", hash2), []*types.TxResult{txResult2}},
|
||||
{fmt.Sprintf("tx.hash = '%X'", hash2), []*abci.TxResult{txResult2}},
|
||||
// search by exact match (one key)
|
||||
{"account.number = 1", []*types.TxResult{txResult1}},
|
||||
{"account.number >= 1 AND account.number <= 5", []*types.TxResult{txResult1}},
|
||||
{"account.number = 1", []*abci.TxResult{txResult1}},
|
||||
{"account.number >= 1 AND account.number <= 5", []*abci.TxResult{txResult1}},
|
||||
// search by range (lower bound)
|
||||
{"account.number >= 1", []*types.TxResult{txResult1}},
|
||||
{"account.number >= 1", []*abci.TxResult{txResult1}},
|
||||
// search by range (upper bound)
|
||||
{"account.number <= 5", []*types.TxResult{txResult1}},
|
||||
{"account.number <= 5", []*abci.TxResult{txResult1}},
|
||||
// search using not allowed key
|
||||
{"not_allowed = 'boom'", []*types.TxResult{}},
|
||||
{"not_allowed = 'boom'", []*abci.TxResult{}},
|
||||
// search for not existing tx result
|
||||
{"account.number >= 2 AND account.number <= 5", []*types.TxResult{}},
|
||||
{"account.number >= 2 AND account.number <= 5", []*abci.TxResult{}},
|
||||
// search using not existing key
|
||||
{"account.date >= TIME 2013-05-03T14:45:00Z", []*types.TxResult{}},
|
||||
{"account.date >= TIME 2013-05-03T14:45:00Z", []*abci.TxResult{}},
|
||||
// search by deprecated key
|
||||
{"sender = 'addr1'", []*types.TxResult{txResult2}},
|
||||
{"sender = 'addr1'", []*abci.TxResult{txResult2}},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -220,7 +223,11 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
t.Run(tc.q, func(t *testing.T) {
|
||||
results, err := indexer.Search(ctx, query.MustParse(tc.q))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, results, tc.results)
|
||||
for _, txr := range results {
|
||||
for _, tr := range tc.results {
|
||||
assert.True(t, proto.Equal(tr, txr))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -243,7 +250,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Len(t, results, 1)
|
||||
assert.Equal(t, []*types.TxResult{txResult}, results)
|
||||
for _, txr := range results {
|
||||
assert.True(t, proto.Equal(txResult, txr))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
@@ -301,9 +310,9 @@ func TestTxSearchMultipleTxs(t *testing.T) {
|
||||
require.Len(t, results, 3)
|
||||
}
|
||||
|
||||
func txResultWithEvents(events []abci.Event) *types.TxResult {
|
||||
func txResultWithEvents(events []abci.Event) *abci.TxResult {
|
||||
tx := types.Tx("HELLO WORLD")
|
||||
return &types.TxResult{
|
||||
return &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
@@ -330,7 +339,7 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) {
|
||||
txIndex := uint32(0)
|
||||
for i := int64(0); i < txsCount; i++ {
|
||||
tx := tmrand.Bytes(250)
|
||||
txResult := &types.TxResult{
|
||||
txResult := &abci.TxResult{
|
||||
Height: 1,
|
||||
Index: txIndex,
|
||||
Tx: tx,
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var _ txindex.TxIndexer = (*TxIndex)(nil)
|
||||
@@ -15,7 +15,7 @@ var _ txindex.TxIndexer = (*TxIndex)(nil)
|
||||
type TxIndex struct{}
|
||||
|
||||
// Get on a TxIndex is disabled and panics when invoked.
|
||||
func (txi *TxIndex) Get(hash []byte) (*types.TxResult, error) {
|
||||
func (txi *TxIndex) Get(hash []byte) (*abci.TxResult, error) {
|
||||
return nil, errors.New(`indexing is disabled (set 'tx_index = "kv"' in config)`)
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ func (txi *TxIndex) AddBatch(batch *txindex.Batch) error {
|
||||
}
|
||||
|
||||
// Index is a noop and always returns nil.
|
||||
func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
func (txi *TxIndex) Index(result *abci.TxResult) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*types.TxResult, error) {
|
||||
return []*types.TxResult{}, nil
|
||||
func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error) {
|
||||
return []*abci.TxResult{}, nil
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ func validateBlock(evidencePool EvidencePool, stateDB dbm.DB, state State, block
|
||||
}
|
||||
|
||||
// Validate basic info.
|
||||
if block.Version != state.Version.Consensus {
|
||||
if block.Version.App != state.Version.Consensus.App ||
|
||||
block.Version.Block != state.Version.Consensus.Block {
|
||||
return fmt.Errorf("wrong Block.Header.Version. Expected %v, got %v",
|
||||
state.Version.Consensus,
|
||||
block.Version,
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -263,7 +262,7 @@ func (s *syncer) Sync(snapshot *snapshot, chunks *chunkQueue) (sm.State, *types.
|
||||
if err != nil {
|
||||
return sm.State{}, nil, err
|
||||
}
|
||||
state.Version.Consensus.App = version.Protocol(appVersion)
|
||||
state.Version.Consensus.App = appVersion
|
||||
|
||||
// Done! 🎉
|
||||
s.logger.Info("Snapshot restored", "height", snapshot.Height, "format", snapshot.Format,
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
p2pmocks "github.com/tendermint/tendermint/p2p/mocks"
|
||||
ssproto "github.com/tendermint/tendermint/proto/statesync"
|
||||
tmversion "github.com/tendermint/tendermint/proto/version"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
proxymocks "github.com/tendermint/tendermint/proxy/mocks"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
@@ -44,7 +45,7 @@ func TestSyncer_SyncAny(t *testing.T) {
|
||||
state := sm.State{
|
||||
ChainID: "chain",
|
||||
Version: sm.Version{
|
||||
Consensus: version.Consensus{
|
||||
Consensus: tmversion.Consensus{
|
||||
Block: version.BlockProtocol,
|
||||
App: 0,
|
||||
},
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||
tmproto "github.com/tendermint/tendermint/proto/types"
|
||||
tmversion "github.com/tendermint/tendermint/proto/version"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -333,10 +332,10 @@ func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int, maxNumEvidence u
|
||||
// - https://github.com/tendermint/spec/blob/master/spec/blockchain/blockchain.md
|
||||
type Header struct {
|
||||
// basic block info
|
||||
Version version.Consensus `json:"version"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Height int64 `json:"height"`
|
||||
Time time.Time `json:"time"`
|
||||
Version tmversion.Consensus `json:"version"`
|
||||
ChainID string `json:"chain_id"`
|
||||
Height int64 `json:"height"`
|
||||
Time time.Time `json:"time"`
|
||||
|
||||
// prev block info
|
||||
LastBlockID BlockID `json:"last_block_id"`
|
||||
@@ -361,7 +360,7 @@ type Header struct {
|
||||
// Populate the Header with state-derived data.
|
||||
// Call this after MakeBlock to complete the Header.
|
||||
func (h *Header) Populate(
|
||||
version version.Consensus, chainID string,
|
||||
version tmversion.Consensus, chainID string,
|
||||
timestamp time.Time, lastBlockID BlockID,
|
||||
valHash, nextValHash []byte,
|
||||
consensusHash, appHash, lastResultsHash []byte,
|
||||
@@ -507,12 +506,13 @@ func (h *Header) ToProto() *tmproto.Header {
|
||||
if h == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &tmproto.Header{
|
||||
Version: tmversion.Consensus{Block: h.Version.App.Uint64(), App: h.Version.App.Uint64()},
|
||||
Version: h.Version,
|
||||
ChainID: h.ChainID,
|
||||
Height: h.Height,
|
||||
Time: h.Time,
|
||||
LastBlockID: h.LastBlockID.ToProto(),
|
||||
LastBlockId: h.LastBlockID.ToProto(),
|
||||
ValidatorsHash: h.ValidatorsHash,
|
||||
NextValidatorsHash: h.NextValidatorsHash,
|
||||
ConsensusHash: h.ConsensusHash,
|
||||
@@ -534,12 +534,12 @@ func HeaderFromProto(ph *tmproto.Header) (Header, error) {
|
||||
|
||||
h := new(Header)
|
||||
|
||||
bi, err := BlockIDFromProto(&ph.LastBlockID)
|
||||
bi, err := BlockIDFromProto(&ph.LastBlockId)
|
||||
if err != nil {
|
||||
return Header{}, err
|
||||
}
|
||||
|
||||
h.Version = version.Consensus{Block: version.Protocol(ph.Version.Block), App: version.Protocol(ph.Version.App)}
|
||||
h.Version = ph.Version
|
||||
h.ChainID = ph.ChainID
|
||||
h.Height = ph.Height
|
||||
h.Time = ph.Time
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
tmproto "github.com/tendermint/tendermint/proto/types"
|
||||
"github.com/tendermint/tendermint/proto/version"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
||||
@@ -175,7 +175,7 @@ func (b *EventBus) PublishEventTx(data EventDataTx) error {
|
||||
|
||||
// add predefined compositeKeys
|
||||
events[EventTypeKey] = append(events[EventTypeKey], EventTx)
|
||||
events[TxHashKey] = append(events[TxHashKey], fmt.Sprintf("%X", data.Tx.Hash()))
|
||||
events[TxHashKey] = append(events[TxHashKey], fmt.Sprintf("%X", Tx(data.Tx).Hash()))
|
||||
events[TxHeightKey] = append(events[TxHeightKey], fmt.Sprintf("%d", data.Height))
|
||||
|
||||
return b.pubsub.PublishWithEvents(ctx, data, events)
|
||||
|
||||
@@ -41,12 +41,12 @@ func TestEventBusPublishEventTx(t *testing.T) {
|
||||
edt := msg.Data().(EventDataTx)
|
||||
assert.Equal(t, int64(1), edt.Height)
|
||||
assert.Equal(t, uint32(0), edt.Index)
|
||||
assert.Equal(t, tx, edt.Tx)
|
||||
assert.EqualValues(t, tx, edt.Tx)
|
||||
assert.Equal(t, result, edt.Result)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
err = eventBus.PublishEventTx(EventDataTx{TxResult{
|
||||
err = eventBus.PublishEventTx(EventDataTx{abci.TxResult{
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
@@ -183,7 +183,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
data := msg.Data().(EventDataTx)
|
||||
assert.Equal(t, int64(1), data.Height)
|
||||
assert.Equal(t, uint32(0), data.Index)
|
||||
assert.Equal(t, tx, data.Tx)
|
||||
assert.EqualValues(t, tx, data.Tx)
|
||||
assert.Equal(t, result, data.Result)
|
||||
close(done)
|
||||
case <-time.After(1 * time.Second):
|
||||
@@ -191,7 +191,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
err = eventBus.PublishEventTx(EventDataTx{TxResult{
|
||||
err = eventBus.PublishEventTx(EventDataTx{abci.TxResult{
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
|
||||
@@ -80,7 +80,7 @@ type EventDataNewBlockHeader struct {
|
||||
|
||||
// All txs fire EventDataTx
|
||||
type EventDataTx struct {
|
||||
TxResult
|
||||
abci.TxResult
|
||||
}
|
||||
|
||||
// NOTE: This goes into the replay WAL
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/crypto/sr25519"
|
||||
tmproto "github.com/tendermint/tendermint/proto/types"
|
||||
)
|
||||
|
||||
//-------------------------------------------------------
|
||||
@@ -42,17 +43,14 @@ var TM2PB = tm2pb{}
|
||||
|
||||
type tm2pb struct{}
|
||||
|
||||
func (tm2pb) Header(header *Header) abci.Header {
|
||||
return abci.Header{
|
||||
Version: abci.Version{
|
||||
Block: header.Version.Block.Uint64(),
|
||||
App: header.Version.App.Uint64(),
|
||||
},
|
||||
func (tm2pb) Header(header *Header) tmproto.Header {
|
||||
return tmproto.Header{
|
||||
Version: header.Version,
|
||||
ChainID: header.ChainID,
|
||||
Height: header.Height,
|
||||
Time: header.Time,
|
||||
|
||||
LastBlockId: TM2PB.BlockID(header.LastBlockID),
|
||||
LastBlockId: header.LastBlockID.ToProto(),
|
||||
|
||||
LastCommitHash: header.LastCommitHash,
|
||||
DataHash: header.DataHash,
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
"github.com/tendermint/tendermint/proto/version"
|
||||
)
|
||||
|
||||
func TestABCIPubKey(t *testing.T) {
|
||||
@@ -105,8 +105,8 @@ func TestABCIHeader(t *testing.T) {
|
||||
cdc := amino.NewCodec()
|
||||
headerBz := cdc.MustMarshalBinaryBare(header)
|
||||
|
||||
pbHeader := TM2PB.Header(header)
|
||||
pbHeaderBz, err := proto.Marshal(&pbHeader)
|
||||
pbHeader := header.ToProto()
|
||||
pbHeaderBz, err := proto.Marshal(pbHeader)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// assert some fields match
|
||||
|
||||
11
types/tx.go
11
types/tx.go
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/merkle"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
@@ -109,13 +108,3 @@ func (tp TxProof) Validate(dataHash []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TxResult contains results of executing the transaction.
|
||||
//
|
||||
// One usage is indexing transaction results.
|
||||
type TxResult struct {
|
||||
Height int64 `json:"height"`
|
||||
Index uint32 `json:"index"`
|
||||
Tx Tx `json:"tx"`
|
||||
Result abci.ResponseDeliverTx `json:"result"`
|
||||
}
|
||||
|
||||
@@ -28,40 +28,12 @@ const (
|
||||
ABCIVersion = ABCISemVer
|
||||
)
|
||||
|
||||
// Protocol is used for implementation agnostic versioning.
|
||||
type Protocol uint64
|
||||
|
||||
// Uint64 returns the Protocol version as a uint64,
|
||||
// eg. for compatibility with ABCI types.
|
||||
func (p Protocol) Uint64() uint64 {
|
||||
return uint64(p)
|
||||
}
|
||||
|
||||
var (
|
||||
// P2PProtocol versions all p2p behaviour and msgs.
|
||||
// This includes proposer selection.
|
||||
P2PProtocol Protocol = 7
|
||||
P2PProtocol uint64 = 7
|
||||
|
||||
// BlockProtocol versions all block data structures and processing.
|
||||
// This includes validity of blocks and state updates.
|
||||
BlockProtocol Protocol = 10
|
||||
BlockProtocol uint64 = 10
|
||||
)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Version types
|
||||
|
||||
// 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 Protocol `json:"protocol"`
|
||||
Software string `json:"software"`
|
||||
}
|
||||
|
||||
// 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 Protocol `json:"block"`
|
||||
App Protocol `json:"app"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user