Skip to content

Commit d9e5421

Browse files
committed
fix: make last_weight_submission_epoch local instead of shared P2P state
1 parent 92c84f7 commit d9e5421

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

bins/validator-node/src/main.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ async fn main() -> Result<()> {
885885
let mut wasm_eval_interval = tokio::time::interval(Duration::from_secs(5));
886886
let mut stale_job_interval = tokio::time::interval(Duration::from_secs(120));
887887
let mut weight_check_interval = tokio::time::interval(Duration::from_secs(30));
888+
let mut last_weight_submission_epoch: u64 = 0; // Local tracking of weight submissions
888889

889890
// Clone p2p_cmd_tx for use in the loop
890891
let p2p_broadcast_tx = p2p_cmd_tx.clone();
@@ -1344,14 +1345,13 @@ async fn main() -> Result<()> {
13441345
_ = weight_check_interval.tick() => {
13451346
let current_block = state_manager.apply(|state| state.bittensor_block);
13461347
let current_epoch = current_block / 360;
1347-
let last_submitted = state_manager.apply(|state| state.last_weight_submission_epoch);
13481348

13491349
// Submit weights if we're at an epoch boundary and haven't submitted for this epoch
13501350
// Check within first 30 blocks of epoch to catch up if we missed
1351-
if current_epoch > last_submitted && current_block % 360 < 30 {
1351+
if current_epoch > last_weight_submission_epoch && current_block % 360 < 30 {
13521352
info!(
13531353
"Weight submission due: block={}, epoch={}, last_submitted={}",
1354-
current_block, current_epoch, last_submitted
1354+
current_block, current_epoch, last_weight_submission_epoch
13551355
);
13561356

13571357
if let (Some(st), Some(sig)) = (subtensor.as_ref(), subtensor_signer.as_ref()) {
@@ -1371,9 +1371,7 @@ async fn main() -> Result<()> {
13711371
match st.set_mechanism_weights(sig, netuid, mechanism_id, &uids, &vals, version_key, ExtrinsicWait::Finalized).await {
13721372
Ok(resp) if resp.success => {
13731373
info!("Weights submitted for epoch {}: {:?}", current_epoch, resp.tx_hash);
1374-
state_manager.apply(|state| {
1375-
state.last_weight_submission_epoch = current_epoch;
1376-
});
1374+
last_weight_submission_epoch = current_epoch;
13771375
}
13781376
Ok(resp) => warn!("Weight submission issue: {}", resp.message),
13791377
Err(e) => error!("Weight submission failed: {}", e),
@@ -1385,9 +1383,7 @@ async fn main() -> Result<()> {
13851383
match st.set_mechanism_weights(sig, netuid, mechanism_id, &[0u16], &[65535u16], version_key, ExtrinsicWait::Finalized).await {
13861384
Ok(resp) if resp.success => {
13871385
info!("Burn weights submitted for epoch {}: {:?}", current_epoch, resp.tx_hash);
1388-
state_manager.apply(|state| {
1389-
state.last_weight_submission_epoch = current_epoch;
1390-
});
1386+
last_weight_submission_epoch = current_epoch;
13911387
}
13921388
Ok(resp) => warn!("Burn weight submission issue: {}", resp.message),
13931389
Err(e) => error!("Burn weight submission failed: {}", e),

crates/p2p-consensus/src/state.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@ pub struct ChainState {
344344
/// Validator penalty counters (hotkey -> consecutive epochs penalized)
345345
#[serde(default, with = "hotkey_map_serde")]
346346
pub validator_penalties: HashMap<Hotkey, u32>,
347-
/// Last epoch for which weights were successfully submitted
348-
#[serde(default)]
349-
pub last_weight_submission_epoch: u64,
350347
}
351348

352349
/// Record of a review assignment
@@ -437,7 +434,6 @@ impl Default for ChainState {
437434
pending_storage_proposals: HashMap::new(),
438435
pending_state_mutations: HashMap::new(),
439436
validator_penalties: HashMap::new(),
440-
last_weight_submission_epoch: 0,
441437
}
442438
}
443439
}

0 commit comments

Comments
 (0)