Skip to content

Commit

Permalink
Merge branch 'devnet-ready' into feat/solidity-get-stake
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Nov 13, 2024
2 parents 9f64385 + 4b45cd3 commit 56b3365
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/hotfixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Handle Hotfix PRs

on:
pull_request:
types: [opened]

permissions:
pull-requests: write
contents: write

jobs:
handle-hotfix-pr:
runs-on: ubuntu-latest
steps:
- name: Check if PR is a hotfix into `main`
if: >
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.ref != 'testnet'
run: |
echo "Hotfix PR detected. Proceeding to label and comment."
- name: Add `hotfix` label
if: >
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.ref != 'testnet'
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d '{"labels":["hotfix"]}'
- name: Add hotfix bot comment
if: >
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.ref != 'testnet'
run: |
COMMENT_BODY=$(cat <<EOF
## 🚨🚨🚨 HOTFIX DETECTED 🚨🚨🚨
It looks like you are trying to merge a hotfix PR into `main`. If this isn't what you wanted to do, and you just wanted to make a regular PR, please close this PR, base your changes off the `devnet-ready` branch and open a new PR into `devnet ready`.
If you _are_ trying to merge a hotfix PR, please complete the following essential steps:
1. [ ] go ahead and get this PR into `main` merged, so we can get the change in as quickly as possible!
2. [ ] merge `main` into `testnet`, bumping `spec_version`
3. [ ] deploy `testnet`
4. [ ] merge `testnet` into `devnet`, bumping `spec_version`
5. [ ] deploy `devnet`
6. [ ] merge `devnet` into `devnet-ready`
If you do not complete these steps, your hotfix may be inadvertently removed in the future when branches are promoted to \`main\`, so it is essential that you do so.
EOF
)
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions pallets/subtensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ try-runtime = [
"pallet-collective/try-runtime"
]
pow-faucet = []
fast-blocks = []
7 changes: 6 additions & 1 deletion pallets/subtensor/src/subnets/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,12 @@ impl<T: Config> Pallet<T> {
);

// --- 3. Ensure the supplied work passes the difficulty.
let difficulty: U256 = U256::from(1_000_000); // Base faucet difficulty.
let difficulty: U256 = if !cfg!(feature = "fast-blocks") {
U256::from(1_000_000) // Base faucet difficulty.
} else {
U256::from(100) // Lowered for fast blocks
};

let work_hash: H256 = Self::vec_to_hash(work.clone());
ensure!(
Self::hash_meets_difficulty(&work_hash, difficulty),
Expand Down
4 changes: 3 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ substrate-wasm-builder = { workspace = true, optional = true }
[features]
default = ["std"]
pow-faucet = ["pallet-subtensor/pow-faucet"]
fast-blocks = []
fast-blocks = [
"pallet-subtensor/fast-blocks"
]
std = [
"frame-try-runtime?/std",
"frame-system-benchmarking?/std",
Expand Down
12 changes: 12 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ pub enum ProxyType {
Transfer,
SmallTransfer,
RootWeights,
ChildKeys,
SudoUncheckedSetCode,
}
// Transfers below SMALL_TRANSFER_LIMIT are considered small transfers
Expand All @@ -664,6 +665,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::remove_stake { .. })
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. })
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::root_register { .. })
| RuntimeCall::SubtensorModule(
pallet_subtensor::Call::schedule_swap_coldkey { .. }
)
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::swap_hotkey { .. })
),
ProxyType::Transfer => matches!(
c,
Expand Down Expand Up @@ -716,6 +721,13 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
c,
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_root_weights { .. })
),
ProxyType::ChildKeys => matches!(
c,
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_children { .. })
| RuntimeCall::SubtensorModule(
pallet_subtensor::Call::set_childkey_take { .. }
)
),
ProxyType::SudoUncheckedSetCode => match c {
RuntimeCall::Sudo(pallet_sudo::Call::sudo_unchecked_weight { call, weight: _ }) => {
let inner_call: RuntimeCall = *call.clone();
Expand Down

0 comments on commit 56b3365

Please sign in to comment.