Skip to content

Commit 89b7c38

Browse files
committed
Merge branch 'devnet-ready' into hybrid-node
2 parents f8b783e + 9709a17 commit 89b7c38

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

evm-tests/test/leasing.precompile.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe("Test Leasing precompile", () => {
2020

2121
let wallet1: ethers.Wallet;
2222
let wallet2: ethers.Wallet;
23-
let wallet3: ethers.Wallet;
2423
let leaseContract: ethers.Contract;
2524
let crowdloanContract: ethers.Contract;
2625
let neuronContract: ethers.Contract;
@@ -34,22 +33,18 @@ describe("Test Leasing precompile", () => {
3433

3534
wallet1 = generateRandomEthersWallet();
3635
wallet2 = generateRandomEthersWallet();
37-
wallet3 = generateRandomEthersWallet();
3836
leaseContract = new ethers.Contract(ILEASING_ADDRESS, ILeasingABI, wallet1);
3937
crowdloanContract = new ethers.Contract(ICROWDLOAN_ADDRESS, ICrowdloanABI, wallet1);
4038
neuronContract = new ethers.Contract(INEURON_ADDRESS, INeuronABI, wallet1);
4139

4240
await forceSetBalanceToEthAddress(api, wallet1.address);
4341
await forceSetBalanceToEthAddress(api, wallet2.address);
44-
await forceSetBalanceToEthAddress(api, wallet3.address);
45-
await neuronContract.burnedRegister(1, convertH160ToPublicKey(wallet3.address));
46-
await forceSetBalanceToEthAddress(api, wallet1.address);
4742
});
4843

4944
it("gets an existing lease created on substrate side, its subnet id and its contributor shares", async () => {
5045
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
5146
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
52-
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
47+
const crowdloanCap = await api.query.SubtensorModule.NetworkLastLockCost.getValue() * BigInt(2);
5348
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
5449
const leaseEmissionsShare = 15;
5550
const leaseEnd = await api.query.System.Number.getValue() + 300;
@@ -104,7 +99,7 @@ describe("Test Leasing precompile", () => {
10499
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
105100
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
106101
const crowdloanMinContribution = BigInt(1_000_000_000); // 1 TAO
107-
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
102+
const crowdloanCap = await api.query.SubtensorModule.NetworkLastLockCost.getValue() * BigInt(2);
108103
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
109104
const leasingEmissionsShare = 15;
110105
const leasingEndBlock = await api.query.System.Number.getValue() + 300;
@@ -158,15 +153,19 @@ describe("Test Leasing precompile", () => {
158153
});
159154

160155
it("terminates a lease", async () => {
156+
const hotkey = generateRandomEthersWallet();
157+
let tx = await neuronContract.burnedRegister(1, convertH160ToPublicKey(hotkey.address));
158+
await tx.wait();
159+
161160
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
162161
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
163162
const crowdloanMinContribution = BigInt(1_000_000_000); // 1 TAO
164-
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
163+
const crowdloanCap = await api.query.SubtensorModule.NetworkLastLockCost.getValue() * BigInt(2);
165164
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
166165
const leasingEmissionsShare = 15;
167166
const leasingEndBlock = await api.query.System.Number.getValue() + 200;
168167

169-
let tx = await leaseContract.createLeaseCrowdloan(
168+
tx = await leaseContract.createLeaseCrowdloan(
170169
crowdloanDeposit,
171170
crowdloanMinContribution,
172171
crowdloanCap,
@@ -193,7 +192,7 @@ describe("Test Leasing precompile", () => {
193192
assert.isDefined(lease);
194193
const netuid = lease.netuid;
195194

196-
tx = await leaseContract.terminateLease(nextLeaseId, convertH160ToPublicKey(wallet3.address));
195+
tx = await leaseContract.terminateLease(nextLeaseId, convertH160ToPublicKey(hotkey.address));
197196
await tx.wait();
198197

199198
lease = await api.query.SubtensorModule.SubnetLeases.getValue(nextLeaseId);
@@ -203,6 +202,6 @@ describe("Test Leasing precompile", () => {
203202
const ownerColdkey = await api.query.SubtensorModule.SubnetOwner.getValue(netuid);
204203
const ownerHotkey = await api.query.SubtensorModule.SubnetOwnerHotkey.getValue(netuid);
205204
assert.equal(ownerColdkey, convertH160ToSS58(wallet1.address));
206-
assert.equal(ownerHotkey, convertH160ToSS58(wallet3.address));
205+
assert.equal(ownerHotkey, convertH160ToSS58(hotkey.address));
207206
});
208207
})

pallets/subtensor/rpc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait SubtensorCustomApi<BlockHash> {
5454
fn get_subnets_info(&self, at: Option<BlockHash>) -> RpcResult<Vec<u8>>;
5555
#[method(name = "subnetInfo_getSubnetInfo_v2")]
5656
fn get_subnet_info_v2(&self, netuid: NetUid, at: Option<BlockHash>) -> RpcResult<Vec<u8>>;
57-
#[method(name = "subnetInfo_getSubnetsInf_v2")]
57+
#[method(name = "subnetInfo_getSubnetsInfo_v2")]
5858
fn get_subnets_info_v2(&self, at: Option<BlockHash>) -> RpcResult<Vec<u8>>;
5959
#[method(name = "subnetInfo_getSubnetHyperparams")]
6060
fn get_subnet_hyperparams(&self, netuid: NetUid, at: Option<BlockHash>) -> RpcResult<Vec<u8>>;

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<T: Config> Pallet<T> {
7676
log::debug!("alpha_emission_i: {:?}", alpha_emission_i);
7777

7878
// Get initial alpha_in
79-
let alpha_in_i: U96F32;
79+
let mut alpha_in_i: U96F32;
8080
let mut tao_in_i: U96F32;
8181
let tao_in_ratio: U96F32 = default_tao_in_i.safe_div_or(
8282
U96F32::saturating_from_num(block_emission),
@@ -108,12 +108,14 @@ impl<T: Config> Pallet<T> {
108108
log::debug!("alpha_in_i: {:?}", alpha_in_i);
109109

110110
// Get alpha_out.
111-
let alpha_out_i = alpha_emission_i;
111+
let mut alpha_out_i = alpha_emission_i;
112112
// Only emit TAO if the subnetwork allows registration.
113113
if !Self::get_network_registration_allowed(*netuid_i)
114114
&& !Self::get_network_pow_registration_allowed(*netuid_i)
115115
{
116116
tao_in_i = asfloat!(0.0);
117+
alpha_in_i = asfloat!(0.0);
118+
alpha_out_i = asfloat!(0.0);
117119
}
118120
// Insert values into maps
119121
tao_in.insert(*netuid_i, tao_in_i);

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
218218
// `spec_version`, and `authoring_version` are the same between Wasm and native.
219219
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
220220
// the compatible custom types.
221-
spec_version: 298,
221+
spec_version: 299,
222222
impl_version: 1,
223223
apis: RUNTIME_API_VERSIONS,
224224
transaction_version: 1,

0 commit comments

Comments
 (0)