Skip to content

Commit

Permalink
Cleanup based on Review and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
AdaJane committed Mar 13, 2023
1 parent 9d18c45 commit ec53bc8
Show file tree
Hide file tree
Showing 19 changed files with 10,207 additions and 65 deletions.
10,075 changes: 10,075 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ assert_matches = { version = "1.5.0" }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
hex-literal = { version = "0.3.4" }
jsonrpc-core = { version = "18.0.0" }
jsonrpsee = { version = "0.16.2" }
log = { version = "0.4.17" }
parity-scale-codec = { version = "3.2.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.152", default-features = false, features = ["derive"] }
Expand All @@ -45,6 +46,7 @@ pallet-creditcoin = { path = "pallets/creditcoin", default-features = false }
pallet-difficulty = { path = "pallets/difficulty", default-features = false }
pallet-offchain-task-scheduler = { path = "pallets/offchain-task-scheduler", default-features = false }
pallet-rewards = { path = "pallets/rewards", default-features = false }
pallet-staking = { path = "pallets/staking", default-features = false }
primitives = { path = "primitives", default-features = false }
runtime-utils = { package = "test-runtime-utils", path = "test/runtime-utils", default-features = false }
task-scheduler-runtime-api = { path = "pallets/offchain-task-scheduler/runtime-api", default-features = false }
Expand All @@ -53,12 +55,15 @@ task-scheduler-runtime-api = { path = "pallets/offchain-task-scheduler/runtime-a
frame-benchmarking-cli = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git"}
frame-benchmarking = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-executive = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-election-provider-support = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-support = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-system = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-system-benchmarking = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
frame-system-rpc-runtime-api = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-balances = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-randomness-collective-flip = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-session = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-staking-substrate = { package = "pallet-staking", branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-scheduler = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-sudo = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
pallet-timestamp = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
Expand Down Expand Up @@ -98,6 +103,7 @@ sp-runtime = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech
sp-runtime-interface = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
sp-session = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
sp-state-machine = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
sp-staking = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
sp-std = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
sp-timestamp = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git" }
sp-transaction-pool = { branch = "polkadot-v0.9.38", git = "https://github.com/paritytech/substrate.git", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion creditcoin-js/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare module '@polkadot/api-base/types/errors' {
**/
ExistingVestingSchedule: AugmentedError<ApiType>;
/**
* Balance too low to send value
* Balance too low to send value.
**/
InsufficientBalance: AugmentedError<ApiType>;
/**
Expand Down
12 changes: 4 additions & 8 deletions creditcoin-js/src/interfaces/augment-api-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {
FrameSystemPhase,
PalletBalancesAccountData,
PalletBalancesBalanceLock,
PalletBalancesReleases,
PalletBalancesReserveData,
PalletCreditcoinAddress,
PalletCreditcoinAskOrder,
Expand Down Expand Up @@ -75,6 +74,10 @@ declare module '@polkadot/api-base/types/storage' {
[AccountId32]
> &
QueryableStorageEntry<ApiType, [AccountId32]>;
/**
* The total units of outstanding deactivated balance in the system.
**/
inactiveIssuance: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Any liquidity locks on some account balances.
* NOTE: Should only be accessed when setting, changing and freeing a lock.
Expand All @@ -94,13 +97,6 @@ declare module '@polkadot/api-base/types/storage' {
[AccountId32]
> &
QueryableStorageEntry<ApiType, [AccountId32]>;
/**
* Storage version of the pallet.
*
* This is set to v2.0.0 for new networks.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<PalletBalancesReleases>, []> &
QueryableStorageEntry<ApiType, []>;
/**
* The total units issued in the system.
**/
Expand Down
9 changes: 1 addition & 8 deletions creditcoin-js/src/interfaces/augment-api-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
} from '@polkadot/api-base/types';
import type { Bytes, Compact, Option, U256, U8aFixed, Vec, bool, i64, u128, u32, u64, u8 } from '@polkadot/types-codec';
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, Call, H256, MultiAddress, Perbill } from '@polkadot/types/interfaces/runtime';
import type { AccountId32, Call, H256, MultiAddress } from '@polkadot/types/interfaces/runtime';
import type {
PalletCreditcoinAskOrderId,
PalletCreditcoinBidOrderId,
Expand Down Expand Up @@ -686,13 +686,6 @@ declare module '@polkadot/api-base/types/submittable' {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
system: {
/**
* A dispatch that will fill the block weight up to the given ratio.
**/
fillBlock: AugmentedSubmittable<
(ratio: Perbill | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>,
[Perbill]
>;
/**
* Kill all storage items with a key that starts with the given prefix.
*
Expand Down
6 changes: 2 additions & 4 deletions creditcoin-js/src/interfaces/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import type {
PalletBalancesError,
PalletBalancesEvent,
PalletBalancesReasons,
PalletBalancesReleases,
PalletBalancesReserveData,
PalletCreditcoinAddress,
PalletCreditcoinAskOrder,
Expand Down Expand Up @@ -95,14 +94,14 @@ import type {
PalletTransactionPaymentChargeTransactionPayment,
PalletTransactionPaymentEvent,
PalletTransactionPaymentReleases,
SpRuntimeArithmeticError,
SpCoreEcdsaPublic,
SpCoreEcdsaSignature,
SpCoreEd25519Public,
SpCoreEd25519Signature,
SpCoreSr25519Public,
SpCoreSr25519Signature,
SpCoreVoid,
SpRuntimeArithmeticError,
SpRuntimeDigest,
SpRuntimeDigestDigestItem,
SpRuntimeDispatchError,
Expand Down Expand Up @@ -151,7 +150,6 @@ declare module '@polkadot/types/types/registry' {
PalletBalancesError: PalletBalancesError;
PalletBalancesEvent: PalletBalancesEvent;
PalletBalancesReasons: PalletBalancesReasons;
PalletBalancesReleases: PalletBalancesReleases;
PalletBalancesReserveData: PalletBalancesReserveData;
PalletCreditcoinAddress: PalletCreditcoinAddress;
PalletCreditcoinAskOrder: PalletCreditcoinAskOrder;
Expand Down Expand Up @@ -207,14 +205,14 @@ declare module '@polkadot/types/types/registry' {
PalletTransactionPaymentChargeTransactionPayment: PalletTransactionPaymentChargeTransactionPayment;
PalletTransactionPaymentEvent: PalletTransactionPaymentEvent;
PalletTransactionPaymentReleases: PalletTransactionPaymentReleases;
SpRuntimeArithmeticError: SpRuntimeArithmeticError;
SpCoreEcdsaPublic: SpCoreEcdsaPublic;
SpCoreEcdsaSignature: SpCoreEcdsaSignature;
SpCoreEd25519Public: SpCoreEd25519Public;
SpCoreEd25519Signature: SpCoreEd25519Signature;
SpCoreSr25519Public: SpCoreSr25519Public;
SpCoreSr25519Signature: SpCoreSr25519Signature;
SpCoreVoid: SpCoreVoid;
SpRuntimeArithmeticError: SpRuntimeArithmeticError;
SpRuntimeDigest: SpRuntimeDigest;
SpRuntimeDigestDigestItem: SpRuntimeDigestDigestItem;
SpRuntimeDispatchError: SpRuntimeDispatchError;
Expand Down
6 changes: 3 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ substrate-build-script-utils = { workspace = true }
targets = ['x86_64-unknown-linux-gnu']

[dependencies]
creditcoin-node-rpc = { version = "2.211.2", path = "./rpc" }
creditcoin-node-rpc = { path = "./rpc" }
creditcoin-node-runtime = { workspace = true }
frame-benchmarking = { features = ["std"], workspace = true }
frame-benchmarking-cli = { workspace = true }
Expand Down Expand Up @@ -60,7 +60,7 @@ substrate-prometheus-endpoint = { workspace = true }
task-scheduler-runtime-api = { workspace = true }
thiserror = "1.0.38"
try-runtime-cli = { workspace = true, optional = true }
jsonrpsee = { version = "0.16.2", features = ["server"] }
jsonrpsee = { workspace = true, features = ["server"] }
serde_json = "1.0.93"
frame-system = { workspace = true }
pallet-transaction-payment = { workspace = true }
Expand All @@ -80,4 +80,4 @@ runtime-benchmarks = [
'frame-benchmarking-cli/runtime-benchmarks',
]
std = ['sp-api/std', 'sp-block-builder/std', 'task-scheduler-runtime-api/std']
try-runtime = ["creditcoin-node-runtime/try-runtime", "try-runtime-cli"]
try-runtime = ["creditcoin-node-runtime/try-runtime", "try-runtime-cli/try-runtime"]
2 changes: 1 addition & 1 deletion node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository.workspace = true
[dependencies]
creditcoin-node-runtime = { workspace = true }
frame-system = { features = ["std"], workspace = true }
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
primitives = { workspace = true, features = ["prometheus"] }
sc-rpc = { workspace = true }
serde = { workspace = true }
Expand Down
19 changes: 12 additions & 7 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
//!
//! Should only be used for benchmarking as it may break in other contexts.

use crate::service::FullClient;
use std::{sync::Arc, time::Duration};

use creditcoin_node_runtime as runtime;
use runtime::{AccountId, Balance, BalancesCall, SystemCall};
use futures::{executor, TryFutureExt};
use sc_cli::Result;
use sc_client_api::BlockBackend;
use sp_core::{Encode, Pair};
use sp_inherents::{InherentData, InherentDataProvider};
use sp_keyring::Sr25519Keyring;
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};

use std::{sync::Arc, time::Duration};
use creditcoin_node_runtime as runtime;
use runtime::{AccountId, Balance, BalancesCall, SystemCall};

use crate::service::FullClient;

/// Generates extrinsics for the `benchmark overhead` command.
///
Expand Down Expand Up @@ -173,8 +175,11 @@ pub fn inherent_benchmark_data() -> Result<InherentData> {
let d = Duration::from_millis(0);
let timestamp = sp_timestamp::InherentDataProvider::new(d.into());

timestamp
.provide_inherent_data(&mut inherent_data)
.map_err(|e| format!("creating inherent data: {e:?}"))?;
executor::block_on(
timestamp
.provide_inherent_data(&mut inherent_data)
.map_err(|e| format!("creating inherent data: {e:?}")),
)?;

Ok(inherent_data)
}
11 changes: 10 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
service,
};
use creditcoin_node_runtime::{Block, ExistentialDeposit};
use frame_benchmarking::frame_support;
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use sc_service::PartialComponents;
Expand Down Expand Up @@ -112,6 +113,8 @@ pub fn run() -> sc_cli::Result<()> {
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use frame_support::sp_io::SubstrateHostFunctions;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
// we don't need any of the components of new_partial, just a runtime, or a task
Expand All @@ -120,7 +123,13 @@ pub fn run() -> sc_cli::Result<()> {
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;
Ok((cmd.run::<Block, service::ExecutorDispatch>(config), task_manager))
Ok((
cmd.run::<Block, ExtendedHostFunctions<
SubstrateHostFunctions,
<service::ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>>(),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Expand Down
Loading

0 comments on commit ec53bc8

Please sign in to comment.