Skip to content

Commit

Permalink
Update to polkadot-v0.9.27 (#51)
Browse files Browse the repository at this point in the history
* bump: polkadot-v0.9.22 -> polkadot-v0.9.27

* Fix PalletId AccountConversionId method from `into_account` to `try_into_account`

* Fix chain extension

* Fix Contracts pallet

* Updated multiple pallet config

* Bump node

* Update mock environment

* Update extension values
- (bug) Chain extension limits value to uint8

* change into_account_truncating to try_into_account
  • Loading branch information
realnimish authored Aug 23, 2022
1 parent 0ea50bd commit c11e543
Show file tree
Hide file tree
Showing 49 changed files with 994 additions and 788 deletions.
1,010 changes: 499 additions & 511 deletions Cargo.lock

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "laguna-node"
targets = ['x86_64-unknown-linux-gnu']

[build-dependencies.substrate-build-script-utils]
branch = "polkadot-v0.9.22"
branch = "polkadot-v0.9.27"
git = 'https://github.com/paritytech/substrate.git'
version = '3.0.0'

Expand All @@ -23,51 +23,51 @@ primitives = {path = "../primitives"}
# laguna chain runtime
laguna-runtime = {path = "../runtime"}

sc-basic-authorship = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-cli = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-client-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-consensus = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-consensus-aura = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-executor = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-finality-grandpa = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-rpc-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-service = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-telemetry = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-transaction-pool = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-transaction-pool-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sc-basic-authorship = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-cli = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-client-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-consensus = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-consensus-aura = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-executor = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-finality-grandpa = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-rpc-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-service = {features = ['wasmtime'], git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-telemetry = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-transaction-pool = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sc-transaction-pool-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

# substrate primitives
sp-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-block-builder = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-blockchain = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-consensus = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-consensus-aura = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-core = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-finality-grandpa = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-inherents = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-keyring = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-runtime = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-timestamp = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-api = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-block-builder = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-blockchain = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-consensus = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-consensus-aura = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-core = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-finality-grandpa = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-inherents = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-keyring = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-runtime = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
sp-timestamp = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

substrate-frame-rpc-system = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
substrate-frame-rpc-system = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

pallet-transaction-payment-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-transaction-payment-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

frame-system = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-support = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-contracts-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-system = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
frame-support = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-contracts-rpc = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

pallet-transaction-payment = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-transaction-payment = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-system-contract-deployer = {path = "../pallets/system-contract-deployer", default-features = false}

# requird for benchmark cli-parsing and conduct runtime-benchmark
frame-benchmarking = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-benchmarking-cli = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-benchmarking = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
frame-benchmarking-cli = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

clap = {version = "3.1.6", features = ["derive"]}
hex-literal = "0.3.4"
jsonrpsee = {version = "0.13.0", features = ["server"]}
jsonrpsee = {version = "0.14.0", features = ["server"]}
pallet-currencies-rpc = {version = "0.1.0", path = "../pallets/currencies/rpc"}

[features]
Expand Down
4 changes: 2 additions & 2 deletions node/src/chain_spec/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
move || {
let pallet_system_contract_deployer_id =
<laguna_runtime::Runtime as pallet_system_contract_deployer::Config>::PalletId::get()
.into_account();
.try_into_account().expect("Invalid PalletId");

testnet_genesis(
wasm_binary,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn devnet_config() -> Result<ChainSpec, String> {
move || {
let pallet_system_contract_deployer_id =
<laguna_runtime::Runtime as pallet_system_contract_deployer::Config>::PalletId::get()
.into_account();
.try_into_account().expect("Invalid PalletId");

testnet_genesis(
wasm_binary,
Expand Down
17 changes: 12 additions & 5 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

use crate::{
cli::{LagunaCli, Subcommand},
command_helper::{inherent_benchmark_data, BenchmarkExtrinsicBuilder},
command_helper::{inherent_benchmark_data, RemarkBuilder},
};

use crate::{chain_spec, service};
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use laguna_runtime::Block;

use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use sc_service::PartialComponents;
use std::sync::Arc;

use sp_runtime::generic;
pub type SignedPayload = generic::SignedPayload<laguna_runtime::Call, laguna_runtime::SignedExtra>;
Expand Down Expand Up @@ -144,9 +143,17 @@ pub fn run() -> sc_cli::Result<()> {
},
BenchmarkCmd::Overhead(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
let ext_builder = BenchmarkExtrinsicBuilder::new(client.clone());
let ext_builder = RemarkBuilder::new(client.clone());

cmd.run(config, client, inherent_benchmark_data()?, Arc::new(ext_builder))
cmd.run(config, client, inherent_benchmark_data()?, &ext_builder)
},
BenchmarkCmd::Extrinsic(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
// Register the *Remark* builders.
let ext_factory =
ExtrinsicFactory(vec![Box::new(RemarkBuilder::new(client.clone()))]);

cmd.run(client, inherent_benchmark_data()?, &ext_factory)
},
BenchmarkCmd::Machine(cmd) =>
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
Expand Down
16 changes: 12 additions & 4 deletions node/src/command_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ use std::{sync::Arc, time::Duration};
/// Generates extrinsics for the `benchmark overhead` command.
///
/// Note: Should only be used for benchmarking.
pub struct BenchmarkExtrinsicBuilder {
pub struct RemarkBuilder {
client: Arc<FullClient>,
}

impl BenchmarkExtrinsicBuilder {
impl RemarkBuilder {
/// Creates a new [`Self`] from the given client.
pub fn new(client: Arc<FullClient>) -> Self {
Self { client }
}
}

impl frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder {
fn remark(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
fn pallet(&self) -> &str {
"system"
}

fn extrinsic(&self) -> &str {
"remark"
}

fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
let acc = Sr25519Keyring::Bob.pair();
let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic(
self.client.as_ref(),
Expand Down
12 changes: 6 additions & 6 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ use laguna_runtime::opaque::Block;
use primitives::{AccountId, Balance, BlockNumber, Hash, Index};
use std::sync::Arc;

use pallet_contracts_rpc::{ContractsApiServer, ContractsRpc, ContractsRuntimeApi};
use pallet_contracts_rpc::{Contracts, ContractsApiServer, ContractsRuntimeApi};
use pallet_currencies_rpc::{CurrenciesApiServer, CurrenciesRpc, CurrenciesRuntimeApi};

use pallet_transaction_payment_rpc::{
TransactionPaymentApiServer, TransactionPaymentRpc, TransactionPaymentRuntimeApi,
TransactionPayment, TransactionPaymentApiServer, TransactionPaymentRuntimeApi,
};
use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use substrate_frame_rpc_system::{AccountNonceApi, SystemApiServer, SystemRpc};
use substrate_frame_rpc_system::{AccountNonceApi, System, SystemApiServer};

pub struct FullDeps<Client, Pool> {
pub client: Arc<Client>,
Expand Down Expand Up @@ -50,14 +50,14 @@ where
// operational rpcs
// ++++++++++++++++

module.merge(SystemRpc::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPaymentRpc::new(client.clone()).into_rpc())?;
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;

// ++++++++++
// extra rpcs
// ++++++++++

module.merge(ContractsRpc::new(client.clone()).into_rpc())?;
module.merge(Contracts::new(client.clone()).into_rpc())?;
module.merge(CurrenciesRpc::new(client).into_rpc())?;

Ok(module)
Expand Down
26 changes: 13 additions & 13 deletions pallets/contract-asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ traits = {path = "../traits", default-features = false}

scale-info = {default-features = false, features = ['derive'], version = '2.0.1'}

frame-support = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-system = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
frame-support = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
frame-system = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

sp-core = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-core = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

# contracts related deps
pallet-contracts = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22", default-features = false}
pallet-contracts-primitives = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22", default-features = false}
pallet-contracts = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27", default-features = false}
pallet-contracts-primitives = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27", default-features = false}

frame-benchmarking = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22", optional = true}
frame-benchmarking = {default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27", optional = true}
hex = {version = "0.4.3", default-features = false}
hex-literal = "0.3.4"

orml-traits = {git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', version = "0.4.1-dev", default-features = false, branch = "polkadot-v0.9.22"}
orml-traits = {git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', version = "0.4.1-dev", default-features = false, branch = "polkadot-v0.9.27"}

[dev-dependencies]
pallet-balances = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-randomness-collective-flip = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-sudo = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-timestamp = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-transaction-payment = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
pallet-balances = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-randomness-collective-flip = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-sudo = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-timestamp = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
pallet-transaction-payment = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}
primitives = {path = "../../primitives"}
sp-io = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.22"}
sp-io = {git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.27"}

[features]
default = ["std"]
Expand Down
6 changes: 3 additions & 3 deletions pallets/contract-asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ where
)?;

pallet_contracts::Pallet::<T>::bare_call(
T::PalletId::get().into_account(),
T::PalletId::get().try_into_account().expect("Invalid PalletId"),
asset_address,
Self::Balance::default(),
T::MaxGas::get(),
Expand Down Expand Up @@ -219,7 +219,7 @@ where
)?;

pallet_contracts::Pallet::<T>::bare_call(
T::PalletId::get().into_account(),
T::PalletId::get().try_into_account().expect("Invalid PalletId"),
asset_address,
Self::Balance::default(),
T::MaxGas::get(),
Expand Down Expand Up @@ -273,7 +273,7 @@ where
},
)?;
pallet_contracts::Pallet::<T>::bare_call(
T::PalletId::get().into_account(),
T::PalletId::get().try_into_account().expect("Invalid PalletId"),
asset_address,
Self::Balance::default(),
T::MaxGas::get(),
Expand Down
11 changes: 6 additions & 5 deletions pallets/contract-asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
// TODO: add benchmark around cross pallet interaction between fee
type Event = Event;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = IdentityFee<Balance>;
Expand Down Expand Up @@ -140,11 +141,7 @@ parameter_types! {
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
)) / 5) as u32;
pub Schedule: pallet_contracts::Schedule<Runtime> = {
let mut schedule = pallet_contracts::Schedule::<Runtime>::default();
schedule.limits.code_len = 256 * 1024;
schedule
};
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
}

impl pallet_contracts::Config for Runtime {
Expand All @@ -171,6 +168,10 @@ impl pallet_contracts::Config for Runtime {

// TODO: use arbitrary value now, need to adjust usage later
type ContractAccessWeight = DefaultContractAccessWeight<()>;

type MaxCodeLen = ConstU32<{ 256 * 1024 }>;
type RelaxedMaxCodeLen = ConstU32<{ 512 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
}

parameter_types! {
Expand Down
Loading

0 comments on commit c11e543

Please sign in to comment.