Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
drewstone committed Jun 14, 2024
1 parent 23695e9 commit b193235
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 216 deletions.
20 changes: 5 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ hyperspace-metrics = { path = "hyperspace/metrics" }
subxt = { git = "https://github.com/paritytech/subxt", tag = "v0.37.0", features = ["substrate-compat"] }
subxt-core = { git = "https://github.com/paritytech/subxt", tag = "v0.37.0", features = ["substrate-compat"] }
subxt-generated = { path = "utils/subxt/generated" }

scale-decode = { version = "0.13.0", default-features = false }
scale-encode = { version = "0.7.0", default-features = false }
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }

# orml
# orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library" }
Expand Down Expand Up @@ -330,8 +332,6 @@ rand = { version = "0.8.5" }
ripemd = { version = "0.1.3" }
rs_merkle = { version = "1.2.0" }
safe-regex = { version = "0.2.5", default-features = false }
scale-info = { version = "2.11.0", default-features = false, features = ["derive"] }
scale-encode = { version = "0.1.2", default-features = false }
schemars = { version = "0.8.10" }
serde = { version = "1.0.193", features = ["derive"], default-features = false }
serde_json = { version = "1.0.109", default-features = false }
Expand Down
8 changes: 3 additions & 5 deletions algorithms/beefy/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ use sp_core::{hexdisplay::AsBytesRef, keccak_256, H256};
use sp_io::crypto;
use sp_mmr_primitives::Proof;
use sp_runtime::traits::BlakeTwo256;
use subxt::{
config::{Header as HeaderT, Header},
Config, OnlineClient,
};
use subxt::{backend::rpc::RpcClient, config::Header, rpc_params, Config, OnlineClient};

use crate::relay_chain_queries::parachain_header_storage_key;
use light_client_common::config::{AsInner, BeefyAuthoritySetT, RuntimeStorage};
Expand Down Expand Up @@ -112,6 +109,7 @@ where
// In development mode validators are the same for all sessions only validator set_id
// changes
let client = client.expect("Client should be defined");
let rpc_client: RpcClient = client.backend();
let latest_beefy_finalized: <T as Config>::Hash =
client.rpc().request("beefy_getFinalizedHead", rpc_params!()).await.unwrap();
let header = client.rpc().header(Some(latest_beefy_finalized)).await.unwrap().unwrap();
Expand Down Expand Up @@ -299,7 +297,7 @@ where
&self,
_signed_commitment: sp_consensus_beefy::SignedCommitment<
u32,
sp_consensus_beefy::crypto::Signature,
sp_consensus_beefy::ecdsa_crypto::Signature,
>,
) -> Result<MmrUpdateProof, Error> {
todo!("fetch beefy authorities")
Expand Down
12 changes: 7 additions & 5 deletions algorithms/beefy/prover/src/relay_chain_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

use crate::error::Error;
// use light_client_common::config::{AsInner, ParaLifecycleT, RuntimeStorage};
use light_client_common::config::{AsInner, ParaLifecycleT, RuntimeStorage};
use mmr_rpc::LeavesProof;
use parity_scale_codec::{Decode, Encode};
use sp_consensus_beefy::{SignedCommitment, VersionedFinalityProof};
use sp_core::{hexdisplay::AsBytesRef, storage::StorageKey, H256};
use sp_runtime::traits::Zero;
use std::collections::{BTreeMap, BTreeSet};
use subxt::{config::Header, Config, OnlineClient};
use subxt::{config::Header, rpc_params, Config, OnlineClient};

/// This contains the leaf indices of the relay chain blocks and a map of relay chain heights to a
/// map of all parachain headers at those heights Used for generating [`ParaHeadsProof`]
Expand All @@ -45,7 +46,8 @@ where
<<T as Config>::Header as Header>::Number: Ord + Zero,
<T as subxt::Config>::Header: Decode,
{
let subxt_block_number: subxt::rpc::types::BlockNumber = commitment_block_number.into();
let subxt_block_number: subxt::backend::legacy::rpc_methods::BlockNumber =
commitment_block_number.into();
let block_hash = client.rpc().block_hash(Some(subxt_block_number)).await?.ok_or_else(|| {
Error::Custom(format!("Block hash not found for block number {}", commitment_block_number))
})?;
Expand All @@ -69,7 +71,7 @@ where
para_ids.push(id);
}
}
let previous_finalized_block_number: subxt::rpc::types::BlockNumber =
let previous_finalized_block_number: subxt::backend::legacy::rpc_methods::BlockNumber =
(latest_beefy_height + 1).into();
let previous_finalized_hash = client
.rpc()
Expand Down Expand Up @@ -131,7 +133,7 @@ where
/// Get beefy justification for latest finalized beefy block
pub async fn fetch_beefy_justification<T: Config>(
client: &OnlineClient<T>,
) -> Result<(SignedCommitment<u32, sp_consensus_beefy::crypto::Signature>, T::Hash), Error> {
) -> Result<(SignedCommitment<u32, sp_consensus_beefy::ecdsa_crypto::Signature>, T::Hash), Error> {
let latest_beefy_finalized: <T as Config>::Hash =
client.rpc().request("beefy_getFinalizedHead", rpc_params!()).await?;
let block = client
Expand All @@ -152,7 +154,7 @@ pub async fn fetch_beefy_justification<T: Config>(
.expect("Should have valid beefy justification");
let VersionedFinalityProof::V1(signed_commitment) = VersionedFinalityProof::<
u32,
sp_consensus_beefy::crypto::Signature,
sp_consensus_beefy::ecdsa_crypto::Signature,
>::decode(&mut &*beefy_justification)
.expect("Beefy justification should decode correctly");

Expand Down
4 changes: 2 additions & 2 deletions algorithms/beefy/verifier/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async fn test_verify_mmr_with_proof() {
{
let beefy_version_finality_proof: VersionedFinalityProof<
u32,
sp_consensus_beefy::crypto::Signature,
sp_consensus_beefy::ecdsa_crypto::Signature,
> = parity_scale_codec::Decode::decode(&mut &*encoded_versioned_finality_proof.0 .0).unwrap();

let signed_commitment = match beefy_version_finality_proof {
Expand Down Expand Up @@ -241,7 +241,7 @@ async fn verify_parachain_headers() {
{
let beefy_version_finality_proof: VersionedFinalityProof<
u32,
sp_consensus_beefy::crypto::Signature,
sp_consensus_beefy::ecdsa_crypto::Signature,
> = parity_scale_codec::Decode::decode(&mut &*encoded_versioned_finality_proof.0 .0).unwrap();

let signed_commitment = match beefy_version_finality_proof {
Expand Down
2 changes: 1 addition & 1 deletion hyperspace/core/src/substrate/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ macro_rules! define_runtime_storage {

fn beefy_authorities() -> LocalAddress<
StaticStorageMapKey,
Vec<sp_consensus_beefy::crypto::Public>,
Vec<sp_consensus_beefy::ecdsa_crypto::Public>,
Yes,
Yes,
(),
Expand Down
2 changes: 1 addition & 1 deletion hyperspace/parachain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type GrandpaJustification = grandpa_light_client_primitives::justification::Gran
>;

type BeefyJustification =
sp_consensus_beefy::SignedCommitment<u32, sp_consensus_beefy::crypto::Signature>;
sp_consensus_beefy::SignedCommitment<u32, sp_consensus_beefy::ecdsa_crypto::Signature>;

/// An encoded justification proving that the given header has been finalized
#[derive(Clone, serde::Serialize, serde::Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion hyperspace/parachain/src/finality_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub enum FinalityEvent {
polkadot_core_primitives::Header,
>,
),
Beefy(sp_consensus_beefy::SignedCommitment<u32, sp_consensus_beefy::crypto::Signature>),
Beefy(sp_consensus_beefy::SignedCommitment<u32, sp_consensus_beefy::ecdsa_crypto::Signature>),
}

impl FinalityProtocol {
Expand Down
2 changes: 1 addition & 1 deletion hyperspace/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ where
&self,
signed_commitment: sp_consensus_beefy::SignedCommitment<
u32,
sp_consensus_beefy::crypto::Signature,
sp_consensus_beefy::ecdsa_crypto::Signature,
>,
) -> Result<MmrUpdateProof, Error> {
let prover = Prover {
Expand Down
3 changes: 2 additions & 1 deletion light-clients/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ std = [
"sp-core/std",
"sp-runtime/std"
]
enable-subxt = ["subxt", "subxt-core"]
enable-subxt = ["subxt", "subxt-core", "scale-decode"]

[dependencies]
# crates.io
Expand All @@ -44,3 +44,4 @@ sp-runtime = { workspace = true }
sp-consensus-beefy = { workspace = true, default-features = false }
subxt = { workspace = true, optional = true }
subxt-core = { workspace = true, optional = true }
scale-decode = { workspace = true, optional = true }
Loading

0 comments on commit b193235

Please sign in to comment.