Skip to content

Commit ae12eb6

Browse files
authored
Merge pull request #1820 from input-output-hk/djo/1785/last_tx_not_proved
Bugfix: Block range computation ignored last block range & last block range if it finished with empty blocks
2 parents 702e519 + 73f7be8 commit ae12eb6

File tree

17 files changed

+356
-380
lines changed

17 files changed

+356
-380
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/mithril-persistence/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-persistence"
3-
version = "0.2.16"
3+
version = "0.2.17"
44
description = "Common types, interfaces, and utilities to persist data for Mithril nodes."
55
authors = { workspace = true }
66
edition = { workspace = true }

internal/mithril-persistence/src/database/query/block_range_root/get_block_range_root.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ impl GetBlockRangeRootQuery {
2222
condition: WhereCondition::new("start < ?*", vec![Value::Integer(block_number as i64)]),
2323
}
2424
}
25+
26+
pub fn highest() -> Self {
27+
Self {
28+
condition: WhereCondition::new("end = (select max(end) from block_range_root)", vec![]),
29+
}
30+
}
2531
}
2632

2733
impl Query for GetBlockRangeRootQuery {
@@ -134,4 +140,26 @@ mod tests {
134140

135141
assert_eq!(dataset, cursor);
136142
}
143+
144+
#[test]
145+
fn test_get_highest_with_empty_db() {
146+
let connection = cardano_tx_db_connection().unwrap();
147+
148+
let cursor: Option<BlockRangeRootRecord> = connection
149+
.fetch_first(GetBlockRangeRootQuery::highest())
150+
.unwrap();
151+
assert_eq!(None, cursor);
152+
}
153+
154+
#[test]
155+
fn test_get_highest() {
156+
let connection = cardano_tx_db_connection().unwrap();
157+
let dataset = block_range_root_dataset();
158+
insert_block_range_roots(&connection, dataset.clone());
159+
160+
let cursor: Option<BlockRangeRootRecord> = connection
161+
.fetch_first(GetBlockRangeRootQuery::highest())
162+
.unwrap();
163+
assert_eq!(dataset.last().cloned(), cursor);
164+
}
137165
}

internal/mithril-persistence/src/database/query/block_range_root/get_interval_without_block_range.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

internal/mithril-persistence/src/database/query/block_range_root/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
mod delete_block_range_root;
22
mod get_block_range_root;
3-
mod get_interval_without_block_range;
43
mod insert_block_range;
54

65
pub use delete_block_range_root::*;
76
pub use get_block_range_root::*;
8-
pub use get_interval_without_block_range::*;
97
pub use insert_block_range::*;
108

119
#[cfg(test)]

internal/mithril-persistence/src/database/record/interval_without_block_range_root.rs

Lines changed: 0 additions & 143 deletions
This file was deleted.

internal/mithril-persistence/src/database/record/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
mod block_range_root;
44
mod cardano_transaction;
5-
mod interval_without_block_range_root;
65

76
pub use block_range_root::*;
87
pub use cardano_transaction::*;
9-
pub use interval_without_block_range_root::*;

0 commit comments

Comments
 (0)