-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial new commit struct * update functions * fixed deserialization for new commit struct * updated links to generator + val_set_test file * Ismail/commit struct followup (#182) * initial new commit struct * update functions * fixed deserialization for new commit struct * updated links to generator + val_set_test file * Update tendermint/src/account.rs Co-Authored-By: Ismail Khoffi <[email protected]> * fmt * clippy * rpc tests: grab latest example fro commit: - use https://docs.tendermint.com/master/rpc/#/Info/commit - update chain_id: cosmoshub-1 to cosmoshub-2 everywhere else - manually kept `id` a string in JSONrpc responses * Actually let's go cosmoshub-3: - grabbed from: https://rpc.cosmos.network/commit?height=2 * Fix commit test - regenerated commit.json via `curl -X GET "http://localhost:26657/commit?height=10" -H "accept: application/json"` * Fix block test - "regenerated" block.json via `curl -X GET "http://localhost:26657/block?height=10" -H "accept: application/json"` * Fix first_block test - "regenerated" block.json via `curl -X GET "http://localhost:26657/block?height=1" -H "accept: application/json" ` Co-authored-by: Shivani Joshi <[email protected]> Co-authored-by: Shivani Joshi <[email protected]> * fix error * more json bisection tests * abci_info struct app_version implemented * Fixed fmt * Updated integration tests to tendermint v0.33 node * update block result response * changes to abci_info and block_results * Removed CircleCI reference and added codecov reference to Cargo * removing unwanted Option from DeliverTx struct fields * last_block_app_hash is now Option<Vec<u8>> * AbciInfo.last_block_app_hash is base64 encoded instead of hex * last_block_app_hash changed to Vec<u8> * Cherry-pick from 87e888b (Liamsi) fix /abci_info & /genesis: - add app_version & use #[serde(default)] to deal with omitted fields in JSON - make app_state in /genesis reply optional - fix string in abci_info test (kvstore wont reply with "GaiaApp") verify tests pass via running `tendermint node --proxy_app=kvstore` and `cargo test -- --nocapture --ignored * [88] Fix JSON ID * [192] Fix abci_info compatibility for v0.33 * [4] block_results test fix * [184][120] Tendermint v0.33 compatibility fixes + integration tests for CI * Added one abci_query test * FMT + get rid of warnings * Relaxed genesis struct AppHash requirements from strict hex to anything * Removed unused Protocol struct * Removed unused Protocol struct * IdType removed and JSON ID made as enum * Duration looks better now * fix fmt * Update tendermint/src/lite_impl/signed_header.rs Co-Authored-By: Ismail Khoffi <[email protected]> * Update tendermint/src/lite_impl/signed_header.rs Co-Authored-By: Ismail Khoffi <[email protected]> * Removed AsRef from JSON ID * Update Proof and ProofOp (#206) * manually update Proof and introduce ProofOp to match the actual JSON encoding * 0.33 branch seems out of date with master, committing to switch back * Fix test * Fix rpc endpoint test (how wasn't this detected before by the integration tests)? * Add missing serializer for TrustThresholdFraction fields (#210) * commit followup (#199) * rename iter -> signed_votes and add validation checks - add basic validation to validate method (depending on `BlockIDFlag`) - move check for unknown validator to validate method (for CommitSig) Co-authored-by: Shivani Joshi <[email protected]> Co-authored-by: Ismail Khoffi <[email protected]> Co-authored-by: Shivani Joshi <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]>
- Loading branch information
1 parent
56400a3
commit 3003fef
Showing
47 changed files
with
18,872 additions
and
15,939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,61 @@ | ||
//! ABCI Merkle proofs | ||
|
||
use crate::error::Error; | ||
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; | ||
use std::{ | ||
fmt::{self, Display}, | ||
str::FromStr, | ||
}; | ||
use subtle_encoding::{Encoding, Hex}; | ||
|
||
/// ABCI Merkle proofs | ||
#[derive(Clone, Debug, Eq, Hash, PartialEq)] | ||
pub struct Proof(Vec<u8>); | ||
|
||
impl AsRef<[u8]> for Proof { | ||
fn as_ref(&self) -> &[u8] { | ||
self.0.as_ref() | ||
} | ||
} | ||
|
||
impl Display for Proof { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!( | ||
f, | ||
"{}", | ||
&Hex::upper_case().encode_to_string(&self.0).unwrap() | ||
) | ||
} | ||
use crate::serializers; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Proof is Merkle proof defined by the list of ProofOps | ||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] | ||
pub struct Proof { | ||
/// The list of ProofOps | ||
pub ops: Vec<ProofOp>, | ||
} | ||
|
||
impl FromStr for Proof { | ||
type Err = Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Error> { | ||
let bytes = Hex::upper_case().decode(s)?; | ||
Ok(Proof(bytes)) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for Proof { | ||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
let hex = String::deserialize(deserializer)?; | ||
Ok(Self::from_str(&hex).map_err(|e| D::Error::custom(format!("{}", e)))?) | ||
} | ||
/// ProofOp defines an operation used for calculating Merkle root | ||
/// The data could be arbitrary format, providing necessary data | ||
/// for example neighbouring node hash | ||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] | ||
pub struct ProofOp { | ||
/// Type of the ProofOp | ||
#[serde(alias = "type")] | ||
pub field_type: String, | ||
/// Key of the ProofOp | ||
#[serde( | ||
default, | ||
serialize_with = "serializers::serialize_base64", | ||
deserialize_with = "serializers::parse_base64" | ||
)] | ||
pub key: Vec<u8>, | ||
/// Actual data | ||
#[serde( | ||
default, | ||
serialize_with = "serializers::serialize_base64", | ||
deserialize_with = "serializers::parse_base64" | ||
)] | ||
pub data: Vec<u8>, | ||
} | ||
|
||
impl Serialize for Proof { | ||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { | ||
self.to_string().serialize(serializer) | ||
#[cfg(test)] | ||
mod test { | ||
use super::Proof; | ||
use crate::test::test_serialization_roundtrip; | ||
|
||
#[test] | ||
fn serialization_roundtrip() { | ||
let payload = r#" | ||
{ | ||
"ops": [ | ||
{ | ||
"type": "iavl:v", | ||
"key": "Y29uc2Vuc3VzU3RhdGUvaWJjb25lY2xpZW50LzIy", | ||
"data": "8QEK7gEKKAgIEAwYHCIgG9RAkJgHlxNjmyzOW6bUAidhiRSja0x6+GXCVENPG1oKKAgGEAUYFyIgwRns+dJvjf1Zk2BaFrXz8inPbvYHB7xx2HCy9ima5f8KKAgEEAMYFyogOr8EGajEV6fG5fzJ2fAAvVMgRLhdMJTzCPlogl9rxlIKKAgCEAIYFyIgcjzX/a+2bFbnNldpawQqZ+kYhIwz5r4wCUzuu1IFW04aRAoeY29uc2Vuc3VzU3RhdGUvaWJjb25lY2xpZW50LzIyEiAZ1uuG60K4NHJZZMuS9QX6o4eEhica5jIHYwflRiYkDBgX" | ||
}, | ||
{ | ||
"type": "multistore", | ||
"key": "aWJj", | ||
"data": "CvEECjAKBGJhbmsSKAomCIjYAxIg2MEyyonbZButYnvSRkf2bPQg+nqA+Am1MeDxG6F4p1UKLwoDYWNjEigKJgiI2AMSIN2YHczeuXNvyetrSFQpkCcJzfB6PXVCw0i/XShMgPnIChEKB3VwZ3JhZGUSBgoECIjYAwovCgNnb3YSKAomCIjYAxIgYM0TfBli7KxhY4nWgDSDPykhUJwtKFql9RU5l86WinQKLwoDaWJjEigKJgiI2AMSIFp6aJASeInQKF8y824zjmgcFORN6M+ECbgFfJkobKs8CjAKBG1haW4SKAomCIjYAxIgsZzwmLQ7PH1UeZ/vCUSqlQmfgt3CGfoMgJLkUqKCv0EKMwoHc3Rha2luZxIoCiYIiNgDEiCiBZoBLyDGj5euy3n33ik+SpqYK9eB5xbI+iY8ycYVbwo0CghzbGFzaGluZxIoCiYIiNgDEiAJz3gEYuIhdensHU3b5qH5ons2quepd6EaRgCHXab6PQoyCgZzdXBwbHkSKAomCIjYAxIglWLA5/THPTiTxAlaLHOBYFIzEJTmKPznItUwAc8zD+AKEgoIZXZpZGVuY2USBgoECIjYAwowCgRtaW50EigKJgiI2AMSIMS8dZ1j8F6JVVv+hB1rHBZC+gIFJxHan2hM8qDC64n/CjIKBnBhcmFtcxIoCiYIiNgDEiB8VIzExUHX+SvHZFz/P9NM9THnw/gTDDLVReuZX8htLgo4CgxkaXN0cmlidXRpb24SKAomCIjYAxIg3u/Nd4L+8LT8OXJCh14o8PHIJ/GLQwsmE7KYIl1GdSYKEgoIdHJhbnNmZXISBgoECIjYAw==" | ||
} | ||
] | ||
}"#; | ||
test_serialization_roundtrip::<Proof>(payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.