init commit

This commit is contained in:
Sylwester Rąpała 2023-09-04 00:56:02 +02:00
commit 7dd891a763
64 changed files with 33113 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.vscode

1411
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

44
Cargo.toml Normal file
View File

@ -0,0 +1,44 @@
[package]
authors = ["Sylwester Rąpała <sylwesterrapala@outlook.com>"]
name = "eiger-p2p"
version = "0.1.0"
description = "Tendermint P2P handshake (eigel test)"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# async stack
tokio = { version = "1.32", features = ["rt", "net", "macros", "sync"] }
tokio-stream = { version = "0.1" }
futures = { version = "0.3" }
# Interact with user
clap = { version = "4.4", features = ["derive"] }
###
# Implementation
###
protobuf = { version = "3.2" }
prost = { version = "0.12.0" }
prost-types = "0.12"
x25519-dalek = { version = "2.0.0", features = ["getrandom", "static_secrets"] }
curve25519-dalek = { version = "4.0.0" }
merlin = { version = "3.0.0" }
hkdf = { version = "0.12.3" }
sha2 = { version = "0.10.7" }
chacha20poly1305 = { version = "0.10.1" }
ed25519-dalek = { version = "2.0.0", features = ["rand_core"] }
tokio-util = { version = "0.7", features = ["codec"] }
hex = { version = "0.4" }
# Error handling
anyhow = { version = "1.0.75" }
thiserror = { version = "1.0.47" }
# tracing/metrics
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[build-dependencies]
prost-build = { version = "0.12" }

71
README.md Normal file
View File

@ -0,0 +1,71 @@
# Eiger test
The solution to [code challenge](https://github.com/eqlabs/recruitment-exercises/blob/c3455b538b1f4462edf8a212645505da38819160/node-handshake.md)
> Pick a publicly available P2P node
I picked tendermint at version [`0.34.X`]
## How to execute handshake
### Running node:
1. Clone tendermint repository:
```sh
git clone https://github.com/tendermint/tendermint
```
2. Checkout to 0.34.X branch
```sh
git checkout v0.34.x
```
3. Run node with (require docker and docker-compose installed)
```sh
make build-linux && make localnet-start
```
** If you found any problems check this documentation: https://github.com/tendermint/tendermint/blob/0.35x/docs/tools/docker-compose.md
4. find `chain_id` parameter (will be needed on the client side)
```sh
cat build/node0/config/genesis.json | grep chain_id
```
### Running code challenge
1. Clone repository
```sh
git clone https://git.sdr.ovh/sr/eiger-p2p
```
2. in run application with trace logging level and replace `chain-D39Q88` with `chain_id` parameter. You can also run it as below and find remote `chain_id` in logs.
```sh
RUST_LOG=eiger_p2p=trace cargo run -- --node 127.0.0.1:26659 --private-key 0x4d818e3802516dfb1c37a87576432bc210c9edf97e8b3217d806361c04d293fa --network chain-D39Q88
```
** It's possible to specify node ID that you want to connect:
```sh
RUST_LOG=eiger_p2p=trace cargo run -- --node 127.0.0.1:26659 --private-key 0x4d818e3802516dfb1c37a87576432bc210c9edf97e8b3217d806361c04d293fa --network chain-D39Q88
```
It may require installed `protoc` check `proto-build` documentation if build fail.
## Possible improvements:
1. `share_eph_pubkey.rs` is blocker for not using AsyncRead/AsyncWrite from beginning. Create simple module `porotbuf-length-delimited` that could handle with async and protobuf variant would be enough here. It allow also to drop `protobuf` dependency.
2. errors should be improvement. for example `SecretConnectionError::HandshakeErr` can internally hold i/o error. But this will be improved on it's own with `1.`
3. secret key should be read from file and not pass as arg
## Requirements check list:
- [X] Both the target node and the handshake code should compile at least on Linux.
- [ ] The solution has to perform a full protocol-level (post-TCP/etc.) handshake with the target node.
- [X] secret connection
- [X] node version exchange
- [ ] full node version verification
- [X] The provided instructions should include information on how to verify that the handshake has concluded.
- **If handshake fail the application will exit with non-zero status code and error message**
- **If handshake succeed the application will block on loop reading protobuf messages when debug level is enabled**:
```sh
2023-09-03T21:34:04.532535Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\n\x1a\x08\x08@\x10\x01\x1a\x02*\0\x1d\x1a\x1b\x08 \x10\x01\x1a\x15\n\x13\x08\x01\x18\x04 \xd5\x83\x02(\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01"
2023-09-03T21:34:05.622605Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\x08\x1a\x06\x10\x01\x1a\x02\n\0"
2023-09-03T21:35:04.432639Z DEBUG eiger_p2p::peer: received raw protobuf frame (ping, pong, channelMsg): b"\x02\n\0"
```
- [X] The solution can not depend on the code of the target node (but it can share some of its dependencies).
- [X] The submitted code can not reuse entire preexisting handshake implementations like libp2p_noise/XX.
[`0.34.X`]: https://github.com/tendermint/tendermint/blob/v0.34.x/spec/p2p/peer.md

12
build.rs Normal file
View File

@ -0,0 +1,12 @@
use std::io::Result;
fn main() -> Result<()> {
prost_build::compile_protos(
&[
"proto_files/tendermint/p2p/conn.proto",
"proto_files/tendermint/p2p/types.proto",
],
&["proto_files/"],
)?;
Ok(())
}

23
proto_files/README.md Normal file
View File

@ -0,0 +1,23 @@
# Protocol Buffers
This sections defines the types and messages shared across implementations. The definition of the data structures are located in the [core/data_structures](../spec/core/data_structures.md) for the core data types and ABCI definitions are located in the [ABCI](../spec/abci/README.md) section.
## Process of Updates
The `.proto` files within this section are core to the protocol and updates must be treated as such.
### Steps
1. Make an issue with the proposed change.
- Within in the issue members from both the Tendermint-go and Tendermint-rs team will leave comments. If there is not consensus on the change an [RFC](../rfc/README.md) may be requested.
1a. Submission of an RFC as a pull request should be made to facilitate further discussion.
1b. Merge the RFC.
2. Make the necessary changes to the `.proto` file(s), [core data structures](../spec/core/data_structures.md) and/or [ABCI protocol](../spec/abci/apps.md).
3. Open issues within Tendermint-go and Tendermint-rs repos. This is used to notify the teams that a change occurred in the spec.
1. Tag the issue with a spec version label. This will notify the team the changed has been made on master but has not entered a release.
### Versioning
The spec repo aims to be versioned. Once it has been versioned, updates to the protobuf files will live on master. After a certain amount of time, decided on by Tendermint-go and Tendermint-rs team leads, a release will be made on the spec repo. The spec may contain minor releases as well, depending on the implementation these changes may lead to a breaking change. If so, the implementation team should open an issue within the spec repo requiring a major release of the spec.
If the steps above were followed each implementation should have issues tagged with a spec change label. Once all issues have been completed the team should signify their readiness for release.

7
proto_files/buf.lock Normal file
View File

@ -0,0 +1,7 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: gogo
repository: protobuf
commit: 4df00b267f944190a229ce3695781e99

11
proto_files/buf.yaml Normal file
View File

@ -0,0 +1,11 @@
version: v1
deps:
- buf.build/gogo/protobuf
breaking:
use:
- FILE
lint:
use:
- BASIC
- FILE_LOWER_SNAKE_CASE
- UNARY_RPC

View File

@ -0,0 +1,147 @@
// Protocol Buffers for Go with Gadgets
//
// Copied from https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package gogoproto;
import "google/protobuf/descriptor.proto";
option java_package = "com.google.protobuf";
option java_outer_classname = "GoGoProtos";
option go_package = "github.com/gogo/protobuf/gogoproto";
extend google.protobuf.EnumOptions {
optional bool goproto_enum_prefix = 62001;
optional bool goproto_enum_stringer = 62021;
optional bool enum_stringer = 62022;
optional string enum_customname = 62023;
optional bool enumdecl = 62024;
}
extend google.protobuf.EnumValueOptions {
optional string enumvalue_customname = 66001;
}
extend google.protobuf.FileOptions {
optional bool goproto_getters_all = 63001;
optional bool goproto_enum_prefix_all = 63002;
optional bool goproto_stringer_all = 63003;
optional bool verbose_equal_all = 63004;
optional bool face_all = 63005;
optional bool gostring_all = 63006;
optional bool populate_all = 63007;
optional bool stringer_all = 63008;
optional bool onlyone_all = 63009;
optional bool equal_all = 63013;
optional bool description_all = 63014;
optional bool testgen_all = 63015;
optional bool benchgen_all = 63016;
optional bool marshaler_all = 63017;
optional bool unmarshaler_all = 63018;
optional bool stable_marshaler_all = 63019;
optional bool sizer_all = 63020;
optional bool goproto_enum_stringer_all = 63021;
optional bool enum_stringer_all = 63022;
optional bool unsafe_marshaler_all = 63023;
optional bool unsafe_unmarshaler_all = 63024;
optional bool goproto_extensions_map_all = 63025;
optional bool goproto_unrecognized_all = 63026;
optional bool gogoproto_import = 63027;
optional bool protosizer_all = 63028;
optional bool compare_all = 63029;
optional bool typedecl_all = 63030;
optional bool enumdecl_all = 63031;
optional bool goproto_registration = 63032;
optional bool messagename_all = 63033;
optional bool goproto_sizecache_all = 63034;
optional bool goproto_unkeyed_all = 63035;
}
extend google.protobuf.MessageOptions {
optional bool goproto_getters = 64001;
optional bool goproto_stringer = 64003;
optional bool verbose_equal = 64004;
optional bool face = 64005;
optional bool gostring = 64006;
optional bool populate = 64007;
optional bool stringer = 67008;
optional bool onlyone = 64009;
optional bool equal = 64013;
optional bool description = 64014;
optional bool testgen = 64015;
optional bool benchgen = 64016;
optional bool marshaler = 64017;
optional bool unmarshaler = 64018;
optional bool stable_marshaler = 64019;
optional bool sizer = 64020;
optional bool unsafe_marshaler = 64023;
optional bool unsafe_unmarshaler = 64024;
optional bool goproto_extensions_map = 64025;
optional bool goproto_unrecognized = 64026;
optional bool protosizer = 64028;
optional bool compare = 64029;
optional bool typedecl = 64030;
optional bool messagename = 64033;
optional bool goproto_sizecache = 64034;
optional bool goproto_unkeyed = 64035;
}
extend google.protobuf.FieldOptions {
optional bool nullable = 65001;
optional bool embed = 65002;
optional string customtype = 65003;
optional string customname = 65004;
optional string jsontag = 65005;
optional string moretags = 65006;
optional string casttype = 65007;
optional string castkey = 65008;
optional string castvalue = 65009;
optional bool stdtime = 65010;
optional bool stdduration = 65011;
optional bool wktpointer = 65012;
optional string castrepeated = 65013;
}

View File

@ -0,0 +1,413 @@
syntax = "proto3";
package tendermint.abci;
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 "tendermint/crypto/proof.proto";
import "tendermint/types/types.proto";
import "tendermint/crypto/keys.proto";
import "tendermint/types/params.proto";
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
// This file is copied from http://github.com/tendermint/abci
// NOTE: When using custom types, mind the warnings.
// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
//----------------------------------------
// Request types
message Request {
oneof value {
RequestEcho echo = 1;
RequestFlush flush = 2;
RequestInfo info = 3;
RequestSetOption set_option = 4;
RequestInitChain init_chain = 5;
RequestQuery query = 6;
RequestBeginBlock begin_block = 7;
RequestCheckTx check_tx = 8;
RequestDeliverTx deliver_tx = 9;
RequestEndBlock end_block = 10;
RequestCommit commit = 11;
RequestListSnapshots list_snapshots = 12;
RequestOfferSnapshot offer_snapshot = 13;
RequestLoadSnapshotChunk load_snapshot_chunk = 14;
RequestApplySnapshotChunk apply_snapshot_chunk = 15;
}
}
message RequestEcho {
string message = 1;
}
message RequestFlush {}
message RequestInfo {
string version = 1;
uint64 block_version = 2;
uint64 p2p_version = 3;
}
// nondeterministic
message RequestSetOption {
string key = 1;
string value = 2;
}
message RequestInitChain {
google.protobuf.Timestamp time = 1
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 2;
ConsensusParams consensus_params = 3;
repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
bytes app_state_bytes = 5;
int64 initial_height = 6;
}
message RequestQuery {
bytes data = 1;
string path = 2;
int64 height = 3;
bool prove = 4;
}
message RequestBeginBlock {
bytes hash = 1;
tendermint.types.Header header = 2 [(gogoproto.nullable) = false];
LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
}
enum CheckTxType {
NEW = 0 [(gogoproto.enumvalue_customname) = "New"];
RECHECK = 1 [(gogoproto.enumvalue_customname) = "Recheck"];
}
message RequestCheckTx {
bytes tx = 1;
CheckTxType type = 2;
}
message RequestDeliverTx {
bytes tx = 1;
}
message RequestEndBlock {
int64 height = 1;
}
message RequestCommit {}
// lists available snapshots
message RequestListSnapshots {}
// offers a snapshot to the application
message RequestOfferSnapshot {
Snapshot snapshot = 1; // snapshot offered by peers
bytes app_hash = 2; // light client-verified app hash for snapshot height
}
// loads a snapshot chunk
message RequestLoadSnapshotChunk {
uint64 height = 1;
uint32 format = 2;
uint32 chunk = 3;
}
// Applies a snapshot chunk
message RequestApplySnapshotChunk {
uint32 index = 1;
bytes chunk = 2;
string sender = 3;
}
//----------------------------------------
// Response types
message Response {
oneof value {
ResponseException exception = 1;
ResponseEcho echo = 2;
ResponseFlush flush = 3;
ResponseInfo info = 4;
ResponseSetOption set_option = 5;
ResponseInitChain init_chain = 6;
ResponseQuery query = 7;
ResponseBeginBlock begin_block = 8;
ResponseCheckTx check_tx = 9;
ResponseDeliverTx deliver_tx = 10;
ResponseEndBlock end_block = 11;
ResponseCommit commit = 12;
ResponseListSnapshots list_snapshots = 13;
ResponseOfferSnapshot offer_snapshot = 14;
ResponseLoadSnapshotChunk load_snapshot_chunk = 15;
ResponseApplySnapshotChunk apply_snapshot_chunk = 16;
}
}
// nondeterministic
message ResponseException {
string error = 1;
}
message ResponseEcho {
string message = 1;
}
message ResponseFlush {}
message ResponseInfo {
string data = 1;
string version = 2;
uint64 app_version = 3;
int64 last_block_height = 4;
bytes last_block_app_hash = 5;
}
// nondeterministic
message ResponseSetOption {
uint32 code = 1;
// bytes data = 2;
string log = 3;
string info = 4;
}
message ResponseInitChain {
ConsensusParams consensus_params = 1;
repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
bytes app_hash = 3;
}
message ResponseQuery {
uint32 code = 1;
// bytes data = 2; // use "value" instead.
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 index = 5;
bytes key = 6;
bytes value = 7;
tendermint.crypto.ProofOps proof_ops = 8;
int64 height = 9;
string codespace = 10;
}
message ResponseBeginBlock {
repeated Event events = 1
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
message ResponseCheckTx {
uint32 code = 1;
bytes data = 2;
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 gas_wanted = 5 [json_name = "gas_wanted"];
int64 gas_used = 6 [json_name = "gas_used"];
repeated Event events = 7
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
string codespace = 8;
string sender = 9;
int64 priority = 10;
// mempool_error is set by Tendermint.
// ABCI applictions creating a ResponseCheckTX should not set mempool_error.
string mempool_error = 11;
}
message ResponseDeliverTx {
uint32 code = 1;
bytes data = 2;
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 gas_wanted = 5 [json_name = "gas_wanted"];
int64 gas_used = 6 [json_name = "gas_used"];
repeated Event events = 7 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "events,omitempty"
]; // nondeterministic
string codespace = 8;
}
message ResponseEndBlock {
repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
message ResponseCommit {
// reserve 1
bytes data = 2;
int64 retain_height = 3;
}
message ResponseListSnapshots {
repeated Snapshot snapshots = 1;
}
message ResponseOfferSnapshot {
Result result = 1;
enum Result {
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
ACCEPT = 1; // Snapshot accepted, apply chunks
ABORT = 2; // Abort all snapshot restoration
REJECT = 3; // Reject this specific snapshot, try others
REJECT_FORMAT = 4; // Reject all snapshots of this format, try others
REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others
}
}
message ResponseLoadSnapshotChunk {
bytes chunk = 1;
}
message ResponseApplySnapshotChunk {
Result result = 1;
repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply
repeated string reject_senders = 3; // Chunk senders to reject and ban
enum Result {
UNKNOWN = 0; // Unknown result, abort all snapshot restoration
ACCEPT = 1; // Chunk successfully accepted
ABORT = 2; // Abort all snapshot restoration
RETRY = 3; // Retry chunk (combine with refetch and reject)
RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject)
REJECT_SNAPSHOT = 5; // Reject this snapshot, try others
}
}
//----------------------------------------
// Misc.
// ConsensusParams contains all consensus-relevant parameters
// that can be adjusted by the abci app
message ConsensusParams {
BlockParams block = 1;
tendermint.types.EvidenceParams evidence = 2;
tendermint.types.ValidatorParams validator = 3;
tendermint.types.VersionParams version = 4;
}
// 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;
}
message LastCommitInfo {
int32 round = 1;
repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
}
// Event allows application developers to attach additional information to
// ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx.
// Later, transactions may be queried using these events.
message Event {
string type = 1;
repeated EventAttribute attributes = 2 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "attributes,omitempty"
];
}
// EventAttribute is a single key-value pair, associated with an event.
message EventAttribute {
bytes key = 1;
bytes value = 2;
bool index = 3; // nondeterministic
}
// 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
// Validator
message Validator {
bytes address = 1; // The first 20 bytes of SHA256(public key)
// PubKey pub_key = 2 [(gogoproto.nullable)=false];
int64 power = 3; // The voting power
}
// ValidatorUpdate
message ValidatorUpdate {
tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
int64 power = 2;
}
// VoteInfo
message VoteInfo {
Validator validator = 1 [(gogoproto.nullable) = false];
bool signed_last_block = 2;
}
enum EvidenceType {
UNKNOWN = 0;
DUPLICATE_VOTE = 1;
LIGHT_CLIENT_ATTACK = 2;
}
message Evidence {
EvidenceType type = 1;
// The offending validator
Validator validator = 2 [(gogoproto.nullable) = false];
// The height when the offense occurred
int64 height = 3;
// The corresponding time where the offense occurred
google.protobuf.Timestamp time = 4
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// Total voting power of the validator set in case the ABCI application does
// not store historical validators.
// https://github.com/tendermint/tendermint/issues/4581
int64 total_voting_power = 5;
}
//----------------------------------------
// State Sync Types
message Snapshot {
uint64 height = 1; // The height at which the snapshot was taken
uint32 format = 2; // The application-specific snapshot format
uint32 chunks = 3; // Number of chunks in the snapshot
bytes hash = 4; // Arbitrary snapshot hash, equal only if identical
bytes metadata = 5; // Arbitrary application metadata
}
//----------------------------------------
// Service Definition
service ABCIApplication {
rpc Echo(RequestEcho) returns (ResponseEcho);
rpc Flush(RequestFlush) returns (ResponseFlush);
rpc Info(RequestInfo) returns (ResponseInfo);
rpc SetOption(RequestSetOption) returns (ResponseSetOption);
rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
rpc Query(RequestQuery) returns (ResponseQuery);
rpc Commit(RequestCommit) returns (ResponseCommit);
rpc InitChain(RequestInitChain) returns (ResponseInitChain);
rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
rpc ListSnapshots(RequestListSnapshots) returns (ResponseListSnapshots);
rpc OfferSnapshot(RequestOfferSnapshot) returns (ResponseOfferSnapshot);
rpc LoadSnapshotChunk(RequestLoadSnapshotChunk)
returns (ResponseLoadSnapshotChunk);
rpc ApplySnapshotChunk(RequestApplySnapshotChunk)
returns (ResponseApplySnapshotChunk);
}

View File

@ -0,0 +1,73 @@
package blockchain
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/p2p"
)
var _ p2p.Wrapper = &StatusRequest{}
var _ p2p.Wrapper = &StatusResponse{}
var _ p2p.Wrapper = &NoBlockResponse{}
var _ p2p.Wrapper = &BlockResponse{}
var _ p2p.Wrapper = &BlockRequest{}
const (
BlockResponseMessagePrefixSize = 4
BlockResponseMessageFieldKeySize = 1
)
func (m *BlockRequest) Wrap() proto.Message {
bm := &Message{}
bm.Sum = &Message_BlockRequest{BlockRequest: m}
return bm
}
func (m *BlockResponse) Wrap() proto.Message {
bm := &Message{}
bm.Sum = &Message_BlockResponse{BlockResponse: m}
return bm
}
func (m *NoBlockResponse) Wrap() proto.Message {
bm := &Message{}
bm.Sum = &Message_NoBlockResponse{NoBlockResponse: m}
return bm
}
func (m *StatusRequest) Wrap() proto.Message {
bm := &Message{}
bm.Sum = &Message_StatusRequest{StatusRequest: m}
return bm
}
func (m *StatusResponse) Wrap() proto.Message {
bm := &Message{}
bm.Sum = &Message_StatusResponse{StatusResponse: m}
return bm
}
// Unwrap implements the p2p Wrapper interface and unwraps a wrapped blockchain
// message.
func (m *Message) Unwrap() (proto.Message, error) {
switch msg := m.Sum.(type) {
case *Message_BlockRequest:
return m.GetBlockRequest(), nil
case *Message_BlockResponse:
return m.GetBlockResponse(), nil
case *Message_NoBlockResponse:
return m.GetNoBlockResponse(), nil
case *Message_StatusRequest:
return m.GetStatusRequest(), nil
case *Message_StatusResponse:
return m.GetStatusResponse(), nil
default:
return nil, fmt.Errorf("unknown message: %T", msg)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
syntax = "proto3";
package tendermint.blockchain;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/blockchain";
import "tendermint/types/block.proto";
// BlockRequest requests a block for a specific height
message BlockRequest {
int64 height = 1;
}
// NoBlockResponse informs the node that the peer does not have block at the requested height
message NoBlockResponse {
int64 height = 1;
}
// BlockResponse returns block to the requested
message BlockResponse {
tendermint.types.Block block = 1;
}
// StatusRequest requests the status of a peer.
message StatusRequest {
}
// StatusResponse is a peer response to inform their status.
message StatusResponse {
int64 height = 1;
int64 base = 2;
}
message Message {
oneof sum {
BlockRequest block_request = 1;
NoBlockResponse no_block_response = 2;
BlockResponse block_response = 3;
StatusRequest status_request = 4;
StatusResponse status_response = 5;
}
}

View File

@ -0,0 +1,109 @@
package consensus
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/p2p"
)
var _ p2p.Wrapper = &VoteSetBits{}
var _ p2p.Wrapper = &VoteSetMaj23{}
var _ p2p.Wrapper = &Vote{}
var _ p2p.Wrapper = &ProposalPOL{}
var _ p2p.Wrapper = &Proposal{}
var _ p2p.Wrapper = &NewValidBlock{}
var _ p2p.Wrapper = &NewRoundStep{}
var _ p2p.Wrapper = &HasVote{}
var _ p2p.Wrapper = &BlockPart{}
func (m *VoteSetBits) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_VoteSetBits{VoteSetBits: m}
return cm
}
func (m *VoteSetMaj23) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_VoteSetMaj23{VoteSetMaj23: m}
return cm
}
func (m *HasVote) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_HasVote{HasVote: m}
return cm
}
func (m *Vote) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_Vote{Vote: m}
return cm
}
func (m *BlockPart) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_BlockPart{BlockPart: m}
return cm
}
func (m *ProposalPOL) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_ProposalPol{ProposalPol: m}
return cm
}
func (m *Proposal) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_Proposal{Proposal: m}
return cm
}
func (m *NewValidBlock) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_NewValidBlock{NewValidBlock: m}
return cm
}
func (m *NewRoundStep) Wrap() proto.Message {
cm := &Message{}
cm.Sum = &Message_NewRoundStep{NewRoundStep: m}
return cm
}
// Unwrap implements the p2p Wrapper interface and unwraps a wrapped consensus
// proto message.
func (m *Message) Unwrap() (proto.Message, error) {
switch msg := m.Sum.(type) {
case *Message_NewRoundStep:
return m.GetNewRoundStep(), nil
case *Message_NewValidBlock:
return m.GetNewValidBlock(), nil
case *Message_Proposal:
return m.GetProposal(), nil
case *Message_ProposalPol:
return m.GetProposalPol(), nil
case *Message_BlockPart:
return m.GetBlockPart(), nil
case *Message_Vote:
return m.GetVote(), nil
case *Message_HasVote:
return m.GetHasVote(), nil
case *Message_VoteSetMaj23:
return m.GetVoteSetMaj23(), nil
case *Message_VoteSetBits:
return m.GetVoteSetBits(), nil
default:
return nil, fmt.Errorf("unknown message: %T", msg)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
syntax = "proto3";
package tendermint.consensus;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/consensus";
import "gogoproto/gogo.proto";
import "tendermint/types/types.proto";
import "tendermint/libs/bits/types.proto";
// NewRoundStep is sent for every step taken in the ConsensusState.
// For every height/round/step transition
message NewRoundStep {
int64 height = 1;
int32 round = 2;
uint32 step = 3;
int64 seconds_since_start_time = 4;
int32 last_commit_round = 5;
}
// NewValidBlock is sent when a validator observes a valid block B in some round r,
// i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r.
// In case the block is also committed, then IsCommit flag is set to true.
message NewValidBlock {
int64 height = 1;
int32 round = 2;
tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false];
tendermint.libs.bits.BitArray block_parts = 4;
bool is_commit = 5;
}
// Proposal is sent when a new block is proposed.
message Proposal {
tendermint.types.Proposal proposal = 1 [(gogoproto.nullable) = false];
}
// ProposalPOL is sent when a previous proposal is re-proposed.
message ProposalPOL {
int64 height = 1;
int32 proposal_pol_round = 2;
tendermint.libs.bits.BitArray proposal_pol = 3 [(gogoproto.nullable) = false];
}
// BlockPart is sent when gossipping a piece of the proposed block.
message BlockPart {
int64 height = 1;
int32 round = 2;
tendermint.types.Part part = 3 [(gogoproto.nullable) = false];
}
// Vote is sent when voting for a proposal (or lack thereof).
message Vote {
tendermint.types.Vote vote = 1;
}
// HasVote is sent to indicate that a particular vote has been received.
message HasVote {
int64 height = 1;
int32 round = 2;
tendermint.types.SignedMsgType type = 3;
int32 index = 4;
}
// VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes.
message VoteSetMaj23 {
int64 height = 1;
int32 round = 2;
tendermint.types.SignedMsgType type = 3;
tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false];
}
// VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID.
message VoteSetBits {
int64 height = 1;
int32 round = 2;
tendermint.types.SignedMsgType type = 3;
tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false];
tendermint.libs.bits.BitArray votes = 5 [(gogoproto.nullable) = false];
}
message Message {
oneof sum {
NewRoundStep new_round_step = 1;
NewValidBlock new_valid_block = 2;
Proposal proposal = 3;
ProposalPOL proposal_pol = 4;
BlockPart block_part = 5;
Vote vote = 6;
HasVote has_vote = 7;
VoteSetMaj23 vote_set_maj23 = 8;
VoteSetBits vote_set_bits = 9;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
syntax = "proto3";
package tendermint.consensus;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/consensus";
import "gogoproto/gogo.proto";
import "tendermint/consensus/types.proto";
import "tendermint/types/events.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
// MsgInfo are msgs from the reactor which may update the state
message MsgInfo {
Message msg = 1 [(gogoproto.nullable) = false];
string peer_id = 2 [(gogoproto.customname) = "PeerID"];
}
// TimeoutInfo internally generated messages which may update the state
message TimeoutInfo {
google.protobuf.Duration duration = 1
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
int64 height = 2;
int32 round = 3;
uint32 step = 4;
}
// EndHeight marks the end of the given height inside WAL.
// @internal used by scripts/wal2json util.
message EndHeight {
int64 height = 1;
}
message WALMessage {
oneof sum {
tendermint.types.EventDataRoundState event_data_round_state = 1;
MsgInfo msg_info = 2;
TimeoutInfo timeout_info = 3;
EndHeight end_height = 4;
}
}
// TimedWALMessage wraps WALMessage and adds Time for debugging purposes.
message TimedWALMessage {
google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
WALMessage msg = 2;
}

View File

@ -0,0 +1,655 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/crypto/keys.proto
package crypto
import (
bytes "bytes"
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.
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
// PublicKey defines the keys available for use with Tendermint Validators
type PublicKey struct {
// Types that are valid to be assigned to Sum:
// *PublicKey_Ed25519
// *PublicKey_Secp256K1
Sum isPublicKey_Sum `protobuf_oneof:"sum"`
}
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_cb048658b234868c, []int{0}
}
func (m *PublicKey) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_PublicKey.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 *PublicKey) XXX_Merge(src proto.Message) {
xxx_messageInfo_PublicKey.Merge(m, src)
}
func (m *PublicKey) XXX_Size() int {
return m.Size()
}
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
MarshalTo([]byte) (int, error)
Size() int
Compare(interface{}) int
}
type PublicKey_Ed25519 struct {
Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"`
}
type PublicKey_Secp256K1 struct {
Secp256K1 []byte `protobuf:"bytes,2,opt,name=secp256k1,proto3,oneof" json:"secp256k1,omitempty"`
}
func (*PublicKey_Ed25519) isPublicKey_Sum() {}
func (*PublicKey_Secp256K1) 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
}
func (m *PublicKey) GetSecp256K1() []byte {
if x, ok := m.GetSum().(*PublicKey_Secp256K1); ok {
return x.Secp256K1
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*PublicKey) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*PublicKey_Ed25519)(nil),
(*PublicKey_Secp256K1)(nil),
}
}
func init() {
proto.RegisterType((*PublicKey)(nil), "tendermint.crypto.PublicKey")
}
func init() { proto.RegisterFile("tendermint/crypto/keys.proto", fileDescriptor_cb048658b234868c) }
var fileDescriptor_cb048658b234868c = []byte{
// 199 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0xd7, 0xcf, 0x4e,
0xad, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x44, 0xc8, 0xea, 0x41, 0x64, 0xa5,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x52, 0x04, 0x17, 0x67,
0x40, 0x69, 0x52, 0x4e, 0x66, 0xb2, 0x77, 0x6a, 0xa5, 0x90, 0x14, 0x17, 0x7b, 0x6a, 0x8a, 0x91,
0xa9, 0xa9, 0xa1, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x8f, 0x07, 0x43, 0x10, 0x4c, 0x40, 0x48,
0x8e, 0x8b, 0xb3, 0x38, 0x35, 0xb9, 0xc0, 0xc8, 0xd4, 0x2c, 0xdb, 0x50, 0x82, 0x09, 0x2a, 0x8b,
0x10, 0xb2, 0xe2, 0x78, 0xb1, 0x40, 0x9e, 0xf1, 0xc5, 0x42, 0x79, 0x46, 0x27, 0x56, 0x2e, 0xe6,
0xe2, 0xd2, 0x5c, 0xa7, 0xa0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48,
0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2,
0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0xf2, 0x05, 0x12, 0x13,
0xe2, 0x4c, 0x0c, 0x1f, 0x26, 0xb1, 0x81, 0x25, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe8,
0x1d, 0x1e, 0xe2, 0xfd, 0x00, 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
case *PublicKey_Secp256K1:
thisType = 1
default:
panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.Sum))
}
that1Type := -1
switch that1.Sum.(type) {
case *PublicKey_Ed25519:
that1Type = 0
case *PublicKey_Secp256K1:
that1Type = 1
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
}
}
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 *PublicKey_Secp256K1) Compare(that interface{}) int {
if that == nil {
if this == nil {
return 0
}
return 1
}
that1, ok := that.(*PublicKey_Secp256K1)
if !ok {
that2, ok := that.(PublicKey_Secp256K1)
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.Secp256K1, that1.Secp256K1); 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
}
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 *PublicKey_Secp256K1) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*PublicKey_Secp256K1)
if !ok {
that2, ok := that.(PublicKey_Secp256K1)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if !bytes.Equal(this.Secp256K1, that1.Secp256K1) {
return false
}
return true
}
func (m *PublicKey) 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 *PublicKey) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Sum != nil {
{
size := m.Sum.Size()
i -= size
if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
}
}
return len(dAtA) - i, nil
}
func (m *PublicKey_Ed25519) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PublicKey_Ed25519) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.Ed25519 != nil {
i -= len(m.Ed25519)
copy(dAtA[i:], m.Ed25519)
i = encodeVarintKeys(dAtA, i, uint64(len(m.Ed25519)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *PublicKey_Secp256K1) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PublicKey_Secp256K1) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.Secp256K1 != nil {
i -= len(m.Secp256K1)
copy(dAtA[i:], m.Secp256K1)
i = encodeVarintKeys(dAtA, i, uint64(len(m.Secp256K1)))
i--
dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
func encodeVarintKeys(dAtA []byte, offset int, v uint64) int {
offset -= sovKeys(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *PublicKey) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Sum != nil {
n += m.Sum.Size()
}
return n
}
func (m *PublicKey_Ed25519) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Ed25519 != nil {
l = len(m.Ed25519)
n += 1 + l + sovKeys(uint64(l))
}
return n
}
func (m *PublicKey_Secp256K1) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Secp256K1 != nil {
l = len(m.Secp256K1)
n += 1 + l + sovKeys(uint64(l))
}
return n
}
func sovKeys(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozKeys(x uint64) (n int) {
return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *PublicKey) 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 ErrIntOverflowKeys
}
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: PublicKey: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: PublicKey: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowKeys
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthKeys
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthKeys
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := make([]byte, postIndex-iNdEx)
copy(v, dAtA[iNdEx:postIndex])
m.Sum = &PublicKey_Ed25519{v}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Secp256K1", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowKeys
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthKeys
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthKeys
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := make([]byte, postIndex-iNdEx)
copy(v, dAtA[iNdEx:postIndex])
m.Sum = &PublicKey_Secp256K1{v}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipKeys(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthKeys
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipKeys(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, ErrIntOverflowKeys
}
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, ErrIntOverflowKeys
}
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, ErrIntOverflowKeys
}
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, ErrInvalidLengthKeys
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupKeys
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthKeys
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthKeys = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowKeys = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -0,0 +1,17 @@
syntax = "proto3";
package tendermint.crypto;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
import "gogoproto/gogo.proto";
// PublicKey defines the keys available for use with Tendermint Validators
message PublicKey {
option (gogoproto.compare) = true;
option (gogoproto.equal) = true;
oneof sum {
bytes ed25519 = 1;
bytes secp256k1 = 2;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
syntax = "proto3";
package tendermint.crypto;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
import "gogoproto/gogo.proto";
message Proof {
int64 total = 1;
int64 index = 2;
bytes leaf_hash = 3;
repeated bytes aunts = 4;
}
message ValueOp {
// Encoded in ProofOp.Key.
bytes key = 1;
// To encode in ProofOp.Data
Proof proof = 2;
}
message DominoOp {
string key = 1;
string input = 2;
string output = 3;
}
// ProofOp defines an operation used for calculating Merkle root
// The data could be arbitrary format, providing nessecary data
// for example neighbouring node hash
message ProofOp {
string type = 1;
bytes key = 2;
bytes data = 3;
}
// ProofOps is Merkle proof defined by the list of ProofOps
message ProofOps {
repeated ProofOp ops = 1 [(gogoproto.nullable) = false];
}

View File

@ -0,0 +1,408 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/libs/bits/types.proto
package bits
import (
fmt "fmt"
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.
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"`
}
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_e91ab2672920d7d4, []int{0}
}
func (m *BitArray) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *BitArray) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
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 m.Size()
}
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.libs.bits.BitArray")
}
func init() { proto.RegisterFile("tendermint/libs/bits/types.proto", fileDescriptor_e91ab2672920d7d4) }
var fileDescriptor_e91ab2672920d7d4 = []byte{
// 168 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0xcf, 0xc9, 0x4c, 0x2a, 0xd6, 0x4f, 0xca, 0x2c, 0x29,
0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0xa8,
0xd0, 0x03, 0xa9, 0xd0, 0x03, 0xa9, 0x50, 0x32, 0xe1, 0xe2, 0x70, 0xca, 0x2c, 0x71, 0x2c, 0x2a,
0x4a, 0xac, 0x14, 0x12, 0xe2, 0x62, 0x01, 0x89, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x81,
0xd9, 0x42, 0x22, 0x5c, 0xac, 0xa9, 0x39, 0xa9, 0xb9, 0xc5, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0x2c,
0x41, 0x10, 0x8e, 0x53, 0xe8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24,
0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59,
0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x39, 0x09, 0x89, 0x09,
0x76, 0x8d, 0x3e, 0x36, 0xe7, 0x26, 0xb1, 0x81, 0xe5, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff,
0x5b, 0x0c, 0xe3, 0x3e, 0xcd, 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 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
}
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) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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")
)

View File

@ -0,0 +1,9 @@
syntax = "proto3";
package tendermint.libs.bits;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits";
message BitArray {
int64 bits = 1;
repeated uint64 elems = 2;
}

View File

@ -0,0 +1,30 @@
package mempool
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/p2p"
)
var _ p2p.Wrapper = &Txs{}
var _ p2p.Unwrapper = &Message{}
// Wrap implements the p2p Wrapper interface and wraps a mempool message.
func (m *Txs) Wrap() proto.Message {
mm := &Message{}
mm.Sum = &Message_Txs{Txs: m}
return mm
}
// Unwrap implements the p2p Wrapper interface and unwraps a wrapped mempool
// message.
func (m *Message) Unwrap() (proto.Message, error) {
switch msg := m.Sum.(type) {
case *Message_Txs:
return m.GetTxs(), nil
default:
return nil, fmt.Errorf("unknown message: %T", msg)
}
}

View File

@ -0,0 +1,556 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/mempool/types.proto
package mempool
import (
fmt "fmt"
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.
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 Txs struct {
Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"`
}
func (m *Txs) Reset() { *m = Txs{} }
func (m *Txs) String() string { return proto.CompactTextString(m) }
func (*Txs) ProtoMessage() {}
func (*Txs) Descriptor() ([]byte, []int) {
return fileDescriptor_2af51926fdbcbc05, []int{0}
}
func (m *Txs) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Txs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Txs.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 *Txs) XXX_Merge(src proto.Message) {
xxx_messageInfo_Txs.Merge(m, src)
}
func (m *Txs) XXX_Size() int {
return m.Size()
}
func (m *Txs) XXX_DiscardUnknown() {
xxx_messageInfo_Txs.DiscardUnknown(m)
}
var xxx_messageInfo_Txs proto.InternalMessageInfo
func (m *Txs) GetTxs() [][]byte {
if m != nil {
return m.Txs
}
return nil
}
type Message struct {
// Types that are valid to be assigned to Sum:
// *Message_Txs
Sum isMessage_Sum `protobuf_oneof:"sum"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_2af51926fdbcbc05, []int{1}
}
func (m *Message) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Message.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 *Message) XXX_Merge(src proto.Message) {
xxx_messageInfo_Message.Merge(m, src)
}
func (m *Message) XXX_Size() int {
return m.Size()
}
func (m *Message) XXX_DiscardUnknown() {
xxx_messageInfo_Message.DiscardUnknown(m)
}
var xxx_messageInfo_Message proto.InternalMessageInfo
type isMessage_Sum interface {
isMessage_Sum()
MarshalTo([]byte) (int, error)
Size() int
}
type Message_Txs struct {
Txs *Txs `protobuf:"bytes,1,opt,name=txs,proto3,oneof" json:"txs,omitempty"`
}
func (*Message_Txs) isMessage_Sum() {}
func (m *Message) GetSum() isMessage_Sum {
if m != nil {
return m.Sum
}
return nil
}
func (m *Message) GetTxs() *Txs {
if x, ok := m.GetSum().(*Message_Txs); ok {
return x.Txs
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*Message) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Message_Txs)(nil),
}
}
func init() {
proto.RegisterType((*Txs)(nil), "tendermint.mempool.Txs")
proto.RegisterType((*Message)(nil), "tendermint.mempool.Message")
}
func init() { proto.RegisterFile("tendermint/mempool/types.proto", fileDescriptor_2af51926fdbcbc05) }
var fileDescriptor_2af51926fdbcbc05 = []byte{
// 179 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0xcf, 0x4d, 0xcd, 0x2d, 0xc8, 0xcf, 0xcf, 0xd1, 0x2f,
0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0xc8, 0xeb, 0x41,
0xe5, 0x95, 0xc4, 0xb9, 0x98, 0x43, 0x2a, 0x8a, 0x85, 0x04, 0xb8, 0x98, 0x4b, 0x2a, 0x8a, 0x25,
0x18, 0x15, 0x98, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x25, 0x5b, 0x2e, 0x76, 0xdf, 0xd4, 0xe2, 0xe2,
0xc4, 0xf4, 0x54, 0x21, 0x6d, 0x98, 0x24, 0xa3, 0x06, 0xb7, 0x91, 0xb8, 0x1e, 0xa6, 0x29, 0x7a,
0x21, 0x15, 0xc5, 0x1e, 0x0c, 0x60, 0x7d, 0x4e, 0xac, 0x5c, 0xcc, 0xc5, 0xa5, 0xb9, 0x4e, 0xc1,
0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72,
0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x99, 0x9e, 0x59, 0x92, 0x51,
0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xe4, 0x60, 0x24, 0x26, 0xd8, 0xb5, 0xfa, 0x98, 0x9e,
0x49, 0x62, 0x03, 0xcb, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xca, 0xc3, 0xa0, 0xfc, 0xe9,
0x00, 0x00, 0x00,
}
func (m *Txs) 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 *Txs) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Txs) > 0 {
for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Txs[iNdEx])
copy(dAtA[i:], m.Txs[iNdEx])
i = encodeVarintTypes(dAtA, i, uint64(len(m.Txs[iNdEx])))
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func (m *Message) 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 *Message) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Sum != nil {
{
size := m.Sum.Size()
i -= size
if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
}
}
return len(dAtA) - i, nil
}
func (m *Message_Txs) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Message_Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.Txs != nil {
{
size, err := m.Txs.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
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 *Txs) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Txs) > 0 {
for _, b := range m.Txs {
l = len(b)
n += 1 + l + sovTypes(uint64(l))
}
}
return n
}
func (m *Message) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Sum != nil {
n += m.Sum.Size()
}
return n
}
func (m *Message_Txs) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Txs != nil {
l = m.Txs.Size()
n += 1 + l + sovTypes(uint64(l))
}
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 *Txs) 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: Txs: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Txs: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Txs", 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.Txs = append(m.Txs, make([]byte, postIndex-iNdEx))
copy(m.Txs[len(m.Txs)-1], dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Message) 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: Message: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &Txs{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Message_Txs{v}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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")
)

View File

@ -0,0 +1,14 @@
syntax = "proto3";
package tendermint.mempool;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/mempool";
message Txs {
repeated bytes txs = 1;
}
message Message {
oneof sum {
Txs txs = 1;
}
}

View File

@ -0,0 +1,30 @@
syntax = "proto3";
package tendermint.p2p;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p";
import "gogoproto/gogo.proto";
import "tendermint/crypto/keys.proto";
message PacketPing {}
message PacketPong {}
message PacketMsg {
int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"];
bool eof = 2 [(gogoproto.customname) = "EOF"];
bytes data = 3;
}
message Packet {
oneof sum {
PacketPing packet_ping = 1;
PacketPong packet_pong = 2;
PacketMsg packet_msg = 3;
}
}
message AuthSigMessage {
tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
bytes sig = 2;
}

View File

@ -0,0 +1,20 @@
syntax = "proto3";
package tendermint.p2p;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p";
import "tendermint/p2p/types.proto";
import "gogoproto/gogo.proto";
message PexRequest {}
message PexAddrs {
repeated NetAddress addrs = 1 [(gogoproto.nullable) = false];
}
message Message {
oneof sum {
PexRequest pex_request = 1;
PexAddrs pex_addrs = 2;
}
}

View File

@ -0,0 +1,34 @@
syntax = "proto3";
package tendermint.p2p;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p";
import "gogoproto/gogo.proto";
message NetAddress {
string id = 1 [(gogoproto.customname) = "ID"];
string ip = 2 [(gogoproto.customname) = "IP"];
uint32 port = 3;
}
message ProtocolVersion {
uint64 p2p = 1 [(gogoproto.customname) = "P2P"];
uint64 block = 2;
uint64 app = 3;
}
message DefaultNodeInfo {
ProtocolVersion protocol_version = 1 [(gogoproto.nullable) = false];
string default_node_id = 2 [(gogoproto.customname) = "DefaultNodeID"];
string listen_addr = 3;
string network = 4;
string version = 5;
bytes channels = 6;
string moniker = 7;
DefaultNodeInfoOther other = 8 [(gogoproto.nullable) = false];
}
message DefaultNodeInfoOther {
string tx_index = 1;
string rpc_address = 2 [(gogoproto.customname) = "RPCAddress"];
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
syntax = "proto3";
package tendermint.privval;
import "tendermint/crypto/keys.proto";
import "tendermint/types/types.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/tendermint/tendermint/proto/tendermint/privval";
enum Errors {
ERRORS_UNKNOWN = 0;
ERRORS_UNEXPECTED_RESPONSE = 1;
ERRORS_NO_CONNECTION = 2;
ERRORS_CONNECTION_TIMEOUT = 3;
ERRORS_READ_TIMEOUT = 4;
ERRORS_WRITE_TIMEOUT = 5;
}
message RemoteSignerError {
int32 code = 1;
string description = 2;
}
// PubKeyRequest requests the consensus public key from the remote signer.
message PubKeyRequest {
string chain_id = 1;
}
// PubKeyResponse is a response message containing the public key.
message PubKeyResponse {
tendermint.crypto.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
RemoteSignerError error = 2;
}
// SignVoteRequest is a request to sign a vote
message SignVoteRequest {
tendermint.types.Vote vote = 1;
string chain_id = 2;
}
// SignedVoteResponse is a response containing a signed vote or an error
message SignedVoteResponse {
tendermint.types.Vote vote = 1 [(gogoproto.nullable) = false];
RemoteSignerError error = 2;
}
// SignProposalRequest is a request to sign a proposal
message SignProposalRequest {
tendermint.types.Proposal proposal = 1;
string chain_id = 2;
}
// SignedProposalResponse is response containing a signed proposal or an error
message SignedProposalResponse {
tendermint.types.Proposal proposal = 1 [(gogoproto.nullable) = false];
RemoteSignerError error = 2;
}
// PingRequest is a request to confirm that the connection is alive.
message PingRequest {}
// PingResponse is a response to confirm that the connection is alive.
message PingResponse {}
message Message {
oneof sum {
PubKeyRequest pub_key_request = 1;
PubKeyResponse pub_key_response = 2;
SignVoteRequest sign_vote_request = 3;
SignedVoteResponse signed_vote_response = 4;
SignProposalRequest sign_proposal_request = 5;
SignedProposalResponse signed_proposal_response = 6;
PingRequest ping_request = 7;
PingResponse ping_response = 8;
}
}

View File

@ -0,0 +1,924 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/rpc/grpc/types.proto
package coregrpc
import (
context "context"
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
types "github.com/tendermint/tendermint/abci/types"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// 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 RequestPing struct {
}
func (m *RequestPing) Reset() { *m = RequestPing{} }
func (m *RequestPing) String() string { return proto.CompactTextString(m) }
func (*RequestPing) ProtoMessage() {}
func (*RequestPing) Descriptor() ([]byte, []int) {
return fileDescriptor_0ffff5682c662b95, []int{0}
}
func (m *RequestPing) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *RequestPing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_RequestPing.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 *RequestPing) XXX_Merge(src proto.Message) {
xxx_messageInfo_RequestPing.Merge(m, src)
}
func (m *RequestPing) XXX_Size() int {
return m.Size()
}
func (m *RequestPing) XXX_DiscardUnknown() {
xxx_messageInfo_RequestPing.DiscardUnknown(m)
}
var xxx_messageInfo_RequestPing proto.InternalMessageInfo
type RequestBroadcastTx struct {
Tx []byte `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
}
func (m *RequestBroadcastTx) Reset() { *m = RequestBroadcastTx{} }
func (m *RequestBroadcastTx) String() string { return proto.CompactTextString(m) }
func (*RequestBroadcastTx) ProtoMessage() {}
func (*RequestBroadcastTx) Descriptor() ([]byte, []int) {
return fileDescriptor_0ffff5682c662b95, []int{1}
}
func (m *RequestBroadcastTx) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *RequestBroadcastTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_RequestBroadcastTx.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 *RequestBroadcastTx) XXX_Merge(src proto.Message) {
xxx_messageInfo_RequestBroadcastTx.Merge(m, src)
}
func (m *RequestBroadcastTx) XXX_Size() int {
return m.Size()
}
func (m *RequestBroadcastTx) XXX_DiscardUnknown() {
xxx_messageInfo_RequestBroadcastTx.DiscardUnknown(m)
}
var xxx_messageInfo_RequestBroadcastTx proto.InternalMessageInfo
func (m *RequestBroadcastTx) GetTx() []byte {
if m != nil {
return m.Tx
}
return nil
}
type ResponsePing struct {
}
func (m *ResponsePing) Reset() { *m = ResponsePing{} }
func (m *ResponsePing) String() string { return proto.CompactTextString(m) }
func (*ResponsePing) ProtoMessage() {}
func (*ResponsePing) Descriptor() ([]byte, []int) {
return fileDescriptor_0ffff5682c662b95, []int{2}
}
func (m *ResponsePing) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ResponsePing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ResponsePing.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 *ResponsePing) XXX_Merge(src proto.Message) {
xxx_messageInfo_ResponsePing.Merge(m, src)
}
func (m *ResponsePing) XXX_Size() int {
return m.Size()
}
func (m *ResponsePing) XXX_DiscardUnknown() {
xxx_messageInfo_ResponsePing.DiscardUnknown(m)
}
var xxx_messageInfo_ResponsePing proto.InternalMessageInfo
type ResponseBroadcastTx struct {
CheckTx *types.ResponseCheckTx `protobuf:"bytes,1,opt,name=check_tx,json=checkTx,proto3" json:"check_tx,omitempty"`
DeliverTx *types.ResponseDeliverTx `protobuf:"bytes,2,opt,name=deliver_tx,json=deliverTx,proto3" json:"deliver_tx,omitempty"`
}
func (m *ResponseBroadcastTx) Reset() { *m = ResponseBroadcastTx{} }
func (m *ResponseBroadcastTx) String() string { return proto.CompactTextString(m) }
func (*ResponseBroadcastTx) ProtoMessage() {}
func (*ResponseBroadcastTx) Descriptor() ([]byte, []int) {
return fileDescriptor_0ffff5682c662b95, []int{3}
}
func (m *ResponseBroadcastTx) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ResponseBroadcastTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ResponseBroadcastTx.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 *ResponseBroadcastTx) XXX_Merge(src proto.Message) {
xxx_messageInfo_ResponseBroadcastTx.Merge(m, src)
}
func (m *ResponseBroadcastTx) XXX_Size() int {
return m.Size()
}
func (m *ResponseBroadcastTx) XXX_DiscardUnknown() {
xxx_messageInfo_ResponseBroadcastTx.DiscardUnknown(m)
}
var xxx_messageInfo_ResponseBroadcastTx proto.InternalMessageInfo
func (m *ResponseBroadcastTx) GetCheckTx() *types.ResponseCheckTx {
if m != nil {
return m.CheckTx
}
return nil
}
func (m *ResponseBroadcastTx) GetDeliverTx() *types.ResponseDeliverTx {
if m != nil {
return m.DeliverTx
}
return nil
}
func init() {
proto.RegisterType((*RequestPing)(nil), "tendermint.rpc.grpc.RequestPing")
proto.RegisterType((*RequestBroadcastTx)(nil), "tendermint.rpc.grpc.RequestBroadcastTx")
proto.RegisterType((*ResponsePing)(nil), "tendermint.rpc.grpc.ResponsePing")
proto.RegisterType((*ResponseBroadcastTx)(nil), "tendermint.rpc.grpc.ResponseBroadcastTx")
}
func init() { proto.RegisterFile("tendermint/rpc/grpc/types.proto", fileDescriptor_0ffff5682c662b95) }
var fileDescriptor_0ffff5682c662b95 = []byte{
// 316 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x2a, 0x48, 0xd6, 0x4f, 0x07, 0x11, 0x25, 0x95,
0x05, 0xa9, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x08, 0x05, 0x7a, 0x45, 0x05,
0xc9, 0x7a, 0x20, 0x05, 0x52, 0xd2, 0x48, 0xba, 0x12, 0x93, 0x92, 0x33, 0x91, 0x75, 0x28, 0xf1,
0x72, 0x71, 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x04, 0x64, 0xe6, 0xa5, 0x2b, 0xa9, 0x70,
0x09, 0x41, 0xb9, 0x4e, 0x45, 0xf9, 0x89, 0x29, 0xc9, 0x89, 0xc5, 0x25, 0x21, 0x15, 0x42, 0x7c,
0x5c, 0x4c, 0x25, 0x15, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x4c, 0x25, 0x15, 0x4a, 0x7c,
0x5c, 0x3c, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x60, 0x5d, 0x53, 0x19, 0xb9, 0x84,
0x61, 0x02, 0xc8, 0xfa, 0xac, 0xb9, 0x38, 0x92, 0x33, 0x52, 0x93, 0xb3, 0xe3, 0xa1, 0xba, 0xb9,
0x8d, 0x14, 0xf4, 0x90, 0x5c, 0x08, 0x72, 0x8c, 0x1e, 0x4c, 0x9f, 0x33, 0x48, 0x61, 0x48, 0x45,
0x10, 0x7b, 0x32, 0x84, 0x21, 0xe4, 0xc8, 0xc5, 0x95, 0x92, 0x9a, 0x93, 0x59, 0x96, 0x5a, 0x04,
0xd2, 0xce, 0x04, 0xd6, 0xae, 0x84, 0x53, 0xbb, 0x0b, 0x44, 0x69, 0x48, 0x45, 0x10, 0x67, 0x0a,
0x8c, 0x69, 0xb4, 0x97, 0x91, 0x8b, 0x07, 0xee, 0x1e, 0xc7, 0x00, 0x4f, 0x21, 0x6f, 0x2e, 0x16,
0x90, 0x83, 0x85, 0x50, 0x9c, 0x01, 0x0b, 0x28, 0x3d, 0xa4, 0x80, 0x90, 0x52, 0xc4, 0xa1, 0x02,
0xe1, 0x6b, 0xa1, 0x04, 0x2e, 0x6e, 0x64, 0xcf, 0xaa, 0xe3, 0x33, 0x13, 0x49, 0xa1, 0x94, 0x06,
0x5e, 0xa3, 0x91, 0x54, 0x3a, 0xf9, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83,
0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43,
0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x52, 0xf4, 0x62,
0x49, 0x1f, 0xd6, 0xc9, 0xf9, 0x45, 0xa9, 0x20, 0x46, 0x12, 0x1b, 0x38, 0xc6, 0x8d, 0x01, 0x01,
0x00, 0x00, 0xff, 0xff, 0xf6, 0x4b, 0x02, 0xd8, 0x46, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// BroadcastAPIClient is the client API for BroadcastAPI service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type BroadcastAPIClient interface {
Ping(ctx context.Context, in *RequestPing, opts ...grpc.CallOption) (*ResponsePing, error)
BroadcastTx(ctx context.Context, in *RequestBroadcastTx, opts ...grpc.CallOption) (*ResponseBroadcastTx, error)
}
type broadcastAPIClient struct {
cc *grpc.ClientConn
}
func NewBroadcastAPIClient(cc *grpc.ClientConn) BroadcastAPIClient {
return &broadcastAPIClient{cc}
}
func (c *broadcastAPIClient) Ping(ctx context.Context, in *RequestPing, opts ...grpc.CallOption) (*ResponsePing, error) {
out := new(ResponsePing)
err := c.cc.Invoke(ctx, "/tendermint.rpc.grpc.BroadcastAPI/Ping", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *broadcastAPIClient) BroadcastTx(ctx context.Context, in *RequestBroadcastTx, opts ...grpc.CallOption) (*ResponseBroadcastTx, error) {
out := new(ResponseBroadcastTx)
err := c.cc.Invoke(ctx, "/tendermint.rpc.grpc.BroadcastAPI/BroadcastTx", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// BroadcastAPIServer is the server API for BroadcastAPI service.
type BroadcastAPIServer interface {
Ping(context.Context, *RequestPing) (*ResponsePing, error)
BroadcastTx(context.Context, *RequestBroadcastTx) (*ResponseBroadcastTx, error)
}
// UnimplementedBroadcastAPIServer can be embedded to have forward compatible implementations.
type UnimplementedBroadcastAPIServer struct {
}
func (*UnimplementedBroadcastAPIServer) Ping(ctx context.Context, req *RequestPing) (*ResponsePing, error) {
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
}
func (*UnimplementedBroadcastAPIServer) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) {
return nil, status.Errorf(codes.Unimplemented, "method BroadcastTx not implemented")
}
func RegisterBroadcastAPIServer(s *grpc.Server, srv BroadcastAPIServer) {
s.RegisterService(&_BroadcastAPI_serviceDesc, srv)
}
func _BroadcastAPI_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RequestPing)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BroadcastAPIServer).Ping(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/tendermint.rpc.grpc.BroadcastAPI/Ping",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BroadcastAPIServer).Ping(ctx, req.(*RequestPing))
}
return interceptor(ctx, in, info, handler)
}
func _BroadcastAPI_BroadcastTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RequestBroadcastTx)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BroadcastAPIServer).BroadcastTx(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/tendermint.rpc.grpc.BroadcastAPI/BroadcastTx",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BroadcastAPIServer).BroadcastTx(ctx, req.(*RequestBroadcastTx))
}
return interceptor(ctx, in, info, handler)
}
var _BroadcastAPI_serviceDesc = grpc.ServiceDesc{
ServiceName: "tendermint.rpc.grpc.BroadcastAPI",
HandlerType: (*BroadcastAPIServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Ping",
Handler: _BroadcastAPI_Ping_Handler,
},
{
MethodName: "BroadcastTx",
Handler: _BroadcastAPI_BroadcastTx_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tendermint/rpc/grpc/types.proto",
}
func (m *RequestPing) 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 *RequestPing) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *RequestPing) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *RequestBroadcastTx) 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 *RequestBroadcastTx) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *RequestBroadcastTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Tx) > 0 {
i -= len(m.Tx)
copy(dAtA[i:], m.Tx)
i = encodeVarintTypes(dAtA, i, uint64(len(m.Tx)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *ResponsePing) 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 *ResponsePing) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *ResponsePing) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *ResponseBroadcastTx) 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 *ResponseBroadcastTx) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *ResponseBroadcastTx) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.DeliverTx != nil {
{
size, err := m.DeliverTx.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if m.CheckTx != nil {
{
size, err := m.CheckTx.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
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 *RequestPing) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *RequestBroadcastTx) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Tx)
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
return n
}
func (m *ResponsePing) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *ResponseBroadcastTx) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.CheckTx != nil {
l = m.CheckTx.Size()
n += 1 + l + sovTypes(uint64(l))
}
if m.DeliverTx != nil {
l = m.DeliverTx.Size()
n += 1 + l + sovTypes(uint64(l))
}
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 *RequestPing) 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: RequestPing: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: RequestPing: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *RequestBroadcastTx) 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: RequestBroadcastTx: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: RequestBroadcastTx: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Tx", 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.Tx = append(m.Tx[:0], dAtA[iNdEx:postIndex]...)
if m.Tx == nil {
m.Tx = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ResponsePing) 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: ResponsePing: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ResponsePing: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ResponseBroadcastTx) 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: ResponseBroadcastTx: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ResponseBroadcastTx: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CheckTx", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.CheckTx == nil {
m.CheckTx = &types.ResponseCheckTx{}
}
if err := m.CheckTx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field DeliverTx", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.DeliverTx == nil {
m.DeliverTx = &types.ResponseDeliverTx{}
}
if err := m.DeliverTx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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")
)

View File

@ -0,0 +1,32 @@
syntax = "proto3";
package tendermint.rpc.grpc;
option go_package = "github.com/tendermint/tendermint/rpc/grpc;coregrpc";
import "tendermint/abci/types.proto";
//----------------------------------------
// Request types
message RequestPing {}
message RequestBroadcastTx {
bytes tx = 1;
}
//----------------------------------------
// Response types
message ResponsePing {}
message ResponseBroadcastTx {
tendermint.abci.ResponseCheckTx check_tx = 1;
tendermint.abci.ResponseDeliverTx deliver_tx = 2;
}
//----------------------------------------
// Service Definition
service BroadcastAPI {
rpc Ping(RequestPing) returns (ResponsePing);
rpc BroadcastTx(RequestBroadcastTx) returns (ResponseBroadcastTx);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
syntax = "proto3";
package tendermint.state;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/state";
import "gogoproto/gogo.proto";
import "tendermint/abci/types.proto";
import "tendermint/types/types.proto";
import "tendermint/types/validator.proto";
import "tendermint/types/params.proto";
import "tendermint/version/types.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.ResponseDeliverTx deliver_txs = 1;
tendermint.abci.ResponseEndBlock end_block = 2;
tendermint.abci.ResponseBeginBlock begin_block = 3;
}
// ValidatorsInfo represents the latest validator set, or the last height it changed
message ValidatorsInfo {
tendermint.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.types.ConsensusParams consensus_params = 1 [(gogoproto.nullable) = false];
int64 last_height_changed = 2;
}
message ABCIResponsesInfo {
ABCIResponses abci_responses = 1;
int64 height = 2;
}
message Version {
tendermint.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"];
int64 initial_height = 14;
// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist)
int64 last_block_height = 3;
tendermint.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.types.ValidatorSet next_validators = 6;
tendermint.types.ValidatorSet validators = 7;
tendermint.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.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 last_results_hash = 12;
// the latest AppHash we've received from calling abci.Commit()
bytes app_hash = 13;
}

View File

@ -0,0 +1,58 @@
package statesync
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/p2p"
)
var _ p2p.Wrapper = &ChunkRequest{}
var _ p2p.Wrapper = &ChunkResponse{}
var _ p2p.Wrapper = &SnapshotsRequest{}
var _ p2p.Wrapper = &SnapshotsResponse{}
func (m *SnapshotsResponse) Wrap() proto.Message {
sm := &Message{}
sm.Sum = &Message_SnapshotsResponse{SnapshotsResponse: m}
return sm
}
func (m *SnapshotsRequest) Wrap() proto.Message {
sm := &Message{}
sm.Sum = &Message_SnapshotsRequest{SnapshotsRequest: m}
return sm
}
func (m *ChunkResponse) Wrap() proto.Message {
sm := &Message{}
sm.Sum = &Message_ChunkResponse{ChunkResponse: m}
return sm
}
func (m *ChunkRequest) Wrap() proto.Message {
sm := &Message{}
sm.Sum = &Message_ChunkRequest{ChunkRequest: m}
return sm
}
// Unwrap implements the p2p Wrapper interface and unwraps a wrapped state sync
// proto message.
func (m *Message) Unwrap() (proto.Message, error) {
switch msg := m.Sum.(type) {
case *Message_ChunkRequest:
return m.GetChunkRequest(), nil
case *Message_ChunkResponse:
return m.GetChunkResponse(), nil
case *Message_SnapshotsRequest:
return m.GetSnapshotsRequest(), nil
case *Message_SnapshotsResponse:
return m.GetSnapshotsResponse(), nil
default:
return nil, fmt.Errorf("unknown message: %T", msg)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
syntax = "proto3";
package tendermint.statesync;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/statesync";
message Message {
oneof sum {
SnapshotsRequest snapshots_request = 1;
SnapshotsResponse snapshots_response = 2;
ChunkRequest chunk_request = 3;
ChunkResponse chunk_response = 4;
}
}
message SnapshotsRequest {}
message SnapshotsResponse {
uint64 height = 1;
uint32 format = 2;
uint32 chunks = 3;
bytes hash = 4;
bytes metadata = 5;
}
message ChunkRequest {
uint64 height = 1;
uint32 format = 2;
uint32 index = 3;
}
message ChunkResponse {
uint64 height = 1;
uint32 format = 2;
uint32 index = 3;
bytes chunk = 4;
bool missing = 5;
}

View File

@ -0,0 +1,334 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/store/types.proto
package store
import (
fmt "fmt"
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.
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 BlockStoreState struct {
Base int64 `protobuf:"varint,1,opt,name=base,proto3" json:"base,omitempty"`
Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"`
}
func (m *BlockStoreState) Reset() { *m = BlockStoreState{} }
func (m *BlockStoreState) String() string { return proto.CompactTextString(m) }
func (*BlockStoreState) ProtoMessage() {}
func (*BlockStoreState) Descriptor() ([]byte, []int) {
return fileDescriptor_ff9e53a0a74267f7, []int{0}
}
func (m *BlockStoreState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *BlockStoreState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_BlockStoreState.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 *BlockStoreState) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockStoreState.Merge(m, src)
}
func (m *BlockStoreState) XXX_Size() int {
return m.Size()
}
func (m *BlockStoreState) XXX_DiscardUnknown() {
xxx_messageInfo_BlockStoreState.DiscardUnknown(m)
}
var xxx_messageInfo_BlockStoreState proto.InternalMessageInfo
func (m *BlockStoreState) GetBase() int64 {
if m != nil {
return m.Base
}
return 0
}
func (m *BlockStoreState) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
func init() {
proto.RegisterType((*BlockStoreState)(nil), "tendermint.store.BlockStoreState")
}
func init() { proto.RegisterFile("tendermint/store/types.proto", fileDescriptor_ff9e53a0a74267f7) }
var fileDescriptor_ff9e53a0a74267f7 = []byte{
// 165 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2f, 0xa9, 0x2c,
0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0xc8, 0xea, 0x81, 0x65, 0x95,
0x6c, 0xb9, 0xf8, 0x9d, 0x72, 0xf2, 0x93, 0xb3, 0x83, 0x41, 0xbc, 0xe0, 0x92, 0xc4, 0x92, 0x54,
0x21, 0x21, 0x2e, 0x96, 0xa4, 0xc4, 0xe2, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xe6, 0x20, 0x30,
0x5b, 0x48, 0x8c, 0x8b, 0x2d, 0x23, 0x35, 0x33, 0x3d, 0xa3, 0x44, 0x82, 0x09, 0x2c, 0x0a, 0xe5,
0x39, 0x05, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13,
0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x79, 0x7a, 0x66,
0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x92, 0x9b, 0x90, 0x98, 0x60, 0x27, 0xe9,
0xa3, 0xbb, 0x37, 0x89, 0x0d, 0x2c, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xef, 0xa6, 0x30,
0x63, 0xca, 0x00, 0x00, 0x00,
}
func (m *BlockStoreState) 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 *BlockStoreState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *BlockStoreState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Height != 0 {
i = encodeVarintTypes(dAtA, i, uint64(m.Height))
i--
dAtA[i] = 0x10
}
if m.Base != 0 {
i = encodeVarintTypes(dAtA, i, uint64(m.Base))
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 *BlockStoreState) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Base != 0 {
n += 1 + sovTypes(uint64(m.Base))
}
if m.Height != 0 {
n += 1 + sovTypes(uint64(m.Height))
}
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 *BlockStoreState) 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: BlockStoreState: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: BlockStoreState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType)
}
m.Base = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Base |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
m.Height = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Height |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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")
)

View File

@ -0,0 +1,9 @@
syntax = "proto3";
package tendermint.store;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/store";
message BlockStoreState {
int64 base = 1;
int64 height = 2;
}

View File

@ -0,0 +1,490 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/types/block.proto
package types
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.
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 EvidenceList `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"`
}
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_70840e82f4357ab1, []int{0}
}
func (m *Block) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Block.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 *Block) XXX_Merge(src proto.Message) {
xxx_messageInfo_Block.Merge(m, src)
}
func (m *Block) XXX_Size() int {
return m.Size()
}
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() EvidenceList {
if m != nil {
return m.Evidence
}
return EvidenceList{}
}
func (m *Block) GetLastCommit() *Commit {
if m != nil {
return m.LastCommit
}
return nil
}
func init() {
proto.RegisterType((*Block)(nil), "tendermint.types.Block")
}
func init() { proto.RegisterFile("tendermint/types/block.proto", fileDescriptor_70840e82f4357ab1) }
var fileDescriptor_70840e82f4357ab1 = []byte{
// 266 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xca, 0xc9,
0x4f, 0xce, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0xc8, 0xea, 0x81, 0x65, 0xa5,
0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0x14, 0xa6, 0x29, 0x60,
0x12, 0x2a, 0x2b, 0x8f, 0x21, 0x9b, 0x5a, 0x96, 0x99, 0x92, 0x9a, 0x97, 0x9c, 0x0a, 0x51, 0xa0,
0xf4, 0x8e, 0x91, 0x8b, 0xd5, 0x09, 0x64, 0xad, 0x90, 0x19, 0x17, 0x5b, 0x46, 0x6a, 0x62, 0x4a,
0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x84, 0x1e, 0xba, 0x0b, 0xf4, 0x3c, 0xc0,
0xf2, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x55, 0x0b, 0x19, 0x70, 0xb1, 0xa4, 0x24,
0x96, 0x24, 0x4a, 0x30, 0x81, 0x75, 0x89, 0x61, 0xea, 0x72, 0x49, 0x2c, 0x49, 0x84, 0xea, 0x01,
0xab, 0x14, 0x72, 0xe0, 0xe2, 0x80, 0xb9, 0x42, 0x82, 0x19, 0xac, 0x4b, 0x0e, 0x53, 0x97, 0x2b,
0x54, 0x85, 0x4f, 0x66, 0x71, 0x09, 0x54, 0x37, 0x5c, 0x97, 0x90, 0x25, 0x17, 0x77, 0x4e, 0x62,
0x71, 0x49, 0x7c, 0x72, 0x7e, 0x6e, 0x6e, 0x66, 0x89, 0x04, 0x0b, 0x2e, 0x07, 0x3b, 0x83, 0xe5,
0x83, 0xb8, 0x40, 0x8a, 0x21, 0x6c, 0xa7, 0xc0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63,
0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96,
0x63, 0x88, 0x32, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x0e,
0x36, 0x04, 0x13, 0x12, 0xf8, 0xe8, 0x41, 0x9a, 0xc4, 0x06, 0x16, 0x37, 0x06, 0x04, 0x00, 0x00,
0xff, 0xff, 0x79, 0x8c, 0xb5, 0x43, 0xd1, 0x01, 0x00, 0x00,
}
func (m *Block) 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 *Block) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.LastCommit != nil {
{
size, err := m.LastCommit.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintBlock(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
{
size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintBlock(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
{
size, err := m.Data.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintBlock(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
{
size, err := m.Header.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintBlock(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func encodeVarintBlock(dAtA []byte, offset int, v uint64) int {
offset -= sovBlock(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *Block) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = m.Header.Size()
n += 1 + l + sovBlock(uint64(l))
l = m.Data.Size()
n += 1 + l + sovBlock(uint64(l))
l = m.Evidence.Size()
n += 1 + l + sovBlock(uint64(l))
if m.LastCommit != nil {
l = m.LastCommit.Size()
n += 1 + l + sovBlock(uint64(l))
}
return n
}
func sovBlock(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozBlock(x uint64) (n int) {
return sovBlock(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Block) 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 ErrIntOverflowBlock
}
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: Block: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Block: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowBlock
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthBlock
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthBlock
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowBlock
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthBlock
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthBlock
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowBlock
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthBlock
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthBlock
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LastCommit", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowBlock
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthBlock
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthBlock
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.LastCommit == nil {
m.LastCommit = &Commit{}
}
if err := m.LastCommit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipBlock(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthBlock
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipBlock(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, ErrIntOverflowBlock
}
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, ErrIntOverflowBlock
}
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, ErrIntOverflowBlock
}
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, ErrInvalidLengthBlock
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupBlock
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthBlock
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthBlock = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowBlock = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupBlock = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -0,0 +1,15 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "tendermint/types/types.proto";
import "tendermint/types/evidence.proto";
message Block {
Header header = 1 [(gogoproto.nullable) = false];
Data data = 2 [(gogoproto.nullable) = false];
tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false];
Commit last_commit = 4;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "tendermint/types/types.proto";
import "google/protobuf/timestamp.proto";
message CanonicalBlockID {
bytes hash = 1;
CanonicalPartSetHeader part_set_header = 2 [(gogoproto.nullable) = false];
}
message CanonicalPartSetHeader {
uint32 total = 1;
bytes hash = 2;
}
message CanonicalProposal {
SignedMsgType type = 1; // type alias for byte
sfixed64 height = 2; // canonicalization requires fixed size encoding here
sfixed64 round = 3; // canonicalization requires fixed size encoding here
int64 pol_round = 4 [(gogoproto.customname) = "POLRound"];
CanonicalBlockID block_id = 5 [(gogoproto.customname) = "BlockID"];
google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 7 [(gogoproto.customname) = "ChainID"];
}
message CanonicalVote {
SignedMsgType type = 1; // type alias for byte
sfixed64 height = 2; // canonicalization requires fixed size encoding here
sfixed64 round = 3; // canonicalization requires fixed size encoding here
CanonicalBlockID block_id = 4 [(gogoproto.customname) = "BlockID"];
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 6 [(gogoproto.customname) = "ChainID"];
}

View File

@ -0,0 +1,386 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/types/events.proto
package types
import (
fmt "fmt"
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.
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 EventDataRoundState struct {
Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"`
Step string `protobuf:"bytes,3,opt,name=step,proto3" json:"step,omitempty"`
}
func (m *EventDataRoundState) Reset() { *m = EventDataRoundState{} }
func (m *EventDataRoundState) String() string { return proto.CompactTextString(m) }
func (*EventDataRoundState) ProtoMessage() {}
func (*EventDataRoundState) Descriptor() ([]byte, []int) {
return fileDescriptor_72cfafd446dedf7c, []int{0}
}
func (m *EventDataRoundState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *EventDataRoundState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_EventDataRoundState.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 *EventDataRoundState) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventDataRoundState.Merge(m, src)
}
func (m *EventDataRoundState) XXX_Size() int {
return m.Size()
}
func (m *EventDataRoundState) XXX_DiscardUnknown() {
xxx_messageInfo_EventDataRoundState.DiscardUnknown(m)
}
var xxx_messageInfo_EventDataRoundState proto.InternalMessageInfo
func (m *EventDataRoundState) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
func (m *EventDataRoundState) GetRound() int32 {
if m != nil {
return m.Round
}
return 0
}
func (m *EventDataRoundState) GetStep() string {
if m != nil {
return m.Step
}
return ""
}
func init() {
proto.RegisterType((*EventDataRoundState)(nil), "tendermint.types.EventDataRoundState")
}
func init() { proto.RegisterFile("tendermint/types/events.proto", fileDescriptor_72cfafd446dedf7c) }
var fileDescriptor_72cfafd446dedf7c = []byte{
// 189 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x2d, 0x4b,
0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x40, 0x48, 0xeb, 0x81, 0xa5,
0x95, 0xc2, 0xb9, 0x84, 0x5d, 0x41, 0x2a, 0x5c, 0x12, 0x4b, 0x12, 0x83, 0xf2, 0x4b, 0xf3, 0x52,
0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xc4, 0xb8, 0xd8, 0x32, 0x52, 0x33, 0xd3, 0x33, 0x4a, 0x24,
0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0xa0, 0x3c, 0x21, 0x11, 0x2e, 0xd6, 0x22, 0x90, 0x2a, 0x09,
0x26, 0x05, 0x46, 0x0d, 0xd6, 0x20, 0x08, 0x47, 0x48, 0x88, 0x8b, 0xa5, 0xb8, 0x24, 0xb5, 0x40,
0x82, 0x59, 0x81, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x76, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2,
0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1,
0xc6, 0x63, 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c,
0x7d, 0x64, 0xe7, 0x22, 0x98, 0x60, 0xc7, 0xea, 0xa3, 0x7b, 0x25, 0x89, 0x0d, 0x2c, 0x6e, 0x0c,
0x08, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xe9, 0x14, 0x02, 0xe5, 0x00, 0x00, 0x00,
}
func (m *EventDataRoundState) 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 *EventDataRoundState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *EventDataRoundState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Step) > 0 {
i -= len(m.Step)
copy(dAtA[i:], m.Step)
i = encodeVarintEvents(dAtA, i, uint64(len(m.Step)))
i--
dAtA[i] = 0x1a
}
if m.Round != 0 {
i = encodeVarintEvents(dAtA, i, uint64(m.Round))
i--
dAtA[i] = 0x10
}
if m.Height != 0 {
i = encodeVarintEvents(dAtA, i, uint64(m.Height))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func encodeVarintEvents(dAtA []byte, offset int, v uint64) int {
offset -= sovEvents(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *EventDataRoundState) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Height != 0 {
n += 1 + sovEvents(uint64(m.Height))
}
if m.Round != 0 {
n += 1 + sovEvents(uint64(m.Round))
}
l = len(m.Step)
if l > 0 {
n += 1 + l + sovEvents(uint64(l))
}
return n
}
func sovEvents(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozEvents(x uint64) (n int) {
return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *EventDataRoundState) 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 ErrIntOverflowEvents
}
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: EventDataRoundState: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: EventDataRoundState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
m.Height = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Height |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType)
}
m.Round = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Round |= int32(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Step", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvents
}
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 ErrInvalidLengthEvents
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthEvents
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Step = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvents(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthEvents
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipEvents(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, ErrIntOverflowEvents
}
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, ErrIntOverflowEvents
}
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, ErrIntOverflowEvents
}
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, ErrInvalidLengthEvents
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupEvents
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthEvents
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -0,0 +1,10 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
message EventDataRoundState {
int64 height = 1;
int32 round = 2;
string step = 3;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "tendermint/types/types.proto";
import "tendermint/types/validator.proto";
message Evidence {
oneof sum {
DuplicateVoteEvidence duplicate_vote_evidence = 1;
LightClientAttackEvidence light_client_attack_evidence = 2;
}
}
// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes.
message DuplicateVoteEvidence {
tendermint.types.Vote vote_a = 1;
tendermint.types.Vote vote_b = 2;
int64 total_voting_power = 3;
int64 validator_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client.
message LightClientAttackEvidence {
tendermint.types.LightBlock conflicting_block = 1;
int64 common_height = 2;
repeated tendermint.types.Validator byzantine_validators = 3;
int64 total_voting_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
message EvidenceList {
repeated Evidence evidence = 1 [(gogoproto.nullable) = false];
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
option (gogoproto.equal_all) = true;
// 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];
VersionParams version = 4 [(gogoproto.nullable) = false];
}
// BlockParams contains limits on the block size.
message BlockParams {
// Max block size, in bytes.
// Note: must be greater than 0
int64 max_bytes = 1;
// Max gas per block.
// Note: must be greater or equal to -1
int64 max_gas = 2;
// Minimum time increment between consecutive blocks (in milliseconds) If the
// block header timestamp is ahead of the system clock, decrease this value.
//
// Not exposed to the application.
int64 time_iota_ms = 3;
}
// EvidenceParams determine how we handle evidence of malfeasance.
message EvidenceParams {
// Max age of evidence, in blocks.
//
// The basic formula for calculating this is: MaxAgeDuration / {average block
// time}.
int64 max_age_num_blocks = 1;
// Max age of evidence, in time.
//
// It should correspond with an app's "unbonding period" or other similar
// mechanism for handling [Nothing-At-Stake
// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed).
google.protobuf.Duration max_age_duration = 2
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
// This sets the maximum size of total evidence in bytes that can be committed in a single block.
// and should fall comfortably under the max block bytes.
// Default is 1048576 or 1MB
int64 max_bytes = 3;
}
// 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;
}
// VersionParams contains the ABCI application version.
message VersionParams {
option (gogoproto.populate) = true;
option (gogoproto.equal) = true;
uint64 app_version = 1;
}
// HashedParams is a subset of ConsensusParams.
//
// It is 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

View File

@ -0,0 +1,157 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "tendermint/crypto/proof.proto";
import "tendermint/version/types.proto";
import "tendermint/types/validator.proto";
// BlockIdFlag indicates which BlcokID the signature is for
enum BlockIDFlag {
option (gogoproto.goproto_enum_stringer) = true;
option (gogoproto.goproto_enum_prefix) = false;
BLOCK_ID_FLAG_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "BlockIDFlagUnknown"];
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) = true;
option (gogoproto.goproto_enum_prefix) = false;
SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"];
// Votes
SIGNED_MSG_TYPE_PREVOTE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"];
SIGNED_MSG_TYPE_PRECOMMIT = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"];
// Proposals
SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"];
}
// PartsetHeader
message PartSetHeader {
uint32 total = 1;
bytes hash = 2;
}
message Part {
uint32 index = 1;
bytes bytes = 2;
tendermint.crypto.Proof proof = 3 [(gogoproto.nullable) = false];
}
// BlockID
message BlockID {
bytes hash = 1;
PartSetHeader part_set_header = 2 [(gogoproto.nullable) = false];
}
// --------------------------------
// Header defines the structure of a Tendermint block header.
message Header {
// basic block info
tendermint.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];
// 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;
}
// 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;
int32 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];
}
// 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;
}
message LightBlock {
SignedHeader signed_header = 1;
tendermint.types.ValidatorSet validator_set = 2;
}
message BlockMeta {
BlockID block_id = 1 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false];
int64 block_size = 2;
Header header = 3 [(gogoproto.nullable) = false];
int64 num_txs = 4;
}
// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
message TxProof {
bytes root_hash = 1;
bytes data = 2;
tendermint.crypto.Proof proof = 3;
}

View File

@ -0,0 +1,944 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/types/validator.proto
package types
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
io "io"
math "math"
math_bits "math/bits"
)
// 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"`
}
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_4e92274df03d3088, []int{0}
}
func (m *ValidatorSet) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ValidatorSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ValidatorSet.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 *ValidatorSet) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValidatorSet.Merge(m, src)
}
func (m *ValidatorSet) XXX_Size() int {
return m.Size()
}
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 crypto.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"`
}
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_4e92274df03d3088, []int{1}
}
func (m *Validator) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Validator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Validator.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 *Validator) XXX_Merge(src proto.Message) {
xxx_messageInfo_Validator.Merge(m, src)
}
func (m *Validator) XXX_Size() int {
return m.Size()
}
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() crypto.PublicKey {
if m != nil {
return m.PubKey
}
return crypto.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
}
type SimpleValidator struct {
PubKey *crypto.PublicKey `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`
VotingPower int64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"`
}
func (m *SimpleValidator) Reset() { *m = SimpleValidator{} }
func (m *SimpleValidator) String() string { return proto.CompactTextString(m) }
func (*SimpleValidator) ProtoMessage() {}
func (*SimpleValidator) Descriptor() ([]byte, []int) {
return fileDescriptor_4e92274df03d3088, []int{2}
}
func (m *SimpleValidator) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SimpleValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SimpleValidator.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 *SimpleValidator) XXX_Merge(src proto.Message) {
xxx_messageInfo_SimpleValidator.Merge(m, src)
}
func (m *SimpleValidator) XXX_Size() int {
return m.Size()
}
func (m *SimpleValidator) XXX_DiscardUnknown() {
xxx_messageInfo_SimpleValidator.DiscardUnknown(m)
}
var xxx_messageInfo_SimpleValidator proto.InternalMessageInfo
func (m *SimpleValidator) GetPubKey() *crypto.PublicKey {
if m != nil {
return m.PubKey
}
return nil
}
func (m *SimpleValidator) GetVotingPower() int64 {
if m != nil {
return m.VotingPower
}
return 0
}
func init() {
proto.RegisterType((*ValidatorSet)(nil), "tendermint.types.ValidatorSet")
proto.RegisterType((*Validator)(nil), "tendermint.types.Validator")
proto.RegisterType((*SimpleValidator)(nil), "tendermint.types.SimpleValidator")
}
func init() { proto.RegisterFile("tendermint/types/validator.proto", fileDescriptor_4e92274df03d3088) }
var fileDescriptor_4e92274df03d3088 = []byte{
// 361 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0x4e, 0xc2, 0x40,
0x10, 0xc6, 0xbb, 0x40, 0x40, 0x17, 0x12, 0x71, 0xe3, 0xa1, 0x41, 0x52, 0x2b, 0x27, 0x12, 0x4d,
0x9b, 0x68, 0x0c, 0x07, 0x6e, 0x5c, 0xb9, 0x60, 0x49, 0x38, 0x78, 0x69, 0x5a, 0xba, 0xa9, 0x1b,
0x0a, 0xbb, 0xd9, 0x6e, 0x31, 0xfb, 0x16, 0x3e, 0x8b, 0x4f, 0xc1, 0x91, 0xa3, 0x27, 0x63, 0xe0,
0x45, 0x4c, 0x5b, 0xfa, 0x27, 0xa8, 0xe1, 0x36, 0x9d, 0xef, 0x9b, 0x99, 0x5f, 0x37, 0x1f, 0xd4,
0x05, 0x5e, 0x79, 0x98, 0x2f, 0xc9, 0x4a, 0x98, 0x42, 0x32, 0x1c, 0x9a, 0x6b, 0x27, 0x20, 0x9e,
0x23, 0x28, 0x37, 0x18, 0xa7, 0x82, 0xa2, 0x76, 0xe1, 0x30, 0x12, 0x47, 0xe7, 0xca, 0xa7, 0x3e,
0x4d, 0x44, 0x33, 0xae, 0x52, 0x5f, 0xa7, 0x5b, 0xda, 0x34, 0xe7, 0x92, 0x09, 0x6a, 0x2e, 0xb0,
0x0c, 0x53, 0xb5, 0xf7, 0x01, 0x60, 0x6b, 0x96, 0x6d, 0x9e, 0x62, 0x81, 0x86, 0x10, 0xe6, 0x97,
0x42, 0x15, 0xe8, 0xd5, 0x7e, 0xf3, 0xe1, 0xda, 0x38, 0xbe, 0x65, 0xe4, 0x33, 0x56, 0xc9, 0x8e,
0x06, 0xf0, 0x8c, 0x71, 0xca, 0x68, 0x88, 0xb9, 0x5a, 0xd1, 0xc1, 0xa9, 0xd1, 0xdc, 0x8c, 0xee,
0x21, 0x12, 0x54, 0x38, 0x81, 0xbd, 0xa6, 0x82, 0xac, 0x7c, 0x9b, 0xd1, 0x37, 0xcc, 0xd5, 0xaa,
0x0e, 0xfa, 0x55, 0xab, 0x9d, 0x28, 0xb3, 0x44, 0x98, 0xc4, 0xfd, 0x18, 0xfa, 0x3c, 0xdf, 0x82,
0x54, 0xd8, 0x70, 0x3c, 0x8f, 0xe3, 0x30, 0xc6, 0x05, 0xfd, 0x96, 0x95, 0x7d, 0xa2, 0x21, 0x6c,
0xb0, 0xc8, 0xb5, 0x17, 0x58, 0x1e, 0x68, 0xba, 0x65, 0x9a, 0xf4, 0x31, 0x8c, 0x49, 0xe4, 0x06,
0x64, 0x3e, 0xc6, 0x72, 0x54, 0xdb, 0x7c, 0xdd, 0x28, 0x56, 0x9d, 0x45, 0xee, 0x18, 0x4b, 0x74,
0x0b, 0x5b, 0x7f, 0xc0, 0x34, 0xd7, 0x05, 0x07, 0xba, 0x83, 0x97, 0xd9, 0x1f, 0xd8, 0x8c, 0x13,
0xca, 0x89, 0x90, 0x6a, 0x2d, 0x85, 0xce, 0x84, 0xc9, 0xa1, 0xdf, 0x5b, 0xc0, 0x8b, 0x29, 0x59,
0xb2, 0x00, 0x17, 0xe4, 0x4f, 0x05, 0x1f, 0x38, 0xcd, 0xf7, 0x2f, 0x59, 0xe5, 0x17, 0xd9, 0xe8,
0x79, 0xb3, 0xd3, 0xc0, 0x76, 0xa7, 0x81, 0xef, 0x9d, 0x06, 0xde, 0xf7, 0x9a, 0xb2, 0xdd, 0x6b,
0xca, 0xe7, 0x5e, 0x53, 0x5e, 0x06, 0x3e, 0x11, 0xaf, 0x91, 0x6b, 0xcc, 0xe9, 0xd2, 0x2c, 0x67,
0xac, 0x28, 0xd3, 0x04, 0x1d, 0xe7, 0xcf, 0xad, 0x27, 0xfd, 0xc7, 0x9f, 0x00, 0x00, 0x00, 0xff,
0xff, 0x48, 0xbf, 0x34, 0x35, 0x9a, 0x02, 0x00, 0x00,
}
func (m *ValidatorSet) 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 *ValidatorSet) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *ValidatorSet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.TotalVotingPower != 0 {
i = encodeVarintValidator(dAtA, i, uint64(m.TotalVotingPower))
i--
dAtA[i] = 0x18
}
if m.Proposer != nil {
{
size, err := m.Proposer.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintValidator(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if len(m.Validators) > 0 {
for iNdEx := len(m.Validators) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Validators[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintValidator(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func (m *Validator) 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 *Validator) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.ProposerPriority != 0 {
i = encodeVarintValidator(dAtA, i, uint64(m.ProposerPriority))
i--
dAtA[i] = 0x20
}
if m.VotingPower != 0 {
i = encodeVarintValidator(dAtA, i, uint64(m.VotingPower))
i--
dAtA[i] = 0x18
}
{
size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintValidator(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if len(m.Address) > 0 {
i -= len(m.Address)
copy(dAtA[i:], m.Address)
i = encodeVarintValidator(dAtA, i, uint64(len(m.Address)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *SimpleValidator) 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 *SimpleValidator) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *SimpleValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.VotingPower != 0 {
i = encodeVarintValidator(dAtA, i, uint64(m.VotingPower))
i--
dAtA[i] = 0x10
}
if m.PubKey != nil {
{
size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintValidator(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintValidator(dAtA []byte, offset int, v uint64) int {
offset -= sovValidator(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *ValidatorSet) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Validators) > 0 {
for _, e := range m.Validators {
l = e.Size()
n += 1 + l + sovValidator(uint64(l))
}
}
if m.Proposer != nil {
l = m.Proposer.Size()
n += 1 + l + sovValidator(uint64(l))
}
if m.TotalVotingPower != 0 {
n += 1 + sovValidator(uint64(m.TotalVotingPower))
}
return n
}
func (m *Validator) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Address)
if l > 0 {
n += 1 + l + sovValidator(uint64(l))
}
l = m.PubKey.Size()
n += 1 + l + sovValidator(uint64(l))
if m.VotingPower != 0 {
n += 1 + sovValidator(uint64(m.VotingPower))
}
if m.ProposerPriority != 0 {
n += 1 + sovValidator(uint64(m.ProposerPriority))
}
return n
}
func (m *SimpleValidator) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.PubKey != nil {
l = m.PubKey.Size()
n += 1 + l + sovValidator(uint64(l))
}
if m.VotingPower != 0 {
n += 1 + sovValidator(uint64(m.VotingPower))
}
return n
}
func sovValidator(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozValidator(x uint64) (n int) {
return sovValidator(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *ValidatorSet) 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 ErrIntOverflowValidator
}
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: ValidatorSet: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ValidatorSet: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthValidator
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthValidator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Validators = append(m.Validators, &Validator{})
if err := m.Validators[len(m.Validators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthValidator
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthValidator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Proposer == nil {
m.Proposer = &Validator{}
}
if err := m.Proposer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType)
}
m.TotalVotingPower = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.TotalVotingPower |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipValidator(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthValidator
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Validator) 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 ErrIntOverflowValidator
}
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: Validator: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Validator: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthValidator
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthValidator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...)
if m.Address == nil {
m.Address = []byte{}
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthValidator
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthValidator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType)
}
m.VotingPower = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.VotingPower |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ProposerPriority", wireType)
}
m.ProposerPriority = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ProposerPriority |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipValidator(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthValidator
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SimpleValidator) 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 ErrIntOverflowValidator
}
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: SimpleValidator: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SimpleValidator: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthValidator
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthValidator
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.PubKey == nil {
m.PubKey = &crypto.PublicKey{}
}
if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType)
}
m.VotingPower = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowValidator
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.VotingPower |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipValidator(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthValidator
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipValidator(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, ErrIntOverflowValidator
}
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, ErrIntOverflowValidator
}
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, ErrIntOverflowValidator
}
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, ErrInvalidLengthValidator
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupValidator
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthValidator
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthValidator = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowValidator = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupValidator = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -0,0 +1,25 @@
syntax = "proto3";
package tendermint.types;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "tendermint/crypto/keys.proto";
message ValidatorSet {
repeated Validator validators = 1;
Validator proposer = 2;
int64 total_voting_power = 3;
}
message Validator {
bytes address = 1;
tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false];
int64 voting_power = 3;
int64 proposer_priority = 4;
}
message SimpleValidator {
tendermint.crypto.PublicKey pub_key = 1;
int64 voting_power = 2;
}

View File

@ -0,0 +1,576 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/version/types.proto
package version
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.
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"`
}
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_f9b42966edc5edad, []int{0}
}
func (m *App) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *App) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
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 m.Size()
}
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"`
}
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_f9b42966edc5edad, []int{1}
}
func (m *Consensus) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Consensus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
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 m.Size()
}
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.version.App")
proto.RegisterType((*Consensus)(nil), "tendermint.version.Consensus")
}
func init() { proto.RegisterFile("tendermint/version/types.proto", fileDescriptor_f9b42966edc5edad) }
var fileDescriptor_f9b42966edc5edad = []byte{
// 218 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0xcd, 0x4b,
0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0x2a, 0xce, 0xcc, 0xcf, 0xd3, 0x2f,
0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x42, 0xc8, 0xeb, 0x41,
0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xd2, 0xfa, 0x20, 0x16, 0x44, 0xa5, 0x92, 0x2d,
0x17, 0xb3, 0x63, 0x41, 0x81, 0x90, 0x14, 0x17, 0x07, 0x98, 0x9f, 0x9c, 0x9f, 0x23, 0xc1, 0xa8,
0xc0, 0xa8, 0xc1, 0x12, 0x04, 0xe7, 0x83, 0xe4, 0x8a, 0xf3, 0xd3, 0x4a, 0xca, 0x13, 0x8b, 0x52,
0x25, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, 0xe0, 0x7c, 0x25, 0x4b, 0x2e, 0x4e, 0xe7, 0xfc, 0xbc,
0xe2, 0xd4, 0xbc, 0xe2, 0xd2, 0x62, 0x21, 0x11, 0x2e, 0xd6, 0xa4, 0x9c, 0xfc, 0xe4, 0x6c, 0xa8,
0x09, 0x10, 0x8e, 0x90, 0x00, 0x17, 0x73, 0x62, 0x41, 0x01, 0x58, 0x27, 0x4b, 0x10, 0x88, 0x69,
0xc5, 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xf0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31,
0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb,
0x31, 0x44, 0x59, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x79,
0x14, 0x89, 0x09, 0xf1, 0x06, 0x66, 0x20, 0x24, 0xb1, 0x81, 0x65, 0x8c, 0x01, 0x01, 0x00, 0x00,
0xff, 0xff, 0x42, 0x43, 0x65, 0xc7, 0x21, 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
}
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 len(m.Software) > 0 {
i -= len(m.Software)
copy(dAtA[i:], m.Software)
i = encodeVarintTypes(dAtA, i, uint64(len(m.Software)))
i--
dAtA[i] = 0x12
}
if m.Protocol != 0 {
i = encodeVarintTypes(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.App != 0 {
i = encodeVarintTypes(dAtA, i, uint64(m.App))
i--
dAtA[i] = 0x10
}
if m.Block != 0 {
i = encodeVarintTypes(dAtA, i, uint64(m.Block))
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 *App) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Protocol != 0 {
n += 1 + sovTypes(uint64(m.Protocol))
}
l = len(m.Software)
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
return n
}
func (m *Consensus) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Block != 0 {
n += 1 + sovTypes(uint64(m.Block))
}
if m.App != 0 {
n += 1 + sovTypes(uint64(m.App))
}
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 *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 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: 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 ErrIntOverflowTypes
}
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 ErrIntOverflowTypes
}
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 ErrInvalidLengthTypes
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Software = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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 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: 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 ErrIntOverflowTypes
}
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 ErrIntOverflowTypes
}
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 := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
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")
)

View File

@ -0,0 +1,24 @@
syntax = "proto3";
package tendermint.version;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/version";
import "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.equal) = true;
uint64 block = 1;
uint64 app = 2;
}

92
src/main.rs Normal file
View File

@ -0,0 +1,92 @@
use std::{
net::{AddrParseError, SocketAddr, TcpStream},
time::Duration,
};
use anyhow::Context;
use clap::Parser;
use ed25519_dalek::SecretKey;
use hex::FromHexError;
use tracing_subscriber::{
prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer,
};
use crate::tendermint_proto::p2p::conn::ProtocolVersion;
use crate::{peer::Peer, secrect_connection::SecretConnection};
mod peer;
pub mod secrect_connection;
mod tendermint_proto;
#[derive(Debug, clap::Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// P2P port of tendermint node in format IP:PORT
#[arg(long)]
node: String,
/// 32 hex bytes
#[arg(long)]
private_key: String,
#[arg(long)]
network: String,
}
impl Cli {
fn node_id_and_addr(&self) -> Result<(Option<String>, SocketAddr), AddrParseError> {
if let Some((id, addr_str)) = self.node.split_once('@') {
addr_str.parse().map(|addr| (Some(String::from(id)), addr))
} else {
self.node.parse().map(|addr| (None, addr))
}
}
fn private_key(&self) -> Result<SecretKey, FromHexError> {
let priv_key_hex_str = self.private_key.trim().trim_start_matches("0x");
let mut priv_key: [u8; 32] = [0u8; 32];
hex::decode_to_slice(priv_key_hex_str, &mut priv_key).map(|_| priv_key)
}
}
fn tracing_subscriber_init() {
let fmt_layer = tracing_subscriber::fmt::layer().with_filter(EnvFilter::from_default_env());
tracing_subscriber::registry()
.with(fmt_layer)
.try_init()
.map(drop)
.unwrap();
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
tracing_subscriber_init();
let (opt_remote_id, remote_node_addr) =
cli.node_id_and_addr().context("parsing P2P node addr")?;
let secret = cli.private_key().context("parsing private key")?;
let tcp = TcpStream::connect_timeout(&remote_node_addr, Duration::from_secs(3))
.context(format!("connecting P2P node {remote_node_addr:?}"))?;
let sc = match opt_remote_id {
Some(remote_id) => SecretConnection::try_connect_with_id(tcp, secret, &remote_id).await,
None => SecretConnection::try_connect(tcp, secret).await,
}
.context("failed to establish secret connection (handshake)")?;
let peer = Peer::handshake(sc, cli.network, load_protocol_version()).await?;
peer.peer_comm_worker().await?;
Ok(())
}
fn load_protocol_version() -> ProtocolVersion {
ProtocolVersion {
p2p: 88,
block: 11,
app: 1,
}
}

96
src/peer.rs Normal file
View File

@ -0,0 +1,96 @@
use futures::TryStreamExt;
use crate::{
secrect_connection::{error::ExchangeFrameErr, SecretConnection},
tendermint_proto::p2p::conn::{DefaultNodeInfo, ProtocolVersion},
};
pub struct Peer {
sc: SecretConnection,
_loc_node_info: DefaultNodeInfo,
_rem_node_info: DefaultNodeInfo,
}
impl Peer {
// TODO here could exist try_conn function that hide secret connection details
/// Execute peer handshake
pub async fn handshake(
mut sc: SecretConnection,
network: String,
protocol_version: ProtocolVersion,
) -> Result<Self, PeerHandshakeErr> {
let loc_node_info = DefaultNodeInfo {
protocol_version: Some(protocol_version),
network,
default_node_id: sc.local_id(),
channels: [64, 32, 33, 34, 35, 48, 56, 96, 97, 0].to_vec(),
listen_addr: "tcp://0.0.0.0:26656".to_string(),
moniker: "427B4DEF0ED2D9E3".to_string(),
version: "0.0.1-alpha.1".to_string(),
..Default::default()
};
tracing::trace!("local node info: {loc_node_info:?}");
let rem_node_info = sc.node_info_exchange(&loc_node_info).await?;
tracing::debug!("remote node info: {rem_node_info:?}");
verify_peer_handshake(&loc_node_info, &rem_node_info)?;
Ok(Self {
sc,
_loc_node_info: loc_node_info,
_rem_node_info: rem_node_info,
})
}
pub async fn peer_comm_worker(self) -> Result<(), ExchangeFrameErr> {
let (mut reader, _writer) = self.sc.into_inner_split();
while let Some(protobuf_item) = reader.try_next().await? {
// TODO: probably register channel for every byteID so this could be sent to Reactor
// something like `notify_on(byteId) -> Receiver<Msg>`
tracing::debug!(
"received raw protobuf frame (ping, pong, channelMsg): {protobuf_item:?}"
);
}
Ok(())
}
}
#[derive(Debug, thiserror::Error)]
pub enum PeerHandshakeErr {
#[error("transport error (exchange frame)")]
ExchangeFrameErr(#[from] ExchangeFrameErr),
#[error("Peers incompatibility")]
NodeVersionErr(#[from] NodeVersionErr),
}
#[derive(Debug, thiserror::Error)]
pub enum NodeVersionErr {
// #[error("Node version is incompatible")]
// TODO: IncorectId,
#[error("BlockVersion does not match")]
BlockVersion,
#[error("Different peer's networks")]
WrongPeerNetwork,
// TODO: peer.Channels does not intersect with our known Channels.
// TODO: peer.NodeInfo.ListenAddr is malformed or is a DNS host that cannot be resolved
}
fn verify_peer_handshake(
loc_node_info: &DefaultNodeInfo,
rem_node_info: &DefaultNodeInfo,
) -> Result<(), NodeVersionErr> {
let loc_prot_ver = loc_node_info.protocol_version.as_ref().unwrap();
let rem_prot_ver = rem_node_info.protocol_version.as_ref().unwrap();
if loc_prot_ver.block != rem_prot_ver.block {
Err(NodeVersionErr::BlockVersion)
} else if loc_node_info.network != rem_node_info.network {
Err(NodeVersionErr::WrongPeerNetwork)
} else {
Ok(())
}
}

View File

@ -0,0 +1,28 @@
use ed25519_dalek::SignatureError;
#[derive(Debug, thiserror::Error)]
pub enum SecretConnectionError {
#[error("handshake error: {0}")]
HandshakeError(#[from] protobuf::Error),
#[error("failed to decode auth")]
AuthSigDecode(prost::DecodeError),
#[error("verify error")]
VerifySignature(#[from] SignatureError),
#[error("incorrect ID")]
IncorrectId,
}
impl From<std::io::Error> for SecretConnectionError {
fn from(value: std::io::Error) -> Self {
Self::HandshakeError(protobuf::Error::from(value))
}
}
#[derive(Debug, thiserror::Error)]
pub enum ExchangeFrameErr {
#[error("Transport error")]
TransportErr(#[from] std::io::Error),
#[error("Decode error")]
DecodeErr(#[from] prost::DecodeError),
}

View File

@ -0,0 +1,305 @@
use std::net::TcpStream as StdTcpStream;
use chacha20poly1305::{ChaCha20Poly1305, KeyInit};
use ed25519_dalek::{SecretKey, Signature, Signer, SigningKey, Verifier, VerifyingKey};
use futures::sink::SinkExt;
use merlin::Transcript;
use prost::Message;
use sha2::{Digest, Sha256};
use tokio::net::TcpStream;
use tokio_stream::StreamExt;
use tokio_util::codec::{FramedRead, FramedWrite};
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
use crate::{
secrect_connection::{
secret_codec::{SecretDecoder, SecretEncoder},
share_eph_pubkey::{derive_secrets, sort_pubkeys},
},
tendermint_proto::p2p::{
conn::{AuthSigMessage, DefaultNodeInfo},
crypto::{public_key::Sum, PublicKey as PublicKeyProto},
},
};
use self::error::{ExchangeFrameErr, SecretConnectionError};
pub(crate) mod error;
mod secret_codec;
mod share_eph_pubkey;
pub struct SecretConnection {
remote_pubkey: PublicKey,
local_pubkey: VerifyingKey,
// TODO: TcpStream can be replaced with AsyncRead/AsyncWrite easily
// after implement `TODO(make async)`
framed_reader: FramedRead<TcpStream, SecretDecoder>,
framed_writer: FramedWrite<TcpStream, SecretEncoder>,
}
impl SecretConnection {
// TODO(make async): this accept StdTcpStream because prost doesn't allow easily to ready from AsyncRead
// implementing simple crate like protobuf-length-delimited that would allow parse lenght variant
// would be enough here to replace `tcp` with general I/O AsyncRead and AsyncWrite traits
pub async fn try_connect(
tcp: StdTcpStream,
secret: SecretKey,
) -> Result<Self, SecretConnectionError> {
let loc_eph_secret = StaticSecret::random();
let loc_eph_pub = PublicKey::from(&loc_eph_secret);
let (reader, writer, rem_eph_pub) = share_eph_pubkey::share_eph_pubkey(
tcp.try_clone().unwrap(),
tcp.try_clone().unwrap(),
loc_eph_pub,
)
.await?;
tracing::trace!("public keys exchanged: local: {loc_eph_pub:?}, remote: {rem_eph_pub:?}");
let (sender_cipher, receiver_cipher, challenge) =
prepare_encrypted_comm(loc_eph_secret, rem_eph_pub);
//sign the common challenge obtained from the hkdf with our persistent private key
let signing_key = SigningKey::from_bytes(&secret);
let challenge_sig = signing_key
.try_sign(&challenge)
.expect("should be able to sign");
// update Tcp to be true async
let reader = TcpStream::from_std(reader).unwrap();
let writer = TcpStream::from_std(writer).unwrap();
let mut framed_reader = FramedRead::new(
reader,
SecretDecoder::new_with_zeroed_nonce(receiver_cipher),
);
let mut framed_writer =
FramedWrite::new(writer, SecretEncoder::new_with_zeroed_nonce(sender_cipher));
let local_pubkey = signing_key.verifying_key();
let loc_auth_sig = AuthSigMessage {
pub_key: Some(PublicKeyProto {
sum: Some(Sum::Ed25519(local_pubkey.to_bytes().to_vec())),
}),
sig: challenge_sig.to_vec(),
}
.encode_length_delimited_to_vec();
let (auth_sig_proto, _) =
tokio::try_join!(framed_reader.try_next(), framed_writer.send(loc_auth_sig))?;
let auth_sig = match auth_sig_proto {
Some(auth_sig) => auth_sig,
None => todo!("return error that connection was closed"),
};
let auth_sig = AuthSigMessage::decode_length_delimited(auth_sig)
.map_err(SecretConnectionError::AuthSigDecode)?;
// verify if secure connection succeeded
let rem_pubkey_proto = match auth_sig
.pub_key
.expect("todo: required?")
.sum
.expect("todo: required?")
{
Sum::Ed25519(pubkey) => {
let pubkey_array: [u8; 32] = pubkey.try_into().unwrap();
PublicKey::from(pubkey_array)
}
Sum::Secp256k1(_) => todo!("return err"),
};
let signature = Signature::from_slice(&auth_sig.sig).expect("throw error here");
VerifyingKey::from_bytes(&rem_pubkey_proto.to_bytes())
.expect("TODO return error")
.verify(&challenge, &signature)?;
// handshake done
Ok(Self {
remote_pubkey: rem_pubkey_proto,
local_pubkey,
framed_reader,
framed_writer,
})
}
pub async fn try_connect_with_id(
tcp: StdTcpStream,
secret: SecretKey,
id: &str,
) -> Result<Self, SecretConnectionError> {
let this = Self::try_connect(tcp, secret).await?;
if this.remote_id() != id {
//FIXME self.close();
tracing::error!("remote ID {} we requested {id}", this.remote_id());
return Err(SecretConnectionError::IncorrectId);
}
Ok(this)
}
pub fn into_inner_split(
self,
) -> (
FramedRead<TcpStream, SecretDecoder>,
FramedWrite<TcpStream, SecretEncoder>,
) {
(self.framed_reader, self.framed_writer)
}
}
impl SecretConnection {
fn remote_address(&self) -> PublicKey {
self.remote_pubkey
}
fn local_address(&self) -> VerifyingKey {
self.local_pubkey
}
pub fn remote_id(&self) -> String {
let id = Sha256::digest(self.remote_address().as_bytes());
let id_raw: &[u8] = id.as_ref();
hex::encode(&id_raw[..20]).to_string()
}
pub fn local_id(&self) -> String {
let id = Sha256::digest(self.local_address().as_bytes());
let id_raw: &[u8] = id.as_ref();
hex::encode(&id_raw[..20]).to_string()
}
pub async fn node_info_exchange(
&mut self,
loc_node_info: &DefaultNodeInfo,
) -> Result<DefaultNodeInfo, ExchangeFrameErr> {
let loc_node_info_proto = loc_node_info.encode_length_delimited_to_vec();
let send_loc_node_info_fut = self.framed_writer.send(loc_node_info_proto);
let get_rem_node_info_fut = self.framed_reader.try_next();
let (opt_rem_node_info_proto, _) =
tokio::try_join!(get_rem_node_info_fut, send_loc_node_info_fut)?;
match opt_rem_node_info_proto {
Some(rem_node_info_proto) => {
DefaultNodeInfo::decode_length_delimited(rem_node_info_proto)
.map_err(ExchangeFrameErr::DecodeErr)
}
None => todo!("TODO handle disconnect error"),
}
}
pub fn close(&self) {
todo!()
}
}
fn prepare_dh_secret(loc_eph_secret: StaticSecret, rem_eph_pub: PublicKey) -> SharedSecret {
loc_eph_secret.diffie_hellman(&rem_eph_pub)
}
/// (sender_cipher, receiver_cipher, challenge)
fn prepare_encrypted_comm(
loc_eph_secret: StaticSecret,
rem_eph_pub: PublicKey,
) -> (ChaCha20Poly1305, ChaCha20Poly1305, [u8; 32]) {
let loc_eph_pub = PublicKey::from(&loc_eph_secret);
//Sort the ephemeral keys
let (lo_eph_pub, hi_eph_pub) = sort_pubkeys(loc_eph_pub, rem_eph_pub);
// create a new Merlin Transcript with the string "TENDERMINT_SECRET_CONNECTION_TRANSCRIPT_HASH"
let mut ts = Transcript::new("TENDERMINT_SECRET_CONNECTION_TRANSCRIPT_HASH".as_ref());
//add low keys labeled "EPHEMERAL_LOWER_PUBLIC_KEY" to the Merlin transcript.
ts.append_message("EPHEMERAL_LOWER_PUBLIC_KEY".as_ref(), lo_eph_pub.as_ref());
//add the high labeled "EPHEMERAL_UPPER_PUBLIC_KEY" to the Merlin transcript.
ts.append_message("EPHEMERAL_UPPER_PUBLIC_KEY".as_ref(), hi_eph_pub.as_ref());
// compute the Diffie-Hellman shared secret using the peers ephemeral public key and our ephemeral private key
let dh_shared_secret = prepare_dh_secret(loc_eph_secret, rem_eph_pub);
//add the DH secret to the transcript labeled DH_SECRET.
ts.append_message("DH_SECRET".as_ref(), dh_shared_secret.as_ref());
/*
generate two keys to use for encryption (sending and receiving) and a challenge for authentication as follows:
- create a hkdf-sha256 instance with the key being the diffie hellman shared secret, and info parameter as TENDERMINT_SECRET_CONNECTION_KEY_AND_CHALLENGE_GEN
- get 64 bytes of output from hkdf-sha256
- if we had the smaller ephemeral pubkey, use the first 32 bytes for the key for receiving, the second 32 bytes for sending; else the opposite.
*/
let loc_is_least = loc_eph_pub == lo_eph_pub;
let (recv_secret, send_secret) = derive_secrets(dh_shared_secret, loc_is_least);
// use a separate nonce for receiving and sending. Both nonces start at 0, and should support the full 96 bit nonce range
let sender_cipher =
ChaCha20Poly1305::new_from_slice(send_secret.as_ref()).expect("correct send_secret size");
let receiver_cipher =
ChaCha20Poly1305::new_from_slice(recv_secret.as_ref()).expect("correct recv_secret size");
// extract a 32 bytes challenge from merlin transcript with the label "SECRET_CONNECTION_MAC"
let mut challenge = [0u8; 32];
ts.challenge_bytes("SECRET_CONNECTION_MAC".as_ref(), &mut challenge);
(sender_cipher, receiver_cipher, challenge)
}
#[cfg(test)]
mod test {
use super::*;
/*
node1 | >>> [392] EPH public: &[244 229 125 89 228 213 197 203 80 12 42 203 65 173 108 15 222 188 14 150 29 189 80 95 252 188 64 7 162 58 139 108]
node1 | EPH private &[159 223 216 177 207 164 33 3 91 173 83 67 212 132 201 29 62 223 36 210 102 41 42 140 227 243 57 118 160 238 117 197]
node1 | >>> [392] EPH remote: &[148 70 131 234 116 107 109 105 135 89 30 3 44 21 118 190 157 153 31 63 97 211 29 52 214 165 221 242 37 110 95 45]
node1 | >>> [392] DHSecret: &[127 199 10 228 174 151 48 90 246 151 38 81 101 225 167 84 205 135 67 142 240 135 0 19 36 184 73 33 246 5 196 78]
node1 | >>> [392] ChallengeSlice [131 34 59 169 142 9 149 108 59 136 2 5 17 136 250 170 210 64 197 172 88 240 237 176 37 248 122 136 92 184 73 205]
*/
fn get_test_eph_keys() -> (StaticSecret, PublicKey) {
let loc_eph_secret = StaticSecret::from([
159, 223, 216, 177, 207, 164, 33, 3, 91, 173, 83, 67, 212, 132, 201, 29, 62, 223, 36,
210, 102, 41, 42, 140, 227, 243, 57, 118, 160, 238, 117, 197,
]);
let rem_eph_pub = PublicKey::from([
148, 70, 131, 234, 116, 107, 109, 105, 135, 89, 30, 3, 44, 21, 118, 190, 157, 153, 31,
63, 97, 211, 29, 52, 214, 165, 221, 242, 37, 110, 95, 45,
]);
(loc_eph_secret, rem_eph_pub)
}
#[test]
fn dh_secret() {
let (loc_eph_secret, rem_eph_pub) = get_test_eph_keys();
let dh_secret = prepare_dh_secret(loc_eph_secret, rem_eph_pub);
assert_eq!(
dh_secret.to_bytes(),
[
127, 199, 10, 228, 174, 151, 48, 90, 246, 151, 38, 81, 101, 225, 167, 84, 205, 135,
67, 142, 240, 135, 0, 19, 36, 184, 73, 33, 246, 5, 196, 78
]
);
}
#[test]
fn generate_challenge() {
let (loc_eph_secret, rem_eph_pub) = get_test_eph_keys();
let (_sender_cipher, _receiver_cipher, challenge) =
prepare_encrypted_comm(loc_eph_secret, rem_eph_pub);
assert_eq!(
challenge,
[
131, 34, 59, 169, 142, 9, 149, 108, 59, 136, 2, 5, 17, 136, 250, 170, 210, 64, 197,
172, 88, 240, 237, 176, 37, 248, 122, 136, 92, 184, 73, 205
]
);
}
}

View File

@ -0,0 +1,179 @@
use chacha20poly1305::{
aead::{AeadInPlace, Nonce},
ChaCha20Poly1305,
};
use prost::bytes::{Bytes, BytesMut};
use tokio_util::codec::{Decoder, Encoder};
/// Hide encryption layer used by SecretConnection
const LEN_DATA_SIZE: usize = 4;
const MAX_DATA_SIZE: usize = 1024;
const FRAME_DATA_SIZE: usize = LEN_DATA_SIZE + MAX_DATA_SIZE;
const ENCODED_FRAME_DATA_SIZE: usize = FRAME_DATA_SIZE + 16;
fn increment_nonce(nonce: &mut Nonce<ChaCha20Poly1305>) {
let nonce = nonce.as_mut_slice();
let mut counter = u64::from_le_bytes(nonce[4..].try_into().unwrap());
counter += 1;
if counter == u64::MAX {
unimplemented!()
}
nonce[4..].copy_from_slice(&counter.to_le_bytes()[..]);
}
pub struct SecretDecoder {
receiver_cipher: ChaCha20Poly1305,
receiver_nonce: Nonce<ChaCha20Poly1305>,
// golang impl use this but I think it's a dead code
// look for "understand how X chunks build bigger frame"
// buffer: BytesMut
}
impl SecretDecoder {
pub fn new_with_zeroed_nonce(receiver_cipher: ChaCha20Poly1305) -> Self {
Self {
receiver_cipher,
receiver_nonce: Default::default(),
}
}
fn decode_one_frame(&mut self, src: &mut BytesMut) -> Option<(usize, Vec<u8>)> {
if src.len() < ENCODED_FRAME_DATA_SIZE {
return None;
}
let encoded_frame = src.split_to(ENCODED_FRAME_DATA_SIZE);
let mut encoded_frame = encoded_frame.to_vec();
// TODO implement ahead::Bytes for bytes::BufMut
self.receiver_cipher
.decrypt_in_place(&self.receiver_nonce, &[], &mut encoded_frame)
.expect("should decode");
increment_nonce(&mut self.receiver_nonce);
let len = u32::from_le_bytes(encoded_frame[..4].try_into().unwrap());
let len = usize::try_from(len).unwrap();
if len > MAX_DATA_SIZE {
todo!("return error")
}
Some((len, encoded_frame[4..].to_vec()))
}
}
impl Decoder for SecretDecoder {
type Item = Bytes;
type Error = std::io::Error;
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
let (len, mut chunk) = match self.decode_one_frame(src) {
Some((len, chunk)) => (len, chunk),
None => return Ok(None),
};
if len == MAX_DATA_SIZE {
todo!("// TODO understand how X chunks build bigger frame");
}
chunk.truncate(len);
Ok(Some(Bytes::from(chunk)))
}
}
pub struct SecretEncoder {
sender_cipher: ChaCha20Poly1305,
sender_nonce: Nonce<ChaCha20Poly1305>,
}
impl SecretEncoder {
pub fn new_with_zeroed_nonce(sender_cipher: ChaCha20Poly1305) -> Self {
Self {
sender_cipher,
sender_nonce: Default::default(),
}
}
}
impl<T> Encoder<T> for SecretEncoder
where
T: AsRef<[u8]>,
{
type Error = std::io::Error;
fn encode(&mut self, item: T, dst: &mut BytesMut) -> Result<(), Self::Error> {
let raw_bytes = item.as_ref();
dst.reserve(5 * MAX_DATA_SIZE);
// TODO: dst reserve capacity for all frames
raw_bytes
.chunks(MAX_DATA_SIZE)
.map(|chunk| {
let mut encoded_frame: Vec<u8> = Vec::with_capacity(ENCODED_FRAME_DATA_SIZE);
let data_len = u32::try_from(chunk.len()).unwrap();
encoded_frame.extend_from_slice(&data_len.to_le_bytes());
encoded_frame.extend_from_slice(chunk);
encoded_frame.resize(FRAME_DATA_SIZE, Default::default());
self.sender_cipher
.encrypt_in_place(&self.sender_nonce, b"", &mut encoded_frame)
.expect("this should always succeed");
increment_nonce(&mut self.sender_nonce);
// Defense programming
assert_eq!(encoded_frame.len(), ENCODED_FRAME_DATA_SIZE);
encoded_frame
})
.for_each(|encoded_fram| dst.extend_from_slice(&encoded_fram));
Ok(())
}
}
pub struct SecretCodec {
encoder: SecretEncoder,
decoder: SecretDecoder,
}
impl Decoder for SecretCodec {
type Item = Bytes;
type Error = std::io::Error;
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
self.decoder.decode(src)
}
}
impl<T> Encoder<T> for SecretCodec
where
T: AsRef<[u8]>,
{
type Error = std::io::Error;
fn encode(&mut self, item: T, dst: &mut BytesMut) -> Result<(), Self::Error> {
self.encoder.encode(item, dst)
}
}
#[cfg(test)]
mod test_super {
use chacha20poly1305::{
aead::AeadCore, aead::AeadInPlace, aead::OsRng, ChaCha20Poly1305, KeyInit,
};
use super::*;
#[test]
fn test_encrypt_size() {
let key = ChaCha20Poly1305::generate_key(&mut OsRng);
let cipher = ChaCha20Poly1305::new(&key);
let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); // 96-bits; unique per message
let mut buffer = vec![0; 1024 + 4];
cipher.encrypt_in_place(&nonce, b"", &mut buffer).unwrap();
println!("{}", buffer.len());
assert_eq!(FRAME_DATA_SIZE, buffer.len());
}
}

View File

@ -0,0 +1,122 @@
use std::{
io::{Read, Write},
mem::swap,
};
use hkdf::Hkdf;
use protobuf::{
well_known_types::wrappers::BytesValue, CodedInputStream, CodedOutputStream, Message,
};
use sha2::Sha256;
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
// Useful links:
// 1. https://github.com/tendermint/tendermint/tree/v0.34.x/spec/p2p
// 2. https://github.com/tendermint/tendermint/blob/v0.34.x/p2p/conn/secret_connection.go
/*********************************
* Share Ephemeral public key
*/
/// share own pubkey and get remote one
pub(crate) async fn share_eph_pubkey<R, W>(
reader: R,
writer: W,
loc_pubkey: PublicKey,
) -> Result<(R, W, PublicKey), protobuf::Error>
where
R: Read + Send + 'static,
W: Write + Send + 'static,
{
let read_task = tokio::task::spawn_blocking(move || get_eph_pubkey(reader));
let write_task = tokio::task::spawn_blocking(move || send_eph_pubkey(writer, loc_pubkey));
let (read_result, write_result) = tokio::try_join!(read_task, write_task).unwrap();
let writer = write_result?;
read_result.map(|(reader, rem_pubkey)| (reader, writer, rem_pubkey))
}
fn send_eph_pubkey<W: Write>(mut writer: W, loc_pubkey: PublicKey) -> Result<W, protobuf::Error> {
let mut out = CodedOutputStream::new(&mut writer);
let loc_pubkey_raw = loc_pubkey.to_bytes();
let loc_pubkey_proto = BytesValue {
value: loc_pubkey_raw.to_vec(),
..Default::default()
};
loc_pubkey_proto.write_length_delimited_to(&mut out)?;
drop(out);
Ok(writer)
}
fn get_eph_pubkey<R: Read>(mut reader: R) -> Result<(R, PublicKey), protobuf::Error> {
let mut protbuf_reader = CodedInputStream::new(&mut reader);
// FIXME: don't panic
let raw_bytes: BytesValue = protbuf_reader.read_message().unwrap();
// FIXME: return error instead of panic
assert_eq!(raw_bytes.value.len(), 32);
let mut pk_raw = [0; 32];
pk_raw.copy_from_slice(&raw_bytes.value);
drop(protbuf_reader);
Ok((reader, PublicKey::from(pk_raw)))
}
/**********************************/
pub(crate) fn sort_pubkeys(key1: PublicKey, key2: PublicKey) -> (PublicKey, PublicKey) {
let k1 = key1.as_bytes();
let k2 = key2.as_bytes();
if k1 <= k2 {
(key1, key2)
} else {
(key2, key1)
}
}
/// return (recvSecret, sendSecret)
pub(crate) fn derive_secrets(
dh_shared_secret: SharedSecret,
local_is_least: bool,
) -> (StaticSecret, StaticSecret) {
/*
generate two keys to use for encryption (sending and receiving) and a challenge for authentication as follows:
create a hkdf-sha256 instance with the key being the diffie hellman shared secret, and info parameter as TENDERMINT_SECRET_CONNECTION_KEY_AND_CHALLENGE_GEN
get 64 bytes of output from hkdf-sha256
if we had the smaller ephemeral pubkey, use the first 32 bytes for the key for receiving, the second 32 bytes for sending; else the opposite.
*/
let hk = Hkdf::<Sha256>::new(
None, // salt
dh_shared_secret.as_ref(), // ikm
);
// get enough data for 2 aead keys, and a 32 byte challenge
let mut out = [0u8; 2 * 32 + 32];
hk.expand(
"TENDERMINT_SECRET_CONNECTION_KEY_AND_CHALLENGE_GEN".as_ref(),
&mut out,
)
.expect("96 is a valid length for Sha256 to output");
// bytes 0 through aeadKeySize - 1 are one aead key.
// bytes aeadKeySize through 2*aeadKeySize -1 are another aead key.
let mut aead_key1 = [0; 32];
let mut aead_key2 = [0; 32];
aead_key1.copy_from_slice(&out[0..32]);
aead_key2.copy_from_slice(&out[32..64]);
// which key corresponds to sending and receiving key depends on whether
// the local key is less than the remote key.
if !local_is_least {
swap(&mut aead_key1, &mut aead_key2);
}
(StaticSecret::from(aead_key1), StaticSecret::from(aead_key2))
}

View File

@ -0,0 +1,9 @@
pub mod p2p {
pub mod conn {
include!(concat!(env!("OUT_DIR"), "/tendermint.p2p.rs"));
}
pub mod crypto {
include!(concat!(env!("OUT_DIR"), "/tendermint.crypto.rs"));
}
}