Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
17b5a2e
feat(slasher): add slasher crates
Rexagon Jul 17, 2025
dc35fa5
feat(collator): propagate original vset item index
Rexagon Nov 25, 2025
b63c270
feat(core): add boxed block/state subscribers
Rexagon Nov 28, 2025
6ceb155
feat(slasher): send block batches to the slasher contract
Rexagon Dec 24, 2025
f97a88a
feat(slasher): add stub contract
Rexagon Dec 25, 2025
0300fa0
feat(slasher): persistent storage
Rexagon Jan 15, 2026
68fac2d
feat(slasher): check blocks batch seqno range
Rexagon Feb 2, 2026
ff207d0
chore(core): change ValidationSessionId signature
MrWad3r Feb 24, 2026
2961c29
chore(contracts): propagate new validation session id into contract
MrWad3r Mar 10, 2026
aa8ef2c
feat(slasher): add slasher analyzer to create signatures reports
MrWad3r Mar 11, 2026
85ed5bf
chore(contract): bump dependencies
MrWad3r Mar 20, 2026
6d2cc48
chore(slasher): update cc_seqno derivation from `KbNextSessionUpdate`
MrWad3r Mar 17, 2026
712a481
chore(slasher): add slasher generation to zerostate
MrWad3r Mar 17, 2026
ab84b83
chore(slasher): add logs with `slasher` target
MrWad3r Mar 17, 2026
6c9d19e
chore(slasher): review pt.1
MrWad3r Mar 26, 2026
a2f882a
chore(slasher): fix signature condition
MrWad3r Mar 27, 2026
587cd70
fix(collator): shuffle with vset_switch_round
Mododo Apr 8, 2026
a79916c
refactor(collator): catchain seqno placement
Mododo Apr 1, 2026
caed98e
feat(consensus): slasher stats output
Mododo Apr 15, 2026
5dd456d
feat(slasher): mempool stats through collator
Mododo Apr 15, 2026
96b61f3
feat(slasher): batches overlap
Mododo Apr 14, 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
47 changes: 41 additions & 6 deletions Cargo.lock

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

21 changes: 17 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ members = [
"gen-protos",
"network",
"rpc",
"rpc-subscriptions",
"simulator",
"slasher",
"slasher-traits",
"storage",
"storage-traits",
"tycho-build-info",
"util",
"util-proc",
"wu-tuner",
"rpc-subscriptions",
]

[workspace.dependencies]
Expand Down Expand Up @@ -61,7 +63,10 @@ exponential-backoff = "1.2.1"
fdlimit = "0.3.0"
futures-executor = "0.3"
futures-util = "0.3"
governor = { version = "0.9", default-features = false, features = ["std", "quanta"] }
governor = { version = "0.9", default-features = false, features = [
"std",
"quanta",
] }
getip = "0.2.1"
hdrhistogram = "7.5.4"
hex = "0.4"
Expand All @@ -86,7 +91,10 @@ proc-macro2 = "1.0"
prost = "0.14.3"
prost-build = "0.14.3"
quick_cache = "0.6.21"
quinn = { version = "0.11.9", default-features = false, features = ["runtime-tokio", "rustls"] }
quinn = { version = "0.11.9", default-features = false, features = [
"runtime-tokio",
"rustls",
] }
quote = "1.0"
object_store = "0.13"
rand = "0.9"
Expand Down Expand Up @@ -129,7 +137,9 @@ tikv-jemalloc-ctl = { version = "0.6.1", features = ["stats"] }
tl-proto = "0.5.4"
tokio = { version = "1", default-features = false }
tokio-stream = "0.1.18"
tokio-util = { version = "0.7.18", default-features = false, features = ["codec"] }
tokio-util = { version = "0.7.18", default-features = false, features = [
"codec",
] }
tower = "0.5"
tower-http = "0.6"
tracing = "0.1"
Expand Down Expand Up @@ -158,6 +168,8 @@ tycho-core = { path = "./core", version = "0.3.9" }
tycho-network = { path = "./network", version = "0.3.9" }
tycho-rpc-subscriptions = { path = "./rpc-subscriptions", version = "0.3.9" }
tycho-rpc = { path = "./rpc", version = "0.3.9" }
tycho-slasher = { path = "./slasher", version = "0.3.9" }
tycho-slasher-traits = { path = "./slasher-traits", version = "0.3.9" }
tycho-storage = { path = "./storage", version = "0.3.9" }
tycho-storage-traits = { path = "./storage-traits", version = "0.3.9" }
tycho-util = { path = "./util", version = "0.3.9" }
Expand All @@ -166,6 +178,7 @@ tycho-wu-tuner = { path = "./wu-tuner", version = "0.3.9" }

[patch.crates-io]
# patches here
tycho-types = { git = "https://github.com/broxus/tycho-types.git", rev = "aeea4e8d007e8a64439d3d923a3752fc823b2256" }

[workspace.lints.rust]
future_incompatible = "warn"
Expand Down
19 changes: 10 additions & 9 deletions block-util/src/block/block_proof_stuff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl BlockProofStuff {

let weight = match signatures
.signatures
.check_signatures(&subset.validators, &checked_data)
.check_signatures(subset.validators.iter().map(AsRef::as_ref), &checked_data)
{
Ok(weight) => weight,
Err(e) => anyhow::bail!("proof contains invalid signatures: {e:?}"),
Expand Down Expand Up @@ -388,15 +388,16 @@ impl BlockProofStuff {
validator_set: &ValidatorSet,
shuffle_validators: bool,
) -> Result<ValidatorSubsetInfo> {
let cc_seqno = self
let Some(vset_switch_round) = self
.inner
.proof
.signatures
.as_ref()
.map(|s| s.validator_info.catchain_seqno)
.unwrap_or_default();

ValidatorSubsetInfo::compute_standard(validator_set, cc_seqno, shuffle_validators)
.map(|s| s.consensus_info.vset_switch_round)
else {
anyhow::bail!("no `consensus_info` to compute subset from");
};
ValidatorSubsetInfo::compute_standard(validator_set, vset_switch_round, shuffle_validators)
}
}

Expand Down Expand Up @@ -520,18 +521,18 @@ fn pre_check_key_block_proof(virt_block: &Block) -> Result<()> {

#[derive(Clone, Debug)]
pub struct ValidatorSubsetInfo {
pub validators: Vec<ValidatorDescription>,
pub validators: Vec<IndexedValidatorDescription>,
pub short_hash: u32,
}

impl ValidatorSubsetInfo {
pub fn compute_standard(
validator_set: &ValidatorSet,
cc_seqno: u32,
vset_switch_round: u32,
shuffle_validators: bool,
) -> Result<Self> {
let Some((validators, short_hash)) =
validator_set.compute_mc_subset(cc_seqno, shuffle_validators)
validator_set.compute_mc_subset_indexed(vset_switch_round, shuffle_validators)
else {
anyhow::bail!("failed to compute a validator subset");
};
Expand Down
11 changes: 9 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[package]
name = "tycho-cli"
description = "Node CLI."
include = ["src/**/*.rs", "res/**/*.boc", "./LICENSE-*", "./README.md", "build.rs"]
include = [
"src/**/*.rs",
"res/**/*.boc",
"./LICENSE-*",
"./README.md",
"build.rs",
]
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand Down Expand Up @@ -55,14 +61,15 @@ weedb = { workspace = true }
# local deps
tycho-block-util = { workspace = true }
tycho-collator = { workspace = true }
tycho-consensus = { workspace = true }
tycho-control = { workspace = true, features = ["full"] }
tycho-core = { workspace = true, features = ["cli"] }
tycho-network = { workspace = true }
tycho-rpc = { workspace = true, features = ["http2"] }
tycho-slasher = { workspace = true }
tycho-storage = { workspace = true }
tycho-util = { workspace = true, features = ["cli"] }
tycho-wu-tuner = { workspace = true }
tycho-consensus = { workspace = true }

[dev-dependencies]
tycho-collator = { workspace = true, features = ["test"] }
Expand Down
Binary file added cli/res/slasher_code.boc
Binary file not shown.
9 changes: 6 additions & 3 deletions cli/src/cmd/tools/gen_zerostate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ impl ZerostateConfig {
fundamental_addresses.set(minter_address, ())?;
}

if let Some(slasher_params) = self.params.get::<ConfigParam666>()? {
fundamental_addresses.set(slasher_params.address, ())?;
}

self.params.set::<ConfigParam31>(&fundamental_addresses)?;
}

Expand Down Expand Up @@ -500,9 +504,9 @@ impl Default for ZerostateConfig {
global_id: 0,
config_public_key: *zero_public_key(),
minter_public_key: None,
config_balance: Tokens::new(500_000_000_000), // 500
config_balance: Tokens::new(500_000_000_000),
config_code: None,
elector_balance: Tokens::new(500_000_000_000), // 500
elector_balance: Tokens::new(500_000_000_000),
elector_code: None,
accounts: Default::default(),
validators: Default::default(),
Expand Down Expand Up @@ -808,7 +812,6 @@ fn make_default_params() -> Result<BlockchainConfigParams> {

// Param 31
params.set_fundamental_addresses(&[HashBytes([0x00; 32]), HashBytes([0x33; 32])])?;

// Param 43
params.set_size_limits(&SizeLimitsConfig {
max_msg_bits: 1 << 21,
Expand Down
5 changes: 5 additions & 0 deletions cli/src/node/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tycho_control::ControlServerConfig;
use tycho_core::node::NodeBaseConfig;
use tycho_crypto::ed25519;
use tycho_rpc::RpcConfig;
use tycho_slasher::SlasherConfig;
use tycho_types::cell::HashBytes;
use tycho_types::models::StdAddr;
use tycho_util::cli::config::ThreadPoolConfig;
Expand Down Expand Up @@ -165,6 +166,9 @@ pub struct NodeConfig {

pub validator: ValidatorStdImplConfig,

#[partial]
pub slasher: SlasherConfig,

#[partial]
pub rpc: Option<RpcConfig>,

Expand All @@ -191,6 +195,7 @@ impl Default for NodeConfig {
mempool: Default::default(),
internal_queue: Default::default(),
validator: Default::default(),
slasher: Default::default(),
rpc: Some(Default::default()),
control: Default::default(),
metrics: Some(Default::default()),
Expand Down
22 changes: 21 additions & 1 deletion cli/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use tycho_core::node::{NodeBase, NodeKeys};
use tycho_core::storage::NodeSyncState;
use tycho_network::InboundRequestMeta;
use tycho_rpc::{NodeBaseInitRpc, RpcConfig};
use tycho_slasher::SlasherConfig;
use tycho_types::models::*;
use tycho_util::futures::JoinTask;
use tycho_wu_tuner::service::WuTunerServiceBuilder;
Expand All @@ -57,6 +58,7 @@ pub struct Node {
collator_config: CollatorConfig,
validator_config: ValidatorStdImplConfig,
internal_queue_config: QueueConfig,
slasher_config: SlasherConfig,
mempool_config_override: Option<MempoolGlobalConfig>,

/// Path to the work units tuner config.
Expand Down Expand Up @@ -131,6 +133,7 @@ impl Node {
collator_config: node_config.collator,
validator_config: node_config.validator,
internal_queue_config: node_config.internal_queue,
slasher_config: node_config.slasher,
mempool_config_override: global_config.mempool,
wu_tuner_config_path,
})
Expand Down Expand Up @@ -222,6 +225,16 @@ impl Node {
let top_shards = mc_state.get_top_shards()?;
message_queue_adapter.clear_uncommitted_state(&top_shards)?;

// NOTE: Stub
let slasher = tycho_slasher::Slasher::new(
base.keypair.clone(),
tycho_slasher::StubSlasherContract,
base.blockchain_rpc_client.clone(),
&base.storage_context,
self.slasher_config,
)
.context("failed to create slasher")?;

let validator = ValidatorStdImpl::new(
ValidatorNetworkContext {
network: base.network.clone(),
Expand All @@ -231,6 +244,7 @@ impl Node {
},
base.keypair.clone(),
self.validator_config,
slasher.validator_events_listener(),
);

// Explicitly handle the initial state
Expand All @@ -257,6 +271,7 @@ impl Node {
CollatorStdImplFactory {
wu_tuner_event_sender: Some(wu_tuner.event_sender.clone()),
},
slasher.validator_events_listener(),
self.mempool_config_override.clone(),
);
let collator_subcriber = CollatorStateSubscriber {
Expand Down Expand Up @@ -349,7 +364,12 @@ impl Node {
(
ShardStateApplier::new(
base.core_storage.clone(),
(collator_subcriber, rpc_state_subscriber, control_server),
(
collator_subcriber,
rpc_state_subscriber,
control_server,
slasher,
),
),
rpc_block_subscriber,
base.validator_resolver().clone(),
Expand Down
1 change: 1 addition & 0 deletions collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tycho-consensus = { workspace = true }
tycho-core = { workspace = true }
tycho-executor = { workspace = true }
tycho-network = { workspace = true }
tycho-slasher-traits = { workspace = true }
tycho-storage = { workspace = true }
tycho-util = { workspace = true }
tycho-vm = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions collator/src/collator/anchors_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ mod tests {
chain_time,
author: PeerId([0; 32]),
externals: Default::default(),
stats: None,
})
}

Expand Down
Loading
Loading