Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
73da72a
move swap interface to primitives since it's not a pllet
gorka-i Mar 23, 2026
e80c0b3
pallet advancing
gorka-i Mar 23, 2026
4f6b85c
pallet execute_orders_batch and also pallet account
girazoki Mar 24, 2026
e441dc7
start adding tests
girazoki Mar 24, 2026
3010345
fmt plus tests
girazoki Mar 24, 2026
c1e26a1
fmt function
girazoki Mar 24, 2026
ffb1637
fixes here and there
girazoki Mar 24, 2026
bf262b4
readme, refactors and security
girazoki Mar 24, 2026
3f853a9
add an additional test checking we get fees from both sides
girazoki Mar 25, 2026
1407762
Add all order types
girazoki Mar 30, 2026
1c2f173
rename order.side to order_type
girazoki Mar 30, 2026
bf29170
remove order-limits
girazoki Mar 30, 2026
88bfa69
order swap remove
girazoki Mar 30, 2026
7c228a7
remove signature
girazoki Mar 30, 2026
e7d3584
fee shoudl be part of the order, as well as fee account
girazoki Mar 31, 2026
1594eec
add tests regarding fee
girazoki Mar 31, 2026
97eac2d
apply limits, including rates, min stake, etc
girazoki Mar 31, 2026
0a6adbd
keep adding more validations
girazoki Mar 31, 2026
738e7bd
check for order validity
girazoki Mar 31, 2026
c7243cd
first integration tests running
girazoki Mar 31, 2026
2dd7c16
apply filters
girazoki Mar 31, 2026
375f6d8
change errors and add new tests
girazoki Apr 1, 2026
59136d6
fix pallet-iner tests
girazoki Apr 1, 2026
2e70f39
use assert_noop in pallet tests
girazoki Apr 1, 2026
5bb9945
add more tests
girazoki Apr 1, 2026
f3375ed
readme change
girazoki Apr 1, 2026
95397db
better doc
girazoki Apr 1, 2026
ee1520c
be more accurate with numbers plus stoploss test
girazoki Apr 1, 2026
fcedbc0
fee related tests
girazoki Apr 1, 2026
a567b6a
kill switch & fmt
girazoki Apr 1, 2026
358a520
first 2 benchmarks added
girazoki Apr 1, 2026
8d56e16
first placeholder for benches of order exec
girazoki Apr 6, 2026
ed5e698
refactor benches and things running
girazoki Apr 6, 2026
8b58a4c
first ts-tests working
girazoki Apr 6, 2026
152f3df
add more tests
girazoki Apr 6, 2026
3829501
more tests
girazoki Apr 6, 2026
7283b51
weights used
girazoki Apr 7, 2026
968b2ee
adapt to event thrown in execute_orders
girazoki Apr 7, 2026
83d15d4
make orders versioned
girazoki Apr 7, 2026
db0e934
adapt ts-tests
girazoki Apr 7, 2026
b382e0a
all tests working
girazoki Apr 7, 2026
9bff196
be more precise in batched
girazoki Apr 7, 2026
bce34c9
move helpers to dev-helpers
girazoki Apr 7, 2026
966bebd
I few more tests and edge cases
girazoki Apr 7, 2026
58d7865
Relayer protection
girazoki Apr 8, 2026
28a80eb
slippage, transactional changes, and a few more dynamic tests
girazoki Apr 8, 2026
e85911c
new tests for partial fills
girazoki Apr 8, 2026
f4360d1
fix benchmarks
girazoki Apr 8, 2026
fe9c039
fix failing test
girazoki Apr 13, 2026
5ec5087
dev helpers cleanup
girazoki Apr 13, 2026
70a02fd
fee event refactor
girazoki Apr 13, 2026
a5cff7f
changes to make things a bit more efficeint
girazoki Apr 13, 2026
05ba26e
more refactor, specialyl in testing
girazoki Apr 13, 2026
42d22b2
commit Cargo.lock
girazoki Apr 13, 2026
d767749
cargo clippy
girazoki Apr 13, 2026
a26c508
cargo fmt
girazoki Apr 13, 2026
8e284e2
commit Cargo.lock
girazoki Apr 13, 2026
6b88048
Merge remote-tracking branch 'origin/devnet-ready' into girazoki-pall…
girazoki Apr 14, 2026
e294f88
cargo fmt
girazoki Apr 13, 2026
383ab80
add chain-id to avoid replay protection across networks
girazoki Apr 14, 2026
b4985ab
remove non-used func
girazoki Apr 14, 2026
9bdfbe0
Merge remote-tracking branch 'origin/devnet-ready' into girazoki-pall…
girazoki May 4, 2026
c377bfd
fix tests and compilation
girazoki May 5, 2026
56acb7c
Merge remote-tracking branch 'origin/devnet-ready' into girazoki-pall…
girazoki May 6, 2026
64ec16a
zepter and fmt
girazoki May 8, 2026
89cacb0
Let's register coldkey-hotkey on genesis and on_runtime_upgrade
girazoki May 8, 2026
9420e91
fix ecotest
girazoki May 8, 2026
28bd3c1
fmt
girazoki May 8, 2026
a7a7fba
clippy
girazoki May 8, 2026
9eddf66
do not require ownership of coldkey and hotkey when buying or selling…
girazoki May 12, 2026
d4d136e
limit price should come as amm price
girazoki May 12, 2026
0fcc91d
make pallet limit orders be disabled on-rt-upgrade
girazoki May 13, 2026
5c4b5a7
change also validation in swap
girazoki May 13, 2026
8cfc635
add sim_swap to avoid slippage-caused errors
girazoki May 18, 2026
79d4851
Merge remote-tracking branch 'origin/devnet-ready' into girazoki-pall…
girazoki May 20, 2026
2784086
allow a set of relayers to be whitelisted
girazoki May 20, 2026
3123f9d
mevshield tests
girazoki May 20, 2026
91886d7
fixes for checking dev node mevshield
girazoki May 20, 2026
48c8a28
mevshield dev node and tests limit orders
girazoki May 20, 2026
6053240
Merge remote-tracking branch 'origin/devnet-ready' into girazoki-pall…
girazoki May 25, 2026
374d897
formatting
girazoki May 25, 2026
c4f5bd6
change imports
girazoki May 25, 2026
55f1f2e
clippy fixes
girazoki May 25, 2026
e82cfd6
change the pallet to default false, but enable it on genesis so that …
girazoki May 25, 2026
fbaedab
add migration fail so that this does not run twice
girazoki May 25, 2026
b4abf46
changes related to conviction
girazoki May 25, 2026
358d718
reorg tests and clippy
girazoki May 26, 2026
ebb2952
fmt and benchmark test
girazoki May 26, 2026
8e2b1d9
make transfer_staked_alpha transactional and push the validations up
girazoki May 26, 2026
903ff73
forward fee
girazoki May 29, 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
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ useless_conversion = "allow" # until polkadot is patched
pallet-alpha-assets = { path = "pallets/alpha-assets", default-features = false }
node-subtensor-runtime = { path = "runtime", default-features = false }
pallet-admin-utils = { path = "pallets/admin-utils", default-features = false }
pallet-limit-orders = { path = "pallets/limit-orders", default-features = false }
pallet-commitments = { path = "pallets/commitments", default-features = false }
pallet-registry = { path = "pallets/registry", default-features = false }
pallet-crowdloan = { path = "pallets/crowdloan", default-features = false }
Expand All @@ -72,7 +73,7 @@ subtensor-custom-rpc = { default-features = false, path = "pallets/subtensor/rpc
subtensor-custom-rpc-runtime-api = { default-features = false, path = "pallets/subtensor/runtime-api" }
subtensor-precompiles = { default-features = false, path = "precompiles" }
subtensor-runtime-common = { default-features = false, path = "common" }
subtensor-swap-interface = { default-features = false, path = "pallets/swap-interface" }
subtensor-swap-interface = { default-features = false, path = "primitives/swap-interface" }
subtensor-transaction-fee = { default-features = false, path = "pallets/transaction-fee" }
subtensor-chain-extensions = { default-features = false, path = "chain-extensions" }
stp-shield = { git = "https://github.com/opentensor/polkadot-sdk.git", rev = "7cc54bf2d50ae3921d718736dfeb0de9468539c7", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion chain-extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ runtime-benchmarks = [
"pallet-subtensor-proxy/runtime-benchmarks",
"pallet-subtensor-utility/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"subtensor-runtime-common/runtime-benchmarks"
"subtensor-runtime-common/runtime-benchmarks",
"subtensor-swap-interface/runtime-benchmarks"
]
2 changes: 1 addition & 1 deletion eco-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pallet-subtensor-proxy = { path = "../pallets/proxy", default-features = false,
pallet-subtensor-utility = { path = "../pallets/utility", default-features = false, features = ["std"] }
pallet-shield = { path = "../pallets/shield", default-features = false, features = ["std"] }
subtensor-runtime-common = { path = "../common", default-features = false, features = ["std"] }
subtensor-swap-interface = { path = "../pallets/swap-interface", default-features = false, features = ["std"] }
subtensor-swap-interface = { path = "../primitives/swap-interface", default-features = false, features = ["std"] }
share-pool = { path = "../primitives/share-pool", default-features = false, features = ["std"] }
safe-math = { path = "../primitives/safe-math", default-features = false, features = ["std"] }
log = { version = "0.4.21", default-features = false, features = ["std"] }
Expand Down
56 changes: 56 additions & 0 deletions node/src/dev_keystore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use stc_shield::MemoryShieldKeystore;
use stp_shield::{Result as TraitResult, ShieldKeystore};

/// A fixed (non-rotating) shield keystore for single-validator dev/manual-seal nodes.
///
/// Uses the same ML-KEM-768 keypair for both `next_enc_key()` and `current_dec_key()`,
/// bypassing the multi-validator key-rotation timing assumption. In a real multi-validator
/// AURA chain, each validator builds every Kth block (K≥3), so the keystore rolls at the
/// same cadence as the on-chain PendingKey pipeline (2-block delay). In single-validator
/// manual-seal mode the keystore would roll on every block, drifting 2 pairs ahead of
/// PendingKey. This keystore avoids that by keeping both keys from the same generated pair.
///
/// Construction: capture `next_enc_key()` from a fresh `MemoryShieldKeystore`, roll once
/// so that key becomes current, then freeze. `current_dec_key()` delegates to the inner
/// store (which now holds the matching pair), and `roll_for_next_slot()` is a no-op.
pub struct DevShieldKeystore {
enc_key_bytes: Vec<u8>,
inner: MemoryShieldKeystore,
}

impl DevShieldKeystore {
#[allow(clippy::expect_used)]
pub fn new() -> Self {
let inner = MemoryShieldKeystore::new();
let enc_key_bytes = inner
.next_enc_key()
.expect("MemoryShieldKeystore always has a next key");
inner
.roll_for_next_slot()
.expect("initial roll should not fail");
Self {
enc_key_bytes,
inner,
}
}
}

impl Default for DevShieldKeystore {
fn default() -> Self {
Self::new()
}
}

impl ShieldKeystore for DevShieldKeystore {
fn roll_for_next_slot(&self) -> TraitResult<()> {
Ok(())
}

fn next_enc_key(&self) -> TraitResult<Vec<u8>> {
Ok(self.enc_key_bytes.clone())
}

fn current_dec_key(&self) -> TraitResult<Vec<u8>> {
self.inner.current_dec_key()
}
}
1 change: 1 addition & 0 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod client;
pub mod clone_spec;
pub mod conditional_evm_block_import;
pub mod consensus;
pub mod dev_keystore;
pub mod ethereum;
pub mod rpc;
pub mod service;
1 change: 1 addition & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod clone_spec;
mod command;
mod conditional_evm_block_import;
mod consensus;
mod dev_keystore;
mod ethereum;
mod rpc;
mod service;
Expand Down
27 changes: 20 additions & 7 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,14 @@ where
.await;

if role.is_authority() {
let shield_keystore = Arc::new(MemoryShieldKeystore::new());

// manual-seal authorship
// manual-seal authorship — use a fixed keystore so the single-validator dev
// node doesn't drift: MemoryShieldKeystore rolls on every own-block import
// (every block in single-validator mode), advancing current_dec_key() 2 pairs
// ahead of PendingKey on-chain. DevShieldKeystore avoids this by keeping the
// same keypair for both next_enc_key() and current_dec_key().
if let Some(sealing) = sealing {
let dev_shield_keystore: stp_shield::ShieldKeystorePtr =
Arc::new(crate::dev_keystore::DevShieldKeystore::new());
run_manual_seal_authorship(
sealing,
client,
Expand All @@ -558,12 +562,14 @@ where
prometheus_registry.as_ref(),
telemetry.as_ref(),
commands_stream,
shield_keystore.clone(),
dev_shield_keystore,
)?;
log::info!("Manual Seal Ready");
return Ok(task_manager);
}

let shield_keystore = Arc::new(MemoryShieldKeystore::new());

stc_shield::spawn_key_rotation_on_own_import(
&task_manager.spawn_handle(),
client.clone(),
Expand Down Expand Up @@ -749,7 +755,7 @@ fn run_manual_seal_authorship(
transaction_pool.clone(),
prometheus_registry,
telemetry.as_ref().map(|x| x.handle()),
shield_keystore,
shield_keystore.clone(),
);

thread_local!(static TIMESTAMP: RefCell<u64> = const { RefCell::new(0) });
Expand Down Expand Up @@ -781,8 +787,15 @@ fn run_manual_seal_authorship(
}
}

let create_inherent_data_providers =
move |_, ()| async move { Ok(MockTimestampInherentDataProvider) };
let create_inherent_data_providers = move |_, ()| {
let keystore = shield_keystore.clone();
async move {
Ok((
MockTimestampInherentDataProvider,
stc_shield::InherentDataProvider::new(keystore),
))
}
};

let aura_data_provider =
sc_consensus_manual_seal::consensus::aura::AuraConsensusDataProvider::new(client.clone());
Expand Down
1 change: 1 addition & 0 deletions pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ runtime-benchmarks = [
"pallet-subtensor-swap/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"subtensor-runtime-common/runtime-benchmarks",
"subtensor-swap-interface/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
59 changes: 59 additions & 0 deletions pallets/limit-orders/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[package]
name = "pallet-limit-orders"
version = "0.1.0"
edition.workspace = true

[dependencies]
codec = { workspace = true, features = ["derive"] }
frame-benchmarking = { workspace = true, optional = true }
sp-io = { workspace = true, optional = true }
sp-keyring = { workspace = true, optional = true }
frame-support.workspace = true
frame-system.workspace = true
scale-info.workspace = true
sp-core.workspace = true
sp-runtime.workspace = true
sp-std.workspace = true
log.workspace = true
substrate-fixed.workspace = true
subtensor-runtime-common.workspace = true
subtensor-macros.workspace = true
subtensor-swap-interface.workspace = true

[dev-dependencies]
sp-io.workspace = true
sp-keyring.workspace = true
sp-keystore.workspace = true

[lints]
workspace = true

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-core/std",
"sp-io?/std",
"sp-keyring?/std",
"sp-keystore/std",
"sp-runtime/std",
"sp-std/std",
"log/std",
"substrate-fixed/std",
"subtensor-runtime-common/std",
"subtensor-swap-interface/std",
]

runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-io",
"subtensor-runtime-common/runtime-benchmarks",
"subtensor-swap-interface/runtime-benchmarks",
]
Loading
Loading