Skip to content

Commit 1610db6

Browse files
Merge branch 'devnet-ready' into root-claim-alpha-maps
2 parents 7645958 + de708ba commit 1610db6

File tree

40 files changed

+869
-204
lines changed

40 files changed

+869
-204
lines changed

.github/workflows/cargo-audit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ jobs:
4646
cargo audit --ignore RUSTSEC-2023-0091 \
4747
--ignore RUSTSEC-2024-0438 \
4848
--ignore RUSTSEC-2025-0009 \
49-
--ignore RUSTSEC-2025-0055
49+
--ignore RUSTSEC-2025-0055 \
50+
--ignore RUSTSEC-2025-0073 \
51+
--ignore RUSTSEC-2025-0118

.github/workflows/check-rust.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install Rust Nightly
3939
uses: actions-rs/toolchain@v1
4040
with:
41-
toolchain: nightly
41+
toolchain: stable
4242
components: rustfmt
4343

4444
- name: Utilize Shared Rust Cache
@@ -48,7 +48,22 @@ jobs:
4848
cache-on-failure: true
4949

5050
- name: cargo fmt
51-
run: cargo +nightly fmt --check --all
51+
run: |
52+
set -euo pipefail
53+
# Run cargo fmt and capture both stdout and stderr
54+
output=$(cargo fmt --check --all 2>&1) || {
55+
echo "❌ cargo fmt failed with non-zero exit code"
56+
echo "$output"
57+
exit 1
58+
}
59+
# Check for panic/ICE messages even if exit code was 0
60+
if echo "$output" | grep -qiE "(the compiler unexpectedly panicked|panicked at|Internal Compiler Error|ICE|error: the compiler unexpectedly panicked)"; then
61+
echo "❌ rustfmt panicked (ICE detected) - this should fail the build"
62+
echo "$output"
63+
exit 1
64+
fi
65+
echo "$output"
66+
echo "✅ cargo fmt completed successfully"
5267
5368
cargo-clippy-default-features:
5469
name: cargo clippy

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ specs/*.json
4646
bt.snap
4747

4848
# localnet spec
49-
scripts/specs/local.json
49+
scripts/specs/local.json
50+
51+
# Node modules
52+
node_modules

chain-extensions/src/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,12 @@ impl SubtensorExtensionEnv<AccountId> for MockEnv {
757757
}
758758

759759
fn charge_weight(&mut self, weight: Weight) -> Result<(), DispatchError> {
760-
if let Some(expected) = self.expected_weight {
761-
if weight != expected {
762-
return Err(DispatchError::Other(
763-
"unexpected weight charged by mock env",
764-
));
765-
}
760+
if let Some(expected) = self.expected_weight
761+
&& weight != expected
762+
{
763+
return Err(DispatchError::Other(
764+
"unexpected weight charged by mock env",
765+
));
766766
}
767767
self.charged_weight = Some(weight);
768768
Ok(())

common/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,37 @@ impl TryFrom<u8> for ProxyType {
184184
14 => Ok(Self::SudoUncheckedSetCode),
185185
15 => Ok(Self::SwapHotkey),
186186
16 => Ok(Self::SubnetLeaseBeneficiary),
187+
17 => Ok(Self::RootClaim),
187188
_ => Err(()),
188189
}
189190
}
190191
}
191192

193+
impl From<ProxyType> for u8 {
194+
fn from(proxy_type: ProxyType) -> Self {
195+
match proxy_type {
196+
ProxyType::Any => 0,
197+
ProxyType::Owner => 1,
198+
ProxyType::NonCritical => 2,
199+
ProxyType::NonTransfer => 3,
200+
ProxyType::Senate => 4,
201+
ProxyType::NonFungible => 5,
202+
ProxyType::Triumvirate => 6,
203+
ProxyType::Governance => 7,
204+
ProxyType::Staking => 8,
205+
ProxyType::Registration => 9,
206+
ProxyType::Transfer => 10,
207+
ProxyType::SmallTransfer => 11,
208+
ProxyType::RootWeights => 12,
209+
ProxyType::ChildKeys => 13,
210+
ProxyType::SudoUncheckedSetCode => 14,
211+
ProxyType::SwapHotkey => 15,
212+
ProxyType::SubnetLeaseBeneficiary => 16,
213+
ProxyType::RootClaim => 17,
214+
}
215+
}
216+
}
217+
192218
impl Default for ProxyType {
193219
// allow all Calls; required to be most permissive
194220
fn default() -> Self {

contract-tests/src/contracts/proxy.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,41 @@ export const IProxyABI = [
144144
"outputs": [],
145145
"stateMutability": "nonpayable",
146146
"type": "function"
147+
},
148+
{
149+
"inputs": [
150+
{
151+
"internalType": "bytes32",
152+
"name": "account",
153+
"type": "bytes32"
154+
}
155+
],
156+
"name": "getProxies",
157+
"outputs": [
158+
{
159+
"components": [
160+
{
161+
"internalType": "bytes32",
162+
"name": "delegate",
163+
"type": "bytes32"
164+
},
165+
{
166+
"internalType": "uint256",
167+
"name": "proxy_type",
168+
"type": "uint256"
169+
},
170+
{
171+
"internalType": "uint256",
172+
"name": "delay",
173+
"type": "uint256"
174+
}
175+
],
176+
"internalType": "struct IProxy.ProxyInfo[]",
177+
"name": "",
178+
"type": "tuple[]"
179+
}
180+
],
181+
"stateMutability": "view",
182+
"type": "function"
147183
}
148184
];

contract-tests/test/pure-proxy.precompile.test.ts

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ async function getProxies(api: TypedApi<typeof devnet>, address: string) {
4646

4747
describe("Test pure proxy precompile", () => {
4848
const evmWallet = generateRandomEthersWallet();
49+
// only used for edge case and normal proxy
4950
const evmWallet2 = generateRandomEthersWallet();
5051
const evmWallet3 = generateRandomEthersWallet();
52+
const evmWallet4 = generateRandomEthersWallet();
5153
const receiver = getRandomSubstrateKeypair();
5254

5355
let api: TypedApi<typeof devnet>
@@ -61,6 +63,7 @@ describe("Test pure proxy precompile", () => {
6163
await forceSetBalanceToEthAddress(api, evmWallet.address)
6264
await forceSetBalanceToEthAddress(api, evmWallet2.address)
6365
await forceSetBalanceToEthAddress(api, evmWallet3.address)
66+
await forceSetBalanceToEthAddress(api, evmWallet4.address)
6467
})
6568

6669
it("Call createPureProxy, then use proxy to call transfer", async () => {
@@ -130,34 +133,78 @@ describe("Test pure proxy precompile", () => {
130133
const proxies = await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet2.address))
131134
const contract = new ethers.Contract(IPROXY_ADDRESS, IProxyABI, evmWallet2)
132135

136+
const proxiesFromContract = await contract.getProxies(convertH160ToPublicKey(evmWallet2.address))
137+
assert.equal(proxiesFromContract.length, proxies[0].length, "proxies length should be equal")
138+
133139
const type = 0;
134140
const delay = 0;
135141

136142
const tx = await contract.addProxy(convertH160ToPublicKey(evmWallet3.address), type, delay)
137143
await tx.wait()
138144

145+
const proxiesAfterAdd = await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet2.address))
146+
const proxiesList = proxiesAfterAdd[0].map(proxy => proxy.delegate)
139147

140-
const proxiesAfterAdd = await await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet2.address))
148+
const proxiesFromContractAfterAdd = await contract.getProxies(convertH160ToPublicKey(evmWallet2.address))
141149

142-
const length = proxiesAfterAdd[0].length
143-
assert.equal(length, proxies[0].length + 1, "proxy should be set")
144-
const proxy = proxiesAfterAdd[0][proxiesAfterAdd[0].length - 1]
150+
assert.equal(proxiesFromContractAfterAdd.length, proxiesList.length, "proxy length should be equal")
145151

146-
assert.equal(proxy.delegate, convertH160ToSS58(evmWallet3.address), "proxy should be set")
152+
for (let index = 0; index < proxiesFromContractAfterAdd.length; index++) {
153+
const proxyInfo = proxiesFromContractAfterAdd[index]
154+
let proxySs58 = convertPublicKeyToSs58(proxyInfo[0])
155+
assert.ok(proxiesList.includes(proxySs58), "proxy should be set")
156+
if (index === proxiesFromContractAfterAdd.length - 1) {
157+
assert.equal(Number(proxyInfo[1]), type, "proxy_type should match")
158+
assert.equal(Number(proxyInfo[2]), delay, "delay should match")
159+
}
160+
}
147161

162+
assert.equal(proxiesList.length, proxies[0].length + 1, "proxy should be set")
163+
const proxy = proxiesList[proxiesList.length - 1]
148164

165+
assert.equal(proxy, convertH160ToSS58(evmWallet3.address), "proxy should be set")
149166
const balance = (await api.query.System.Account.getValue(convertPublicKeyToSs58(receiver.publicKey))).data.free
150-
151167
const amount = 1000000000;
152168

153169
const contract2 = new ethers.Contract(IPROXY_ADDRESS, IProxyABI, evmWallet3)
154-
155-
156170
const callCode = await getTransferCallCode(api, receiver, amount)
157171
const tx2 = await contract2.proxyCall(convertH160ToPublicKey(evmWallet2.address), [type], callCode)
158172
await tx2.wait()
159173

160174
const balanceAfter = (await api.query.System.Account.getValue(convertPublicKeyToSs58(receiver.publicKey))).data.free
161175
assert.equal(balanceAfter, balance + BigInt(amount), "balance should be increased")
162176
})
177+
178+
it("Call addProxy many times, then check getProxies is correct", async () => {
179+
const proxies = await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet4.address))
180+
const contract = new ethers.Contract(IPROXY_ADDRESS, IProxyABI, evmWallet4)
181+
assert.equal(proxies[0].length, 0, "proxies length should be 0")
182+
183+
const proxiesFromContract = await contract.getProxies(convertH160ToPublicKey(evmWallet4.address))
184+
assert.equal(proxiesFromContract.length, proxies[0].length, "proxies length should be equal")
185+
186+
const type = 1;
187+
const delay = 2;
188+
189+
for (let i = 0; i < 5; i++) {
190+
const evmWallet = generateRandomEthersWallet()
191+
const tx = await contract.addProxy(convertH160ToPublicKey(evmWallet.address), type, delay)
192+
await tx.wait()
193+
}
194+
195+
const proxiesAfterAdd = await await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet4.address))
196+
const proxiesList = proxiesAfterAdd[0].map(proxy => proxy.delegate)
197+
198+
const proxiesFromContractAfterAdd = await contract.getProxies(convertH160ToPublicKey(evmWallet4.address))
199+
200+
assert.equal(proxiesFromContractAfterAdd.length, proxiesList.length, "proxy length should be equal")
201+
202+
for (let index = 0; index < proxiesFromContractAfterAdd.length; index++) {
203+
const proxyInfo = proxiesFromContractAfterAdd[index]
204+
let proxySs58 = convertPublicKeyToSs58(proxyInfo[0])
205+
assert.ok(proxiesList.includes(proxySs58), "proxy should be set")
206+
assert.equal(Number(proxyInfo[1]), type, "proxy_type should match")
207+
assert.equal(Number(proxyInfo[2]), delay, "delay should match")
208+
}
209+
})
163210
});

node/src/benchmarking.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use crate::client::FullClient;
66

77
use node_subtensor_runtime as runtime;
8-
use node_subtensor_runtime::pallet_subtensor;
98
use node_subtensor_runtime::{check_nonce, transaction_payment_wrapper};
9+
use node_subtensor_runtime::{pallet_subtensor, sudo_wrapper};
1010
use runtime::{BalancesCall, SystemCall};
1111
use sc_cli::Result;
1212
use sc_client_api::BlockBackend;
@@ -139,6 +139,7 @@ pub fn create_benchmark_extrinsic(
139139
transaction_payment_wrapper::ChargeTransactionPaymentWrapper::new(
140140
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
141141
),
142+
sudo_wrapper::SudoTransactionExtension::<runtime::Runtime>::new(),
142143
pallet_subtensor::transaction_extension::SubtensorTransactionExtension::<
143144
runtime::Runtime,
144145
>::new(),
@@ -160,6 +161,7 @@ pub fn create_benchmark_extrinsic(
160161
(),
161162
(),
162163
(),
164+
(),
163165
None,
164166
),
165167
);

node/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
272272
{
273273
log::info!("Failed to aquire DB lock, trying again in 1s...");
274274
std::thread::sleep(std::time::Duration::from_secs(1));
275-
return start_babe_service(arg_matches);
275+
start_babe_service(arg_matches)
276276
// Unknown error, return it.
277277
} else {
278278
log::error!("Failed to start Babe service: {e:?}");

node/src/consensus/aura_consensus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl ConsensusMechanism for AuraConsensus {
120120
Self {}
121121
}
122122

123-
fn build_biq(&mut self) -> Result<BIQ, sc_service::Error>
123+
fn build_biq(&mut self) -> Result<BIQ<'_>, sc_service::Error>
124124
where
125125
NumberFor<Block>: BlockNumberOps,
126126
{

0 commit comments

Comments
 (0)