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

[WIP] Substrate monthly 2023 08 #1780

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
31296b7
use workspace deps more.
Neopallium Jan 3, 2025
d1e43d4
Update Substrate.
Neopallium Jan 3, 2025
0281b73
Update WeightMeter
Neopallium Sep 30, 2024
8065f13
Deprecated GenesisBuild, use BuildGenesisConfig.
Neopallium Jan 6, 2025
3b86e04
Use Weight::from_parts instead of Weight::from_ref_time
Neopallium Jan 6, 2025
0ade364
T::BlockNumber update.
Neopallium Jan 6, 2025
9980d5e
Update balances pallet.
Neopallium Jan 6, 2025
f0033c8
Fix chrono deprecated warnings.
Neopallium Jan 6, 2025
3735f59
Fix deprecated check_accrue call.
Neopallium Jan 6, 2025
d254cb4
Add TypeInfo to Runtime API types.
Neopallium Jan 6, 2025
5823656
System pallet renamed Index -> Nonce.
Neopallium Jan 6, 2025
a094a87
Update contracts
Neopallium Jan 6, 2025
b714573
Update weights.
Neopallium Jan 6, 2025
5c66462
Bump recursion_limit
Neopallium Jan 6, 2025
a49cec4
Update Babe and Grandpa.
Neopallium Jan 6, 2025
99541a9
Update staking pallet.
Neopallium Jan 6, 2025
d984838
Update im-online.
Neopallium Jan 7, 2025
a6bf16d
Require serde.
Neopallium Jan 7, 2025
8ff3bdc
no_std GenesisConfig.
Neopallium Jan 7, 2025
4d462e1
Update node binary service/command code.
Neopallium Jan 7, 2025
ac3ec4b
Add missing runtime_version attribute.
Neopallium Jan 7, 2025
d70eb69
Fix wasm-builder
Neopallium Jan 8, 2025
c774b4d
Remove old test.
Neopallium Jan 8, 2025
1177a76
Fix warnings.
Neopallium Jan 8, 2025
039683b
Fix warnings about OldWeight.
Neopallium Jan 9, 2025
a266c34
Fix benchmark build.
Neopallium Jan 9, 2025
cc9144b
Fix RPC port number.
Neopallium Jan 9, 2025
b882e13
Update rust integration deps.
Neopallium Jan 9, 2025
7ce2fb8
FIXUP: Update Substrate
Neopallium Jan 9, 2025
8c1fdb4
System.set_code doesn't use max block weight anymore.
Neopallium Jan 9, 2025
2cf4fbe
Fix Staking.reap_stash.
Neopallium Jan 10, 2025
acd1e46
Use sensible maths for `from_rational`.
Neopallium Jan 10, 2025
9ecb66a
Bump contract gas fees.
Neopallium Jan 10, 2025
60f903c
Add NoopMigration for v10 contracts pallet.
Neopallium Jan 24, 2025
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
5,300 changes: 2,531 additions & 2,769 deletions Cargo.lock

Large diffs are not rendered by default.

297 changes: 173 additions & 124 deletions Cargo.toml

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions integration/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions integration/tests/contract_permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn contract_as_secondary_key_change_identity() -> Result<()> {
.polymesh_contracts()
.instantiate_with_code_perms(
0,
Weight::from_parts(10_000_000_000, 0),
Weight::from_parts(10_000_000_000, 20_000),
None,
call_runtime_bytes.to_vec(),
vec![0x9b, 0xae, 0x9d, 0x5e], // Selector for `new` constructor.
Expand Down Expand Up @@ -134,7 +134,7 @@ async fn contract_as_secondary_key_change_identity() -> Result<()> {
.call(
contract.into(),
0,
Weight::from_parts(10_000_000_000, 0),
Weight::from_parts(19_000_000_000, 40_000),
None,
encoded_call,
)?
Expand Down
49 changes: 24 additions & 25 deletions node-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,28 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
jsonrpsee = { version = "0.16.2", features = ["server"] }

polymesh-primitives = { path = "../primitives", default-features = false }
pallet-group-rpc = { path = "../pallets/group/rpc" }
pallet-staking-rpc = { path = "../pallets/staking/rpc" }
pallet-protocol-fee-rpc = { path = "../pallets/protocol-fee/rpc" }
node-rpc = { path = "../rpc" }
polymesh-primitives = { workspace = true, default-features = false }
pallet-group-rpc = { workspace = true }
pallet-staking-rpc = { workspace = true }
pallet-protocol-fee-rpc = { workspace = true }
node-rpc = { workspace = true }

sc-chain-spec = { version = "4.0.0-dev" }
sc-client-api = { version = "4.0.0-dev" }
sc-consensus-babe = { version = "0.10.0-dev" }
sc-consensus-babe-rpc = { version = "0.10.0-dev" }
sc-consensus-epochs = { version = "0.10.0-dev" }
sc-consensus-grandpa = { version = "0.10.0-dev" }
sc-consensus-grandpa-rpc = { version = "0.10.0-dev" }
sc-rpc = { version = "4.0.0-dev" }
sc-rpc-api = { version = "0.10.0-dev" }
sc-rpc-spec-v2 = { version = "0.10.0-dev" }
sc-sync-state-rpc = { version = "0.10.0-dev" }
sc-transaction-pool-api = { version = "4.0.0-dev" }
sp-api = { version = "4.0.0-dev" }
sp-block-builder = { version = "4.0.0-dev" }
sp-blockchain = { version = "4.0.0-dev" }
sp-consensus = { version = "0.10.0-dev" }
sp-consensus-babe = { version = "0.10.0-dev" }
sp-keystore = { version = "0.13.0" }
sp-runtime = { version = "7.0.0" }
substrate-frame-rpc-system = { version = "4.0.0-dev" }
sc-chain-spec = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus-babe = { workspace = true }
sc-consensus-babe-rpc = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-grandpa-rpc = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sc-rpc-spec-v2 = { workspace = true }
sc-sync-state-rpc = { workspace = true }
sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-blockchain = { workspace = true }
sp-consensus = { workspace = true }
sp-consensus-babe = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
substrate-frame-rpc-system = { workspace = true }
50 changes: 23 additions & 27 deletions node-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
use std::sync::Arc;

use jsonrpsee::RpcModule;
use polymesh_primitives::{AccountId, Block, BlockNumber, Hash, IdentityId, Index, Moment, Ticker};
use polymesh_primitives::{AccountId, Block, BlockNumber, Hash, IdentityId, Moment, Nonce, Ticker};
use sc_client_api::AuxStore;
use sc_consensus_babe::{BabeConfiguration, Epoch};
use sc_consensus_epochs::SharedEpochChanges;
use sc_consensus_babe::BabeWorkerHandle;
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
Expand All @@ -48,16 +47,14 @@ use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sp_keystore::SyncCryptoStorePtr;
use sp_keystore::KeystorePtr;

/// Extra dependencies for BABE.
pub struct BabeDeps {
/// BABE protocol config.
pub babe_config: BabeConfiguration,
/// BABE pending epoch changes.
pub shared_epoch_changes: SharedEpochChanges<Block, Epoch>,
/// A handle to the BABE worker for issuing requests.
pub babe_worker_handle: BabeWorkerHandle<Block>,
/// The keystore that manages the keys of the node.
pub keystore: SyncCryptoStorePtr,
pub keystore: KeystorePtr,
}

/// Extra dependencies for GRANDPA
Expand Down Expand Up @@ -90,12 +87,22 @@ pub struct FullDeps<C, P, SC, B> {
pub babe: BabeDeps,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<B>,
/// The backend used by the node.
pub backend: Arc<B>,
}

/// Instantiate all Full RPC extensions.
pub fn create_full<C, P, SC, B>(
deps: FullDeps<C, P, SC, B>,
_backend: Arc<B>,
FullDeps {
client,
pool,
select_chain,
chain_spec,
deny_unsafe,
babe,
grandpa,
backend: _,
}: FullDeps<C, P, SC, B>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>
Expand All @@ -106,7 +113,7 @@ where
+ Sync
+ Send
+ 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: node_rpc::transaction_payment::TransactionPaymentRuntimeApi<Block>,
C::Api: pallet_staking_rpc::StakingRuntimeApi<Block>,
C::Api: node_rpc::pips::PipsRuntimeApi<Block, AccountId>,
Expand All @@ -121,7 +128,7 @@ where
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashingFor<Block>>,
{
use node_rpc::{
asset::{Asset, AssetApiServer},
Expand All @@ -142,20 +149,10 @@ where
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut io = RpcModule::new(());
let FullDeps {
client,
pool,
select_chain,
chain_spec,
deny_unsafe,
babe,
grandpa,
} = deps;

let BabeDeps {
keystore,
babe_config,
shared_epoch_changes,
babe_worker_handle,
} = babe;
let GrandpaDeps {
shared_voter_state,
Expand All @@ -179,9 +176,8 @@ where
io.merge(
Babe::new(
client.clone(),
shared_epoch_changes.clone(),
babe_worker_handle.clone(),
keystore,
babe_config,
select_chain,
deny_unsafe,
)
Expand All @@ -203,7 +199,7 @@ where
chain_spec,
client.clone(),
shared_authority_set,
shared_epoch_changes,
babe_worker_handle,
)?
.into_rpc(),
)?;
Expand Down
26 changes: 13 additions & 13 deletions pallets/asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ polymesh-runtime-common = { workspace = true, default-features = false }
# Other
serde = { version = "1.0.104", default-features = false }
serde_derive = { version = "1.0.104", optional = true, default-features = false }
serde_json = "1.0.48"
serde_json = { version = "1.0.48", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
hex-literal = "0.2.1"
arrayvec = { version = "0.7.1", default-features = false }
log = "0.4"

# Substrate
codec = { workspace = true, default-features = false, features = ["derive"] }
scale-info = { version = "2.0", default-features = false, features = ["derive"] }
sp-arithmetic = { version = "6.0.0", default-features = false }
sp-core = { version = "7.0.0", default-features = false }
sp-std = { version = "5.0.0", default-features = false }
sp-io = { version = "7.0.0", default-features = false }
sp-runtime = { version = "7.0.0", default-features = false }
sp-version = { version = "5.0.0", default-features = false }
sp-api = { version = "4.0.0-dev", default-features = false }
frame-system = { version = "4.0.0-dev", default-features = false }
frame-support = { version = "4.0.0-dev", default-features = false }
pallet-timestamp = { version = "4.0.0-dev", default-features = false }
scale-info = { workspace = true, default-features = false, features = ["derive"] }
sp-arithmetic = { workspace = true, default-features = false }
sp-core = { workspace = true, default-features = false }
sp-std = { workspace = true, default-features = false }
sp-io = { workspace = true, default-features = false }
sp-runtime = { workspace = true, default-features = false }
sp-version = { workspace = true, default-features = false }
sp-api = { workspace = true, default-features = false }
frame-system = { workspace = true, default-features = false }
frame-support = { workspace = true, default-features = false }
pallet-timestamp = { workspace = true, default-features = false }

# Only in STD
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true }
frame-benchmarking = { workspace = true, default-features = false, optional = true }

[features]
default = ["std"]
Expand Down
8 changes: 5 additions & 3 deletions pallets/asset/src/checkpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ pub mod pallet {
pub(super) type StorageVersion<T: Config> = StorageValue<_, Version, ValueQuery>;

#[pallet::genesis_config]
#[derive(Default)]
pub struct GenesisConfig {
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T> {
pub schedules_max_complexity: u64,
#[serde(skip)]
pub _config: sp_std::marker::PhantomData<T>,
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig {
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
StorageVersion::<T>::put(Version::new(2));

Expand Down
10 changes: 6 additions & 4 deletions pallets/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ use frame_support::traits::{Currency, Get, UnixTime};
use frame_support::weights::Weight;
use frame_support::BoundedBTreeSet;
use frame_system::ensure_root;
use frame_system::pallet_prelude::*;
use sp_io::hashing::blake2_128;
use sp_runtime::traits::Zero;
use sp_std::collections::btree_set::BTreeSet;
Expand Down Expand Up @@ -149,7 +150,6 @@ pub use pallet::*;
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

#[pallet::config]
pub trait Config:
Expand Down Expand Up @@ -571,15 +571,17 @@ pub mod pallet {

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig {
pub struct GenesisConfig<T> {
// TODO: Why is serde required here?
pub ticker_registration_config: TickerRegistrationConfig<polymesh_primitives::Moment>,
pub reserved_country_currency_codes: Vec<Ticker>,
pub asset_metadata: Vec<(AssetMetadataName, AssetMetadataSpec)>,
#[serde(skip)]
pub _config: sp_std::marker::PhantomData<T>,
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig
impl<T: Config> BuildGenesisConfig for GenesisConfig<T>
where
T: AssetConfig,
{
Expand Down Expand Up @@ -3101,7 +3103,7 @@ impl<T: AssetConfig> Pallet<T> {
}

pub fn generate_asset_id(caller_acc: T::AccountId, update: bool) -> AssetId {
let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero());
let genesis_hash = frame_system::Pallet::<T>::block_hash(BlockNumberFor::<T>::zero());
let nonce = Self::get_nonce(&caller_acc, update);
blake2_128(&(b"modlpy/pallet_asset", genesis_hash, caller_acc, nonce).encode()).into()
}
Expand Down
6 changes: 2 additions & 4 deletions pallets/asset/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#[cfg(feature = "std")]
use sp_runtime::{Deserialize, Serialize};

use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};

use polymesh_primitives::asset::AssetType;
use polymesh_primitives::{Balance, IdentityId};
Expand Down Expand Up @@ -64,7 +62,7 @@ pub struct TickerRegistration<T> {
}

/// struct to store the ticker registration config.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Serialize, Deserialize)]
#[derive(
Clone,
Debug,
Expand Down
Loading