Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into gpestana/on_idle_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gpestana committed Apr 4, 2023
2 parents 492813f + 8548a97 commit 8a9a45b
Show file tree
Hide file tree
Showing 88 changed files with 1,191 additions and 692 deletions.
23 changes: 18 additions & 5 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,10 @@ impl pallet_scheduler::Config for Runtime {
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
#[cfg(feature = "runtime-benchmarks")]
type MaxScheduledPerBlock = ConstU32<512>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MaxScheduledPerBlock = ConstU32<50>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = Preimage;
Expand Down
4 changes: 4 additions & 0 deletions client/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ fn initialize(
deterministic_stack_limit: None,
canonicalize_nans: false,
parallel_compilation: true,
wasm_multi_value: false,
wasm_bulk_memory: false,
wasm_reference_types: false,
wasm_simd: false,
},
};

Expand Down
4 changes: 4 additions & 0 deletions client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ where
deterministic_stack_limit: None,
canonicalize_nans: false,
parallel_compilation: true,
wasm_multi_value: false,
wasm_bulk_memory: false,
wasm_reference_types: false,
wasm_simd: false,
},
},
)
Expand Down
20 changes: 16 additions & 4 deletions client/executor/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,

// Be clear and specific about the extensions we support. If an update brings new features
// they should be introduced here as well.
config.wasm_reference_types(false);
config.wasm_simd(false);
config.wasm_bulk_memory(false);
config.wasm_multi_value(false);
config.wasm_reference_types(semantics.wasm_reference_types);
config.wasm_simd(semantics.wasm_simd);
config.wasm_bulk_memory(semantics.wasm_bulk_memory);
config.wasm_multi_value(semantics.wasm_multi_value);
config.wasm_multi_memory(false);
config.wasm_threads(false);
config.wasm_memory64(false);
Expand Down Expand Up @@ -504,6 +504,18 @@ pub struct Semantics {

/// The heap allocation strategy to use.
pub heap_alloc_strategy: HeapAllocStrategy,

/// Enables WASM Multi-Value proposal
pub wasm_multi_value: bool,

/// Enables WASM Bulk Memory Operations proposal
pub wasm_bulk_memory: bool,

/// Enables WASM Reference Types proposal
pub wasm_reference_types: bool,

/// Enables WASM Fixed-Width SIMD proposal
pub wasm_simd: bool,
}

#[derive(Clone)]
Expand Down
8 changes: 8 additions & 0 deletions client/executor/wasmtime/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ impl RuntimeBuilder {
canonicalize_nans: self.canonicalize_nans,
parallel_compilation: true,
heap_alloc_strategy: self.heap_pages,
wasm_multi_value: false,
wasm_bulk_memory: false,
wasm_reference_types: false,
wasm_simd: false,
},
};

Expand Down Expand Up @@ -474,6 +478,10 @@ fn test_instances_without_reuse_are_not_leaked() {
canonicalize_nans: false,
parallel_compilation: true,
heap_alloc_strategy: HeapAllocStrategy::Static { extra_pages: 2048 },
wasm_multi_value: false,
wasm_bulk_memory: false,
wasm_reference_types: false,
wasm_simd: false,
},
},
)
Expand Down
4 changes: 4 additions & 0 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
# Force 0.9.2 as snow release to fix the compilation.
#
# When libp2p also enforces this version, we can get rid off this extra dep here.
snow = "0.9.2"

[dev-dependencies]
assert_matches = "1.3"
Expand Down
10 changes: 7 additions & 3 deletions client/rpc-api/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use self::helpers::ReadProof;
/// Substrate state API
#[rpc(client, server)]
pub trait StateApi<Hash> {
/// Call a contract at a block's state.
/// Call a method from the runtime API at a block's state.
#[method(name = "state_call", aliases = ["state_callAt"], blocking)]
fn call(&self, name: String, bytes: Bytes, hash: Option<Hash>) -> RpcResult<Bytes>;

Expand Down Expand Up @@ -85,8 +85,10 @@ pub trait StateApi<Hash> {
/// Query historical storage entries (by key) starting from a block given as the second
/// parameter.
///
/// NOTE This first returned result contains the initial state of storage for all keys.
/// NOTE: The first returned result contains the initial state of storage for all keys.
/// Subsequent values in the vector represent changes to the previous state (diffs).
/// WARNING: The time complexity of this query is O(|keys|*dist(block, hash)), and the
/// memory complexity is O(dist(block, hash)) -- use with caution.
#[method(name = "state_queryStorage", blocking)]
fn query_storage(
&self,
Expand All @@ -95,7 +97,9 @@ pub trait StateApi<Hash> {
hash: Option<Hash>,
) -> RpcResult<Vec<StorageChangeSet<Hash>>>;

/// Query storage entries (by key) starting at block hash given as the second parameter.
/// Query storage entries (by key) at a block hash given as the second parameter.
/// NOTE: Each StorageChangeSet in the result corresponds to exactly one element --
/// the storage value under an input key at the input block hash.
#[method(name = "state_queryStorageAt", blocking)]
fn query_storage_at(
&self,
Expand Down
1 change: 0 additions & 1 deletion client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ where
let executor = crate::client::LocalCallExecutor::new(
backend.clone(),
executor,
spawn_handle.clone(),
config.clone(),
execution_extensions,
)?;
Expand Down
11 changes: 1 addition & 10 deletions client/service/src/client/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sc_client_api::{
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
use sp_api::{ProofRecorder, StorageTransactionCache};
use sp_core::{
traits::{CallContext, CodeExecutor, RuntimeCode, SpawnNamed},
traits::{CallContext, CodeExecutor, RuntimeCode},
ExecutionContext,
};
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
Expand All @@ -39,7 +39,6 @@ pub struct LocalCallExecutor<Block: BlockT, B, E> {
executor: E,
wasm_override: Arc<Option<WasmOverride>>,
wasm_substitutes: WasmSubstitutes<Block, E, B>,
spawn_handle: Box<dyn SpawnNamed>,
execution_extensions: Arc<ExecutionExtensions<Block>>,
}

Expand All @@ -52,7 +51,6 @@ where
pub fn new(
backend: Arc<B>,
executor: E,
spawn_handle: Box<dyn SpawnNamed>,
client_config: ClientConfig<Block>,
execution_extensions: ExecutionExtensions<Block>,
) -> sp_blockchain::Result<Self> {
Expand All @@ -72,7 +70,6 @@ where
backend,
executor,
wasm_override: Arc::new(wasm_override),
spawn_handle,
wasm_substitutes,
execution_extensions: Arc::new(execution_extensions),
})
Expand Down Expand Up @@ -142,7 +139,6 @@ where
backend: self.backend.clone(),
executor: self.executor.clone(),
wasm_override: self.wasm_override.clone(),
spawn_handle: self.spawn_handle.clone(),
wasm_substitutes: self.wasm_substitutes.clone(),
execution_extensions: self.execution_extensions.clone(),
}
Expand Down Expand Up @@ -196,7 +192,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
context,
)
.set_parent_hash(at_hash);
Expand Down Expand Up @@ -256,7 +251,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
call_context,
)
.with_storage_transaction_cache(storage_transaction_cache.as_deref_mut())
Expand All @@ -272,7 +266,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
call_context,
)
.with_storage_transaction_cache(storage_transaction_cache.as_deref_mut())
Expand Down Expand Up @@ -313,7 +306,6 @@ where
trie_backend,
&mut Default::default(),
&self.executor,
self.spawn_handle.clone(),
method,
call_data,
&runtime_code,
Expand Down Expand Up @@ -425,7 +417,6 @@ mod tests {
backend: backend.clone(),
executor: executor.clone(),
wasm_override: Arc::new(Some(overrides)),
spawn_handle: Box::new(TaskExecutor::new()),
wasm_substitutes: WasmSubstitutes::new(
Default::default(),
executor.clone(),
Expand Down
9 changes: 2 additions & 7 deletions client/service/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,8 @@ where
sc_offchain::OffchainDb::factory_from_backend(&*backend),
);

let call_executor = LocalCallExecutor::new(
backend.clone(),
executor,
spawn_handle.clone(),
config.clone(),
extensions,
)?;
let call_executor =
LocalCallExecutor::new(backend.clone(), executor, config.clone(), extensions)?;

Client::new(
backend,
Expand Down
7 changes: 0 additions & 7 deletions client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ fn construct_block(
let mut overlay = OverlayedChanges::default();
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
let task_executor = Box::new(TaskExecutor::new());

StateMachine::new(
backend,
Expand All @@ -114,7 +113,6 @@ fn construct_block(
&header.encode(),
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand All @@ -129,7 +127,6 @@ fn construct_block(
&tx.encode(),
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand All @@ -144,7 +141,6 @@ fn construct_block(
&[],
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand Down Expand Up @@ -217,7 +213,6 @@ fn construct_genesis_should_work_with_native() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand Down Expand Up @@ -251,7 +246,6 @@ fn construct_genesis_should_work_with_wasm() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::AlwaysWasm)
Expand Down Expand Up @@ -285,7 +279,6 @@ fn construct_genesis_with_bad_transaction_should_panic() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm);
Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ fn set_min_balance_should_work() {
#[test]
fn balance_conversion_should_work() {
new_test_ext().execute_with(|| {
use frame_support::traits::tokens::BalanceConversion;
use frame_support::traits::tokens::ConversionToAssetBalance;

let id = 42;
assert_ok!(Assets::force_create(RuntimeOrigin::root(), id, 1, true, 10));
Expand Down
4 changes: 2 additions & 2 deletions frame/assets/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use super::*;
use frame_support::{
pallet_prelude::*,
traits::{fungible, tokens::BalanceConversion},
traits::{fungible, tokens::ConversionToAssetBalance},
};
use sp_runtime::{traits::Convert, FixedPointNumber, FixedPointOperand, FixedU128};

Expand Down Expand Up @@ -228,7 +228,7 @@ type BalanceOf<F, T> = <F as fungible::Inspect<AccountIdOf<T>>>::Balance;
/// Converts a balance value into an asset balance based on the ratio between the fungible's
/// minimum balance and the minimum asset balance.
pub struct BalanceToAssetBalance<F, T, CON, I = ()>(PhantomData<(F, T, CON, I)>);
impl<F, T, CON, I> BalanceConversion<BalanceOf<F, T>, AssetIdOf<T, I>, AssetBalanceOf<T, I>>
impl<F, T, CON, I> ConversionToAssetBalance<BalanceOf<F, T>, AssetIdOf<T, I>, AssetBalanceOf<T, I>>
for BalanceToAssetBalance<F, T, CON, I>
where
F: fungible::Inspect<AccountIdOf<T>>,
Expand Down
7 changes: 6 additions & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,12 @@ pub mod pallet {
// Gah!! We have a non-zero reserve balance but no provider refs :(
// This shouldn't practically happen, but we need a failsafe anyway: let's give
// them enough for an ED.
a.free = a.free.min(Self::ed());
log::warn!(
target: LOG_TARGET,
"account with a non-zero reserve balance has no provider refs, account_id: '{:?}'.",
who
);
a.free = a.free.max(Self::ed());
system::Pallet::<T>::inc_providers(who);
}
let _ = system::Pallet::<T>::inc_consumers(who).defensive();
Expand Down
Loading

0 comments on commit 8a9a45b

Please sign in to comment.