Skip to content

Commit

Permalink
Small polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
ggawryal committed Aug 16, 2023
1 parent 7965537 commit 521c54a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 2 additions & 4 deletions aleph-client/docker/subxt-integration-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash

subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 --config-path aleph-node/rustfmt.toml > aleph_zero.rs
../generate_interface.sh

diff -y -W 200 --suppress-common-lines aleph_zero.rs aleph-node/aleph-client/src/aleph_zero.rs
diff_exit_code=$?
if [[ ! $diff_exit_code -eq 0 ]]; then
echo "Current runtime metadata is different than versioned in git!"
echo "Run subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 >" \
"src/aleph_zero.rs from aleph-client directory and commit to git."
echo "Run ./generate_interface.sh from aleph-client directory and commit to git."
exit 1
fi
echo "Current runtime metadata and versioned in git matches."
2 changes: 1 addition & 1 deletion aleph-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub type AlephKeyPair = ed25519::Pair;
/// An alias for a type of a key pair that signs chain transactions.
pub type RawKeyPair = sr25519::Pair;
/// An alias for an account id type.
pub type AccountId = sp_runtime::AccountId32;
pub type AccountId = subxt::ext::sp_core::crypto::AccountId32;
/// An alias for a hash type.
pub type CodeHash = H256;
/// An alias for a block hash type.
Expand Down
2 changes: 1 addition & 1 deletion aleph-client/src/pallets/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl Context<Closed> {
self.call_hash
}
/// Read approvers set.
pub fn approvers(&self) -> &HashSet<impl Into<AccountId> + From<AccountId>> {
pub fn approvers(&self) -> &HashSet<AccountId> {
&self.approvers
}
}
Expand Down
15 changes: 9 additions & 6 deletions aleph-client/src/pallets/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ impl StakingSudoApi for RootConnection {
}
}

fn extend_with_twox64_concat_hash<T: Encode>(key: &mut Vec<u8>, value_to_hash: T) {
key.extend(subxt::ext::sp_core::twox_64(&value_to_hash.encode()));
key.extend(&value_to_hash.encode());
}

#[async_trait::async_trait]
impl<C: AsConnection + Sync> StakingRawApi for C {
async fn get_stakers_storage_keys(
Expand All @@ -449,8 +454,8 @@ impl<C: AsConnection + Sync> StakingRawApi for C {
) -> anyhow::Result<Vec<StorageKey>> {
let key_addrs = api::storage().staking().eras_stakers_root();
let mut key = key_addrs.to_root_bytes();
key.extend(subxt::ext::sp_core::twox_64(&era.encode()));
key.extend(&era.encode());
extend_with_twox64_concat_hash(&mut key, era);

let storage = self.as_connection().as_client().storage();
let block = match at {
Some(block_hash) => storage.at(block_hash),
Expand All @@ -467,14 +472,12 @@ impl<C: AsConnection + Sync> StakingRawApi for C {
) -> Vec<StorageKey> {
let key_addrs = api::storage().staking().eras_stakers_root();
let mut key = key_addrs.to_root_bytes();
key.extend(subxt::ext::sp_core::twox_64(&era.encode()));
key.extend(&era.encode());
extend_with_twox64_concat_hash(&mut key, era);
accounts
.iter()
.map(|account| {
let mut key = key.clone();
key.extend(subxt::ext::sp_core::twox_64(&account.encode()));
key.extend(&account.encode());
extend_with_twox64_concat_hash(&mut key, account);

StorageKey(key)
})
Expand Down

0 comments on commit 521c54a

Please sign in to comment.