Skip to content

Commit 377c7aa

Browse files
committed
fix: broadcast events for "stale" chunks
1 parent b385e86 commit 377c7aa

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

stackslib/src/net/relay.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,12 @@ impl Relayer {
24972497
let tx = self.stacker_dbs.tx_begin(config.clone())?;
24982498
for sync_result in sync_results.into_iter() {
24992499
for chunk in sync_result.chunks_to_store.into_iter() {
2500+
if let Some(event_list) = all_events.get_mut(&sync_result.contract_id) {
2501+
event_list.push(chunk.clone());
2502+
} else {
2503+
all_events.insert(sync_result.contract_id.clone(), vec![chunk.clone()]);
2504+
}
2505+
25002506
let md = chunk.get_slot_metadata();
25012507
if let Err(e) = tx.try_replace_chunk(&sc, &md, &chunk.data) {
25022508
if matches!(e, Error::StaleChunk { .. }) {
@@ -2525,11 +2531,6 @@ impl Relayer {
25252531
debug!("Stored chunk"; "stackerdb_contract_id" => %sync_result.contract_id, "slot_id" => md.slot_id, "slot_version" => md.slot_version);
25262532
}
25272533

2528-
if let Some(event_list) = all_events.get_mut(&sync_result.contract_id) {
2529-
event_list.push(chunk.clone());
2530-
} else {
2531-
all_events.insert(sync_result.contract_id.clone(), vec![chunk.clone()]);
2532-
}
25332534
let msg = StacksMessageType::StackerDBPushChunk(StackerDBPushChunkData {
25342535
contract_id: sc.clone(),
25352536
rc_consensus_hash: rc_consensus_hash.clone(),

stackslib/src/net/stackerdb/db.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use stacks_common::util::get_epoch_time_secs;
2525
use stacks_common::util::hash::Sha512Trunc256Sum;
2626
use stacks_common::util::secp256k1::MessageSignature;
2727

28-
use super::StackerDBEventDispatcher;
2928
use crate::net::stackerdb::{StackerDBConfig, StackerDBTx, StackerDBs, STACKERDB_INV_MAX};
3029
use crate::net::{Error as net_error, StackerDBChunkData};
3130
use crate::util_lib::db::{
@@ -396,20 +395,6 @@ impl StackerDBTx<'_> {
396395
Ok(())
397396
}
398397

399-
/// Try to upload a chunk to the StackerDB instance, notifying
400-
/// and subscribed listeners via the `dispatcher`
401-
pub fn put_chunk<ED: StackerDBEventDispatcher>(
402-
self,
403-
contract: &QualifiedContractIdentifier,
404-
chunk: StackerDBChunkData,
405-
dispatcher: &ED,
406-
) -> Result<(), net_error> {
407-
self.try_replace_chunk(contract, &chunk.get_slot_metadata(), &chunk.data)?;
408-
self.commit()?;
409-
dispatcher.new_stackerdb_chunks(contract.clone(), vec![chunk]);
410-
Ok(())
411-
}
412-
413398
/// Add or replace a chunk for a given reward cycle, if it is valid
414399
/// Otherwise, this errors out with Error::StaleChunk
415400
pub fn try_replace_chunk(

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ use crate::event_dispatcher::{
105105
EventObserver, MinedNakamotoBlockEvent, TEST_SKIP_BLOCK_ANNOUNCEMENT,
106106
};
107107
use crate::nakamoto_node::miner::{
108-
TEST_BLOCK_ANNOUNCE_STALL, TEST_BLOCK_PUSH_SKIP, TEST_BROADCAST_PROPOSAL_STALL,
109-
TEST_MINE_STALL, TEST_P2P_BROADCAST_STALL,
108+
TEST_BLOCK_ANNOUNCE_STALL, TEST_BROADCAST_PROPOSAL_STALL, TEST_MINE_STALL,
109+
TEST_P2P_BROADCAST_STALL,
110110
};
111111
use crate::nakamoto_node::stackerdb_listener::TEST_IGNORE_SIGNERS;
112112
use crate::neon::{Counters, RunLoopCounter};
@@ -17374,8 +17374,6 @@ fn bitcoin_reorg_extended_tenure() {
1737417374

1737517375
miners.wait_for_chains(60);
1737617376

17377-
thread::sleep(Duration::from_secs(5));
17378-
1737917377
// stall p2p broadcast and signer block announcements
1738017378
// so that we can ensure all the signers approve the proposal
1738117379
// before it gets accepted by stacks-nodes

0 commit comments

Comments
 (0)