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

Removed amino folder #592

Merged
merged 34 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e243c70
Removed amino traits, block, signature, vote
greg-szabo Sep 30, 2020
007bb09
tendermint: Fix header hashing
thanethomson Sep 30, 2020
f7bd911
light-client: Resolve #600
thanethomson Sep 30, 2020
0b05bdb
tendermint: Use shorthand form of method call
thanethomson Sep 30, 2020
4d55b61
tendermint: Add header hash check in integration test
thanethomson Oct 1, 2020
9bcdbaf
tendermint: Add workaround for empty BlockId
thanethomson Oct 1, 2020
d5cd63c
rpc: Update integration test fixture
thanethomson Oct 1, 2020
535e5a1
Added Proposal domain type with signing - tests fail for now
greg-szabo Oct 1, 2020
c66fe9d
tendermint: Make last_block_id encoding workaround more explicit
thanethomson Oct 1, 2020
428a369
tendermint: Fix empty last_block_id encoding issue
thanethomson Oct 1, 2020
631f5c2
Proposal and Vote signable bytes functions
greg-szabo Oct 1, 2020
da4db48
Merge remote-tracking branch 'refs/remotes/origin/greg/aminoff3' into…
greg-szabo Oct 1, 2020
b46bc85
PubKeyResponse made into PublicKey
greg-szabo Oct 1, 2020
90ecfc8
Header.Hash() fixes
greg-szabo Oct 2, 2020
66a3a54
Merge branch 'master' into greg/aminoff3
greg-szabo Oct 2, 2020
8600b54
Merge conflict fixes
greg-szabo Oct 2, 2020
fcef436
Proposal test fixes
greg-szabo Oct 2, 2020
8f9f0ba
Updated CHANGELOG
greg-szabo Oct 2, 2020
696efd3
Update CHANGELOG.md
greg-szabo Oct 2, 2020
661e294
Update CHANGELOG.md
greg-szabo Oct 2, 2020
19dddbb
regenerate static model-based files
andrey-kuprianov Oct 2, 2020
9fade2b
Update tendermint/Cargo.toml
greg-szabo Oct 2, 2020
5a63cb9
Remvoed amino bech32 encoding
greg-szabo Oct 5, 2020
3829909
Updated priv_validator.json test with non-amino public key result
greg-szabo Oct 5, 2020
665fe72
Removed comments referencing amino.
greg-szabo Oct 5, 2020
f5b1202
Review fixes #1
greg-szabo Oct 6, 2020
96b6f7f
Review fixes #2
greg-szabo Oct 6, 2020
8cc3d23
Review fixes #3
greg-szabo Oct 6, 2020
ff3cb43
Updated tests using testgen (#615)
greg-szabo Oct 7, 2020
2557cf4
Update tendermint/src/public_key.rs
greg-szabo Oct 7, 2020
54be939
Merge branch 'master' into greg/aminoff3
greg-szabo Oct 7, 2020
1d84575
fmt fix
greg-szabo Oct 7, 2020
1e1255a
Fixes number four, additional derive traits
greg-szabo Oct 8, 2020
e2d3773
Merge branch 'master' into greg/aminoff3
greg-szabo Oct 8, 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: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
- Add spec for the light client attack evidence handling ([#526])
- Return RFC6962 hash for empty merkle tree ([#498])
- The `tendermint`, `tendermint-rpc`, and `tendermint-light-client` crates now compile to WASM on the `wasm32-unknown-unknown` and `wasm32-wasi` targets ([#463])
- Implement protobuf encoding/decoding of Tendermint Proto types ([#504])
- Separate protobuf types from Rust domain types using the DomainType trait ([#535])
- Changed validator sorting order to sort by voting power (descending) and address (ascending). ([#506])
- Dependency update: sled 0.34 ([#490])

### BREAKING CHANGES:
Expand All @@ -18,6 +15,11 @@
subscription. To access this struct, you now need to enable both the
`client` and `transport_http` features when using the `tendermint-rpc`
crate. ([#516])
- `[tendermint]` Removed Amino types. All types are now `DomainType`s
implementing Protobuf-encoding using Prost. ([#504], [#535], [#536],
[#585])
- `[tendermint]` Changed validator sorting order to sort by voting power
(descending) and address (ascending). ([#506])

### IMPROVEMENTS:

Expand Down Expand Up @@ -46,6 +48,8 @@
[#535]: https://github.com/informalsystems/tendermint-rs/issues/535
[#506]: https://github.com/informalsystems/tendermint-rs/issues/506
[#516]: https://github.com/informalsystems/tendermint-rs/pull/516
[#536]: https://github.com/informalsystems/tendermint-rs/issues/536
[#585]: https://github.com/informalsystems/tendermint-rs/issues/585

## v0.16.0

Expand Down
1 change: 0 additions & 1 deletion light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ contracts = "0.4.0"
crossbeam-channel = "0.4.2"
derive_more = "0.99.5"
futures = "0.3.4"
prost-amino = "0.6.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

serde = "1.0.106"
serde_cbor = "0.11.1"
serde_derive = "1.0.106"
Expand Down
3 changes: 2 additions & 1 deletion light-client/src/components/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ mod prod {
/// A peer map which maps peer IDS to their network address must be supplied.
pub fn new(
peer_id: PeerId,
rpc_client: rpc::HttpClient, // TODO(thane): Generalize over client transport (instead of using HttpClient directly)
rpc_client: rpc::HttpClient, /* TODO(thane): Generalize over client transport
* (instead of using HttpClient directly) */
timeout: Option<Duration>,
) -> Self {
Self {
Expand Down
5 changes: 4 additions & 1 deletion light-client/src/components/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use contracts::*;

use crate::store::LightStore;
use crate::types::Height;
use std::convert::TryInto;

/// The scheduler decides what block to verify next given the current and target heights.
///
Expand Down Expand Up @@ -122,5 +123,7 @@ pub fn valid_schedule(
#[pre(low <= high)]
#[post(low <= ret && ret <= high)]
fn midpoint(low: Height, high: Height) -> Height {
(low.value() + (high.value() + 1 - low.value()) / 2).into()
(low.value() + (high.value() + 1 - low.value()) / 2)
.try_into()
.unwrap() // Will panic if midpoint is higher than i64::MAX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we label these with something consistent so it's easy to find them in the future if we change how we handle this? Maybe should be an XXX or something easy to find...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, although in this case it's more of a theoretical possibility than a real one.
You can get the biggest number with high.value()==i64::MAX and midpoint is going to be i64::MAX/2 in that case. So this is an unwrap case that can never fail, unless the developer changes the types without concern to the note.

Maybe it's better to remove it, since it's theoretical only.

}
25 changes: 17 additions & 8 deletions light-client/src/operations/voting_power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt;

use std::convert::{TryFrom, TryInto};
use tendermint::block::CommitSig;
use tendermint::trust_threshold::TrustThreshold as _;
use tendermint::vote::{SignedVote, Vote};
use tendermint::vote::{SignedVote, ValidatorIndex, Vote};

/// Tally for the voting power computed by the `VotingPowerCalculator`
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -115,7 +116,11 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator {

// Get non-absent votes from the signatures
let non_absent_votes = signatures.iter().enumerate().flat_map(|(idx, signature)| {
if let Some(vote) = non_absent_vote(signature, idx as u16, &signed_header.commit) {
if let Some(vote) = non_absent_vote(
signature,
ValidatorIndex::try_from(idx).unwrap(),
&signed_header.commit,
) {
Some((signature, vote))
} else {
None
Expand All @@ -138,8 +143,8 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator {
};

let signed_vote = SignedVote::new(
(&vote).into(),
signed_header.header.chain_id.as_str(),
vote.clone(),
signed_header.header.chain_id.clone(),
vote.validator_address,
vote.signature,
);
Expand Down Expand Up @@ -179,7 +184,11 @@ impl VotingPowerCalculator for ProdVotingPowerCalculator {
}
}

fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit) -> Option<Vote> {
fn non_absent_vote(
commit_sig: &CommitSig,
validator_index: ValidatorIndex,
commit: &Commit,
) -> Option<Vote> {
let (validator_address, timestamp, signature, block_id) = match commit_sig {
CommitSig::BlockIDFlagAbsent { .. } => return None,
CommitSig::BlockIDFlagCommit {
Expand All @@ -190,7 +199,7 @@ fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit
*validator_address,
*timestamp,
signature,
Some(commit.block_id.clone()),
Some(commit.block_id),
),
CommitSig::BlockIDFlagNil {
validator_address,
Expand All @@ -202,9 +211,9 @@ fn non_absent_vote(commit_sig: &CommitSig, validator_index: u16, commit: &Commit
Some(Vote {
vote_type: tendermint::vote::Type::Precommit,
height: commit.height,
round: commit.round,
round: commit.round.try_into().unwrap(),
block_id,
timestamp,
timestamp: Some(timestamp),
validator_address,
validator_index,
signature: *signature,
Expand Down
2 changes: 1 addition & 1 deletion light-client/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn sync() {
let handle = supervisor.handle();
std::thread::spawn(|| supervisor.run());

let max_iterations: usize = 1; // FIXME: Fix no witness left error in subsequent iterations
let max_iterations: usize = 10;

for i in 1..=max_iterations {
println!("[info ] - iteration {}/{}", i, max_iterations);
Expand Down
3 changes: 2 additions & 1 deletion light-client/tests/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tendermint_light_client::{
types::{LightBlock, Status, TrustThreshold},
};

use std::convert::TryInto;
use tendermint_testgen::Tester;

// Link to JSON test files repo:
Expand Down Expand Up @@ -169,7 +170,7 @@ fn bisection_lower_test(tc: TestBisection<AnonLightBlock>) {
trusted_height = trusted_height.increment();
}

tc.height_to_verify = (trusted_height.value() - 1).into();
tc.height_to_verify = (trusted_height.value() - 1).try_into().unwrap();

let test_result = run_bisection_test(tc);
match test_result.new_states {
Expand Down
Loading