Skip to content

Commit 6b9801f

Browse files
authored
Merge pull request #533 from opentensor/sam-add-freeze-layout
prevent accidental changes to storage structs
2 parents 7d589c4 + c572ed6 commit 6b9801f

File tree

25 files changed

+260
-21
lines changed

25 files changed

+260
-21
lines changed

.cargo-husky/hooks/prepare-commit-msg

Lines changed: 0 additions & 18 deletions
This file was deleted.

CITATION.cft

Whitespace-only changes.

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"pallets/commitments",
55
"pallets/subtensor",
66
"runtime",
7+
"support/macros",
78
]
89
resolver = "2"
910

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

40+
subtensor-macros = { path = "support/macros" }
41+
3942
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }
4043
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0" }
4144
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.10.0", default-features = false }

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json
4545
COPY ./node /subtensor/node
4646
COPY ./pallets /subtensor/pallets
4747
COPY ./runtime /subtensor/runtime
48+
COPY ./support /subtensor/support
4849

49-
# Update to nightly toolchain
50+
# Copy our toolchain
5051
COPY rust-toolchain.toml /subtensor/
5152
RUN /subtensor/scripts/init.sh
5253

pallets/admin-utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ workspace = true
1616
targets = ["x86_64-unknown-linux-gnu"]
1717

1818
[dependencies]
19+
subtensor-macros.workspace = true
1920
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
2021
"derive",
2122
] }

pallets/collective/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ workspace = true
1616
targets = ["x86_64-unknown-linux-gnu"]
1717

1818
[dependencies]
19+
subtensor-macros.workspace = true
1920
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
2021
"derive",
2122
] }

pallets/collective/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ mod benchmarking;
6565
pub mod weights;
6666

6767
pub use pallet::*;
68+
use subtensor_macros::freeze_struct;
6869
pub use weights::WeightInfo;
6970

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

152153
/// Info for keeping track of a motion being voted on.
154+
#[freeze_struct("a8e7b0b34ad52b17")]
153155
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
154156
pub struct Votes<AccountId, BlockNumber> {
155157
/// The proposal's unique index.

pallets/commitments/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ workspace = true
1616
targets = ["x86_64-unknown-linux-gnu"]
1717

1818
[dependencies]
19+
subtensor-macros.workspace = true
1920
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
2021
"derive",
2122
"max-encoded-len",

pallets/commitments/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod types;
88
pub mod weights;
99

1010
pub use pallet::*;
11+
use subtensor_macros::freeze_struct;
1112
pub use types::*;
1213
pub use weights::WeightInfo;
1314

@@ -208,6 +209,7 @@ use {
208209
},
209210
};
210211

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

0 commit comments

Comments
 (0)