Skip to content

Commit 496b1a7

Browse files
authored
Updat abci-rs to work with tendermint 0.33.0 (#10)
1 parent 818fe22 commit 496b1a7

File tree

12 files changed

+533
-398
lines changed

12 files changed

+533
-398
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "abci-rs"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Devashish Dixit <devashishdxt@gmail.com>"]
55
license = "MIT/Apache-2.0"
66
description = "A Rust crate for creating ABCI applications"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Add `abci-rs` in your `Cargo.toml`'s `dependencies` section:
2626

2727
```toml
2828
[dependencies]
29-
abci-rs = "0.5"
29+
abci-rs = "0.6"
3030
```
3131

3232
Each ABCI application has to implement three core traits corresponding to all three ABCI connections, `Consensus`,
@@ -55,8 +55,7 @@ will fail if either both of them are enabled or none of them are enabled.
5555

5656
## Minimum Supported Versions
5757

58-
- Tendermint v0.32.8
59-
- ABCI v0.16.1
58+
- Tendermint: [`v0.33.0`](https://github.com/tendermint/tendermint/releases/tag/v0.33.0)
6059

6160
## License
6261

gen-proto/assets/github.com/tendermint/tendermint/abci/types/abci.proto

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
syntax = "proto3";
2-
package types;
2+
package tendermint.abci.types;
3+
option go_package = "github.com/tendermint/tendermint/abci/types";
34

45
// For more information on gogo.proto, see:
56
// https://github.com/gogo/protobuf/blob/master/extensions.md
67
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
78
import "github.com/tendermint/tendermint/crypto/merkle/merkle.proto";
8-
import "github.com/tendermint/tendermint/libs/common/types.proto";
9+
import "github.com/tendermint/tendermint/libs/kv/types.proto";
910
import "google/protobuf/timestamp.proto";
11+
import "google/protobuf/duration.proto";
1012

1113
// This file is copied from http://github.com/tendermint/abci
1214
// NOTE: When using custom types, mind the warnings.
@@ -165,7 +167,7 @@ message ResponseQuery {
165167
int64 index = 5;
166168
bytes key = 6;
167169
bytes value = 7;
168-
merkle.Proof proof = 8;
170+
tendermint.crypto.merkle.Proof proof = 8;
169171
int64 height = 9;
170172
string codespace = 10;
171173
}
@@ -226,10 +228,10 @@ message BlockParams {
226228
int64 max_gas = 2;
227229
}
228230

229-
// EvidenceParams contains limits on the evidence.
230231
message EvidenceParams {
231232
// Note: must be greater than 0
232-
int64 max_age = 1;
233+
int64 max_age_num_blocks = 1;
234+
google.protobuf.Duration max_age_duration = 2 [(gogoproto.nullable)=false, (gogoproto.stdduration)=true];
233235
}
234236

235237
// ValidatorParams contains limits on validators.
@@ -244,7 +246,7 @@ message LastCommitInfo {
244246

245247
message Event {
246248
string type = 1;
247-
repeated common.KVPair attributes = 2 [(gogoproto.nullable)=false, (gogoproto.jsontag)="attributes,omitempty"];
249+
repeated tendermint.libs.kv.Pair attributes = 2 [(gogoproto.nullable)=false, (gogoproto.jsontag)="attributes,omitempty"];
248250
}
249251

250252
//----------------------------------------
@@ -256,26 +258,24 @@ message Header {
256258
string chain_id = 2 [(gogoproto.customname)="ChainID"];
257259
int64 height = 3;
258260
google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true];
259-
int64 num_txs = 5;
260-
int64 total_txs = 6;
261261

262262
// prev block info
263-
BlockID last_block_id = 7 [(gogoproto.nullable)=false];
263+
BlockID last_block_id = 5 [(gogoproto.nullable)=false];
264264

265265
// hashes of block data
266-
bytes last_commit_hash = 8; // commit from validators from the last block
267-
bytes data_hash = 9; // transactions
266+
bytes last_commit_hash = 6; // commit from validators from the last block
267+
bytes data_hash = 7; // transactions
268268

269269
// hashes from the app output from the prev block
270-
bytes validators_hash = 10; // validators for the current block
271-
bytes next_validators_hash = 11; // validators for the next block
272-
bytes consensus_hash = 12; // consensus params for current block
273-
bytes app_hash = 13; // state after txs from the previous block
274-
bytes last_results_hash = 14;// root hash of all results from the txs from the previous block
270+
bytes validators_hash = 8; // validators for the current block
271+
bytes next_validators_hash = 9; // validators for the next block
272+
bytes consensus_hash = 10; // consensus params for current block
273+
bytes app_hash = 11; // state after txs from the previous block
274+
bytes last_results_hash = 12;// root hash of all results from the txs from the previous block
275275

276276
// consensus info
277-
bytes evidence_hash = 15; // evidence included in the block
278-
bytes proposer_address = 16; // original proposer of the block
277+
bytes evidence_hash = 13; // evidence included in the block
278+
bytes proposer_address = 14; // original proposer of the block
279279
}
280280

281281
message Version {

gen-proto/assets/github.com/tendermint/tendermint/crypto/merkle/merkle.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
2-
package merkle;
2+
package tendermint.crypto.merkle;
3+
option go_package = "github.com/tendermint/tendermint/crypto/merkle";
34

45
// For more information on gogo.proto, see:
56
// https://github.com/gogo/protobuf/blob/master/extensions.md

gen-proto/assets/github.com/tendermint/tendermint/libs/common/types.proto renamed to gen-proto/assets/github.com/tendermint/tendermint/libs/kv/types.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
syntax = "proto3";
2-
package common;
2+
package tendermint.libs.kv;
3+
option go_package = "github.com/tendermint/tendermint/libs/kv";
34

45
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
56

@@ -16,7 +17,7 @@ option (gogoproto.testgen_all) = true;
1617
// Abstract types
1718

1819
// Define these here for compatibility but use tmlibs/common.KVPair.
19-
message KVPair {
20+
message Pair {
2021
bytes key = 1;
2122
bytes value = 2;
2223
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
// https://developers.google.com/protocol-buffers/
4+
//
5+
// Redistribution and use in source and binary forms, with or without
6+
// modification, are permitted provided that the following conditions are
7+
// met:
8+
//
9+
// * Redistributions of source code must retain the above copyright
10+
// notice, this list of conditions and the following disclaimer.
11+
// * Redistributions in binary form must reproduce the above
12+
// copyright notice, this list of conditions and the following disclaimer
13+
// in the documentation and/or other materials provided with the
14+
// distribution.
15+
// * Neither the name of Google Inc. nor the names of its
16+
// contributors may be used to endorse or promote products derived from
17+
// this software without specific prior written permission.
18+
//
19+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
syntax = "proto3";
32+
33+
package google.protobuf;
34+
35+
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
36+
option cc_enable_arenas = true;
37+
option go_package = "github.com/golang/protobuf/ptypes/duration";
38+
option java_package = "com.google.protobuf";
39+
option java_outer_classname = "DurationProto";
40+
option java_multiple_files = true;
41+
option objc_class_prefix = "GPB";
42+
43+
// A Duration represents a signed, fixed-length span of time represented
44+
// as a count of seconds and fractions of seconds at nanosecond
45+
// resolution. It is independent of any calendar and concepts like "day"
46+
// or "month". It is related to Timestamp in that the difference between
47+
// two Timestamp values is a Duration and it can be added or subtracted
48+
// from a Timestamp. Range is approximately +-10,000 years.
49+
//
50+
// # Examples
51+
//
52+
// Example 1: Compute Duration from two Timestamps in pseudo code.
53+
//
54+
// Timestamp start = ...;
55+
// Timestamp end = ...;
56+
// Duration duration = ...;
57+
//
58+
// duration.seconds = end.seconds - start.seconds;
59+
// duration.nanos = end.nanos - start.nanos;
60+
//
61+
// if (duration.seconds < 0 && duration.nanos > 0) {
62+
// duration.seconds += 1;
63+
// duration.nanos -= 1000000000;
64+
// } else if (duration.seconds > 0 && duration.nanos < 0) {
65+
// duration.seconds -= 1;
66+
// duration.nanos += 1000000000;
67+
// }
68+
//
69+
// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
70+
//
71+
// Timestamp start = ...;
72+
// Duration duration = ...;
73+
// Timestamp end = ...;
74+
//
75+
// end.seconds = start.seconds + duration.seconds;
76+
// end.nanos = start.nanos + duration.nanos;
77+
//
78+
// if (end.nanos < 0) {
79+
// end.seconds -= 1;
80+
// end.nanos += 1000000000;
81+
// } else if (end.nanos >= 1000000000) {
82+
// end.seconds += 1;
83+
// end.nanos -= 1000000000;
84+
// }
85+
//
86+
// Example 3: Compute Duration from datetime.timedelta in Python.
87+
//
88+
// td = datetime.timedelta(days=3, minutes=10)
89+
// duration = Duration()
90+
// duration.FromTimedelta(td)
91+
//
92+
// # JSON Mapping
93+
//
94+
// In JSON format, the Duration type is encoded as a string rather than an
95+
// object, where the string ends in the suffix "s" (indicating seconds) and
96+
// is preceded by the number of seconds, with nanoseconds expressed as
97+
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
98+
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
99+
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
100+
// microsecond should be expressed in JSON format as "3.000001s".
101+
//
102+
//
103+
message Duration {
104+
// Signed seconds of the span of time. Must be from -315,576,000,000
105+
// to +315,576,000,000 inclusive. Note: these bounds are computed from:
106+
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
107+
int64 seconds = 1;
108+
109+
// Signed fractions of a second at nanosecond resolution of the span
110+
// of time. Durations less than one second are represented with a 0
111+
// `seconds` field and a positive or negative `nanos` field. For durations
112+
// of one second or more, a non-zero value for the `nanos` field must be
113+
// of the same sign as the `seconds` field. Must be from -999,999,999
114+
// to +999,999,999 inclusive.
115+
int32 nanos = 2;
116+
}

gen-proto/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use bytes::Bytes;
44
use protobuf_codegen_pure::{run, Args};
55
use reqwest::Result;
66

7-
const TENDERMINT_URL: &str = "https://raw.githubusercontent.com/tendermint/tendermint/v0.32.8/";
7+
const TENDERMINT_URL: &str = "https://raw.githubusercontent.com/tendermint/tendermint/v0.33.0/";
88

99
const FILES_TO_DOWNLOAD: [(&str, &str); 3] = [
1010
(
11-
"libs/common/types.proto",
12-
"gen-proto/assets/github.com/tendermint/tendermint/libs/common/types.proto",
11+
"libs/kv/types.proto",
12+
"gen-proto/assets/github.com/tendermint/tendermint/libs/kv/types.proto",
1313
),
1414
(
1515
"abci/types/types.proto",
@@ -44,7 +44,7 @@ async fn main() {
4444
includes: &["gen-proto/assets"],
4545
input: &[
4646
"gen-proto/assets/github.com/tendermint/tendermint/abci/types/abci.proto",
47-
"gen-proto/assets/github.com/tendermint/tendermint/libs/common/types.proto",
47+
"gen-proto/assets/github.com/tendermint/tendermint/libs/kv/types.proto",
4848
"gen-proto/assets/github.com/tendermint/tendermint/crypto/merkle/merkle.proto",
4949
],
5050
customize: Default::default(),

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//!
2626
//! ```toml
2727
//! [dependencies]
28-
//! abci-rs = "0.5"
28+
//! abci-rs = "0.6"
2929
//! ```
3030
//!
3131
//! Each ABCI application has to implement three core traits corresponding to all three ABCI connections, `Consensus`,
@@ -54,8 +54,7 @@
5454
//!
5555
//! ## Minimum Supported Versions
5656
//!
57-
//! - Tendermint v0.32.8
58-
//! - ABCI v0.16.1
57+
//! - Tendermint: [`v0.33.0`](https://github.com/tendermint/tendermint/releases/tag/v0.33.0)
5958
#![cfg_attr(feature = "doc", feature(doc_cfg))]
6059

6160
#[cfg(all(feature = "async-std", feature = "tokio"))]

0 commit comments

Comments
 (0)