From adb5bd2644579de9c6549f859d1263bd99664f1a Mon Sep 17 00:00:00 2001 From: error <95016903+error1100@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:02:45 +0200 Subject: [PATCH 1/5] Fix overlapping datapoint submits with epoch change --- core/src/state.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/state.rs b/core/src/state.rs index e804fc58..119c7f4b 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -34,12 +34,12 @@ pub fn process( if let Some(local_datapoint_box_state) = live_epoch.local_datapoint_box_state { match local_datapoint_box_state { Collected { height: _ } => { - // publish datapoint after some blocks have passed after the pool box published - // to avoid some oracle box become stale on the next refresh - // (datapoint posted on the first block of the epoch go out of the epoch window too fast) - if current_height.0 - > live_epoch.latest_pool_box_height.0 + (epoch_length.0 as u32) / 2 - { + // publish datapoint one block after or before scheduled epoch changes + // to avoid some oracle boxes becoming stale on next refresh + // (datapoint posted on the first block of the epoch goes out of the epoch window too fast) + let l = epoch_length.0 as u32; + let d = current_height.0.abs_diff(live_epoch.latest_pool_box_height.0) % l; + if d.min(l - d) > 1 { Some(PoolCommand::PublishSubsequentDataPoint { republish: false }) } else { None From 91aaf6bc21fdf39eb2ef0ce19c93a726857b59d7 Mon Sep 17 00:00:00 2001 From: error <95016903+error1100@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:10:33 +0200 Subject: [PATCH 2/5] bump cargo version --- core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 63de9725..29efd741 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "oracle-core" -version = "2.0.1" +version = "2.0.5" authors = [ "Robert Kornacki <11645932+robkorn@users.noreply.github.com>", "@greenhat", From 92ab4da7332d9ec0bf4656fedd2148b058faea44 Mon Sep 17 00:00:00 2001 From: error <95016903+error1100@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:25:50 +0200 Subject: [PATCH 3/5] Adjust for delays --- core/src/state.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/state.rs b/core/src/state.rs index 119c7f4b..6c7495cf 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -34,12 +34,10 @@ pub fn process( if let Some(local_datapoint_box_state) = live_epoch.local_datapoint_box_state { match local_datapoint_box_state { Collected { height: _ } => { - // publish datapoint one block after or before scheduled epoch changes + // publish datapoint two blocks after scheduled epoch changes // to avoid some oracle boxes becoming stale on next refresh // (datapoint posted on the first block of the epoch goes out of the epoch window too fast) - let l = epoch_length.0 as u32; - let d = current_height.0.abs_diff(live_epoch.latest_pool_box_height.0) % l; - if d.min(l - d) > 1 { + if (current_height.0 - live_epoch.latest_pool_box_height.0) % epoch_length.0 as u32 > 2 { Some(PoolCommand::PublishSubsequentDataPoint { republish: false }) } else { None From d1abd2348c06e1489e463f89c95463e9f13c362c Mon Sep 17 00:00:00 2001 From: error <95016903+error1100@users.noreply.github.com> Date: Wed, 1 Oct 2025 09:01:27 +0200 Subject: [PATCH 4/5] publish datapoint in second part of epoch only --- core/src/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/state.rs b/core/src/state.rs index 6c7495cf..c2596ecd 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -34,10 +34,10 @@ pub fn process( if let Some(local_datapoint_box_state) = live_epoch.local_datapoint_box_state { match local_datapoint_box_state { Collected { height: _ } => { - // publish datapoint two blocks after scheduled epoch changes + // publish datapoint in the second part of the epoch // to avoid some oracle boxes becoming stale on next refresh // (datapoint posted on the first block of the epoch goes out of the epoch window too fast) - if (current_height.0 - live_epoch.latest_pool_box_height.0) % epoch_length.0 as u32 > 2 { + if (current_height.0 - live_epoch.latest_pool_box_height.0) % epoch_length.0 as u32 >= (epoch_length.0 as u32) / 2 { Some(PoolCommand::PublishSubsequentDataPoint { republish: false }) } else { None From cd1d2c9219244c8ec2898084c0e8b39fae6a650d Mon Sep 17 00:00:00 2001 From: error <95016903+error1100@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:30:06 +0200 Subject: [PATCH 5/5] try to account for creation and settlement height diff --- core/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/state.rs b/core/src/state.rs index c2596ecd..bbcc9050 100644 --- a/core/src/state.rs +++ b/core/src/state.rs @@ -37,7 +37,7 @@ pub fn process( // publish datapoint in the second part of the epoch // to avoid some oracle boxes becoming stale on next refresh // (datapoint posted on the first block of the epoch goes out of the epoch window too fast) - if (current_height.0 - live_epoch.latest_pool_box_height.0) % epoch_length.0 as u32 >= (epoch_length.0 as u32) / 2 { + if (current_height.0 - live_epoch.latest_pool_box_height.0) % epoch_length.0 as u32 > (epoch_length.0 as u32) / 2 { Some(PoolCommand::PublishSubsequentDataPoint { republish: false }) } else { None