Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 171 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ members = ["crates/*"]
resolver = "2"

[workspace.dependencies]
sqd-contract-client = { git = "https://github.com/subsquid/sqd-network.git", rev = "11f4230", version = "1.3.0" }
sqd-messages = { git = "https://github.com/subsquid/sqd-network.git", rev = "11f4230", version = "2.1.0", features = ["bitstring"] }
sqd-network-transport = { git = "https://github.com/subsquid/sqd-network.git", rev = "11f4230", version = "3.1.0" }

# The sqd-network fork builds its crates against its in-tree libp2p-identity (path = "identity"), so
# consumers must redirect the crates.io libp2p-identity to the same source, otherwise two incompatible
# copies of libp2p_identity are linked. See the fork's "Use libp2p-identity from the fork" commit.
[patch.crates-io]
libp2p-identity = { git = "https://github.com/kalabukdima/rust-libp2p.git", rev = "fac3b0c9" }
sqd-contract-client = { git = "https://github.com/subsquid/sqd-network.git", rev = "e1460fd", version = "1.3.0" }
sqd-messages = { git = "https://github.com/subsquid/sqd-network.git", rev = "e1460fd", version = "3.1.0", features = ["bitstring"] }
sqd-network-transport = { git = "https://github.com/subsquid/sqd-network.git", rev = "e1460fd", version = "3.1.0" }
1 change: 1 addition & 0 deletions crates/collector-utils/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ mod tests {
compression: Default::default(),
query_engine: Default::default(),
output_format: Default::default(),
chunk_version: Default::default(),
};
query.sign(&client_keypair, worker_id).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/logs-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "logs-collector"
version = "2.5.0"
version = "2.5.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/pings-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pings-collector"
version = "2.9.0"
version = "2.9.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/portal-logs-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "portal-logs-collector"
version = "1.1.6"
version = "1.1.7"
edition = "2021"

[dependencies]
Expand Down
13 changes: 5 additions & 8 deletions crates/router-controller/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,12 @@ mod tests {
.set_datasets((0..2).map(|i| (i.to_string(), i.to_string())))
.build();

let chunk = |top, first_block, last_block| {
DataChunk::new(top, first_block, last_block, "abcde").expect("valid chunk")
};
let chunks = [
vec![
DataChunk::new(0, 0, 10, "".to_string()),
DataChunk::new(0, 11, 200, "".to_string()),
],
vec![
DataChunk::new(0, 0, 5, "".to_string()),
DataChunk::new(6, 6, 20, "".to_string()),
],
vec![chunk(0, 0, 10), chunk(0, 11, 200)],
vec![chunk(0, 0, 5), chunk(6, 6, 20)],
];

for w in 0..8 {
Expand Down
51 changes: 46 additions & 5 deletions crates/router/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ fn invalid_object_key(key: &str) -> String {
format!("invalid object key - {key}")
}

/// The chunk of a `<chunk id>/blocks.parquet` key; `None` for the chunk's other files.
fn chunk_of_blocks_key(key: &str) -> Result<Option<DataChunk>, String> {
let Some(chunk_id) = key.strip_suffix("/blocks.parquet") else {
return Ok(None);
};

DataChunk::from_str(chunk_id)
.map(Some)
.map_err(|()| invalid_object_key(key))
}

fn trim_trailing_slash(value: &str) -> String {
let mut value = value.to_string();
value.pop();
Expand Down Expand Up @@ -84,11 +95,8 @@ impl Storage for S3Storage {
let mut chunks = vec![];
for object in &objects {
if let Some(key) = object.key() {
if key.ends_with("blocks.parquet") {
match DataChunk::from_str(key) {
Ok(chunk) => chunks.push(chunk),
Err(..) => return Err(invalid_object_key(key)),
}
if let Some(chunk) = chunk_of_blocks_key(key)? {
chunks.push(chunk);
}
}
}
Expand Down Expand Up @@ -127,3 +135,36 @@ impl S3Storage {
Ok(items)
}
}

#[cfg(test)]
mod tests {
use super::chunk_of_blocks_key;

#[test]
fn reads_the_chunk_from_a_full_object_key() {
let key = "0000000000/0000000000-0000000099-abcde/blocks.parquet";

let chunk = chunk_of_blocks_key(key)
.unwrap()
.expect("a blocks.parquet key");

assert_eq!(chunk.to_string(), "0000000000/0000000000-0000000099-abcde");
}

#[test]
fn skips_the_other_files_of_a_chunk() {
let key = "0000000000/0000000000-0000000099-abcde/transactions.parquet";

assert_eq!(chunk_of_blocks_key(key), Ok(None));
}

#[test]
fn rejects_a_malformed_chunk_id() {
let key = "0000000000/0000000099-abcde/blocks.parquet";

assert_eq!(
chunk_of_blocks_key(key),
Err(format!("invalid object key - {key}"))
);
}
}
Loading