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 polkadot-v0.9.29 #1053

Merged
merged 13 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
513 changes: 276 additions & 237 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 27 additions & 17 deletions app-libs/sgx-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,35 @@ scale-info = { version = "2.0.1", default-features = false, features = ["derive"
itp-sgx-runtime-primitives = { path = "../../core-primitives/sgx-runtime-primitives", default-features = false }

# Substrate dependencies
frame-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-system-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-inherents = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-system-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-aura = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-grandpa = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-block-builder = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-consensus-aura = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-inherents = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-offchain = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-session = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }

# Integritee dependencies
pallet-evm = { default-features = false, optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.28" }
pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "develop" }
pallet-evm = { default-features = false, optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.29" }
pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "master" }

[features]
default = ["std"]
Expand Down
14 changes: 7 additions & 7 deletions app-libs/sgx-runtime/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub use pallet_evm::{
pub type HashedAddressMapping = GenericHashedAddressMapping<BlakeTwo256>;

/// Maximum weight per block
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2);

// FIXME: For now just a random value.
pub struct FixedGasPrice;
impl FeeCalculator for FixedGasPrice {
fn min_gas_price() -> (U256, u64) {
(1.into(), 1)
fn min_gas_price() -> (U256, Weight) {
(1.into(), Weight::from_ref_time(1))
}
}

Expand All @@ -34,16 +34,16 @@ pub const GAS_PER_SECOND: u64 = 40_000_000;

/// Approximate ratio of the amount of Weight per Gas.
/// u64 works for approximations because Weight is a very small unit compared to gas.
pub const WEIGHT_PER_GAS: u64 = WEIGHT_PER_SECOND / GAS_PER_SECOND;
pub const WEIGHT_PER_GAS: u64 = WEIGHT_PER_SECOND.ref_time() / GAS_PER_SECOND;

pub struct FixedGasWeightMapping;

impl GasWeightMapping for FixedGasWeightMapping {
fn gas_to_weight(gas: u64) -> Weight {
gas.saturating_mul(WEIGHT_PER_GAS)
Weight::from_ref_time(gas.saturating_mul(WEIGHT_PER_GAS))
}
fn weight_to_gas(weight: Weight) -> u64 {
weight.wrapping_div(WEIGHT_PER_GAS)
weight.ref_time().wrapping_div(WEIGHT_PER_GAS)
}
}

Expand All @@ -60,7 +60,7 @@ impl<T: From<H160>> AddressMapping<T> for IntoAddressMapping {

parameter_types! {
pub const ChainId: u64 = 42;
pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WEIGHT_PER_GAS);
pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS);
//pub PrecompilesValue: FrontierPrecompiles<Runtime> = FrontierPrecompiles::<_>::new();
}

Expand Down
4 changes: 2 additions & 2 deletions app-libs/sgx-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsReversedWithSystemFirst,
AllPalletsWithSystem,
>;

/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
Expand Down Expand Up @@ -141,7 +141,7 @@ parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
::with_sensible_defaults(WEIGHT_PER_SECOND.saturating_mul(2), NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u8 = 42;
Expand Down
18 changes: 9 additions & 9 deletions app-libs/stf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ itp-utils = { default-features = false, path = "../../core-primitives/utils" }
sp-io = { default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator"], path = "../../core-primitives/substrate-sgx/sp-io" }

# Substrate dependencies
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-application-crypto = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-application-crypto = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-core = { default-features = false, features = ["full_crypto"], git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }

# scs / integritee
my-node-runtime = { package = "integritee-node-runtime", optional = true, git = "https://github.com/integritee-network/integritee-node.git", branch = "master" }
pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "develop" }
pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "master" }


[dev-dependencies]
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }

[features]
default = ["std"]
Expand Down
11 changes: 5 additions & 6 deletions app-libs/stf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use codec::{Compact, Decode, Encode};
use derive_more::Display;
use sp_core::{crypto::AccountId32, ed25519, sr25519, Pair, H256};
use sp_runtime::{traits::Verify, MultiSignature};
use std::string::String;
use std::{boxed::Box, string::String};

pub use getter::*;
pub use stf_sgx_primitives::{types::*, Stf};
Expand Down Expand Up @@ -81,11 +81,10 @@ pub enum StfError {
StorageHashMismatch,
InvalidStorageDiff,
}

#[derive(Clone)]
pub enum KeyPair {
Sr25519(sr25519::Pair),
Ed25519(ed25519::Pair),
Sr25519(Box<sr25519::Pair>),
Ed25519(Box<ed25519::Pair>),
}

impl KeyPair {
Expand All @@ -99,13 +98,13 @@ impl KeyPair {

impl From<ed25519::Pair> for KeyPair {
fn from(x: ed25519::Pair) -> Self {
KeyPair::Ed25519(x)
KeyPair::Ed25519(Box::new(x))
}
}

impl From<sr25519::Pair> for KeyPair {
fn from(x: sr25519::Pair) -> Self {
KeyPair::Sr25519(x)
KeyPair::Sr25519(Box::new(x))
}
}

Expand Down
8 changes: 6 additions & 2 deletions app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,12 @@ mod tests {
42,
42,
);
let signed_call =
call.sign(&KeyPair::Sr25519(AccountKeyring::Alice.pair()), nonce, &mrenclave, &shard);
let signed_call = call.sign(
&KeyPair::Sr25519(Box::new(AccountKeyring::Alice.pair())),
nonce,
&mrenclave,
&shard,
);

assert!(signed_call.verify_signature(&mrenclave, &shard));
}
Expand Down
22 changes: 11 additions & 11 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ ws = { version = "0.9.1", features = ["ssl"] }

# scs / integritee
my-node-runtime = { package = "integritee-node-runtime", git = "https://github.com/integritee-network/integritee-node.git", branch = "master" }
pallet-evm = { optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.28" }
substrate-api-client = { features = ["ws-client"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.28" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.28" }
teerex-primitives = { git = "https://github.com/integritee-network/pallets.git", branch = "develop" }
pallet-evm = { optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.29" }
substrate-api-client = { features = ["ws-client"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.29" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.29" }
teerex-primitives = { git = "https://github.com/integritee-network/pallets.git", branch = "master" }

# substrate dependencies
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sc-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sc-keystore = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.29" }

# local dependencies
ita-stf = { path = "../app-libs/stf" }
Expand Down
15 changes: 11 additions & 4 deletions cli/src/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use sgx_crypto_helper::rsa3072::Rsa3072PubKey;
use sp_application_crypto::sr25519;
use sp_core::{sr25519 as sr25519_core, Pair};
use std::{
boxed::Box,
string::ToString,
sync::mpsc::{channel, Receiver},
thread, time,
Expand Down Expand Up @@ -149,7 +150,12 @@ impl BenchmarkCommands {
account.public().into(),
initial_balance,
)
.sign(&KeyPair::Sr25519(funding_account_keys.clone()), nonce, &mrenclave, &shard)
.sign(
&KeyPair::Sr25519(Box::new(funding_account_keys.clone())),
nonce,
&mrenclave,
&shard,
)
.into_trusted_operation(trusted_args.direct);

// For the last account we wait for confirmation in order to ensure all accounts were setup correctly
Expand Down Expand Up @@ -201,7 +207,7 @@ impl BenchmarkCommands {
new_account.public().into(),
EXISTENTIAL_DEPOSIT,
)
.sign(&KeyPair::Sr25519(client.account.clone()), nonce, &mrenclave, &shard)
.sign(&KeyPair::Sr25519(Box::new(client.account.clone())), nonce, &mrenclave, &shard)
.into_trusted_operation(trusted_args.direct);

let last_iteration = i == self.number_iterations - 1;
Expand Down Expand Up @@ -251,7 +257,7 @@ fn get_balance(
) -> Option<u128> {
let getter = Getter::trusted(
TrustedGetter::free_balance(account.public().into())
.sign(&KeyPair::Sr25519(account.clone())),
.sign(&KeyPair::Sr25519(Box::new(account.clone()))),
);

let getter_start_timer = Instant::now();
Expand All @@ -270,7 +276,8 @@ fn get_nonce(
direct_client: &DirectClient,
) -> Index {
let getter = Getter::trusted(
TrustedGetter::nonce(account.public().into()).sign(&KeyPair::Sr25519(account.clone())),
TrustedGetter::nonce(account.public().into())
.sign(&KeyPair::Sr25519(Box::new(account.clone()))),
);

let getter_start_timer = Instant::now();
Expand Down
4 changes: 2 additions & 2 deletions cli/src/evm/commands/evm_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use ita_stf::{Index, KeyPair, TrustedCall, TrustedGetter, TrustedOperation};
use itp_types::AccountId;
use log::*;
use sp_core::{crypto::Ss58Codec, Pair, H160, U256};
use std::vec::Vec;
use std::{boxed::Box, vec::Vec};
use substrate_api_client::utils::FromHexString;

#[derive(Parser)]
Expand Down Expand Up @@ -78,7 +78,7 @@ impl EvmCallCommands {
Some(U256::from(evm_nonce)),
Vec::new(),
)
.sign(&KeyPair::Sr25519(sender), nonce, &mrenclave, &shard)
.sign(&KeyPair::Sr25519(Box::new(sender)), nonce, &mrenclave, &shard)
.into_trusted_operation(trusted_args.direct);
let _ = perform_trusted_operation(cli, trusted_args, &function_call);
}
Expand Down
3 changes: 1 addition & 2 deletions cli/src/evm/commands/evm_command_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
limitations under the License.

*/

#[macro_export]
macro_rules! get_layer_two_evm_nonce {
($signer_pair:ident, $cli:ident, $trusted_args:ident ) => {{
let top: TrustedOperation = TrustedGetter::evm_nonce($signer_pair.public().into())
.sign(&KeyPair::Sr25519($signer_pair.clone()))
.sign(&KeyPair::Sr25519(Box::new($signer_pair.clone())))
.into();
let res = perform_trusted_operation($cli, $trusted_args, &top);
let nonce: Index = if let Some(n) = res {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/evm/commands/evm_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ita_stf::{KeyPair, TrustedGetter, TrustedOperation};
use itp_types::AccountId;
use log::*;
use sp_core::{crypto::Ss58Codec, Pair, H160, H256};
use std::vec::Vec;
use std::{boxed::Box, vec::Vec};
use substrate_api_client::utils::FromHexString;

#[derive(Parser)]
Expand Down Expand Up @@ -55,7 +55,7 @@ impl EvmReadCommands {

let top: TrustedOperation =
TrustedGetter::evm_account_storages(sender_acc, execution_address, H256::zero())
.sign(&KeyPair::Sr25519(sender))
.sign(&KeyPair::Sr25519(Box::new(sender)))
.into();
let res = perform_trusted_operation(cli, trusted_args, &top);

Expand Down
3 changes: 2 additions & 1 deletion cli/src/trusted_base_cli/commands/set_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use ita_stf::{Index, KeyPair, TrustedCall, TrustedGetter, TrustedOperation};
use log::*;
use my_node_runtime::Balance;
use sp_core::{crypto::Ss58Codec, Pair};
use std::boxed::Box;

#[derive(Parser)]
pub struct SetBalanceCommand {
Expand All @@ -53,7 +54,7 @@ impl SetBalanceCommand {
self.amount,
self.amount,
)
.sign(&KeyPair::Sr25519(signer), nonce, &mrenclave, &shard)
.sign(&KeyPair::Sr25519(Box::new(signer)), nonce, &mrenclave, &shard)
.into_trusted_operation(trusted_args.direct);
let _ = perform_trusted_operation(cli, trusted_args, &top);
}
Expand Down
Loading