Skip to content

Commit

Permalink
Bugfix: trimmed metadata hash comparison fails in `is_codegen_valid_f…
Browse files Browse the repository at this point in the history
…or` (#1306)

* cargo: Switch to workspace lints (#1299)

* subxt: Remove unstable lints that cause compile warnings

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Switch to workspace lints

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Fix codec package at root level

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Move profiles to the root level

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Fix lightclient and metadata crates

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Revert "cargo: Fix codec package at root level"

This reverts commit cdf9e16.

* Fix complexity clippy

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Remove lints to be replaced by `cargo machete`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Remove unused dependencies (detected by machete)

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Add machete step

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Bump rust version

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Rename machete step

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Rename cargo machete step

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* test and outer enum pre compute

* explicit OuterEnumHashes type

* clippy

* move outer enums to their own module

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
tadeohepperle authored Dec 6, 2023
1 parent c3b4331 commit c3e02e7
Show file tree
Hide file tree
Showing 3 changed files with 375 additions and 127 deletions.
11 changes: 5 additions & 6 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ mod utils;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use std::collections::HashMap;
use std::sync::Arc;
use utils::ordered_map::OrderedMap;
use utils::variant_index::VariantIndex;
use utils::{ordered_map::OrderedMap, validation::outer_enum_hashes::OuterEnumHashes};

type ArcStr = Arc<str>;

Expand Down Expand Up @@ -163,7 +163,7 @@ impl Metadata {
Some(crate::utils::validation::get_type_hash(
&self.types,
id,
&mut HashMap::new(),
&OuterEnumHashes::empty(),
))
}

Expand Down Expand Up @@ -324,7 +324,7 @@ impl<'a> PalletMetadata<'a> {

/// Return a hash for the entire pallet.
pub fn hash(&self) -> [u8; HASH_LEN] {
crate::utils::validation::get_pallet_hash(*self)
crate::utils::validation::get_pallet_hash(*self, &OuterEnumHashes::empty())
}
}

Expand Down Expand Up @@ -643,7 +643,7 @@ impl<'a> RuntimeApiMetadata<'a> {

/// Return a hash for the runtime API trait.
pub fn hash(&self) -> [u8; HASH_LEN] {
crate::utils::validation::get_runtime_trait_hash(*self)
crate::utils::validation::get_runtime_trait_hash(*self, &OuterEnumHashes::empty())
}
}

Expand Down Expand Up @@ -766,8 +766,7 @@ impl<'a> CustomValueMetadata<'a> {

/// Calculates the hash for the CustomValueMetadata.
pub fn hash(&self) -> [u8; HASH_LEN] {
let mut cache = HashMap::new();
get_custom_value_hash(self, &mut cache)
get_custom_value_hash(self, &OuterEnumHashes::empty())
}
}

Expand Down
Loading

0 comments on commit c3e02e7

Please sign in to comment.