Skip to content

devnet deploy 12-6-2024 CR3 debug #1072

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 73 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5e2d135
add impl; needs tests
camfairchild Nov 26, 2024
8642fd4
Update chainspecs
camfairchild Nov 26, 2024
48456db
only error on commit enabled
camfairchild Nov 26, 2024
fce1dc1
fix doc string
camfairchild Nov 26, 2024
1eacf69
Update chainspecs
camfairchild Nov 26, 2024
a84fe51
add test for set weights batch and fix doc string
camfairchild Nov 26, 2024
0756cc5
add batch commit and test
camfairchild Nov 26, 2024
9294d3a
add index comment next to errors
camfairchild Nov 26, 2024
fe9b33c
bump spec ver
camfairchild Nov 26, 2024
e6bc596
Update chainspecs
camfairchild Nov 26, 2024
5b90f6c
Add admin extrinsic to set chain ID
gztensor Nov 27, 2024
6540ed4
Add unit tests for setting chain ID admin extrinsic
gztensor Nov 27, 2024
df5877c
Update chainspecs
gztensor Nov 27, 2024
2a1db9d
add length check
camfairchild Nov 27, 2024
a0e0636
chore: fmt
camfairchild Nov 27, 2024
c8369c1
add error to comments
camfairchild Nov 27, 2024
edb2412
Update chainspecs
camfairchild Nov 27, 2024
e33a580
Pending children, tests passing, no specific tests
gztensor Dec 3, 2024
88bf635
Pending children, specific tests
gztensor Dec 3, 2024
07cef6a
Merge branch 'devnet-ready' into feat/pending-childkeys
gztensor Dec 3, 2024
aad6f56
Add pending childkey cooldown test
gztensor Dec 3, 2024
01e90ab
Merge branch 'devnet-ready' into feat/admin-set-evm-chain-id
gztensor Dec 3, 2024
e9fb1c5
Bump spec version
gztensor Dec 3, 2024
796ffdb
Bump spec version
gztensor Dec 3, 2024
eb154a8
Revert "Bump spec version"
gztensor Dec 4, 2024
962bf82
Revert "Bump spec version"
gztensor Dec 4, 2024
2c63c6c
Fix clippy issues
gztensor Dec 4, 2024
19d175f
fmt
gztensor Dec 4, 2024
d001c99
Fix test for removing stake
gztensor Dec 4, 2024
b4d41d0
Add ChildkeysMinStake, fix clippy, fix tests
gztensor Dec 4, 2024
91c0d4a
Use StakeThreshold instead of WeightsMinStake and ChildkeyMinStake
gztensor Dec 4, 2024
c596998
Set that migration has run for StakeThreshold migration
gztensor Dec 4, 2024
7e03512
Merge branch 'devnet-ready' into feat/pending-childkeys
gztensor Dec 4, 2024
8a4962c
throw TooManyUnrevealedCommits per hotkey
JohnReedV Dec 4, 2024
c113b88
Merge pull request #1061 from opentensor/spiigot/fix-crv3-devnet-2
sam0x17 Dec 5, 2024
ffa76ba
fix Dockerfile
sam0x17 Dec 5, 2024
5096be2
bump CI
sam0x17 Dec 5, 2024
c7ae614
use newer ubuntu
sam0x17 Dec 5, 2024
31f9e54
docker build must pass for CI to pass
sam0x17 Dec 5, 2024
6e43a0d
rename
sam0x17 Dec 5, 2024
7b5ad83
add workflow_dispatch option
sam0x17 Dec 5, 2024
a202f44
Merge pull request #1063 from opentensor/fix-dockerfile
sam0x17 Dec 5, 2024
0cad3de
use correct grandpa addresses for devnet
sam0x17 Dec 5, 2024
7bcf2ec
log drand deserialization
JohnReedV Dec 5, 2024
01ff37b
Merge pull request #1064 from opentensor/fix-devnet-chainspec
sam0x17 Dec 5, 2024
4fdd7f3
Merge branch 'devnet-ready' into feat/batch-set-weights
camfairchild Dec 5, 2024
346377b
chore: fmt
camfairchild Dec 5, 2024
3ebcdb9
cargo run -p node-subtensor -- build-spec --chain dev >chainspecs/pla…
sam0x17 Dec 5, 2024
63ff23a
revert to debug
JohnReedV Dec 5, 2024
048d1b3
cargo run -p node-subtensor -- build-spec --chain dev --raw > raw_spe…
sam0x17 Dec 5, 2024
a558ab3
whoops
sam0x17 Dec 5, 2024
ee302fc
bump spec_version to 215
sam0x17 Dec 5, 2024
8b36200
Update chainspecs
sam0x17 Dec 5, 2024
888438e
bump CI
sam0x17 Dec 5, 2024
9efedff
change call index
sam0x17 Dec 6, 2024
8d4adf9
bump spec version
sam0x17 Dec 6, 2024
f87d97d
Merge pull request #1030 from opentensor/feat/admin-set-evm-chain-id
sam0x17 Dec 6, 2024
51cdd9c
Merge pull request #1050 from opentensor/feat/pending-childkeys
sam0x17 Dec 6, 2024
28780d9
Merge remote-tracking branch 'origin/devnet-ready' into feat/batch-se…
sam0x17 Dec 6, 2024
7417fac
commit Cargo.lock changes
sam0x17 Dec 6, 2024
ed8a892
Merge pull request #1070 from opentensor/update-devnet-chainspec
sam0x17 Dec 6, 2024
81345c1
Merge remote-tracking branch 'origin/devnet-ready' into spiigot/log-d…
sam0x17 Dec 6, 2024
4877062
Use new stake_threshold
camfairchild Dec 6, 2024
25758dc
Merge pull request #1065 from opentensor/spiigot/log-drand-deserializion
sam0x17 Dec 6, 2024
cc76060
clippy
sam0x17 Dec 6, 2024
83af209
Merge remote-tracking branch 'origin/devnet-ready' into feat/batch-se…
sam0x17 Dec 6, 2024
e44fbf6
Merge pull request #1022 from opentensor/feat/batch-set-weights
sam0x17 Dec 6, 2024
7d8f591
fix release notes script
sam0x17 Dec 6, 2024
197798f
Merge pull request #1073 from opentensor/fix-release-notes-script
sam0x17 Dec 6, 2024
f5a1443
remove unneeded files
sam0x17 Dec 6, 2024
ed9d9e8
Merge pull request #1074 from opentensor/remove-extra-chainspec-files
sam0x17 Dec 6, 2024
8fdfb73
tweak
sam0x17 Dec 6, 2024
dec011f
tweaks
sam0x17 Dec 6, 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
21 changes: 21 additions & 0 deletions .github/workflows/check-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Docker Image

on:
pull_request:

jobs:
build:
runs-on: SubtensorCI

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker Image
run: docker build .
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Publish Docker Image
on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=ubuntu:20.04
ARG BASE_IMAGE=ubuntu:24.04

FROM $BASE_IMAGE AS builder
SHELL ["/bin/bash", "-c"]
Expand All @@ -15,7 +15,7 @@ LABEL ai.opentensor.image.authors="[email protected]" \
# Set up Rust environment
ENV RUST_BACKTRACE=1
RUN apt-get update && \
apt-get install -y curl build-essential protobuf-compiler clang git && \
apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev && \
rm -rf /var/lib/apt/lists/*

RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
Expand Down
63 changes: 36 additions & 27 deletions chainspecs/plain_spec_devnet.json

Large diffs are not rendered by default.

144 changes: 91 additions & 53 deletions chainspecs/raw_spec_devnet.json

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions node/src/chain_spec/devnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,23 @@ pub fn devnet_config() -> Result<ChainSpec, String> {
// Keys for debug
authority_keys_from_ss58(
"5D5ABUyMsdmJdH7xrsz9vREq5eGXr5pXhHxix2dENQR62dEo",
"5H3qMjQjoeZxZ98jzDmoCwbz2sugd5fDN1wrr8Phf49zemKL",
"5DLBJuPvyPYit5h5ZaYiF8NvCweXCozUs6pLx3fng1mdVcbw",
),
authority_keys_from_ss58(
"5GbRc5sNDdhcPAU9suV2g9P5zyK1hjAQ9JHeeadY1mb8kXoM",
"5GbkysfaCjK3cprKPhi3CUwaB5xWpBwcfrkzs6FmqHxej8HZ",
"5ELAzpniRUzAtvydVLmfs5ogbjzoBVxfn6XrN91ahBeDukoY",
),
authority_keys_from_ss58(
"5CoVWwBwXz2ndEChGcS46VfSTb3RMUZzZzAYdBKo263zDhEz",
"5HTLp4BvPp99iXtd8YTBZA1sMfzo8pd4mZzBJf7HYdCn2boU",
"5EHVLDoMqjWrBnUrNtj8FAb1sFFg97vydLGydH8vz7BGs9Qf",
),
authority_keys_from_ss58(
"5EekcbqupwbgWqF8hWGY4Pczsxp9sbarjDehqk7bdyLhDCwC",
"5GAemcU4Pzyfe8DwLwDFx3aWzyg3FuqYUCCw2h4sdDZhyFvE",
"5CdFyer8NZ4m8QXAHkgZ7zQ8oM8U6N5XrMSDzcMWdDjbAwUg",
),
authority_keys_from_ss58(
"5GgdEQyS5DZzUwKuyucEPEZLxFKGmasUFm1mqM3sx1MRC5RV",
"5EibpMomXmgekxcfs25SzFBpGWUsG9Lc8ALNjXN3TYH5Tube",
),
authority_keys_from_ss58(
"5Ek5JLCGk2PuoT1fS23GXiWYUT98HVUBERFQBu5g57sNf44x",
"5Gyrc6b2mx1Af6zWJYHdx3gwgtXgZvD9YkcG9uTUPYry4V2a",
"5FYgXyYc59s9c161swNEf4VEGezLd3q5ca6rSYWuJPjbBNKf",
),
],
// Sudo account
Expand Down
4 changes: 3 additions & 1 deletion pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ log = { workspace = true }
pallet-subtensor = { version = "4.0.0-dev", default-features = false, path = "../subtensor" }
sp-weights = { workspace = true }
substrate-fixed = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-drand = { workspace = true, default-features = false }


[dev-dependencies]
sp-core = { workspace = true }
sp-io = { workspace = true }
Expand All @@ -52,6 +52,7 @@ std = [
"pallet-subtensor/std",
"sp-consensus-aura/std",
"pallet-balances/std",
"pallet-evm-chain-id/std",
"pallet-scheduler/std",
"sp-runtime/std",
"sp-tracing/std",
Expand All @@ -77,6 +78,7 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-evm-chain-id/try-runtime",
"pallet-scheduler/try-runtime",
"sp-runtime/try-runtime",
"pallet-subtensor/try-runtime",
Expand Down
32 changes: 29 additions & 3 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod pallet {
use frame_support::pallet_prelude::*;
use frame_support::traits::tokens::Balance;
use frame_system::pallet_prelude::*;
use pallet_evm_chain_id::{self, ChainId};
use sp_runtime::BoundedVec;

/// The main data structure of the module.
Expand All @@ -29,7 +30,11 @@ pub mod pallet {

/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
pub trait Config: frame_system::Config + pallet_subtensor::pallet::Config {
pub trait Config:
frame_system::Config
+ pallet_subtensor::pallet::Config
+ pallet_evm_chain_id::pallet::Config
{
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

Expand Down Expand Up @@ -885,9 +890,9 @@ pub mod pallet {
/// The extrinsic will call the Subtensor pallet to set the weights min stake.
#[pallet::call_index(42)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_weights_min_stake(origin: OriginFor<T>, min_stake: u64) -> DispatchResult {
pub fn sudo_set_stake_threshold(origin: OriginFor<T>, min_stake: u64) -> DispatchResult {
ensure_root(origin)?;
pallet_subtensor::Pallet::<T>::set_weights_min_stake(min_stake);
pallet_subtensor::Pallet::<T>::set_stake_threshold(min_stake);
Ok(())
}

Expand Down Expand Up @@ -1212,6 +1217,27 @@ pub mod pallet {
);
Ok(())
}

/// Sets the EVM ChainID.
///
/// # Arguments
/// * `origin` - The origin of the call, which must be the subnet owner or the root account.
/// * `chainId` - The u64 chain ID
///
/// # Errors
/// * `BadOrigin` - If the caller is neither the subnet owner nor the root account.
///
/// # Weight
/// Weight is handled by the `#[pallet::weight]` attribute.
#[pallet::call_index(58)]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_evm_chain_id())]
pub fn sudo_set_evm_chain_id(origin: OriginFor<T>, chain_id: u64) -> DispatchResult {
// Ensure the call is made by the root account
ensure_root(origin)?;

ChainId::<T>::set(chain_id);
Ok(())
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ frame_support::construct_runtime!(
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>, Error<T>} = 4,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 5,
Drand: pallet_drand::{Pallet, Call, Storage, Event<T>} = 6,
EVMChainId: pallet_evm_chain_id = 7,
}
);

Expand Down Expand Up @@ -277,6 +278,7 @@ impl pallet_scheduler::Config for Test {
type Preimages = ();
}

impl pallet_evm_chain_id::Config for Test {}
impl pallet_drand::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_drand::weights::SubstrateWeight<Test>;
Expand Down
45 changes: 39 additions & 6 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,23 @@ fn test_sudo_set_max_allowed_validators() {
}

#[test]
fn test_sudo_set_weights_min_stake() {
fn test_sudo_set_stake_threshold() {
new_test_ext().execute_with(|| {
let to_be_set: u64 = 10;
let init_value: u64 = SubtensorModule::get_weights_min_stake();
let init_value: u64 = SubtensorModule::get_stake_threshold();
assert_eq!(
AdminUtils::sudo_set_weights_min_stake(
AdminUtils::sudo_set_stake_threshold(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
to_be_set
),
Err(DispatchError::BadOrigin)
);
assert_eq!(SubtensorModule::get_weights_min_stake(), init_value);
assert_ok!(AdminUtils::sudo_set_weights_min_stake(
assert_eq!(SubtensorModule::get_stake_threshold(), init_value);
assert_ok!(AdminUtils::sudo_set_stake_threshold(
<<Test as Config>::RuntimeOrigin>::root(),
to_be_set
));
assert_eq!(SubtensorModule::get_weights_min_stake(), to_be_set);
assert_eq!(SubtensorModule::get_stake_threshold(), to_be_set);
});
}

Expand Down Expand Up @@ -1433,3 +1433,36 @@ fn sudo_set_commit_reveal_weights_interval() {
assert_eq!(SubtensorModule::get_reveal_period(netuid), to_be_set);
});
}

#[test]
fn test_sudo_root_sets_evm_chain_id() {
new_test_ext().execute_with(|| {
let chain_id: u64 = 945;
assert_eq!(pallet_evm_chain_id::ChainId::<Test>::get(), 0);

assert_ok!(AdminUtils::sudo_set_evm_chain_id(
<<Test as Config>::RuntimeOrigin>::root(),
chain_id
));

assert_eq!(pallet_evm_chain_id::ChainId::<Test>::get(), chain_id);
});
}

#[test]
fn test_sudo_non_root_cannot_set_evm_chain_id() {
new_test_ext().execute_with(|| {
let chain_id: u64 = 945;
assert_eq!(pallet_evm_chain_id::ChainId::<Test>::get(), 0);

assert_eq!(
AdminUtils::sudo_set_evm_chain_id(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(0)),
chain_id
),
Err(DispatchError::BadOrigin)
);

assert_eq!(pallet_evm_chain_id::ChainId::<Test>::get(), 0);
});
}
9 changes: 9 additions & 0 deletions pallets/admin-utils/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub trait WeightInfo {
fn sudo_set_tempo() -> Weight;
fn sudo_set_commit_reveal_weights_interval() -> Weight;
fn sudo_set_commit_reveal_weights_enabled() -> Weight;
fn sudo_set_evm_chain_id() -> Weight;
}

/// Weights for `pallet_admin_utils` using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -431,6 +432,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
fn sudo_set_evm_chain_id() -> Weight {
Weight::from_parts(20_200_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}

// For backwards compatibility and tests.
Expand Down Expand Up @@ -805,4 +810,8 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
fn sudo_set_evm_chain_id() -> Weight {
Weight::from_parts(20_200_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
17 changes: 15 additions & 2 deletions pallets/drand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,13 @@ impl<T: Config> Pallet<T> {
let mut last_stored_round = LastStoredRound::<T>::get();
let latest_pulse_body = Self::fetch_drand_latest().map_err(|_| "Failed to query drand")?;
let latest_unbounded_pulse: DrandResponseBody = serde_json::from_str(&latest_pulse_body)
.map_err(|_| "Drand: Failed to serialize response body to pulse")?;
.map_err(|_| {
log::warn!(
"Drand: Response that failed to deserialize: {}",
latest_pulse_body
);
"Drand: Failed to serialize response body to pulse"
})?;
let latest_pulse = latest_unbounded_pulse
.try_into_pulse()
.map_err(|_| "Drand: Received pulse contains invalid data")?;
Expand All @@ -417,7 +423,14 @@ impl<T: Config> Pallet<T> {
let pulse_body = Self::fetch_drand_by_round(round)
.map_err(|_| "Drand: Failed to query drand for round")?;
let unbounded_pulse: DrandResponseBody = serde_json::from_str(&pulse_body)
.map_err(|_| "Drand: Failed to serialize response body to pulse")?;
.map_err(|_| {
log::warn!(
"Drand: Response that failed to deserialize for round {}: {}",
round,
pulse_body
);
"Drand: Failed to serialize response body to pulse"
})?;
let pulse = unbounded_pulse
.try_into_pulse()
.map_err(|_| "Drand: Received pulse contains invalid data")?;
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/coinbase/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ impl<T: Config> Pallet<T> {

// Check to see if the hotkey has enough stake to set weights.
ensure!(
Self::get_total_stake_for_hotkey(&hotkey) >= Self::get_weights_min_stake(),
Self::get_total_stake_for_hotkey(&hotkey) >= Self::get_stake_threshold(),
Error::<T>::NotEnoughStakeToSetWeights
);

Expand Down
3 changes: 3 additions & 0 deletions pallets/subtensor/src/coinbase/run_coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ impl<T: Config> Pallet<T> {
);
log::debug!("Accumulated emissions on hotkey {:?} for netuid {:?}: mining {:?}, validator {:?}", hotkey, *netuid, mining_emission, validator_emission);
}

// 4.5 Apply pending childkeys of this subnet for the next epoch
Self::do_set_pending_children(*netuid);
} else {
// No epoch, increase blocks since last step and continue
Self::set_blocks_since_last_step(
Expand Down
Loading
Loading