Skip to content

Commit reveal v3 #982

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

Merged
merged 46 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c213d2c
etf crypto
orriin Nov 12, 2024
676ad8c
wip crv3
orriin Nov 15, 2024
4ee5e06
Merge branch 'spiigot/add-pallet-drand' into commit-reveal-v3
orriin Nov 15, 2024
41cfff9
crv3 implementation
orriin Nov 18, 2024
3224834
Merge branch 'spiigot/add-pallet-drand' into commit-reveal-v3
orriin Nov 18, 2024
bb16b28
clippy
orriin Nov 18, 2024
c8facf4
zepter
orriin Nov 18, 2024
ddc51e5
merge
orriin Nov 21, 2024
46b512f
doc
orriin Nov 21, 2024
357fd6a
bring drand into mock runtimes
JohnReedV Nov 21, 2024
557da60
remove redundant comments
JohnReedV Nov 22, 2024
b1401c2
fix tests
JohnReedV Nov 23, 2024
3d9e408
consider reveal epochs in crv3
JohnReedV Nov 23, 2024
bb11a7c
add hyperparam crv3 rate limit
JohnReedV Nov 23, 2024
318c244
move test
JohnReedV Nov 23, 2024
7492611
move imports
JohnReedV Nov 23, 2024
fdd4280
Merge pull request #1012 from opentensor/spiigot/drand-mock-runtimes
JohnReedV Nov 23, 2024
47df1b4
Merge branch 'spiigot/add-pallet-drand' into commit-reveal-v3
JohnReedV Nov 23, 2024
faa5d9b
Update chainspecs
JohnReedV Nov 23, 2024
1a59ba0
fmt & clippy
JohnReedV Nov 23, 2024
a123ad7
add hyperparam enable/disable crv3
JohnReedV Nov 23, 2024
5479995
Update chainspecs
JohnReedV Nov 24, 2024
3e4076d
add tests & fix bugs
JohnReedV Nov 26, 2024
a51741f
freeze struct WeightsTlockPayload
JohnReedV Nov 26, 2024
40b67df
zepter
JohnReedV Nov 26, 2024
08961fa
Update chainspecs
JohnReedV Nov 26, 2024
9d4dcb5
enable NewPulse event
JohnReedV Nov 26, 2024
2c4c109
Update chainspecs
JohnReedV Nov 26, 2024
aeeaad8
use commit-reveal-enabled
JohnReedV Nov 26, 2024
61d754b
fix bug and test
JohnReedV Nov 26, 2024
62ccf80
Merge branch 'commit-reveal-v3' of github.com:opentensor/subtensor in…
JohnReedV Nov 26, 2024
45830c5
fmt
JohnReedV Nov 26, 2024
8b6351b
Update chainspecs
JohnReedV Nov 26, 2024
574bf7f
add test & saturating math
JohnReedV Nov 26, 2024
3fba9a0
Merge branch 'commit-reveal-v3' of github.com:opentensor/subtensor in…
JohnReedV Nov 26, 2024
af3e095
Update chainspecs
JohnReedV Nov 26, 2024
b510fc8
check weightsminstake pre-dispatch crv3
JohnReedV Nov 26, 2024
864c89a
Update chainspecs
JohnReedV Nov 26, 2024
a0b9d66
more unit tests
JohnReedV Nov 27, 2024
4f90985
Update chainspecs
JohnReedV Nov 27, 2024
3addecc
even more unit tests
JohnReedV Nov 27, 2024
f1ed637
Update chainspecs
JohnReedV Nov 27, 2024
16551f8
expand a test
JohnReedV Nov 27, 2024
965ee3e
Update chainspecs
JohnReedV Nov 27, 2024
af90612
remove deprecated
JohnReedV Nov 27, 2024
e62d438
Merge branch 'commit-reveal-v3' of github.com:opentensor/subtensor in…
JohnReedV Nov 27, 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
231 changes: 145 additions & 86 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", t
getrandom = { version = "0.2.15", features = ["custom"], default-features = false }
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
w3f-bls = { version = "=0.1.3", default-features = false }
ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [ "r1cs", "snark" ] }
ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [ "r1cs", "snark" ] }
ark-scale = { version = "0.0.11", default-features = false, features = ["hazmat"] }
sp-ark-bls12-381 = { git = "https://github.com/paritytech/substrate-curves", default-features = false }
ark-bls12-381 = { version = "0.4.0", features = ["curve"], default-features = false }
Expand All @@ -207,6 +207,7 @@ ark-ec = { version = "0.4.0", default-features = false }
ark-std = { version = "0.4.0", default-features = false }
anyhow = "1.0.81"
sha2 = { version = "0.10.8", default-features = false }
rand_chacha = { version = "0.3.1", default-features = false }
tle = { git = "https://github.com/ideal-lab5/timelock", rev = "5416406cfd32799e31e1795393d4916894de4468", default-features = false }

frame-metadata = "16"
Expand Down
60 changes: 30 additions & 30 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Implementation of the AuraInterface
type Aura: crate::AuraInterface<Self::AuthorityId, Self::MaxAuthorities>;
type Aura: crate::AuraInterface<<Self as Config>::AuthorityId, Self::MaxAuthorities>;

/// The identifier type for an authority.
type AuthorityId: Member
Expand Down Expand Up @@ -71,10 +71,10 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Aura pallet to change the authorities.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::swap_authorities(new_authorities.len() as u32))]
#[pallet::weight(<T as Config>::WeightInfo::swap_authorities(new_authorities.len() as u32))]
pub fn swap_authorities(
origin: OriginFor<T>,
new_authorities: BoundedVec<T::AuthorityId, T::MaxAuthorities>,
new_authorities: BoundedVec<<T as Config>::AuthorityId, T::MaxAuthorities>,
) -> DispatchResult {
ensure_root(origin)?;

Expand All @@ -90,7 +90,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the default take.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::sudo_set_default_take())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_default_take())]
pub fn sudo_set_default_take(origin: OriginFor<T>, default_take: u16) -> DispatchResult {
ensure_root(origin)?;
pallet_subtensor::Pallet::<T>::set_max_delegate_take(default_take);
Expand All @@ -114,7 +114,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the serving rate limit.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::sudo_set_serving_rate_limit())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_serving_rate_limit())]
pub fn sudo_set_serving_rate_limit(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -134,7 +134,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the minimum difficulty.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::sudo_set_min_difficulty())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_min_difficulty())]
pub fn sudo_set_min_difficulty(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -159,7 +159,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the maximum difficulty.
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::sudo_set_max_difficulty())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_difficulty())]
pub fn sudo_set_max_difficulty(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -184,7 +184,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the weights version key.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::sudo_set_weights_version_key())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_weights_version_key())]
pub fn sudo_set_weights_version_key(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -209,7 +209,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the weights set rate limit.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::sudo_set_weights_set_rate_limit())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_weights_set_rate_limit())]
pub fn sudo_set_weights_set_rate_limit(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -237,7 +237,7 @@ pub mod pallet {
/// It is only callable by the root account, not changeable by the subnet owner.
/// The extrinsic will call the Subtensor pallet to set the adjustment interval.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::sudo_set_adjustment_interval())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_adjustment_interval())]
pub fn sudo_set_adjustment_interval(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -292,7 +292,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the adjustment beta.
#[pallet::call_index(12)]
#[pallet::weight(T::WeightInfo::sudo_set_max_weight_limit())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_weight_limit())]
pub fn sudo_set_max_weight_limit(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -317,7 +317,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the immunity period.
#[pallet::call_index(13)]
#[pallet::weight(T::WeightInfo::sudo_set_immunity_period())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_immunity_period())]
pub fn sudo_set_immunity_period(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -342,7 +342,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the minimum allowed weights.
#[pallet::call_index(14)]
#[pallet::weight(T::WeightInfo::sudo_set_min_allowed_weights())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_min_allowed_weights())]
pub fn sudo_set_min_allowed_weights(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -367,7 +367,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the maximum allowed UIDs for a subnet.
#[pallet::call_index(15)]
#[pallet::weight(T::WeightInfo::sudo_set_max_allowed_uids())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_allowed_uids())]
pub fn sudo_set_max_allowed_uids(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -395,7 +395,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the kappa.
#[pallet::call_index(16)]
#[pallet::weight(T::WeightInfo::sudo_set_kappa())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_kappa())]
pub fn sudo_set_kappa(origin: OriginFor<T>, netuid: u16, kappa: u16) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;

Expand All @@ -412,7 +412,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the rho.
#[pallet::call_index(17)]
#[pallet::weight(T::WeightInfo::sudo_set_rho())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_rho())]
pub fn sudo_set_rho(origin: OriginFor<T>, netuid: u16, rho: u16) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;

Expand All @@ -429,7 +429,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the activity cutoff.
#[pallet::call_index(18)]
#[pallet::weight(T::WeightInfo::sudo_set_activity_cutoff())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_activity_cutoff())]
pub fn sudo_set_activity_cutoff(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -511,7 +511,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the target registrations per interval.
#[pallet::call_index(21)]
#[pallet::weight(T::WeightInfo::sudo_set_target_registrations_per_interval())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_target_registrations_per_interval())]
pub fn sudo_set_target_registrations_per_interval(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -539,7 +539,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the minimum burn.
#[pallet::call_index(22)]
#[pallet::weight(T::WeightInfo::sudo_set_min_burn())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_min_burn())]
pub fn sudo_set_min_burn(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -564,7 +564,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the maximum burn.
#[pallet::call_index(23)]
#[pallet::weight(T::WeightInfo::sudo_set_max_burn())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_burn())]
pub fn sudo_set_max_burn(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -589,7 +589,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the difficulty.
#[pallet::call_index(24)]
#[pallet::weight(T::WeightInfo::sudo_set_difficulty())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_difficulty())]
pub fn sudo_set_difficulty(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -613,7 +613,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the maximum allowed validators.
#[pallet::call_index(25)]
#[pallet::weight(T::WeightInfo::sudo_set_max_allowed_validators())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_allowed_validators())]
pub fn sudo_set_max_allowed_validators(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -646,7 +646,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the bonds moving average.
#[pallet::call_index(26)]
#[pallet::weight(T::WeightInfo::sudo_set_bonds_moving_average())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_bonds_moving_average())]
pub fn sudo_set_bonds_moving_average(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -671,7 +671,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the maximum registrations per block.
#[pallet::call_index(27)]
#[pallet::weight(T::WeightInfo::sudo_set_max_registrations_per_block())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_max_registrations_per_block())]
pub fn sudo_set_max_registrations_per_block(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -742,7 +742,7 @@ pub mod pallet {
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the tempo.
#[pallet::call_index(30)]
#[pallet::weight(T::WeightInfo::sudo_set_tempo())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_tempo())]
pub fn sudo_set_tempo(origin: OriginFor<T>, netuid: u16, tempo: u16) -> DispatchResult {
ensure_root(origin)?;
ensure!(
Expand Down Expand Up @@ -964,7 +964,7 @@ pub mod pallet {
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the value.
#[pallet::call_index(49)]
#[pallet::weight(T::WeightInfo::sudo_set_commit_reveal_weights_enabled())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_commit_reveal_weights_enabled())]
pub fn sudo_set_commit_reveal_weights_enabled(
origin: OriginFor<T>,
netuid: u16,
Expand Down Expand Up @@ -1037,7 +1037,7 @@ pub mod pallet {
///
/// # Errors
/// * `DispatchError::BadOrigin` - If the origin is not the root account.
// #[pallet::weight(T::WeightInfo::sudo_set_hotkey_emission_tempo())]
// #[pallet::weight(<T as Config>::WeightInfo::sudo_set_hotkey_emission_tempo())]
#[pallet::call_index(52)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_hotkey_emission_tempo(
Expand Down Expand Up @@ -1080,7 +1080,7 @@ pub mod pallet {
///
// - Consider adding a check to ensure the `netuid` corresponds to an existing network.
// - Implement a mechanism to gradually adjust the max stake to prevent sudden changes.
// #[pallet::weight(T::WeightInfo::sudo_set_network_max_stake())]
// #[pallet::weight(<T as Config>::WeightInfo::sudo_set_network_max_stake())]
#[pallet::call_index(53)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_network_max_stake(
Expand Down Expand Up @@ -1188,7 +1188,7 @@ pub mod pallet {
/// # Weight
/// Weight is handled by the `#[pallet::weight]` attribute.
#[pallet::call_index(57)]
#[pallet::weight(T::WeightInfo::sudo_set_commit_reveal_weights_interval())]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_commit_reveal_weights_interval())]
pub fn sudo_set_commit_reveal_weights_interval(
origin: OriginFor<T>,
netuid: u16,
Expand All @@ -1213,7 +1213,7 @@ pub mod pallet {
}

impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
type Public = T::AuthorityId;
type Public = <T as Config>::AuthorityId;
}

// Interfaces to interact with other pallets
Expand Down
17 changes: 14 additions & 3 deletions pallets/subtensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ pallet-utility = { workspace = true }
ndarray = { workspace = true }
hex = { workspace = true }

# Used for sudo decentralization
pallet-collective = { version = "4.0.0-dev", default-features = false, path = "../collective" }
pallet-drand = { path = "../drand", default-features = false }
pallet-membership = { workspace = true }
hex-literal = { workspace = true }
num-traits = { version = "0.2.19", default-features = false, features = ["libm"] }
tle = { workspace = true, default-features = false }
ark-bls12-381 = { workspace = true, default-features = false }
ark-serialize = { workspace = true, default-features = false }
w3f-bls = { workspace = true, default-features = false }

[dev-dependencies]
pallet-balances = { workspace = true, features = ["std"] }
Expand Down Expand Up @@ -89,7 +93,12 @@ std = [
"serde_with/std",
"substrate-fixed/std",
"num-traits/std",
"serde_json/std"
"serde_json/std",
"tle/std",
"pallet-drand/std",
"ark-bls12-381/std",
"ark-serialize/std",
"w3f-bls/std"
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand All @@ -102,6 +111,7 @@ runtime-benchmarks = [
"pallet-collective/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-drand/runtime-benchmarks"
]
try-runtime = [
"frame-support/try-runtime",
Expand All @@ -113,7 +123,8 @@ try-runtime = [
"pallet-transaction-payment/try-runtime",
"pallet-utility/try-runtime",
"sp-runtime/try-runtime",
"pallet-collective/try-runtime"
"pallet-collective/try-runtime",
"pallet-drand/try-runtime"
]
pow-faucet = []
fast-blocks = []
2 changes: 1 addition & 1 deletion pallets/subtensor/src/coinbase/block_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;
use frame_support::storage::IterableStorageMap;
use substrate_fixed::types::I110F18;

impl<T: Config> Pallet<T> {
impl<T: Config + pallet_drand::Config> Pallet<T> {
/// Executes the necessary operations for each block.
pub fn block_step() -> Result<(), &'static str> {
let block_number: u64 = Self::get_current_block_as_u64();
Expand Down
Loading
Loading