Skip to content

Commit

Permalink
Update to 0.9.31 (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike1729 authored Dec 1, 2022
1 parent 8fc5f7e commit 7d41148
Show file tree
Hide file tree
Showing 44 changed files with 4,876 additions and 5,951 deletions.
2,155 changes: 649 additions & 1,506 deletions Cargo.lock

Large diffs are not rendered by default.

993 changes: 495 additions & 498 deletions aleph-client/Cargo.lock

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions aleph-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph_client"
version = "2.2.0"
version = "2.3.0"
edition = "2021"
license = "Apache 2.0"

Expand All @@ -12,16 +12,15 @@ hex = { version = "0.4.3", features = ["alloc"] }
log = "0.4"
serde_json = { version = "1.0" }
thiserror = "1.0"
contract-metadata = "1.5"
contract-transcode = "0.1"
ink_metadata = "3.3"
subxt = "0.24.0"
contract-metadata = "2.0.0-beta"
contract-transcode = "2.0.0-beta"
ink_metadata = "4.0.0-beta"
subxt = "0.25.0"
futures = "0.3.25"
serde = { version = "1.0", features = ["derive"] }

frame-support = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sp-core = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30", features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
pallet-contracts-primitives = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }

frame-support = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.31" }
sp-core = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.31", features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.31" }
pallet-contracts-primitives = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.31" }
primitives = { path = "../primitives" }
1,067 changes: 591 additions & 476 deletions aleph-client/src/aleph_zero.rs

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ pub trait SudoCall {
impl SudoCall for RootConnection {
async fn sudo_unchecked(&self, call: Call, status: TxStatus) -> anyhow::Result<BlockHash> {
info!(target: "aleph-client", "sending call as sudo_unchecked {:?}", call);
let sudo = api::tx()
.sudo()
.sudo_unchecked_weight(call, Weight { ref_time: 0 });
let sudo = api::tx().sudo().sudo_unchecked_weight(
call,
Weight {
ref_time: 0,
proof_size: 0,
},
);

self.as_signed().send_tx(sudo, status).await
}
Expand Down
16 changes: 8 additions & 8 deletions aleph-client/src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ use std::{
fs::File,
};

use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result};
use codec::{Compact, Decode};
use contract_metadata::ContractMetadata;
use contract_transcode::ContractMessageTranscoder;
use ink_metadata::{InkProject, MetadataVersioned};
use ink_metadata::InkProject;
use serde_json::{from_reader, from_value};

use crate::{
Expand All @@ -67,6 +67,7 @@ use crate::{
pub struct ContractInstance {
address: AccountId,
ink_project: InkProject,
transcoder: ContractMessageTranscoder,
}

impl ContractInstance {
Expand All @@ -80,6 +81,7 @@ impl ContractInstance {
Ok(Self {
address,
ink_project: load_metadata(metadata_path)?,
transcoder: ContractMessageTranscoder::new(load_metadata(metadata_path)?),
})
}

Expand Down Expand Up @@ -112,6 +114,7 @@ impl ContractInstance {
value: 0,
gas_limit: Weight {
ref_time: Self::MAX_READ_GAS,
proof_size: u64::MAX,
},
input_data: payload,
storage_deposit_limit: None,
Expand Down Expand Up @@ -139,6 +142,7 @@ impl ContractInstance {
Self::PAYABLE_VALUE as u128,
Weight {
ref_time: Self::MAX_GAS,
proof_size: u64::MAX,
},
Self::STORAGE_FEE_LIMIT,
data,
Expand All @@ -151,7 +155,7 @@ impl ContractInstance {
}

fn encode(&self, message: &str, args: &[&str]) -> Result<Vec<u8>> {
ContractMessageTranscoder::new(&self.ink_project).encode(message, args)
self.transcoder.encode(message, args)
}
}

Expand All @@ -174,9 +178,5 @@ fn load_metadata(path: &str) -> Result<InkProject> {
let metadata: ContractMetadata = from_reader(file)?;
let ink_metadata = from_value(serde_json::Value::Object(metadata.abi))?;

if let MetadataVersioned::V3(ink_project) = ink_metadata {
Ok(ink_project)
} else {
Err(anyhow!("Unsupported ink metadata version. Expected V3"))
}
Ok(ink_metadata)
}
2 changes: 1 addition & 1 deletion aleph-client/src/pallets/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl ContractRpc for Connection {

let res: ContractExecResult<Balance> =
self.rpc_call("state_call".to_string(), params).await?;
let res = T::decode(&mut (res.result.unwrap().data.0.as_slice()))?;
let res = T::decode(&mut (res.result.unwrap().data.as_slice()))?;

Ok(res)
}
Expand Down
4 changes: 2 additions & 2 deletions aleph-client/src/pallets/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl StakingRawApi for Connection {
) -> Vec<StorageKey> {
let key_addrs = api::storage().staking().eras_stakers_root();
let mut key = key_addrs.to_root_bytes();
StorageMapKey::new(&era, StorageHasher::Twox64Concat).to_bytes(&mut key);
StorageMapKey::new(era, StorageHasher::Twox64Concat).to_bytes(&mut key);
self.client
.storage()
.fetch_keys(&key, 10, None, at)
Expand All @@ -319,7 +319,7 @@ impl StakingRawApi for Connection {
) -> Vec<StorageKey> {
let key_addrs = api::storage().staking().eras_stakers_root();
let mut key = key_addrs.to_root_bytes();
StorageMapKey::new(&era, StorageHasher::Twox64Concat).to_bytes(&mut key);
StorageMapKey::new(era, StorageHasher::Twox64Concat).to_bytes(&mut key);
accounts
.iter()
.map(|account| {
Expand Down
7 changes: 5 additions & 2 deletions aleph-client/src/runtime_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ impl TryFrom<String> for SessionKeys {
}

impl Weight {
pub fn new(ref_time: u64) -> Self {
Self { ref_time }
pub fn new(ref_time: u64, proof_size: u64) -> Self {
Self {
ref_time,
proof_size,
}
}
}
32 changes: 12 additions & 20 deletions aleph-client/src/waiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ pub trait WaitingExt {
impl AlephWaiting for Connection {
async fn wait_for_block<P: Fn(u32) -> bool + Send>(&self, predicate: P, status: BlockStatus) {
let mut block_sub = match status {
BlockStatus::Best => self.client.rpc().subscribe_blocks().await.unwrap(),
BlockStatus::Finalized => self
.client
.rpc()
.subscribe_finalized_blocks()
.await
.unwrap(),
BlockStatus::Best => self.client.blocks().subscribe_best().await.unwrap(),
BlockStatus::Finalized => self.client.blocks().subscribe_finalized().await.unwrap(),
};

while let Some(Ok(block)) = block_sub.next().await {
if predicate(block.number) {
if predicate(block.number()) {
return;
}
}
Expand All @@ -58,24 +53,19 @@ impl AlephWaiting for Connection {
predicate: P,
status: BlockStatus,
) -> T {
let mut event_sub = match status {
BlockStatus::Best => self.client.events().subscribe().await.unwrap().boxed(),
BlockStatus::Finalized => self
.client
.events()
.subscribe_finalized()
.await
.unwrap()
.boxed(),
let mut block_sub = match status {
BlockStatus::Best => self.client.blocks().subscribe_best().await.unwrap(),
BlockStatus::Finalized => self.client.blocks().subscribe_finalized().await.unwrap(),
};

info!(target: "aleph-client", "waiting for event {}.{}", T::PALLET, T::EVENT);

loop {
let events = match event_sub.next().await {
Some(Ok(events)) => events,
while let Some(Ok(block)) = block_sub.next().await {
let events = match block.events().await {
Ok(events) => events,
_ => continue,
};

for event in events.iter() {
let event = event.unwrap();
if let Ok(Some(ev)) = event.as_event::<T>() {
Expand All @@ -85,6 +75,8 @@ impl AlephWaiting for Connection {
}
}
}

panic!("No more blocks");
}

async fn wait_for_era(&self, era: EraIndex, status: BlockStatus) {
Expand Down
Loading

0 comments on commit 7d41148

Please sign in to comment.