Skip to content

Commit a738099

Browse files
committed
Merge remote-tracking branch 'origin/development' into sam-revamp-deployment
2 parents 48d323f + 0288a73 commit a738099

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+581
-747
lines changed

.github/workflows/check-rust.yml

+5-59
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ jobs:
7171
- name: cargo fmt
7272
run: cargo fmt --check --all
7373

74-
# runs cargo check --workspace
75-
cargo-check:
76-
name: cargo check
74+
# runs cargo clippy --workspace --all-targets --all-features
75+
cargo-clippy:
76+
name: cargo clippy
7777
runs-on: SubtensorCI
7878
strategy:
7979
matrix:
@@ -117,8 +117,8 @@ jobs:
117117
with:
118118
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
119119

120-
- name: cargo check --workspace
121-
run: cargo check --workspace
120+
- name: cargo clippy --workspace --all-targets --all-features
121+
run: cargo clippy --workspace --all-targets --all-features
122122

123123
# runs cargo test --workspace
124124
cargo-test:
@@ -218,60 +218,6 @@ jobs:
218218
- name: cargo test --workspace --features=runtime-benchmarks
219219
run: cargo test --workspace --features=runtime-benchmarks
220220

221-
# runs cargo clippy
222-
clippy:
223-
name: cargo clippy
224-
runs-on: SubtensorCI
225-
strategy:
226-
matrix:
227-
rust-branch:
228-
- nightly-2024-03-05
229-
rust-target:
230-
- x86_64-unknown-linux-gnu
231-
# - x86_64-apple-darwin
232-
os:
233-
- ubuntu-latest
234-
# - macos-latest
235-
include:
236-
- os: ubuntu-latest
237-
# - os: macos-latest
238-
env:
239-
RELEASE_NAME: development
240-
# RUSTFLAGS: -A warnings
241-
RUSTV: ${{ matrix.rust-branch }}
242-
RUST_BACKTRACE: full
243-
RUST_BIN_DIR: target/${{ matrix.rust-target }}
244-
SKIP_WASM_BUILD: 1
245-
TARGET: ${{ matrix.rust-target }}
246-
steps:
247-
- name: Check-out repository under $GITHUB_WORKSPACE
248-
uses: actions/checkout@v4
249-
250-
- name: Install dependencies
251-
run: |
252-
sudo apt-get update &&
253-
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
254-
255-
- name: Install Rust ${{ matrix.rust-branch }}
256-
uses: actions-rs/toolchain@v1.0.6
257-
with:
258-
toolchain: ${{ matrix.rust-branch }}
259-
components: rustfmt, clippy
260-
profile: minimal
261-
262-
- name: Utilize Rust shared cached
263-
uses: Swatinem/rust-cache@v2.2.1
264-
with:
265-
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
266-
267-
- name: cargo clippy
268-
run: |
269-
cargo clippy -- -D clippy::panic \
270-
-D clippy::todo \
271-
-D clippy::unimplemented
272-
# -D clippy::indexing_slicing \
273-
# -D clippy::unwrap_used \
274-
275221
# ensures cargo fix has no trivial changes that can be applied
276222
cargo-fix:
277223
name: cargo fix

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ members = [
88
]
99
resolver = "2"
1010

11+
[workspace.lints.clippy]
12+
type_complexity = "allow"
13+
1114
[profile.release]
1215
panic = "unwind"
1316

integration-tests/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ edition = "2021"
77
license = "Unlicense"
88
repository = "https://github.com/opentensor/subtensor"
99

10+
[lints]
11+
workspace = true
12+
1013
[dependencies]
1114

1215
##

node/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ publish = false
1010
repository = "https://github.com/opentensor/subtensor"
1111
build = "build.rs"
1212

13+
[lints]
14+
workspace = true
15+
1316
[package.metadata.docs.rs]
1417
targets = ["x86_64-unknown-linux-gnu"]
1518

node/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
8989
acc,
9090
BalancesCall::transfer_keep_alive {
9191
dest: self.dest.clone().into(),
92-
value: self.value.into(),
92+
value: self.value,
9393
}
9494
.into(),
9595
nonce,

node/src/chain_spec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ fn localnet_genesis(
492492
}
493493

494494
// Configure initial storage state for FRAME modules.
495+
#[allow(clippy::too_many_arguments)]
495496
fn testnet_genesis(
496497
wasm_binary: &[u8],
497498
initial_authorities: Vec<(AuraId, GrandpaId)>,
@@ -551,6 +552,7 @@ fn testnet_genesis(
551552
}
552553

553554
// Configure initial storage state for FRAME modules.
555+
#[allow(clippy::too_many_arguments)]
554556
fn finney_genesis(
555557
wasm_binary: &[u8],
556558
initial_authorities: Vec<(AuraId, GrandpaId)>,

node/src/cli.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct Cli {
99
pub run: RunCmd,
1010
}
1111

12+
#[allow(clippy::large_enum_variant)]
1213
#[derive(Debug, clap::Subcommand)]
1314
pub enum Subcommand {
1415
// Key management cli utilities

node/src/command.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use node_subtensor_runtime::Block;
1717
use sc_cli::SubstrateCli;
1818
use sc_service::PartialComponents;
1919

20-
2120
impl SubstrateCli for Cli {
2221
fn impl_name() -> String {
2322
"Subtensor Node".into()

node/src/rpc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use std::sync::Arc;
99

1010
use jsonrpsee::RpcModule;
11-
use node_subtensor_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Index, Hash};
11+
use node_subtensor_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index};
12+
use sc_consensus_grandpa::FinalityProofProvider;
1213
use sc_transaction_pool_api::TransactionPool;
1314
use sp_api::ProvideRuntimeApi;
1415
use sp_block_builder::BlockBuilder;
1516
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
16-
use sc_consensus_grandpa::FinalityProofProvider;
1717

1818
pub use sc_rpc_api::DenyUnsafe;
1919

@@ -64,9 +64,9 @@ where
6464
P: TransactionPool + 'static,
6565
{
6666
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
67+
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
6768
use substrate_frame_rpc_system::{System, SystemApiServer};
6869
use subtensor_custom_rpc::{SubtensorCustom, SubtensorCustomApiServer};
69-
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
7070

7171
let mut module = RpcModule::new(());
7272
let FullDeps {
@@ -99,7 +99,7 @@ where
9999
justification_stream,
100100
finality_provider,
101101
)
102-
.into_rpc(),
102+
.into_rpc(),
103103
)?;
104104

105105
// Extend this RPC with a custom API by using the following syntax.

node/src/service.rs

+31-30
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
222222
);
223223
}
224224

225-
let finality_proof_provider = sc_consensus_grandpa::FinalityProofProvider::new_for_service(
226-
backend.clone(),
227-
Some(grandpa_link.shared_authority_set().clone()),
228-
);
229-
let rpc_backend = backend.clone();
230-
let justification_stream = grandpa_link.justification_stream();
231-
let shared_authority_set = grandpa_link.shared_authority_set().clone();
232-
let shared_voter_state = SharedVoterState::empty();
225+
let finality_proof_provider = sc_consensus_grandpa::FinalityProofProvider::new_for_service(
226+
backend.clone(),
227+
Some(grandpa_link.shared_authority_set().clone()),
228+
);
229+
let rpc_backend = backend.clone();
230+
let justification_stream = grandpa_link.justification_stream();
231+
let shared_authority_set = grandpa_link.shared_authority_set().clone();
232+
let shared_voter_state = SharedVoterState::empty();
233233

234234
let role = config.role.clone();
235235
let force_authoring = config.force_authoring;
@@ -238,28 +238,29 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
238238
let enable_grandpa = !config.disable_grandpa;
239239
let prometheus_registry = config.prometheus_registry().cloned();
240240

241-
let rpc_extensions_builder = {
242-
let client = client.clone();
243-
let pool = transaction_pool.clone();
244-
245-
Box::new(move |deny_unsafe, subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
246-
let deps =
247-
crate::rpc::FullDeps {
248-
client: client.clone(),
249-
pool: pool.clone(),
250-
deny_unsafe,
251-
grandpa: crate::rpc::GrandpaDeps {
252-
shared_voter_state: shared_voter_state.clone(),
253-
shared_authority_set: shared_authority_set.clone(),
254-
justification_stream: justification_stream.clone(),
255-
subscription_executor: subscription_executor.clone(),
256-
finality_provider: finality_proof_provider.clone(),
257-
},
258-
backend: rpc_backend.clone(),
259-
};
260-
crate::rpc::create_full(deps).map_err(Into::into)
261-
})
262-
};
241+
let rpc_extensions_builder = {
242+
let client = client.clone();
243+
let pool = transaction_pool.clone();
244+
245+
Box::new(
246+
move |deny_unsafe, subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
247+
let deps = crate::rpc::FullDeps {
248+
client: client.clone(),
249+
pool: pool.clone(),
250+
deny_unsafe,
251+
grandpa: crate::rpc::GrandpaDeps {
252+
shared_voter_state: shared_voter_state.clone(),
253+
shared_authority_set: shared_authority_set.clone(),
254+
justification_stream: justification_stream.clone(),
255+
subscription_executor: subscription_executor.clone(),
256+
finality_provider: finality_proof_provider.clone(),
257+
},
258+
backend: rpc_backend.clone(),
259+
};
260+
crate::rpc::create_full(deps).map_err(Into::into)
261+
},
262+
)
263+
};
263264

264265
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
265266
network: network.clone(),

pallets/admin-utils/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ license = "Unlicense"
99
publish = false
1010
repository = "https://github.com/opentensor/subtensor"
1111

12+
[lints]
13+
workspace = true
14+
1215
[package.metadata.docs.rs]
1316
targets = ["x86_64-unknown-linux-gnu"]
1417

pallets/admin-utils/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> {
836836
hotkey: &AccountId,
837837
increment: u64,
838838
);
839-
fn u64_to_balance(input: u64) -> Option<Balance>;
840839
fn add_balance_to_coldkey_account(coldkey: &AccountId, amount: Balance);
841840
fn get_current_block_as_u64() -> u64;
842841
fn get_subnetwork_n(netuid: u16) -> u16;

pallets/admin-utils/tests/mock.rs

-4
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ impl pallet_admin_utils::SubtensorInterface<AccountId, Balance, RuntimeOrigin> f
279279
SubtensorModule::increase_stake_on_coldkey_hotkey_account(coldkey, hotkey, increment);
280280
}
281281

282-
fn u64_to_balance(input: u64) -> Option<Balance> {
283-
SubtensorModule::u64_to_balance(input)
284-
}
285-
286282
fn add_balance_to_coldkey_account(coldkey: &AccountId, amount: Balance) {
287283
SubtensorModule::add_balance_to_coldkey_account(coldkey, amount);
288284
}

pallets/collective/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ repository = "https://github.com/opentensor/subtensor"
99
description = "Collective system: Members of a set of account IDs can make their collective feelings known through dispatched calls from one of two specialized origins."
1010
readme = "README.md"
1111

12+
[lints]
13+
workspace = true
14+
1215
[package.metadata.docs.rs]
1316
targets = ["x86_64-unknown-linux-gnu"]
1417

pallets/collective/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ benchmarks_instance_pallet! {
248248
verify {
249249
// All proposals exist and the last proposal has just been updated.
250250
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);
251-
let voting = Collective::<T, I>::voting(&last_hash).ok_or("Proposal Missing")?;
251+
let voting = Collective::<T, I>::voting(last_hash).ok_or("Proposal Missing")?;
252252
assert_eq!(voting.ayes.len(), (m - 3) as usize);
253253
assert_eq!(voting.nays.len(), 1);
254254
}

0 commit comments

Comments
 (0)