Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
e9cda43
bump spec
sam0x17 Feb 24, 2026
925f6eb
hoist crypto dependencies and add zeroize
l0r1s Feb 9, 2026
785361b
introduce ShieldKeystore on node side
l0r1s Feb 9, 2026
7271534
add InherentDatapProvider for MEV shield
l0r1s Feb 9, 2026
e069774
add key rotation task on own block import
l0r1s Feb 9, 2026
8509933
remove old author/proposer tasks
l0r1s Feb 9, 2026
4bba8d2
extract Executive Context
l0r1s Feb 9, 2026
e862719
remove keys default and swap safely
l0r1s Feb 9, 2026
96202f1
make inherent public key possibly none in case of node failure
l0r1s Feb 9, 2026
8c0892e
move shield client logic to own stc-shield crate
l0r1s Feb 9, 2026
386f759
added shield primitives crate (stp-shield)
l0r1s Feb 9, 2026
a0051f9
refactor MemoryShieldKeystore and implement ShieldKeystore
l0r1s Feb 9, 2026
3560a2c
fix types following stp-shield crate creation
l0r1s Feb 9, 2026
1869239
remove unused deps from node
l0r1s Feb 9, 2026
f58c3d7
added subtensor primitives for I/O aka custom host functions (stp-io)
l0r1s Feb 9, 2026
1d228bc
fix imports and features
l0r1s Feb 9, 2026
898cc21
stp-shield: added basic shield runtime API
l0r1s Feb 9, 2026
01bf8b6
fix type errors in node consensus
l0r1s Feb 9, 2026
d387a22
stp-io: aead_decrypt now returns Vec<u8> because unknown result size
l0r1s Feb 10, 2026
3086ac0
add SubtensorHostFunctions to node
l0r1s Feb 10, 2026
bd37bba
rework the pallet-shield
l0r1s Feb 10, 2026
1b37161
implement stp_shield::ShieldApi Runtime API
l0r1s Feb 10, 2026
803ac24
pallet-shield: expose Current and Next keys
l0r1s Feb 10, 2026
831f118
pallet-shield: tx ext to filter based on used key
l0r1s Feb 11, 2026
9db5bad
pallet-shield: fix shielded transaction format
l0r1s Feb 11, 2026
5453211
some renaming
l0r1s Feb 11, 2026
1021d8e
fix some tx extensions org
l0r1s Feb 11, 2026
637cf7f
move ShieldedTransaction to shield/primitives
l0r1s Feb 11, 2026
a66575d
fix runtime API impl
l0r1s Feb 11, 2026
245f53b
renaming
l0r1s Feb 12, 2026
3e780ad
simplify key rotation in pallet-shield
l0r1s Feb 13, 2026
9557a50
fix shield tx extension
l0r1s Feb 13, 2026
e3191a5
types in stp-shield and more logging
l0r1s Feb 13, 2026
772a319
track CurrentKey and fix extension
l0r1s Feb 13, 2026
cb9090d
added tests for MemoryShieldKeystore
l0r1s Feb 13, 2026
7dcef9f
added shielded_tx tests
l0r1s Feb 13, 2026
8f85b06
cargo fmt
l0r1s Feb 13, 2026
61fd3f3
added shield extension tests
l0r1s Feb 13, 2026
8a25a5a
update comment
l0r1s Feb 13, 2026
b2ffefc
added tests for pallet-shield
l0r1s Feb 13, 2026
db0f27e
update workspace Cargo.toml
l0r1s Feb 14, 2026
b647a52
fix Cargo.toml for pallet-shield and workspace
l0r1s Feb 14, 2026
6e395b8
move stp-shield/stc-shield to polkadot-sdk to avoid circular deps
l0r1s Feb 14, 2026
c41af63
update benchmarks
l0r1s Feb 14, 2026
2f4543f
update Cargo.toml/lock
l0r1s Feb 14, 2026
bd01847
added migration to clear old storage + tests
l0r1s Feb 16, 2026
5ddc1bd
commit Cargo.lock
l0r1s Feb 16, 2026
5c63248
cargo check
l0r1s Feb 16, 2026
8f61a81
clippy fix
l0r1s Feb 16, 2026
5ae7a37
update fix_rust script to match CI
l0r1s Feb 16, 2026
a74e9c5
fix clippy with expect used for the stp-io methods
l0r1s Feb 16, 2026
31935ab
zepter fix
l0r1s Feb 16, 2026
c8a345f
fix benchmark compilation issue with rand stuff
l0r1s Feb 16, 2026
c24274b
use rand_chacha (portable + nostd) instead of OsRng in benchmarks
l0r1s Feb 17, 2026
e5fbf0f
downgrade rand_chacha back to 0.3.1
l0r1s Feb 17, 2026
88864ba
fix compilation issues after cherrypick on devnet-ready
l0r1s Feb 17, 2026
93163ff
move CustomTransactionError to subtensor common
l0r1s Feb 18, 2026
8551cab
added new custom transaction error for shielded txs
l0r1s Feb 18, 2026
a5833c1
bump frontier and psdk deps
l0r1s Feb 18, 2026
28e99de
setup pnpm workspace for e2e
l0r1s Feb 18, 2026
06dffe7
added shared e2e package including node utils, chainspec and sequencer
l0r1s Feb 18, 2026
9caf775
add helpers to e2e/shared/client
l0r1s Feb 18, 2026
3d2228f
setup e2e/shield package for mev shields e2e tests
l0r1s Feb 18, 2026
32ee32f
added e2e tests for shield
l0r1s Feb 18, 2026
efa5b9e
add workflow to run e2e
l0r1s Feb 19, 2026
d0a9def
added missing readmes
l0r1s Feb 19, 2026
7c2ee83
move multiple tx in same block tests to basic/scaling
l0r1s Feb 19, 2026
845dd51
fix rand crate api changes when upgrading
l0r1s Feb 19, 2026
a0cb873
split E2E into another PR
l0r1s Feb 19, 2026
ffbd02d
remove e2e workflow
l0r1s Feb 19, 2026
59761da
fix clippy
l0r1s Feb 19, 2026
69904f2
fix benchmarks
l0r1s Feb 19, 2026
097280e
fix benchmarks
l0r1s Feb 19, 2026
fbff3ca
set longevity to 3 for mev shield txs
l0r1s Feb 23, 2026
805de46
bump spec version to 383
l0r1s Feb 25, 2026
f12df5a
fix post cherry-pick compilation issues
l0r1s Feb 25, 2026
dda2342
cleanup unused pallets in mock
l0r1s Feb 25, 2026
921dac0
fix zepter
l0r1s Feb 25, 2026
ca97f24
Merge branch 'testnet' into mev-shield-rework
l0r1s Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
name: E2E Tests

concurrency:
group: e2e-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
pull_request:

workflow_dispatch:
inputs:
verbose:
description: "Output more information when triggered manually"
required: false
default: ""
1,211 changes: 703 additions & 508 deletions Cargo.lock

Large diffs are not rendered by default.

478 changes: 144 additions & 334 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ use sp_runtime::{
use subtensor_macros::freeze_struct;

pub use currency::*;
pub use transaction_error::*;

mod currency;
mod transaction_error;

/// Balance of an account.
pub type Balance = u64;
Expand Down
70 changes: 70 additions & 0 deletions common/src/transaction_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
use sp_runtime::transaction_validity::{InvalidTransaction, TransactionValidityError};

#[derive(Debug, PartialEq)]
pub enum CustomTransactionError {
ColdkeyInSwapSchedule,
StakeAmountTooLow,
BalanceTooLow,
SubnetNotExists,
HotkeyAccountDoesntExist,
NotEnoughStakeToWithdraw,
RateLimitExceeded,
InsufficientLiquidity,
SlippageTooHigh,
TransferDisallowed,
HotKeyNotRegisteredInNetwork,
InvalidIpAddress,
ServingRateLimitExceeded,
InvalidPort,
BadRequest,
ZeroMaxAmount,
InvalidRevealRound,
CommitNotFound,
CommitBlockNotInRevealRange,
InputLengthsUnequal,
UidNotFound,
EvmKeyAssociateRateLimitExceeded,
ColdkeySwapDisputed,
InvalidRealAccount,
FailedShieldedTxParsing,
InvalidShieldedTxPubKeyHash,
}

impl From<CustomTransactionError> for u8 {
fn from(variant: CustomTransactionError) -> u8 {
match variant {
CustomTransactionError::ColdkeyInSwapSchedule => 0,
CustomTransactionError::StakeAmountTooLow => 1,
CustomTransactionError::BalanceTooLow => 2,
CustomTransactionError::SubnetNotExists => 3,
CustomTransactionError::HotkeyAccountDoesntExist => 4,
CustomTransactionError::NotEnoughStakeToWithdraw => 5,
CustomTransactionError::RateLimitExceeded => 6,
CustomTransactionError::InsufficientLiquidity => 7,
CustomTransactionError::SlippageTooHigh => 8,
CustomTransactionError::TransferDisallowed => 9,
CustomTransactionError::HotKeyNotRegisteredInNetwork => 10,
CustomTransactionError::InvalidIpAddress => 11,
CustomTransactionError::ServingRateLimitExceeded => 12,
CustomTransactionError::InvalidPort => 13,
CustomTransactionError::BadRequest => 255,
CustomTransactionError::ZeroMaxAmount => 14,
CustomTransactionError::InvalidRevealRound => 15,
CustomTransactionError::CommitNotFound => 16,
CustomTransactionError::CommitBlockNotInRevealRange => 17,
CustomTransactionError::InputLengthsUnequal => 18,
CustomTransactionError::UidNotFound => 19,
CustomTransactionError::EvmKeyAssociateRateLimitExceeded => 20,
CustomTransactionError::ColdkeySwapDisputed => 21,
CustomTransactionError::InvalidRealAccount => 22,
CustomTransactionError::FailedShieldedTxParsing => 23,
CustomTransactionError::InvalidShieldedTxPubKeyHash => 24,
}
}
}

impl From<CustomTransactionError> for TransactionValidityError {
fn from(variant: CustomTransactionError) -> Self {
TransactionValidityError::Invalid(InvalidTransaction::Custom(variant.into()))
}
}
19 changes: 6 additions & 13 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
serde = { workspace = true, features = ["derive"] }
hex.workspace = true
tokio = { workspace = true, features = ["time"] }

# Storage import
memmap2.workspace = true
Expand Down Expand Up @@ -77,6 +78,7 @@ sp-keystore.workspace = true
polkadot-sdk = { workspace = true, features = [
"cumulus-primitives-proof-size-hostfunction",
] }
stp-io.workspace = true

# These dependencies are used for the subtensor's RPCs
jsonrpsee = { workspace = true, features = ["server"] }
Expand All @@ -94,6 +96,7 @@ pallet-transaction-payment-rpc-runtime-api.workspace = true
# These dependencies are used for runtime benchmarking
frame-benchmarking.workspace = true
frame-benchmarking-cli.workspace = true
pallet-subtensor.workspace = true

# Needed for Frontier
fc-mapping-sync.workspace = true
Expand All @@ -116,18 +119,8 @@ num-traits = { workspace = true, features = ["std"] }

# Mev Shield
pallet-shield.workspace = true
tokio = { version = "1.38", features = ["time"] }
x25519-dalek = "2"
hkdf = "0.12"
chacha20poly1305 = { version = "0.10", features = ["std"] }
codec.workspace = true
rand.workspace = true
sha2.workspace = true
anyhow.workspace = true
pallet-subtensor.workspace = true
ml-kem.workspace = true
rand_core = "0.9.3"
blake2 = "0.10.6"
stp-shield.workspace = true
stc-shield.workspace = true

# Local Dependencies
node-subtensor-runtime = { workspace = true, features = ["std"] }
Expand Down Expand Up @@ -187,8 +180,8 @@ try-runtime = [
"pallet-commitments/try-runtime",
"pallet-drand/try-runtime",
"polkadot-sdk/try-runtime",
"pallet-shield/try-runtime",
"pallet-subtensor/try-runtime",
"pallet-shield/try-runtime",
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
35 changes: 18 additions & 17 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn create_benchmark_extrinsic(
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let extra: runtime::TransactionExtensions =
let extra: runtime::TxExtension = (
(
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
Expand All @@ -136,32 +136,33 @@ pub fn create_benchmark_extrinsic(
)),
check_nonce::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
transaction_payment_wrapper::ChargeTransactionPaymentWrapper::new(
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
),
),
(
transaction_payment_wrapper::ChargeTransactionPaymentWrapper::new(0),
sudo_wrapper::SudoTransactionExtension::<runtime::Runtime>::new(),
pallet_shield::CheckShieldedTxValidity::<runtime::Runtime>::new(),
pallet_subtensor::transaction_extension::SubtensorTransactionExtension::<
runtime::Runtime,
>::new(),
pallet_drand::drand_priority::DrandPriority::<runtime::Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
);
),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
);

let raw_payload = runtime::SignedPayload::from_raw(
call.clone(),
extra.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(),
(),
(),
(),
(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(),
),
((), (), (), (), ()),
None,
),
);
Expand Down
1 change: 1 addition & 0 deletions node/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ pub type HostFunctions = (
frame_benchmarking::benchmarking::HostFunctions,
sp_crypto_ec_utils::bls12_381::host_calls::HostFunctions,
ProofSize,
stp_io::SubtensorHostFunctions,
);
pub type RuntimeExecutor = WasmExecutor<HostFunctions>;
11 changes: 9 additions & 2 deletions node/src/consensus/aura_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::Block as BlockT;
use sp_runtime::traits::NumberFor;
use stc_shield::InherentDataProvider as ShieldInherentDataProvider;
use std::{error::Error, sync::Arc};
use stp_shield::ShieldKeystorePtr;

pub struct AuraConsensus;

impl ConsensusMechanism for AuraConsensus {
type InherentDataProviders = (
sp_consensus_aura::inherents::InherentDataProvider,
sp_timestamp::InherentDataProvider,
stc_shield::InherentDataProvider,
);

fn start_authoring<C, SC, I, PF, SO, L, CIDP, BS, Error>(
Expand Down Expand Up @@ -101,18 +104,21 @@ impl ConsensusMechanism for AuraConsensus {

fn create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn Error + Send + Sync>> {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
let shield = ShieldInherentDataProvider::new(shield_keystore);
Ok((slot, timestamp, shield))
}

fn pending_create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn Error + Send + Sync>> {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current
Expand All @@ -125,7 +131,8 @@ impl ConsensusMechanism for AuraConsensus {
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
let shield = stc_shield::InherentDataProvider::new(shield_keystore);
Ok((slot, timestamp, shield))
}

fn new() -> Self {
Expand Down
11 changes: 9 additions & 2 deletions node/src/consensus/babe_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use sp_consensus_slots::SlotDuration;
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::NumberFor;
use stc_shield::InherentDataProvider as ShieldInherentDataProvider;
use std::{error::Error, sync::Arc};
use stp_shield::ShieldKeystorePtr;

pub struct BabeConsensus {
babe_link: Option<BabeLink<Block>>,
Expand All @@ -42,6 +44,7 @@ impl ConsensusMechanism for BabeConsensus {
type InherentDataProviders = (
sp_consensus_babe::inherents::InherentDataProvider,
sp_timestamp::InherentDataProvider,
stc_shield::InherentDataProvider,
);

#[allow(clippy::expect_used)]
Expand Down Expand Up @@ -111,18 +114,21 @@ impl ConsensusMechanism for BabeConsensus {

fn create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn Error + Send + Sync>> {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
let shield = stc_shield::InherentDataProvider::new(shield_keystore);
Ok((slot, timestamp, shield))
}

fn pending_create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn Error + Send + Sync>> {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current
Expand All @@ -135,7 +141,8 @@ impl ConsensusMechanism for BabeConsensus {
*timestamp,
slot_duration,
);
Ok((slot, timestamp))
let shield = ShieldInherentDataProvider::new(shield_keystore);
Ok((slot, timestamp, shield))
}

fn new() -> Self {
Expand Down
3 changes: 3 additions & 0 deletions node/src/consensus/consensus_mechanism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use sp_keystore::KeystorePtr;
use sp_runtime::traits::NumberFor;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use stp_shield::ShieldKeystorePtr;

use crate::client::FullClient;
use crate::service::BIQ;
Expand Down Expand Up @@ -85,11 +86,13 @@ pub trait ConsensusMechanism {
/// Creates IDPs for the consensus mechanism.
fn create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn std::error::Error + Send + Sync>>;

/// Creates IDPs for the consensus mechanism for pending blocks.
fn pending_create_inherent_data_providers(
slot_duration: SlotDuration,
shield_keystore: ShieldKeystorePtr,
) -> Result<Self::InherentDataProviders, Box<dyn std::error::Error + Send + Sync>>;

/// Creates the frontier consensus data provider with this mechanism.
Expand Down
1 change: 0 additions & 1 deletion node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ pub mod client;
pub mod conditional_evm_block_import;
pub mod consensus;
pub mod ethereum;
pub mod mev_shield;
pub mod rpc;
pub mod service;
1 change: 0 additions & 1 deletion node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod command;
mod conditional_evm_block_import;
mod consensus;
mod ethereum;
mod mev_shield;
mod rpc;
mod service;

Expand Down
Loading
Loading