Skip to content

Commit

Permalink
remove unneeded json serde for BadEncodingFraudProof
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Nov 12, 2024
1 parent 1a0b9be commit 8f383b6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion node/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ use std::time::Duration;

use blockstore::Blockstore;
use celestia_proto::p2p::pb::{header_request, HeaderRequest};
use celestia_types::fraud_proof::BadEncodingFraudProof;
use celestia_types::hash::Hash;
use celestia_types::nmt::{Namespace, NamespacedSha2Hasher};
use celestia_types::row::{Row, RowId};
use celestia_types::row_namespace_data::{RowNamespaceData, RowNamespaceDataId};
use celestia_types::sample::{Sample, SampleId};
use celestia_types::{fraud_proof::BadEncodingFraudProof, hash::Hash};
use celestia_types::{Blob, ExtendedHeader, FraudProof};
use cid::Cid;
use futures::stream::FuturesOrdered;
Expand Down
4 changes: 0 additions & 4 deletions proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const SERIALIZED_DEFAULT: &str =
r#"#[derive(::serde::Deserialize, ::serde::Serialize)] #[serde(default)]"#;
const TRANSPARENT: &str = r#"#[serde(transparent)]"#;
const BASE64STRING: &str = r#"#[serde(with = "crate::serializers::bytes::base64string")]"#;
const QUOTED: &str = r#"#[serde(with = "crate::serializers::from_str")]"#;
const QUOTED_WITH_DEFAULT: &str = r#"#[serde(with = "crate::serializers::from_str", default)]"#;
const VEC_BASE64STRING: &str = r#"#[serde(with = "crate::serializers::bytes::vec_base64string")]"#;
const OPTION_TIMESTAMP: &str = r#"#[serde(with = "crate::serializers::option_timestamp")]"#;
Expand Down Expand Up @@ -43,8 +42,6 @@ static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[
(".cosmos.staking.v1beta1.UnbondingDelegation", SERIALIZED_DEFAULT),
(".cosmos.staking.v1beta1.UnbondingDelegationEntry", SERIALIZED_DEFAULT),
(".header.pb.ExtendedHeader", SERIALIZED_DEFAULT),
(".share.eds.byzantine.pb.BadEncoding", SERIALIZED_DEFAULT),
(".share.eds.byzantine.pb.Share", SERIALIZED_DEFAULT),
(".proof.pb.Proof", SERIALIZED_DEFAULT),
(".proto.blob.v1.BlobProto", SERIALIZED),
(".shwap.AxisType", SERIALIZED),
Expand Down Expand Up @@ -76,7 +73,6 @@ static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
(".cosmos.base.query.v1beta1.PageResponse.next_key", BASE64STRING),
(".cosmos.staking.v1beta1.RedelegationEntry.completion_time", OPTION_TIMESTAMP),
(".cosmos.staking.v1beta1.UnbondingDelegationEntry.completion_time", OPTION_TIMESTAMP),
(".share.eds.byzantine.pb.BadEncoding.axis", QUOTED),
(".proof.pb.Proof.leaf_hash", BASE64STRING),
(".proof.pb.Proof.nodes", VEC_BASE64STRING),
(".proto.blob.v1.BlobProto.data", BASE64STRING),
Expand Down
9 changes: 2 additions & 7 deletions types/src/byzantine.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use celestia_proto::share::eds::byzantine::pb::BadEncoding as RawBadEncodingFraudProof;
use celestia_proto::share::eds::byzantine::pb::Share as RawShareWithProof;
use serde::{Deserialize, Serialize};
use tendermint::block::Height;
use tendermint::Hash;
use tendermint_proto::Protobuf;

use crate::bail_validation;
use crate::consts::appconsts;
use crate::eds::AxisType;
use crate::fraud_proof::FraudProof;
use crate::hash::Hash;
use crate::nmt::{Namespace, NamespaceProof, Nmt, NmtExt, NS_SIZE};
use crate::{Error, ExtendedHeader, Result};

Expand All @@ -26,11 +25,7 @@ use crate::{Error, ExtendedHeader, Result};
/// [`Data Availability Sampling`]: https://docs.celestia.org/learn/how-celestia-works/data-availability-layer
/// [`ExtendedDataSquare`]: crate::ExtendedDataSquare
/// [`Share`]: crate::share::Share
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(
try_from = "RawBadEncodingFraudProof",
into = "RawBadEncodingFraudProof"
)]
#[derive(Debug, Clone, PartialEq)]
pub struct BadEncodingFraudProof {
header_hash: Hash,
block_height: Height,
Expand Down
3 changes: 2 additions & 1 deletion types/src/serializers/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::str::FromStr;

use celestia_proto::serializers::cow_str::CowStr;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tendermint::hash::Hash;

Expand All @@ -10,7 +11,7 @@ pub fn deserialize<'de, D>(deserializer: D) -> Result<Hash, D::Error>
where
D: Deserializer<'de>,
{
let hex = Option::<String>::deserialize(deserializer)?.unwrap_or_default();
let hex = Option::<CowStr>::deserialize(deserializer)?.unwrap_or_default();
Hash::from_str(&hex).map_err(serde::de::Error::custom)
}

Expand Down
3 changes: 2 additions & 1 deletion types/src/sync.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use serde::{Deserialize, Serialize};
use tendermint::hash::Hash;
use tendermint::time::Time;

use crate::hash::Hash;

/// A state of the blockchain synchronization.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SyncState {
Expand Down

0 comments on commit 8f383b6

Please sign in to comment.