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

Re-built tendermint-proto with serialization annotations #639

Merged
merged 47 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
eb00c8e
Re-built tendermint-proto with serialization annontations
greg-szabo Oct 14, 2020
1612d1c
Bumped tendermint-proto version number
greg-szabo Oct 14, 2020
356324a
AbciInfo reimplemented as domain type with JSON serialization
greg-szabo Oct 15, 2020
3bbe2c5
JSON serialization work
greg-szabo Oct 19, 2020
c8c44c3
Block serialization work
greg-szabo Oct 20, 2020
bfd8e96
Block JSON encoding fixed
greg-szabo Oct 20, 2020
59199be
Add test for JSON timestamp de/serialization precision
thanethomson Oct 20, 2020
5f768f8
Fix Go/chrono timestamp serialization compatibility
thanethomson Oct 20, 2020
b5c6ce6
Tendermint basic integration tests succeed, clippy fixes
greg-szabo Oct 21, 2020
d7f04be
part_set_header fix and others
greg-szabo Oct 21, 2020
604ffbb
More cleanup of serialization
greg-szabo Oct 21, 2020
71ac2d7
txs fix and BlockMeta serialization
greg-szabo Oct 21, 2020
ae0bd5a
Test fixes, serialization fixes
greg-szabo Oct 22, 2020
a87679e
Merge latest changes from master
thanethomson Oct 22, 2020
7d6572e
tendermint integration tests all succeed
greg-szabo Oct 22, 2020
2bf5d7e
More test fixes
greg-szabo Oct 22, 2020
8df8b24
More test fixes
greg-szabo Oct 22, 2020
d69663e
More test fixes
greg-szabo Oct 22, 2020
d8610f6
model-based tests updated
greg-szabo Oct 23, 2020
ea26da9
ConsensusParams domain type
greg-szabo Oct 23, 2020
7a41690
genesis temp fix
greg-szabo Oct 23, 2020
3f139ca
Removed single_step tests as mentioned by Andrey
greg-szabo Oct 23, 2020
6607bac
Merge branch 'master' into greg/research-json
greg-szabo Oct 23, 2020
d679c1e
Merge conflict fix refix, voting_power tests removed as per Andrey
greg-szabo Oct 23, 2020
d6b94bb
Added Hash custom serialization
greg-szabo Oct 23, 2020
766ac64
Fixes some bisection test files
greg-szabo Oct 24, 2020
f1332eb
Restored voting_power tests
greg-szabo Oct 24, 2020
275dc57
More test fixes
greg-szabo Oct 24, 2020
e06fd1f
fmt fix
greg-szabo Oct 24, 2020
91a41b1
Disabled model-based single step tests until they can be recreated co…
greg-szabo Oct 25, 2020
15c6a3d
Enable alias for part_set_header
thanethomson Oct 26, 2020
e2bb333
Add Anca's changes and fix test failures
thanethomson Oct 27, 2020
105db3b
cargo fmt
thanethomson Oct 27, 2020
0c5ffb2
Provide default validator set if none supplied in genesis
thanethomson Oct 28, 2020
ccf13fd
add Eq to TrustThresholdFraction
ancazamfir Oct 28, 2020
820b634
Fix git clone/update mechanism for proto compiler
thanethomson Oct 29, 2020
3bcf76a
Implement domain types for merke Proof
ancazamfir Nov 3, 2020
61aee58
Add checks for abci_query proof deserialization
thanethomson Nov 4, 2020
e834eaf
Make the consensus parameter's version Option
ancazamfir Nov 4, 2020
cd99fbd
Add alias "proofOps" for "proof" field in abci_query response
thanethomson Nov 4, 2020
998e813
Block TryFrom cleaning
greg-szabo Nov 5, 2020
3195dfd
Merge latest changes from master (ignoring model-based single step te…
thanethomson Nov 5, 2020
cd096ec
Make structs with constructors non-exhaustive
thanethomson Nov 6, 2020
ffe1625
Merge latest changes from master
thanethomson Nov 6, 2020
5f8fe33
Update CHANGELOG
thanethomson Nov 6, 2020
b59ddae
Use simple constructor for validator set construction
thanethomson Nov 6, 2020
3fbeb8a
Restore getters for Block and SignedHeader
thanethomson Nov 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Unreleased

### BREAKING CHANGES:

- `[tendermint]` - Direct serialization capabilities have been removed from the
domain types. They are temporarily available in the `protos` crate. **NB:
this is unstable and is planned to change again in v0.17.0-rc3**. ([#639])
- `[tendermint]` - Work has started on making it compulsory to construct domain
types by way of their constructors to ensure validity. This work is scheduled
for completion in v0.17.0-rc3. ([#639])

### BUG FIXES:

- `[light-client]` Fix bug where a commit with only absent signatures would be
Expand All @@ -9,6 +18,7 @@

[#650]: https://github.com/informalsystems/tendermint-rs/issues/650
[#652]: https://github.com/informalsystems/tendermint-rs/pulls/652
[#639]: https://github.com/informalsystems/tendermint-rs/pull/639

## v0.17.0-rc1

Expand Down
2 changes: 1 addition & 1 deletion light-client/src/builder/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl LightClientBuilder<NoTrustedState> {
let trusted_state = self
.light_store
.latest_trusted_or_verified()
.ok_or_else(|| error::Kind::NoTrustedStateInStore)?;
.ok_or(error::Kind::NoTrustedStateInStore)?;

self.trust_light_block(trusted_state)
}
Expand Down
2 changes: 1 addition & 1 deletion light-client/src/components/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod prod {
let res = block_on(self.timeout, async move { client.validators(height).await })?;

match res {
Ok(response) => Ok(TMValidatorSet::new(response.validators)),
Ok(response) => Ok(TMValidatorSet::new_simple(response.validators)),
Err(err) => Err(IoError::RpcError(err)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion light-client/src/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl LightClient {
let trusted_state = state
.light_store
.latest_trusted_or_verified()
.ok_or_else(|| ErrorKind::NoInitialTrustedState)?;
.ok_or(ErrorKind::NoInitialTrustedState)?;

if target_height < trusted_state.height() {
bail!(ErrorKind::TargetLowerThanTrustedState {
Expand Down
4 changes: 2 additions & 2 deletions light-client/src/operations/voting_power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt;

use std::convert::{TryFrom, TryInto};
use std::convert::TryFrom;
use tendermint::block::CommitSig;
use tendermint::trust_threshold::TrustThreshold as _;
use tendermint::vote::{SignedVote, ValidatorIndex, Vote};
Expand Down Expand Up @@ -211,7 +211,7 @@ fn non_absent_vote(
Some(Vote {
vote_type: tendermint::vote::Type::Precommit,
height: commit.height,
round: commit.round.try_into().unwrap(),
round: commit.round,
block_id,
timestamp: Some(timestamp),
validator_address,
Expand Down
8 changes: 8 additions & 0 deletions light-client/src/predicates/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ pub enum VerificationError {
#[error("header from the future: header_time={header_time} now={now}")]
HeaderFromTheFuture {
/// Time in the header
#[serde(with = "tendermint::serializers::time")]
header_time: Time,
/// Current time
#[serde(with = "tendermint::serializers::time")]
now: Time,
},

Expand Down Expand Up @@ -52,26 +54,32 @@ pub enum VerificationError {
#[error("invalid commit value: header_hash={header_hash} commit_hash={commit_hash}")]
InvalidCommitValue {
/// Header hash
#[serde(with = "tendermint::serializers::hash")]
header_hash: Hash,
/// Commit hash
#[serde(with = "tendermint::serializers::hash")]
commit_hash: Hash,
},

/// Hash mismatch for the next validator set
#[error("invalid next validator set: header_next_validators_hash={header_next_validators_hash} next_validators_hash={next_validators_hash}")]
InvalidNextValidatorSet {
/// Next validator set hash
#[serde(with = "tendermint::serializers::hash")]
header_next_validators_hash: Hash,
/// Validator set hash
#[serde(with = "tendermint::serializers::hash")]
next_validators_hash: Hash,
},

/// Hash mismatch for the validator set
#[error("invalid validator set: header_validators_hash={header_validators_hash} validators_hash={validators_hash}")]
InvalidValidatorSet {
/// Hash of validator set stored in header
#[serde(with = "tendermint::serializers::hash")]
header_validators_hash: Hash,
/// Actual hash of validator set in header
#[serde(with = "tendermint::serializers::hash")]
validators_hash: Hash,
},

Expand Down
2 changes: 1 addition & 1 deletion light-client/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl Supervisor {
Ok(verified_block) => {
let trusted_block = primary
.latest_trusted()
.ok_or_else(|| ErrorKind::NoTrustedState(Status::Trusted))?;
.ok_or(ErrorKind::NoTrustedState(Status::Trusted))?;

// Perform fork detection with the highest verified block and the trusted block.
let outcome = self.detect_forks(&verified_block, &trusted_block)?;
Expand Down
2 changes: 2 additions & 0 deletions light-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Initial {
pub signed_header: SignedHeader,
pub next_validator_set: ValidatorSet,
pub trusting_period: DurationStr,
#[serde(with = "tendermint::serializers::time")]
pub now: Time,
}

Expand All @@ -48,6 +49,7 @@ pub struct TestBisection<LB> {
pub primary: Provider<LB>,
pub witnesses: Vec<WitnessProvider<LB>>,
pub height_to_verify: HeightStr,
#[serde(with = "tendermint::serializers::time")]
pub now: Time,
pub expected_output: Option<String>,
pub expected_num_of_bisections: usize,
Expand Down
2 changes: 2 additions & 0 deletions light-client/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ pub struct LatestStatus {
/// The latest height we are trusting.
pub height: Option<u64>,
/// The latest block hash we are trusting.
#[serde(with = "tendermint::serializers::option_hash")]
pub block_hash: Option<Hash>,
/// The latest validator set we are trusting.
/// Note that this potentially did not yet sign a header yet.
#[serde(with = "tendermint::serializers::option_hash")]
pub valset_hash: Option<Hash>,
/// The list of fullnodes we are connected to, primary and witnesses.
pub connected_nodes: Vec<PeerId>,
Expand Down
14 changes: 7 additions & 7 deletions light-client/tests/model_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::str::FromStr;
use std::time::Duration;
use tendermint::block::CommitSigs;
use tendermint_light_client::components::verifier::Verdict;
use tendermint_light_client::types::ValidatorSet;
use tendermint_light_client::{
Expand Down Expand Up @@ -63,6 +62,7 @@ pub struct SingleStepTestCase {
pub struct BlockVerdict {
block: AnonLightBlock,
testgen_block: TestgenLightBlock,
#[serde(with = "tendermint::serializers::time")]
now: Time,
verdict: LiteVerdict,
}
Expand Down Expand Up @@ -230,7 +230,7 @@ impl SingleStepTestFuzzer for HeaderValHashFuzzer {
Validator::new("2"),
Validator::new("3"),
];
let valset = ValidatorSet::new(generate_validators(&vals).unwrap());
let valset = ValidatorSet::new_simple(generate_validators(&vals).unwrap());

input.block.validators = valset;
(String::from("header validators_hash"), true)
Expand All @@ -245,7 +245,7 @@ impl SingleStepTestFuzzer for HeaderNextValHashFuzzer {
Validator::new("2"),
Validator::new("3"),
];
let valset = ValidatorSet::new(generate_validators(&vals).unwrap());
let valset = ValidatorSet::new_simple(generate_validators(&vals).unwrap());

input.block.next_validators = valset;
(String::from("header next_validators_hash"), true)
Expand Down Expand Up @@ -319,12 +319,12 @@ struct CommitRoundFuzzer {}
impl SingleStepTestFuzzer for CommitRoundFuzzer {
fn fuzz_input(input: &mut BlockVerdict) -> (String, bool) {
let mut rng = rand::thread_rng();
let r: u32 = input.block.signed_header.commit.round;
let r: u32 = input.block.signed_header.commit.round.value();
let mut round: u32 = rng.gen();
while round == r {
round = rng.gen();
}
input.block.signed_header.commit.round = round;
input.block.signed_header.commit.round = (round as u16).into();
(format!("commit round from {} into {}", r, round), true)
}
}
Expand Down Expand Up @@ -425,8 +425,7 @@ impl SingleStepTestFuzzer for SignaturesFuzzer {

input.block.signed_header.commit = commit.generate().unwrap();
} else {
let commitsigs = CommitSigs::new(vec![]);
input.block.signed_header.commit.signatures = commitsigs;
input.block.signed_header.commit.signatures = vec![];
}

(String::from("signatures"), true)
Expand Down Expand Up @@ -630,6 +629,7 @@ fn model_based_test_batch(batch: ApalacheTestBatch) -> Vec<(String, String)> {
const TEST_DIR: &str = "./tests/support/model_based";

#[test]
#[ignore]
fn run_model_based_single_step_tests() {
let mut tester = Tester::new("test_run", TEST_DIR);
tester.add_test_with_env("static model-based single-step test", fuzz_single_step_test);
Expand Down
Loading