Skip to content

Commit 3041d03

Browse files
authored
Merge pull request #6304 from obycode/fix/stale-stackerdb-msgs
fix: do not send events to observers for stale stackerdb messages
2 parents bbab9e9 + 3f523e1 commit 3041d03

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2020
### Fixed
2121

2222
- Fixed tenure downloader logic on reward cycle boundaries (#6234).
23+
- Do not send events to event observers for stale StackerDB chunks.
2324

2425
## [3.1.0.0.13]
2526

stackslib/src/net/relay.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,12 +2437,6 @@ impl Relayer {
24372437
let mut all_events: HashMap<QualifiedContractIdentifier, Vec<StackerDBChunkData>> =
24382438
HashMap::new();
24392439
for chunk in uploaded_chunks.into_iter() {
2440-
if let Some(events) = all_events.get_mut(&chunk.contract_id) {
2441-
events.push(chunk.chunk_data.clone());
2442-
} else {
2443-
all_events.insert(chunk.contract_id.clone(), vec![chunk.chunk_data.clone()]);
2444-
}
2445-
24462440
// forward if not stale
24472441
if chunk.rc_consensus_hash != *rc_consensus_hash {
24482442
debug!("Drop stale uploaded StackerDB chunk";
@@ -2454,6 +2448,12 @@ impl Relayer {
24542448
continue;
24552449
}
24562450

2451+
if let Some(events) = all_events.get_mut(&chunk.contract_id) {
2452+
events.push(chunk.chunk_data.clone());
2453+
} else {
2454+
all_events.insert(chunk.contract_id.clone(), vec![chunk.chunk_data.clone()]);
2455+
}
2456+
24572457
debug!("Got uploaded StackerDB chunk"; "stackerdb_contract_id" => %chunk.contract_id, "slot_id" => chunk.chunk_data.slot_id, "slot_version" => chunk.chunk_data.slot_version);
24582458

24592459
let msg = StacksMessageType::StackerDBPushChunk(chunk);
@@ -2496,12 +2496,6 @@ impl Relayer {
24962496
let tx = self.stacker_dbs.tx_begin(config.clone())?;
24972497
for sync_result in sync_results.into_iter() {
24982498
for chunk in sync_result.chunks_to_store.into_iter() {
2499-
if let Some(event_list) = all_events.get_mut(&sync_result.contract_id) {
2500-
event_list.push(chunk.clone());
2501-
} else {
2502-
all_events.insert(sync_result.contract_id.clone(), vec![chunk.clone()]);
2503-
}
2504-
25052499
let md = chunk.get_slot_metadata();
25062500
if let Err(e) = tx.try_replace_chunk(&sc, &md, &chunk.data) {
25072501
if matches!(e, Error::StaleChunk { .. }) {
@@ -2530,6 +2524,12 @@ impl Relayer {
25302524
debug!("Stored chunk"; "stackerdb_contract_id" => %sync_result.contract_id, "slot_id" => md.slot_id, "slot_version" => md.slot_version);
25312525
}
25322526

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

0 commit comments

Comments
 (0)