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

[devnet companion] prevent accidental changes to storage structs #550

Merged
merged 56 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4b21dca
add macros crate
sam0x17 Jun 7, 2024
dc1550e
scaffold
sam0x17 Jun 7, 2024
d116b3b
almost working
sam0x17 Jun 7, 2024
54f31ce
working
sam0x17 Jun 7, 2024
2885c23
rip out cargo-husky 🐶✂️
sam0x17 Jun 7, 2024
201c15e
fix
JohnReedV Jun 13, 2024
7113573
fix priority
JohnReedV Jun 13, 2024
7408aca
root weight dipatch test
Jun 13, 2024
d99f7dc
handle zero args case
sam0x17 Jun 13, 2024
54fee90
stable hashing algorithm
sam0x17 Jun 13, 2024
e6175e9
Merge remote-tracking branch 'origin/main' into sam-add-freeze-layout
sam0x17 Jun 13, 2024
5e95bd0
delete random file
sam0x17 Jun 13, 2024
0618272
add macros to workspace deps
sam0x17 Jun 13, 2024
e8b03cb
chore: bump spec version
Jun 13, 2024
ad39bdd
add to existing storage structs
sam0x17 Jun 13, 2024
b52e2e5
update localnet script
Jun 13, 2024
0a5368a
chore: run ci on every push
Jun 13, 2024
377086e
add freeze_struct_ignore_ra
sam0x17 Jun 13, 2024
4c05546
WIP
sam0x17 Jun 13, 2024
a2464b8
fix : ci rust
Jun 13, 2024
dd78f0e
chore: uncomment push conditions
Jun 13, 2024
7682875
chore: lint
Jun 13, 2024
d237974
chore: silence clippy in tests
Jun 13, 2024
a079954
fix problematic cases
sam0x17 Jun 13, 2024
f9ff8d1
chore: fmt
Jun 13, 2024
398b8f5
chore: use stable in ci
Jun 13, 2024
2bf5a35
chore: comment out clippy
Jun 13, 2024
fc2bf27
add test for root weights transaction validation
camfairchild Jun 14, 2024
07cf0e0
also test commit/reveal transaction validity check
camfairchild Jun 14, 2024
e42c10a
uncomment ci
Jun 14, 2024
c638e59
chore: clippy
Jun 14, 2024
98ed152
fix clippy
open-junius Jun 14, 2024
673d619
fix clippy
open-junius Jun 14, 2024
3656126
fix clippy
open-junius Jun 14, 2024
530b05d
fix clippy
open-junius Jun 14, 2024
7173614
fix clippy
open-junius Jun 14, 2024
8445ab7
fix clippy
open-junius Jun 14, 2024
cecdf02
fix clippy
open-junius Jun 14, 2024
edce0dd
fix clippy
open-junius Jun 14, 2024
2b07546
fix clippy
open-junius Jun 14, 2024
6cccfb5
fix clippy
open-junius Jun 14, 2024
ef4b241
fix: fast blocks false
Jun 14, 2024
eba20c2
chore: remove hard coded false
Jun 14, 2024
d16970a
Update pallets/subtensor/tests/block_step.rs
distributedstatemachine Jun 14, 2024
5a40b75
Update pallets/subtensor/tests/block_step.rs
distributedstatemachine Jun 14, 2024
87e47c5
clippy: just block
camfairchild Jun 14, 2024
b4ca34b
Merge pull request #527 from opentensor/hotfix/set-root-weights
distributedstatemachine Jun 14, 2024
64784b9
working
sam0x17 Jun 14, 2024
a764728
Merge remote-tracking branch 'origin/main' into sam-add-freeze-layout
sam0x17 Jun 14, 2024
1fe85aa
clippy fixes
sam0x17 Jun 14, 2024
a79a38a
fix Dockerfile
sam0x17 Jun 14, 2024
65423b4
only apply devnet-pass/testnet-pass label check to PRs on main
sam0x17 Jun 14, 2024
e8eae82
Merge pull request #538 from opentensor/sam-fix-check-labels
sam0x17 Jun 18, 2024
c8016ca
Merge remote-tracking branch 'origin/main' into sam-add-freeze-layout
sam0x17 Jun 19, 2024
5e9955a
Merge remote-tracking branch 'origin/devnet-ready' into sam-add-freez…
sam0x17 Jun 19, 2024
68ab335
appease clippy
sam0x17 Jun 19, 2024
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
18 changes: 0 additions & 18 deletions .cargo-husky/hooks/prepare-commit-msg

This file was deleted.

59 changes: 5 additions & 54 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
- stable
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
Expand Down Expand Up @@ -119,55 +119,7 @@ jobs:
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
os:
- ubuntu-latest
# - macos-latest
include:
- os: ubuntu-latest
# - os: macos-latest
env:
RELEASE_NAME: development
# RUSTFLAGS: -A warnings
RUSTV: ${{ matrix.rust-branch }}
RUST_BACKTRACE: full
RUST_BIN_DIR: target/${{ matrix.rust-target }}
SKIP_WASM_BUILD: 1
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Install Rust ${{ matrix.rust-branch }}
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: ${{ matrix.rust-branch }}
components: rustfmt, clippy
profile: minimal

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2.2.1
with:
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}

- name: cargo clippy --workspace --all-targets --all-features -- -D warnings
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

cargo-clippy-all-features:
name: cargo clippy --all-features
runs-on: SubtensorCI
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
- stable
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
Expand Down Expand Up @@ -208,15 +160,14 @@ jobs:

- name: cargo clippy --workspace --all-targets --all-features -- -D warnings
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

# runs cargo test --workspace
cargo-test:
name: cargo test
runs-on: SubtensorCI
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
- stable
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
Expand Down Expand Up @@ -265,7 +216,7 @@ jobs:
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
- stable
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
Expand Down Expand Up @@ -314,7 +265,7 @@ jobs:
strategy:
matrix:
rust-branch:
- nightly-2024-03-05
- stable
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/devnet-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Tested on Devnet
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [main]
jobs:
check-labels:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/testnet-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Tested on Testnet
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [main]
jobs:
check-labels:
runs-on: ubuntu-latest
Expand Down
Empty file removed CITATION.cft
Empty file.
16 changes: 16 additions & 0 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"pallets/commitments",
"pallets/subtensor",
"runtime",
"support/macros",
]
resolver = "2"

Expand Down Expand Up @@ -36,6 +37,8 @@ serde_with = { version = "=2.0.0", default-features = false }
smallvec = "1.13.2"
litep2p = { git = "https://github.com/paritytech/litep2p", branch = "master" }

subtensor-macros = { path = "support/macros" }

frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ COPY ./raw_testspec.json /subtensor/raw_testspec.json
COPY ./node /subtensor/node
COPY ./pallets /subtensor/pallets
COPY ./runtime /subtensor/runtime
COPY ./support /subtensor/support

# Update to nightly toolchain
# Copy our toolchain
COPY rust-toolchain.toml /subtensor/
RUN /subtensor/scripts/init.sh

Expand Down
4 changes: 2 additions & 2 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct FullDeps<C, P, B> {
/// Grandpa block import setup.
pub grandpa: GrandpaDeps<B>,
/// Backend used by the node.
pub backend: Arc<B>,
pub _backend: Arc<B>,
}

/// Instantiate all full RPC extensions.
Expand Down Expand Up @@ -74,7 +74,7 @@ where
pool,
deny_unsafe,
grandpa,
backend: _,
_backend: _,
} = deps;

// Custom RPC methods for Paratensor
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
subscription_executor: subscription_executor.clone(),
finality_provider: finality_proof_provider.clone(),
},
backend: rpc_backend.clone(),
_backend: rpc_backend.clone(),
};
crate::rpc::create_full(deps).map_err(Into::into)
},
Expand Down
1 change: 1 addition & 0 deletions pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
subtensor-macros.workspace = true
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
] }
Expand Down
1 change: 0 additions & 1 deletion pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub use weights::WeightInfo;
use sp_runtime::DispatchError;
use sp_runtime::{traits::Member, RuntimeAppPublic};

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

#[deny(missing_docs)]
Expand Down
1 change: 1 addition & 0 deletions pallets/collective/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
subtensor-macros.workspace = true
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
] }
Expand Down
2 changes: 2 additions & 0 deletions pallets/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ mod benchmarking;
pub mod weights;

pub use pallet::*;
use subtensor_macros::freeze_struct;
pub use weights::WeightInfo;

const LOG_TARGET: &str = "runtime::collective";
Expand Down Expand Up @@ -150,6 +151,7 @@ impl<AccountId, I> GetBacking for RawOrigin<AccountId, I> {
}

/// Info for keeping track of a motion being voted on.
#[freeze_struct("5959418cdb31993b")]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct Votes<AccountId, BlockNumber> {
/// The proposal's unique index.
Expand Down
1 change: 1 addition & 0 deletions pallets/commitments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
subtensor-macros.workspace = true
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
"max-encoded-len",
Expand Down
8 changes: 4 additions & 4 deletions pallets/commitments/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![cfg_attr(not(feature = "std"), no_std)]

mod benchmarking;
#[cfg(test)]
mod tests;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

pub mod types;
pub mod weights;

pub use pallet::*;
use subtensor_macros::freeze_struct;
pub use types::*;
pub use weights::WeightInfo;

Expand Down Expand Up @@ -210,6 +209,7 @@ use {
},
};

#[freeze_struct("6a00398e14a8a984")]
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
pub struct CommitmentsSignedExtension<T: Config + Send + Sync + TypeInfo>(pub PhantomData<T>);

Expand All @@ -235,7 +235,7 @@ where
pub fn get_priority_vanilla() -> u64 {
// Return high priority so that every extrinsic except set_weights function will
// have a higher priority than the set_weights call
u64::max_value()
u64::MAX
}
}

Expand Down
4 changes: 3 additions & 1 deletion pallets/commitments/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use sp_runtime::{
RuntimeDebug,
};
use sp_std::{fmt::Debug, iter::once, prelude::*};
use subtensor_macros::freeze_struct;

/// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater
/// than 32-bytes then it will be truncated when encoding.
Expand Down Expand Up @@ -283,11 +284,12 @@ impl Default for Data {
}
}

#[freeze_struct("25c84048dcc90813")]
#[derive(
CloneNoBound, Encode, Decode, Eq, MaxEncodedLen, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo,
)]
#[codec(mel_bound())]
#[cfg_attr(test, derive(frame_support::DefaultNoBound))]
#[derive(frame_support::DefaultNoBound)]
#[scale_info(skip_type_params(FieldLimit))]
pub struct CommitmentInfo<FieldLimit: Get<u32>> {
pub fields: BoundedVec<Data, FieldLimit>,
Expand Down
1 change: 1 addition & 0 deletions pallets/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
subtensor-macros.workspace = true
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
"max-encoded-len",
Expand Down
1 change: 0 additions & 1 deletion pallets/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[cfg(test)]
mod tests;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod types;
pub mod weights;
Expand Down
4 changes: 3 additions & 1 deletion pallets/registry/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use sp_runtime::{
RuntimeDebug,
};
use sp_std::{fmt::Debug, iter::once, ops::Add, prelude::*};
use subtensor_macros::freeze_struct;

/// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater
/// than 32-bytes then it will be truncated when encoding.
Expand Down Expand Up @@ -278,11 +279,12 @@ impl TypeInfo for IdentityFields {
///
/// NOTE: This should be stored at the end of the storage item to facilitate the addition of extra
/// fields in a backwards compatible way through a specialized `Decode` impl.
#[freeze_struct("70b183c8753429f1")]
#[derive(
CloneNoBound, Encode, Decode, Eq, MaxEncodedLen, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo,
)]
#[codec(mel_bound())]
#[cfg_attr(test, derive(frame_support::DefaultNoBound))]
#[derive(frame_support::DefaultNoBound)]
#[scale_info(skip_type_params(FieldLimit))]
pub struct IdentityInfo<FieldLimit: Get<u32>> {
/// Additional fields of the identity that are not catered for with the struct's explicit
Expand Down
Loading
Loading