Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-popescu-reef committed Apr 4, 2024
1 parent 09e0270 commit 3cb512e
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 15 deletions.
2 changes: 2 additions & 0 deletions pallets/subtensor/src/certificate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use crate::Vec;
pub type Certificate = Vec<u8>;
3 changes: 1 addition & 2 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,6 @@ pub mod pallet {
))
.saturating_add(migration::migrate_delete_subnet_3::<T>())
.saturating_add(migration::migrate_delete_subnet_21::<T>());

return weight;
}
}
Expand Down Expand Up @@ -1637,7 +1636,7 @@ pub mod pallet {
}

#[pallet::call_index(59)]
#[pallet::weight((Weight::from_ref_time(85_000_000)
#[pallet::weight((Weight::from_ref_time(0)
.saturating_add(T::DbWeight::get().reads(16))
.saturating_add(T::DbWeight::get().writes(28)), DispatchClass::Operational, Pays::No))]
pub fn register_network(origin: OriginFor<T>) -> DispatchResult {
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ 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 = U256::from(10); // Base faucet difficulty. HEREEE
let work_hash: H256 = Self::vec_to_hash(work.clone());
ensure!(
Self::hash_meets_difficulty(&work_hash, difficulty),
Expand All @@ -400,7 +400,7 @@ impl<T: Config> Pallet<T> {
UsedWork::<T>::insert(&work.clone(), current_block_number);

// --- 5. Add Balance via faucet.
let balance_to_add: u64 = 100_000_000_000;
let balance_to_add: u64 = 1_000_000_000_000;
let balance_to_be_added_as_balance = Self::u64_to_balance(balance_to_add);
Self::add_balance_to_coldkey_account(&coldkey, balance_to_be_added_as_balance.unwrap());
TotalIssuance::<T>::put(TotalIssuance::<T>::get().saturating_add(balance_to_add));
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl<T: Config> Pallet<T> {
Self::set_target_registrations_per_interval(netuid, 1);
Self::set_adjustment_alpha(netuid, 17_893_341_751_498_265_066); // 18_446_744_073_709_551_615 * 0.97 = 17_893_341_751_498_265_066
Self::set_immunity_period(netuid, 5000);
Self::set_min_burn(netuid, 1);
Self::set_min_burn(netuid, 0);
Self::set_min_difficulty(netuid, u64::MAX);
Self::set_max_difficulty(netuid, u64::MAX);

Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<T: Config> Pallet<T> {
prev_axon_info: &AxonInfoOf,
current_block: u64,
) -> bool {
let rate_limit: u64 = Self::get_serving_rate_limit(netuid);
let rate_limit: u64 = 0; //Self::get_serving_rate_limit(netuid);
let last_serve = prev_axon_info.block;
return rate_limit == 0 || last_serve == 0 || current_block - last_serve >= rate_limit;
}
Expand Down
67 changes: 67 additions & 0 deletions raw_testspec_andr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ parameter_types! {
pub const SubtensorInitialSubnetOwnerCut: u16 = 11_796; // 18 percent
pub const SubtensorInitialSubnetLimit: u16 = 12;
pub const SubtensorInitialNetworkLockReductionInterval: u64 = 14 * 7200;
pub const SubtensorInitialNetworkRateLimit: u64 = 1 * 7200;
pub const SubtensorInitialNetworkRateLimit: u64 = 1 * 200; // HEREEE
}

impl pallet_subtensor::Config for Runtime {
Expand Down
19 changes: 11 additions & 8 deletions scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ if [[ $BUILD_BINARY == "1" ]]; then
echo "*** Binary compiled"
fi

echo "*** Building chainspec..."
./target/release/node-subtensor build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH
echo "*** Chainspec built and output to file"

echo "*** Purging previous state..."
./target/release/node-subtensor purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1
./target/release/node-subtensor purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1
echo "*** Previous chainstate purged"
echo $CHAIN
echo $FULL_PATH

# echo "*** Building chainspec..."
# ./target/release/node-subtensor build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH
# echo "*** Chainspec built and output to file"

# echo "*** Purging previous state..."
# ./target/release/node-subtensor purge-chain -y --base-path /tmp/bob --chain="$FULL_PATH" >/dev/null 2>&1
# ./target/release/node-subtensor purge-chain -y --base-path /tmp/alice --chain="$FULL_PATH" >/dev/null 2>&1
# echo "*** Previous chainstate purged"

echo "*** Starting localnet nodes..."
alice_start=(
Expand Down
61 changes: 61 additions & 0 deletions scripts/update_localnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

: "${CHAIN:=local}"
: "${BUILD_BINARY:=1}"
: "${SPEC_PATH:=specs/}"
: "${FEATURES:=pow-faucet}"

FULL_PATH="$SPEC_PATH$CHAIN.json"

if [ ! -d "$SPEC_PATH" ]; then
echo "*** Creating directory ${SPEC_PATH}..."
mkdir $SPEC_PATH
fi

if [[ $BUILD_BINARY == "1" ]]; then
echo "*** Building substrate binary..."
cargo build --release --features "$FEATURES"
echo "*** Binary compiled"
fi

echo $CHAIN
echo $FULL_PATH

echo "*** Building chainspec..."
./target/release/node-subtensor build-spec --disable-default-bootnode --raw --chain $CHAIN > $FULL_PATH
echo "*** Chainspec built and output to file"

echo "*** Purging previous state..."
./target/release/node-subtensor purge-chain -y --base-path /tmp/update/bob --chain="$FULL_PATH" >/dev/null 2>&1
./target/release/node-subtensor purge-chain -y --base-path /tmp/update/alice --chain="$FULL_PATH" >/dev/null 2>&1
echo "*** Previous chainstate purged"

echo "*** Starting localnet nodes..."
alice_start=(
./target/release/node-subtensor
--base-path /tmp/update/alice
--chain="$FULL_PATH"
--alice
--port 30334
--ws-port 9946
--rpc-port 9934
--validator
--rpc-cors=all
--allow-private-ipv4
--discover-local
)

bob_start=(
./target/release/node-subtensor
--base-path /tmp/update/bob
--chain="$FULL_PATH"
--bob
--port 30335
--ws-port 9947
--rpc-port 9935
--validator
--allow-private-ipv4
--discover-local
)

(trap 'kill 0' SIGINT; ("${alice_start[@]}" 2>&1) & ("${bob_start[@]}" 2>&1))

0 comments on commit 3cb512e

Please sign in to comment.