Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 0.9.31 #759

Merged
merged 38 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a9efedc
fix runtime
mike1729 Nov 22, 2022
d6eea08
fix aleph-node
mike1729 Nov 22, 2022
6488f27
bump spec version
mike1729 Nov 22, 2022
91c73d9
bump versions
kostekIV Nov 22, 2022
1b7c272
update runtime in aleph-client
kostekIV Nov 22, 2022
f18fee2
Temporarily remove try-runtime
mike1729 Nov 22, 2022
ca2d0a5
review nits
mike1729 Nov 22, 2022
0582d42
Fix pallets
mike1729 Nov 22, 2022
0b3ea60
fix runtime
mike1729 Nov 22, 2022
749c3d1
fix aleph-node
mike1729 Nov 22, 2022
7d1aff2
fix migrations
mike1729 Nov 22, 2022
5f0c429
Fix tomls
mike1729 Nov 22, 2022
b21e711
fix runtime
mike1729 Nov 22, 2022
788f00e
Merge branch 'main' into update_to_0.9.31
kostekIV Nov 28, 2022
086c193
Merge branch 'main' into update_to_0.9.31
kostekIV Nov 29, 2022
b5a5918
remove contracts rpc + clap upgrade
kostekIV Nov 29, 2022
a653719
Merge remote-tracking branch 'origin/update_to_0.9.31' into update_to…
kostekIV Nov 29, 2022
4526050
fix multiple yes args
kostekIV Nov 29, 2022
7d454f1
fix runtime weights
kostekIV Nov 29, 2022
8c17186
Merge branch 'main' into update_to_0.9.31
mike1729 Nov 29, 2022
7419f38
cargo update
mike1729 Nov 29, 2022
88f357d
fix try-runtime
mike1729 Nov 29, 2022
0ff9f1d
fmt
mike1729 Nov 29, 2022
f165696
fix aleph-client
kostekIV Nov 29, 2022
4b03041
Merge remote-tracking branch 'origin/update_to_0.9.31' into update_to…
kostekIV Nov 29, 2022
37d6d53
fix cliain
kostekIV Nov 29, 2022
bb903b6
lint
kostekIV Nov 29, 2022
9452d3d
clippy
kostekIV Nov 29, 2022
842a3b2
lints etc
kostekIV Nov 29, 2022
aec4007
more lints
kostekIV Nov 29, 2022
dc387a2
more lints
kostekIV Nov 29, 2022
8ea2e10
even more lints
kostekIV Nov 30, 2022
89826f1
even more lints
kostekIV Nov 30, 2022
0c1a53f
use snake case
kostekIV Nov 30, 2022
e141194
Merge branch 'main' into update_to_0.9.31
kostekIV Nov 30, 2022
8a3a5bd
lint
kostekIV Dec 1, 2022
9df0e75
Merge branch 'update_to_0.9.31' of github.com:Cardinal-Cryptography/a…
kostekIV Dec 1, 2022
8f0a22a
Merge remote-tracking branch 'origin/main' into update_to_0.9.31
kostekIV Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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