Skip to content

Commit 7eb6f9b

Browse files
authored
Merge pull request #2485 from opentensor/upgrade-1
Mainnet Upgrade 1 (3/17/2026)
2 parents f05c791 + 384aaad commit 7eb6f9b

File tree

106 files changed

+15237
-4192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+15237
-4192
lines changed

Cargo.lock

Lines changed: 459 additions & 466 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 132 additions & 330 deletions
Large diffs are not rendered by default.

chain-extensions/src/mock.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use sp_runtime::{
2525
traits::{BlakeTwo256, Convert, IdentityLookup},
2626
};
2727
use sp_std::{cell::RefCell, cmp::Ordering, sync::OnceLock};
28-
use subtensor_runtime_common::{AlphaCurrency, NetUid, TaoCurrency};
28+
use subtensor_runtime_common::{AlphaCurrency, AuthorshipInfo, NetUid, TaoCurrency};
2929

3030
type Block = frame_system::mocking::MockBlock<Test>;
3131

@@ -262,6 +262,14 @@ parameter_types! {
262262
pub const AnnouncementDepositFactor: Balance = 1;
263263
}
264264

265+
pub struct MockAuthorshipProvider;
266+
267+
impl AuthorshipInfo<U256> for MockAuthorshipProvider {
268+
fn author() -> Option<U256> {
269+
Some(U256::from(12345u64))
270+
}
271+
}
272+
265273
parameter_types! {
266274
pub const InitialMinAllowedWeights: u16 = 0;
267275
pub const InitialEmissionValue: u16 = 0;
@@ -325,9 +333,8 @@ parameter_types! {
325333
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
326334
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
327335
pub const InitialYuma3On: bool = false; // Default value for Yuma3On
328-
// pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED)
329-
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
330-
pub const InitialColdkeySwapRescheduleDuration: u64 = 24 * 60 * 60 / 12; // Default as 1 day
336+
pub const InitialColdkeySwapAnnouncementDelay: u64 = 50;
337+
pub const InitialColdkeySwapReannouncementDelay: u64 = 10;
331338
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
332339
pub const InitialTaoWeight: u64 = 0; // 100% global weight.
333340
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
@@ -397,8 +404,8 @@ impl pallet_subtensor::Config for Test {
397404
type LiquidAlphaOn = InitialLiquidAlphaOn;
398405
type Yuma3On = InitialYuma3On;
399406
type Preimages = Preimage;
400-
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
401-
type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration;
407+
type InitialColdkeySwapAnnouncementDelay = InitialColdkeySwapAnnouncementDelay;
408+
type InitialColdkeySwapReannouncementDelay = InitialColdkeySwapReannouncementDelay;
402409
type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration;
403410
type InitialTaoWeight = InitialTaoWeight;
404411
type InitialEmaPriceHalvingPeriod = InitialEmaPriceHalvingPeriod;
@@ -412,6 +419,7 @@ impl pallet_subtensor::Config for Test {
412419
type MaxImmuneUidsPercentage = MaxImmuneUidsPercentage;
413420
type CommitmentsInterface = CommitmentsI;
414421
type EvmKeyAssociateRateLimit = EvmKeyAssociateRateLimit;
422+
type AuthorshipProvider = MockAuthorshipProvider;
415423
}
416424

417425
// Swap-related parameter types

common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1212

1313
[dependencies]
1414
codec = { workspace = true, features = ["derive"] }
15+
environmental.workspace = true
1516
frame-support.workspace = true
1617
scale-info.workspace = true
1718
serde.workspace = true
@@ -31,6 +32,7 @@ approx = ["dep:approx"]
3132
fast-runtime = []
3233
std = [
3334
"codec/std",
35+
"environmental/std",
3436
"frame-support/std",
3537
"scale-info/std",
3638
"serde/std",

common/src/evm_context.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
environmental::environmental!(IN_EVM: bool);
2+
3+
/// Returns `true` if the current dispatch originated from an EVM precompile.
4+
pub fn is_in_evm() -> bool {
5+
IN_EVM::with(|v| *v).unwrap_or(false)
6+
}
7+
8+
/// Executes `f` within an EVM context, making `is_in_evm()` return `true`
9+
/// for the duration of the closure. Uses `using_once` so nested calls
10+
/// reuse the already-set value instead of building a stack.
11+
pub fn with_evm_context<R>(f: impl FnOnce() -> R) -> R {
12+
IN_EVM::using_once(&mut true, f)
13+
}
14+
15+
#[cfg(test)]
16+
mod tests {
17+
use super::*;
18+
19+
#[test]
20+
fn is_in_evm_returns_false_by_default() {
21+
assert!(!is_in_evm());
22+
}
23+
24+
#[test]
25+
fn with_evm_context_sets_flag() {
26+
with_evm_context(|| {
27+
assert!(is_in_evm());
28+
});
29+
}
30+
31+
#[test]
32+
fn flag_clears_after_evm_context() {
33+
with_evm_context(|| {});
34+
assert!(!is_in_evm());
35+
}
36+
37+
#[test]
38+
fn nested_evm_context_stays_true() {
39+
with_evm_context(|| {
40+
with_evm_context(|| {
41+
assert!(is_in_evm());
42+
});
43+
// Still true after inner context exits thanks to using_once.
44+
assert!(is_in_evm());
45+
});
46+
}
47+
}

common/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ use sp_runtime::{
1515
use subtensor_macros::freeze_struct;
1616

1717
pub use currency::*;
18+
pub use evm_context::*;
1819

1920
mod currency;
21+
mod evm_context;
2022

2123
/// Balance of an account.
2224
pub type Balance = u64;
@@ -260,6 +262,12 @@ pub trait BalanceOps<AccountId> {
260262
) -> Result<AlphaCurrency, DispatchError>;
261263
}
262264

265+
/// Allows to query the current block author
266+
pub trait AuthorshipInfo<AccountId> {
267+
/// Return the current block author
268+
fn author() -> Option<AccountId>;
269+
}
270+
263271
pub mod time {
264272
use super::*;
265273

contract-tests/bittensor/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ edition = "2021"
1010
ink = { version = "5.1.1", default-features = false }
1111
parity-scale-codec = { version = "3.0.0", default-features = false }
1212
serde = { version = "1.0.228", default-features = false }
13-
subtensor-runtime-common = { path = "../../common", default-features = false }
1413
[dev-dependencies]
1514
ink_e2e = { version = "5.1.1" }
1615

@@ -23,7 +22,6 @@ std = [
2322
"ink/std",
2423
"parity-scale-codec/std",
2524
"serde/std",
26-
"subtensor-runtime-common/std",
2725
]
2826

2927
ink-as-dependency = []

0 commit comments

Comments
 (0)