Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final protobuf for 0.17.0 / Go 0.34.0 #737

Merged
merged 11 commits into from
Dec 14, 2020
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
runs-on: ubuntu-latest
services:
tendermint:
image: informaldev/tendermint:0.34.0-d7d0ffea
image: informaldev/tendermint:0.34.0
ports:
- 26656:26656
- 26657:26657
Expand All @@ -118,7 +118,7 @@ jobs:
runs-on: ubuntu-latest
services:
tendermint:
image: informaldev/tendermint:0.34.0-d7d0ffea
image: informaldev/tendermint:0.34.0
ports:
- 26656:26656
- 26657:26657
Expand All @@ -138,7 +138,7 @@ jobs:
runs-on: ubuntu-latest
services:
tendermint:
image: informaldev/tendermint:0.34.0-d7d0ffea
image: informaldev/tendermint:0.34.0
ports:
- 26656:26656
- 26657:26657
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
were Base64-encoded ([#717])
- `[tendermint]` (Since v0.17.0-rc3) Bech32 encoding fix ([#690])
- `[tendermint, light-client]` Specify the proposer in the validator set of fetched light blocks ([#705])
- `[tendermint-proto]` (Since v0.17.0-rc3) Upgrade protobuf definitions to Tendermint Go v0.34.0 ([#737])

[#425]: https://github.com/informalsystems/tendermint-rs/issues/425
[#646]: https://github.com/informalsystems/tendermint-rs/pull/646
[#690]: https://github.com/informalsystems/tendermint-rs/issues/690
[#701]: https://github.com/informalsystems/tendermint-rs/pull/701
[#717]: https://github.com/informalsystems/tendermint-rs/issues/717
[#705]: https://github.com/informalsystems/tendermint-rs/issues/705
[#737]: https://github.com/informalsystems/tendermint-rs/pull/737

## v0.17.0-rc3

Expand Down
1 change: 1 addition & 0 deletions p2p/src/secret_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl<IoHandler: Read + Write + Send + Sync> SecretConnection<IoHandler> {
proto::crypto::public_key::Sum::Ed25519(ref bytes) => {
ed25519::PublicKey::from_bytes(bytes).ok()
}
proto::crypto::public_key::Sum::Secp256k1(_) => None,
})
.ok_or(Error::CryptoError)?;

Expand Down
18 changes: 8 additions & 10 deletions proto-compiler/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub const TENDERMINT_REPO: &str = "https://github.com/tendermint/tendermint";
// Tag: v0.34.0-rc4
// Branch: master
// Commit ID (full length): d7d0ffea13c60c98b812d243ba5a2c375f341c15
pub const TENDERMINT_COMMITISH: &str = "d7d0ffea13c60c98b812d243ba5a2c375f341c15";
pub const TENDERMINT_COMMITISH: &str = "v0.34.0";

/// Predefined custom attributes for message annotations
const PRIMITIVE_ENUM: &str = r#"#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)]"#;
Expand All @@ -28,13 +28,13 @@ const ALIAS_POWER_QUOTED: &str =
r#"#[serde(alias = "power", with = "crate::serializers::from_str")]"#;
const PART_SET_HEADER_TOTAL: &str =
r#"#[serde(with = "crate::serializers::part_set_header_total")]"#;
const RENAME_PUBKEY: &str = r#"#[serde(rename = "tendermint/PubKeyEd25519", with = "crate::serializers::bytes::base64string")]"#;
const RENAME_EDPUBKEY: &str = r#"#[serde(rename = "tendermint/PubKeyEd25519", with = "crate::serializers::bytes::base64string")]"#;
const RENAME_SECPPUBKEY: &str = r#"#[serde(rename = "tendermint/PubKeySecp256k1", with = "crate::serializers::bytes::base64string")]"#;
const RENAME_DUPLICATEVOTE: &str = r#"#[serde(rename = "tendermint/DuplicateVoteEvidence")]"#;
const RENAME_LIGHTCLIENTATTACK: &str =
r#"#[serde(rename = "tendermint/LightClientAttackEvidence")]"#;
const EVIDENCE_VARIANT: &str = r#"#[serde(from = "crate::serializers::evidence::EvidenceVariant", into = "crate::serializers::evidence::EvidenceVariant")]"#;
const ALIAS_PARTS: &str = r#"#[serde(alias = "parts")]"#;
const DEFAULT: &str = r#"#[serde(default)]"#;

/// Custom type attributes applied on top of protobuf structs
/// The first item in the tuple defines the message where the annotation should apply and
Expand All @@ -47,7 +47,7 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
(".tendermint.types.BlockIDFlag", PRIMITIVE_ENUM),
(".tendermint.types.Block", SERIALIZED),
(".tendermint.types.Data", SERIALIZED),
(".tendermint.types.EvidenceData", SERIALIZED),
(".tendermint.types.EvidenceList", SERIALIZED),
(".tendermint.types.Evidence", SERIALIZED),
(".tendermint.types.DuplicateVoteEvidence", SERIALIZED),
(".tendermint.types.Vote", SERIALIZED),
Expand Down Expand Up @@ -82,12 +82,9 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
/// https://docs.rs/prost-build/0.6.1/prost_build/struct.Config.html#method.btree_map
pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
(
".tendermint.types.EvidenceParams.max_num",
".tendermint.types.EvidenceParams.max_bytes",
QUOTED_WITH_DEFAULT,
),
(".tendermint.types.Data.hash", DEFAULT),
(".tendermint.types.EvidenceData.hash", DEFAULT),
(".tendermint.types.Commit.hash", DEFAULT),
(".tendermint.abci.ResponseInfo.last_block_height", QUOTED),
(".tendermint.version.Consensus.block", QUOTED),
(".tendermint.version.Consensus.app", QUOTED_WITH_DEFAULT),
Expand Down Expand Up @@ -119,7 +116,7 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
(".tendermint.types.Header.evidence_hash", HEXSTRING),
(".tendermint.types.Header.proposer_address", HEXSTRING),
(".tendermint.types.Data.txs", NULLABLEVECARRAY),
(".tendermint.types.EvidenceData.evidence", NULLABLE),
(".tendermint.types.EvidenceList.evidence", NULLABLE),
(".tendermint.types.Commit.height", QUOTED),
(".tendermint.types.Commit.signatures", NULLABLE),
(".tendermint.types.CommitSig.validator_address", HEXSTRING),
Expand All @@ -142,7 +139,8 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
), // Default is for /genesis deserialization
(".tendermint.types.BlockMeta.block_size", QUOTED),
(".tendermint.types.BlockMeta.num_txs", QUOTED),
(".tendermint.crypto.PublicKey.sum.ed25519", RENAME_PUBKEY),
(".tendermint.crypto.PublicKey.sum.ed25519", RENAME_EDPUBKEY),
(".tendermint.crypto.PublicKey.sum.secp256k1", RENAME_SECPPUBKEY),
(
".tendermint.types.Evidence.sum.duplicate_vote_evidence",
RENAME_DUPLICATEVOTE,
Expand Down
5 changes: 4 additions & 1 deletion proto/src/prost/tendermint.crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct ProofOps {
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct PublicKey {
#[prost(oneof="public_key::Sum", tags="1")]
#[prost(oneof="public_key::Sum", tags="1, 2")]
pub sum: ::std::option::Option<public_key::Sum>,
}
pub mod public_key {
Expand All @@ -65,5 +65,8 @@ pub mod public_key {
#[prost(bytes, tag="1")]
#[serde(rename = "tendermint/PubKeyEd25519", with = "crate::serializers::bytes::base64string")]
Ed25519(std::vec::Vec<u8>),
#[prost(bytes, tag="2")]
#[serde(rename = "tendermint/PubKeySecp256k1", with = "crate::serializers::bytes::base64string")]
Secp256k1(std::vec::Vec<u8>),
}
}
16 changes: 0 additions & 16 deletions proto/src/prost/tendermint.evidence.rs

This file was deleted.

76 changes: 37 additions & 39 deletions proto/src/prost/tendermint.types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ pub struct Data {
#[prost(bytes, repeated, tag="1")]
#[serde(with = "crate::serializers::txs")]
pub txs: ::std::vec::Vec<std::vec::Vec<u8>>,
/// Volatile
#[prost(bytes, tag="2")]
#[serde(default)]
pub hash: std::vec::Vec<u8>,
}
/// Vote represents a prevote, precommit, or commit vote from validators for
/// consensus.
Expand Down Expand Up @@ -182,11 +178,6 @@ pub struct Commit {
#[prost(message, repeated, tag="4")]
#[serde(with = "crate::serializers::nullable")]
pub signatures: ::std::vec::Vec<CommitSig>,
#[prost(bytes, tag="5")]
#[serde(default)]
pub hash: std::vec::Vec<u8>,
#[prost(message, optional, tag="6")]
pub bit_array: ::std::option::Option<super::libs::bits::BitArray>,
}
/// CommitSig is a part of the Vote included in a Commit.
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -342,13 +333,12 @@ pub struct EvidenceParams {
/// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed).
#[prost(message, optional, tag="2")]
pub max_age_duration: ::std::option::Option<super::super::google::protobuf::Duration>,
/// This sets the maximum number of evidence that can be committed in a single block.
/// and should fall comfortably under the max block bytes when we consider the size of
/// each evidence (See MaxEvidenceBytes). The maximum number is MaxEvidencePerBlock.
/// Default is 50
#[prost(uint32, tag="3")]
/// 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
#[prost(int64, tag="3")]
#[serde(with = "crate::serializers::from_str", default)]
pub max_num: u32,
pub max_bytes: i64,
}
/// ValidatorParams restrict the public key types validators can use.
/// NOTE: uses ABCI pubkey naming, not Amino names.
Expand All @@ -373,24 +363,6 @@ pub struct HashedParams {
#[prost(int64, tag="2")]
pub block_max_gas: i64,
}
/// DuplicateVoteEvidence contains evidence a validator signed two conflicting
/// votes.
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct DuplicateVoteEvidence {
#[prost(message, optional, tag="1")]
pub vote_a: ::std::option::Option<Vote>,
#[prost(message, optional, tag="2")]
pub vote_b: ::std::option::Option<Vote>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct LightClientAttackEvidence {
#[prost(message, optional, tag="1")]
pub conflicting_block: ::std::option::Option<LightBlock>,
#[prost(int64, tag="2")]
pub common_height: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
#[serde(from = "crate::serializers::evidence::EvidenceVariant", into = "crate::serializers::evidence::EvidenceVariant")]
Expand All @@ -412,16 +384,42 @@ pub mod evidence {
LightClientAttackEvidence(super::LightClientAttackEvidence),
}
}
/// EvidenceData contains any evidence of malicious wrong-doing by validators
/// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes.
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct EvidenceData {
pub struct DuplicateVoteEvidence {
#[prost(message, optional, tag="1")]
pub vote_a: ::std::option::Option<Vote>,
#[prost(message, optional, tag="2")]
pub vote_b: ::std::option::Option<Vote>,
#[prost(int64, tag="3")]
pub total_voting_power: i64,
#[prost(int64, tag="4")]
pub validator_power: i64,
#[prost(message, optional, tag="5")]
pub timestamp: ::std::option::Option<super::super::google::protobuf::Timestamp>,
}
/// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client.
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct LightClientAttackEvidence {
#[prost(message, optional, tag="1")]
pub conflicting_block: ::std::option::Option<LightBlock>,
#[prost(int64, tag="2")]
pub common_height: i64,
#[prost(message, repeated, tag="3")]
pub byzantine_validators: ::std::vec::Vec<Validator>,
#[prost(int64, tag="4")]
pub total_voting_power: i64,
#[prost(message, optional, tag="5")]
pub timestamp: ::std::option::Option<super::super::google::protobuf::Timestamp>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
pub struct EvidenceList {
#[prost(message, repeated, tag="1")]
#[serde(with = "crate::serializers::nullable")]
pub evidence: ::std::vec::Vec<Evidence>,
#[prost(bytes, tag="2")]
#[serde(default)]
pub hash: std::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(::serde::Deserialize, ::serde::Serialize)]
Expand Down Expand Up @@ -487,7 +485,7 @@ pub struct Block {
#[prost(message, optional, tag="2")]
pub data: ::std::option::Option<Data>,
#[prost(message, optional, tag="3")]
pub evidence: ::std::option::Option<EvidenceData>,
pub evidence: ::std::option::Option<EvidenceList>,
#[prost(message, optional, tag="4")]
pub last_commit: ::std::option::Option<Commit>,
}
6 changes: 1 addition & 5 deletions proto/src/tendermint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ pub mod abci {
include!("prost/tendermint.abci.rs");
}

pub mod evidence {
include!("prost/tendermint.evidence.rs");
}

pub mod store {
include!("prost/tendermint.store.rs");
}
Expand Down Expand Up @@ -66,5 +62,5 @@ pub mod rpc {

pub mod meta {
pub const REPOSITORY: &str = "https://github.com/tendermint/tendermint";
pub const COMMITISH: &str = "d7d0ffea13c60c98b812d243ba5a2c375f341c15";
pub const COMMITISH: &str = "v0.34.0";
}
5 changes: 4 additions & 1 deletion rpc/tests/support/block_with_evidences.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
"validator_address": "0F1F93CC25A6CFC083F54E4DA26F73B7F24DC85B",
"validator_index": "0",
"signature": "gT2fdleX4BUzbAuUDazkbJBJ99HX7YgSTml7rumzWAm4hlOWtBGPe9BmkUF6Ypy8kzgMU/0P0D96KxCts5tpCQ=="
}
},
"total_voting_power": 0,
"validator_power": 0,
"timestamp": "2020-04-28T15:48:20.640286Z"
}
}
]
Expand Down
6 changes: 1 addition & 5 deletions tendermint/src/abci/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ impl From<RawData> for Data {
impl From<Data> for RawData {
fn from(value: Data) -> Self {
if value.txs.is_none() {
return RawData {
txs: vec![],
hash: vec![],
};
return RawData { txs: vec![] };
}
RawData {
txs: value
Expand All @@ -107,7 +104,6 @@ impl From<Data> for RawData {
.iter()
.map(|tx| tx.clone().into())
.collect(),
hash: vec![],
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions tendermint/src/block/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ impl From<Commit> for RawCommit {
round: value.round.into(),
block_id: Some(value.block_id.into()),
signatures: value.signatures.into_iter().map(Into::into).collect(),
hash: vec![],
bit_array: None,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tendermint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ pub enum Kind {
#[error("missing evidence field")]
MissingEvidence,

/// Missing Timestamp in Block
#[error("missing timestamp field")]
MissingTimestamp,

/// Invalid Block
#[error("invalid block")]
InvalidBlock,
Expand Down
Loading