upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-22 21:02:03 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-22 21:02:03 +0000
commit1df90c609399c675e629b97294aee81a0b1e66dd (patch)
tree8482cdd0ea87cc0df5a86672bf99399aa0aa1a3d
parent5d3d96c7f0397a079384b7291ff21df76029b126 (diff)
chore: bump rust-nostr to latest master
so we can more easily support grasp purgatory feature
-rw-r--r--Cargo.lock127
-rw-r--r--Cargo.toml6
-rw-r--r--grasp-audit/Cargo.toml2
-rw-r--r--grasp-audit/src/audit.rs6
-rw-r--r--grasp-audit/src/fixtures.rs14
-rw-r--r--grasp-audit/src/specs/grasp01/event_acceptance_policy.rs4
-rw-r--r--grasp-audit/src/specs/grasp01/nip01_smoke.rs4
-rw-r--r--grasp-audit/src/specs/grasp01/push_authorization.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/nostr/builder.rs56
-rw-r--r--src/sync/mod.rs12
11 files changed, 85 insertions, 150 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4f7835b..fbcc015 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -271,6 +271,12 @@ dependencies = [
271] 271]
272 272
273[[package]] 273[[package]]
274name = "btreecap"
275version = "0.1.0"
276source = "registry+https://github.com/rust-lang/crates.io-index"
277checksum = "6160c957d8aa33d0a8ba1dbab98e3cb57023ad9374c501441e88559f99e6c4c9"
278
279[[package]]
274name = "bumpalo" 280name = "bumpalo"
275version = "3.19.0" 281version = "3.19.0"
276source = "registry+https://github.com/rust-lang/crates.io-index" 282source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -463,7 +469,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
463checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 469checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
464dependencies = [ 470dependencies = [
465 "generic-array", 471 "generic-array",
466 "rand_core 0.6.4",
467 "typenum", 472 "typenum",
468] 473]
469 474
@@ -772,7 +777,7 @@ dependencies = [
772 "chrono", 777 "chrono",
773 "clap", 778 "clap",
774 "futures", 779 "futures",
775 "nostr-sdk 0.43.0", 780 "nostr-sdk",
776 "regex", 781 "regex",
777 "reqwest 0.11.27", 782 "reqwest 0.11.27",
778 "serde", 783 "serde",
@@ -1245,9 +1250,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1245checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" 1250checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
1246dependencies = [ 1251dependencies = [
1247 "cfg-if", 1252 "cfg-if",
1248 "js-sys",
1249 "wasm-bindgen",
1250 "web-sys",
1251] 1253]
1252 1254
1253[[package]] 1255[[package]]
@@ -1436,7 +1438,7 @@ dependencies = [
1436 "lazy_static", 1438 "lazy_static",
1437 "nostr-lmdb", 1439 "nostr-lmdb",
1438 "nostr-relay-builder", 1440 "nostr-relay-builder",
1439 "nostr-sdk 0.44.1", 1441 "nostr-sdk",
1440 "prometheus", 1442 "prometheus",
1441 "rand 0.8.5", 1443 "rand 0.8.5",
1442 "reqwest 0.12.24", 1444 "reqwest 0.12.24",
@@ -1453,32 +1455,8 @@ dependencies = [
1453 1455
1454[[package]] 1456[[package]]
1455name = "nostr" 1457name = "nostr"
1456version = "0.43.1"
1457source = "registry+https://github.com/rust-lang/crates.io-index"
1458checksum = "62a97d745f1bd8d5e05a978632bbb87b0614567d5142906fe7c86fb2440faac6"
1459dependencies = [
1460 "base64 0.22.1",
1461 "bech32",
1462 "bip39",
1463 "bitcoin_hashes 0.14.0",
1464 "cbc",
1465 "chacha20",
1466 "chacha20poly1305",
1467 "getrandom 0.2.16",
1468 "instant",
1469 "scrypt",
1470 "secp256k1",
1471 "serde",
1472 "serde_json",
1473 "unicode-normalization",
1474 "url",
1475]
1476
1477[[package]]
1478name = "nostr"
1479version = "0.44.1" 1458version = "0.44.1"
1480source = "registry+https://github.com/rust-lang/crates.io-index" 1459source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1481checksum = "d3595fecf0e0aaacb69a0dc0101a4453f3c76eda333d6bbc49f68f64390b3d85"
1482dependencies = [ 1460dependencies = [
1483 "base64 0.22.1", 1461 "base64 0.22.1",
1484 "bech32", 1462 "bech32",
@@ -1487,9 +1465,10 @@ dependencies = [
1487 "cbc", 1465 "cbc",
1488 "chacha20", 1466 "chacha20",
1489 "chacha20poly1305", 1467 "chacha20poly1305",
1490 "getrandom 0.2.16",
1491 "hex", 1468 "hex",
1492 "instant", 1469 "instant",
1470 "once_cell",
1471 "rand 0.9.2",
1493 "scrypt", 1472 "scrypt",
1494 "secp256k1", 1473 "secp256k1",
1495 "serde", 1474 "serde",
@@ -1500,47 +1479,34 @@ dependencies = [
1500 1479
1501[[package]] 1480[[package]]
1502name = "nostr-database" 1481name = "nostr-database"
1503version = "0.43.0"
1504source = "registry+https://github.com/rust-lang/crates.io-index"
1505checksum = "b1c75a8c2175d2785ba73cfddef21d1e30da5fbbdf158569b6808ba44973a15b"
1506dependencies = [
1507 "lru",
1508 "nostr 0.43.1",
1509 "tokio",
1510]
1511
1512[[package]]
1513name = "nostr-database"
1514version = "0.44.0" 1482version = "0.44.0"
1515source = "registry+https://github.com/rust-lang/crates.io-index" 1483source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1516checksum = "7462c9d8ae5ef6a28d66a192d399ad2530f1f2130b13186296dbb11bdef5b3d1"
1517dependencies = [ 1484dependencies = [
1485 "btreecap",
1518 "flatbuffers", 1486 "flatbuffers",
1519 "lru", 1487 "lru",
1520 "nostr 0.44.1", 1488 "nostr",
1521 "tokio", 1489 "tokio",
1522] 1490]
1523 1491
1524[[package]] 1492[[package]]
1525name = "nostr-gossip" 1493name = "nostr-gossip"
1526version = "0.44.0" 1494version = "0.44.0"
1527source = "registry+https://github.com/rust-lang/crates.io-index" 1495source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1528checksum = "ade30de16869618919c6b5efc8258f47b654a98b51541eb77f85e8ec5e3c83a6"
1529dependencies = [ 1496dependencies = [
1530 "nostr 0.44.1", 1497 "nostr",
1531] 1498]
1532 1499
1533[[package]] 1500[[package]]
1534name = "nostr-lmdb" 1501name = "nostr-lmdb"
1535version = "0.44.0" 1502version = "0.44.0"
1536source = "registry+https://github.com/rust-lang/crates.io-index" 1503source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1537checksum = "1201bcf1f900c352f9f2cea5249960dc6b23049b65699a516e1327243becf6a2"
1538dependencies = [ 1504dependencies = [
1539 "async-utility", 1505 "async-utility",
1540 "flume", 1506 "flume",
1541 "heed", 1507 "heed",
1542 "nostr 0.44.1", 1508 "nostr",
1543 "nostr-database 0.44.0", 1509 "nostr-database",
1544 "tokio", 1510 "tokio",
1545 "tracing", 1511 "tracing",
1546] 1512]
@@ -1548,33 +1514,16 @@ dependencies = [
1548[[package]] 1514[[package]]
1549name = "nostr-relay-builder" 1515name = "nostr-relay-builder"
1550version = "0.44.0" 1516version = "0.44.0"
1551source = "registry+https://github.com/rust-lang/crates.io-index" 1517source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1552checksum = "51ba8e48eaadd5644e7317ca2f892b89a394a8cc57e99fea9f624dc081df1a24"
1553dependencies = [ 1518dependencies = [
1554 "async-utility", 1519 "async-utility",
1555 "async-wsocket", 1520 "async-wsocket",
1556 "atomic-destructor", 1521 "atomic-destructor",
1557 "hex", 1522 "hex",
1558 "negentropy", 1523 "negentropy",
1559 "nostr 0.44.1", 1524 "nostr",
1560 "nostr-database 0.44.0", 1525 "nostr-database",
1561 "tokio", 1526 "nostr-relay-pool",
1562 "tracing",
1563]
1564
1565[[package]]
1566name = "nostr-relay-pool"
1567version = "0.43.1"
1568source = "registry+https://github.com/rust-lang/crates.io-index"
1569checksum = "2b2f43b70d13dfc50508a13cd902e11f4625312b2ce0e4b7c4c2283fd04001bd"
1570dependencies = [
1571 "async-utility",
1572 "async-wsocket",
1573 "atomic-destructor",
1574 "lru",
1575 "negentropy",
1576 "nostr 0.43.1",
1577 "nostr-database 0.43.0",
1578 "tokio", 1527 "tokio",
1579 "tracing", 1528 "tracing",
1580] 1529]
@@ -1582,8 +1531,7 @@ dependencies = [
1582[[package]] 1531[[package]]
1583name = "nostr-relay-pool" 1532name = "nostr-relay-pool"
1584version = "0.44.0" 1533version = "0.44.0"
1585source = "registry+https://github.com/rust-lang/crates.io-index" 1534source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1586checksum = "4b1073ccfbaea5549fb914a9d52c68dab2aecda61535e5143dd73e95445a804b"
1587dependencies = [ 1535dependencies = [
1588 "async-utility", 1536 "async-utility",
1589 "async-wsocket", 1537 "async-wsocket",
@@ -1591,36 +1539,22 @@ dependencies = [
1591 "hex", 1539 "hex",
1592 "lru", 1540 "lru",
1593 "negentropy", 1541 "negentropy",
1594 "nostr 0.44.1", 1542 "nostr",
1595 "nostr-database 0.44.0", 1543 "nostr-database",
1596 "tokio", 1544 "tokio",
1597 "tracing", 1545 "tracing",
1598] 1546]
1599 1547
1600[[package]] 1548[[package]]
1601name = "nostr-sdk" 1549name = "nostr-sdk"
1602version = "0.43.0"
1603source = "registry+https://github.com/rust-lang/crates.io-index"
1604checksum = "599f8963d6a1522a13b1a2b0ea6e168acfc367706606f1d33fa595e91fa22db0"
1605dependencies = [
1606 "async-utility",
1607 "nostr 0.43.1",
1608 "nostr-database 0.43.0",
1609 "nostr-relay-pool 0.43.1",
1610 "tokio",
1611]
1612
1613[[package]]
1614name = "nostr-sdk"
1615version = "0.44.1" 1550version = "0.44.1"
1616source = "registry+https://github.com/rust-lang/crates.io-index" 1551source = "git+https://github.com/rust-nostr/nostr?rev=e09c9d82a1778683d2a6b968d09eb2c619883bf3#e09c9d82a1778683d2a6b968d09eb2c619883bf3"
1617checksum = "471732576710e779b64f04c55e3f8b5292f865fea228436daf19694f0bf70393"
1618dependencies = [ 1552dependencies = [
1619 "async-utility", 1553 "async-utility",
1620 "nostr 0.44.1", 1554 "nostr",
1621 "nostr-database 0.44.0", 1555 "nostr-database",
1622 "nostr-gossip", 1556 "nostr-gossip",
1623 "nostr-relay-pool 0.44.0", 1557 "nostr-relay-pool",
1624 "tokio", 1558 "tokio",
1625 "tracing", 1559 "tracing",
1626] 1560]
@@ -2209,7 +2143,6 @@ version = "0.29.1"
2209source = "registry+https://github.com/rust-lang/crates.io-index" 2143source = "registry+https://github.com/rust-lang/crates.io-index"
2210checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" 2144checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113"
2211dependencies = [ 2145dependencies = [
2212 "rand 0.8.5",
2213 "secp256k1-sys", 2146 "secp256k1-sys",
2214 "serde", 2147 "serde",
2215] 2148]
diff --git a/Cargo.toml b/Cargo.toml
index d1650e0..e1e1627 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,11 +17,11 @@ hyper-util = { version = "0.1", features = ["tokio", "server", "http1", "http2"]
17http-body-util = "0.1" 17http-body-util = "0.1"
18 18
19# Nostr relay 19# Nostr relay
20nostr-relay-builder = "0.44" 20nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" }
21 21
22# Nostr 22# Nostr
23nostr-sdk = "0.44" 23nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" }
24nostr-lmdb = "0.44" 24nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" }
25 25
26# Utilities 26# Utilities
27futures-util = "0.3" 27futures-util = "0.3"
diff --git a/grasp-audit/Cargo.toml b/grasp-audit/Cargo.toml
index 9198cd5..88f3d60 100644
--- a/grasp-audit/Cargo.toml
+++ b/grasp-audit/Cargo.toml
@@ -12,7 +12,7 @@ path = "src/bin/grasp-audit.rs"
12 12
13[dependencies] 13[dependencies]
14# Nostr 14# Nostr
15nostr-sdk = "0.43" 15nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "e09c9d82a1778683d2a6b968d09eb2c619883bf3" }
16 16
17# Async 17# Async
18tokio = { version = "1", features = ["full"] } 18tokio = { version = "1", features = ["full"] }
diff --git a/grasp-audit/src/audit.rs b/grasp-audit/src/audit.rs
index 0a4df42..5fb6904 100644
--- a/grasp-audit/src/audit.rs
+++ b/grasp-audit/src/audit.rs
@@ -132,7 +132,7 @@ impl AuditConfig {
132 TagKind::SingleLetter(t_tag), 132 TagKind::SingleLetter(t_tag),
133 vec![format!( 133 vec![format!(
134 "audit-cleanup-after-{}", 134 "audit-cleanup-after-{}",
135 self.cleanup_after.as_u64() 135 self.cleanup_after.as_secs()
136 )], 136 )],
137 ), 137 ),
138 ] 138 ]
@@ -328,7 +328,7 @@ mod tests {
328 let after = Timestamp::now(); 328 let after = Timestamp::now();
329 329
330 // Event timestamp should be between before and after (inclusive) 330 // Event timestamp should be between before and after (inclusive)
331 assert!(event.created_at.as_u64() >= before.as_u64()); 331 assert!(event.created_at.as_secs() >= before.as_secs());
332 assert!(event.created_at.as_u64() <= after.as_u64()); 332 assert!(event.created_at.as_secs() <= after.as_secs());
333 } 333 }
334} 334}
diff --git a/grasp-audit/src/fixtures.rs b/grasp-audit/src/fixtures.rs
index a15bd79..62f93e8 100644
--- a/grasp-audit/src/fixtures.rs
+++ b/grasp-audit/src/fixtures.rs
@@ -676,7 +676,7 @@ impl<'a> TestContext<'a> {
676 .to_string(); 676 .to_string();
677 677
678 // Create state announcement with deterministic commit hash 678 // Create state announcement with deterministic commit hash
679 let base_time = Timestamp::now().as_u64(); 679 let base_time = Timestamp::now().as_secs();
680 let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago 680 let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago
681 681
682 // Tag format: ["refs/heads/main", "<commit_hash>"] 682 // Tag format: ["refs/heads/main", "<commit_hash>"]
@@ -712,7 +712,7 @@ impl<'a> TestContext<'a> {
712 .to_string(); 712 .to_string();
713 713
714 // Create PR event 1 second in the past 714 // Create PR event 1 second in the past
715 let base_time = Timestamp::now().as_u64(); 715 let base_time = Timestamp::now().as_secs();
716 let pr_timestamp = Timestamp::from(base_time - 1); 716 let pr_timestamp = Timestamp::from(base_time - 1);
717 717
718 // Build NIP-34 PR event (kind 1618) 718 // Build NIP-34 PR event (kind 1618)
@@ -755,7 +755,7 @@ impl<'a> TestContext<'a> {
755 .to_string(); 755 .to_string();
756 756
757 // Create PR event 1 second in the past 757 // Create PR event 1 second in the past
758 let base_time = Timestamp::now().as_u64(); 758 let base_time = Timestamp::now().as_secs();
759 let pr_timestamp = Timestamp::from(base_time - 1); 759 let pr_timestamp = Timestamp::from(base_time - 1);
760 760
761 // Build NIP-34 PR event (kind 1618) 761 // Build NIP-34 PR event (kind 1618)
@@ -883,7 +883,7 @@ impl<'a> TestContext<'a> {
883 let repo_id = self.extract_repo_id(&repo)?; 883 let repo_id = self.extract_repo_id(&repo)?;
884 884
885 // Build state event 885 // Build state event
886 let base_time = Timestamp::now().as_u64(); 886 let base_time = Timestamp::now().as_secs();
887 let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago 887 let older_timestamp = Timestamp::from(base_time - 10); // 10 seconds ago
888 888
889 let state_event = self 889 let state_event = self
@@ -1036,7 +1036,7 @@ impl<'a> TestContext<'a> {
1036 let repo = self.get_cached_dependency(FixtureKind::ValidRepo)?; 1036 let repo = self.get_cached_dependency(FixtureKind::ValidRepo)?;
1037 1037
1038 // Build maintainer's state event (state event ONLY - no announcement) 1038 // Build maintainer's state event (state event ONLY - no announcement)
1039 let base_time = Timestamp::now().as_u64(); 1039 let base_time = Timestamp::now().as_secs();
1040 let maintainer_timestamp = Timestamp::from(base_time - 5); // 5 seconds ago (more recent than owner's state) 1040 let maintainer_timestamp = Timestamp::from(base_time - 5); // 5 seconds ago (more recent than owner's state)
1041 1041
1042 let maintainer_state_event = self 1042 let maintainer_state_event = self
@@ -1187,7 +1187,7 @@ impl<'a> TestContext<'a> {
1187 self.client.send_event(maintainer_announcement).await?; 1187 self.client.send_event(maintainer_announcement).await?;
1188 1188
1189 // Build recursive maintainer's state event 1189 // Build recursive maintainer's state event
1190 let base_time = Timestamp::now().as_u64(); 1190 let base_time = Timestamp::now().as_secs();
1191 let recursive_maintainer_timestamp = Timestamp::from(base_time - 2); // 2 seconds ago (most recent) 1191 let recursive_maintainer_timestamp = Timestamp::from(base_time - 2); // 2 seconds ago (most recent)
1192 1192
1193 let recursive_maintainer_state_event = self 1193 let recursive_maintainer_state_event = self
@@ -1338,7 +1338,7 @@ impl<'a> TestContext<'a> {
1338 // ============================================================ 1338 // ============================================================
1339 // Use the same commit hash that's already pushed to the relay 1339 // Use the same commit hash that's already pushed to the relay
1340 // but point HEAD to develop branch instead of main 1340 // but point HEAD to develop branch instead of main
1341 let base_time = Timestamp::now().as_u64(); 1341 let base_time = Timestamp::now().as_secs();
1342 let develop_timestamp = Timestamp::from(base_time - 1); // 1 second ago (most recent) 1342 let develop_timestamp = Timestamp::from(base_time - 1); // 1 second ago (most recent)
1343 1343
1344 let develop_state_event = self 1344 let develop_state_event = self
diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs
index c34fe66..00a48fd 100644
--- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs
+++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs
@@ -271,7 +271,7 @@ impl EventAcceptancePolicyTests {
271 .to_string(); 271 .to_string();
272 272
273 // Create unique repository identifier 273 // Create unique repository identifier
274 let timestamp = Timestamp::now().as_u64(); 274 let timestamp = Timestamp::now().as_secs();
275 let repo_id = format!("test-repo-no-clone-{}", timestamp); 275 let repo_id = format!("test-repo-no-clone-{}", timestamp);
276 276
277 // Create repo announcement WITHOUT service in clone tag 277 // Create repo announcement WITHOUT service in clone tag
@@ -352,7 +352,7 @@ impl EventAcceptancePolicyTests {
352 .replace("wss://", "https://"); 352 .replace("wss://", "https://");
353 353
354 // Create unique repository identifier 354 // Create unique repository identifier
355 let timestamp = Timestamp::now().as_u64(); 355 let timestamp = Timestamp::now().as_secs();
356 let repo_id = format!("test-repo-no-relays-{}", timestamp); 356 let repo_id = format!("test-repo-no-relays-{}", timestamp);
357 357
358 // Create repo announcement WITHOUT service in relays tag 358 // Create repo announcement WITHOUT service in relays tag
diff --git a/grasp-audit/src/specs/grasp01/nip01_smoke.rs b/grasp-audit/src/specs/grasp01/nip01_smoke.rs
index 4dbcd3d..bd45ea4 100644
--- a/grasp-audit/src/specs/grasp01/nip01_smoke.rs
+++ b/grasp-audit/src/specs/grasp01/nip01_smoke.rs
@@ -216,7 +216,7 @@ impl Nip01SmokeTests {
216 let invalid_event_json = serde_json::json!({ 216 let invalid_event_json = serde_json::json!({
217 "id": event.id.to_hex(), 217 "id": event.id.to_hex(),
218 "pubkey": event.pubkey.to_hex(), 218 "pubkey": event.pubkey.to_hex(),
219 "created_at": event.created_at.as_u64(), 219 "created_at": event.created_at.as_secs(),
220 "kind": event.kind.as_u16(), 220 "kind": event.kind.as_u16(),
221 "tags": event.tags, 221 "tags": event.tags,
222 "content": event.content, 222 "content": event.content,
@@ -261,7 +261,7 @@ impl Nip01SmokeTests {
261 let invalid_event_json = serde_json::json!({ 261 let invalid_event_json = serde_json::json!({
262 "id": EventId::all_zeros().to_hex(), // Wrong ID! 262 "id": EventId::all_zeros().to_hex(), // Wrong ID!
263 "pubkey": event.pubkey.to_hex(), 263 "pubkey": event.pubkey.to_hex(),
264 "created_at": event.created_at.as_u64(), 264 "created_at": event.created_at.as_secs(),
265 "kind": event.kind.as_u16(), 265 "kind": event.kind.as_u16(),
266 "tags": event.tags, 266 "tags": event.tags,
267 "content": event.content, 267 "content": event.content,
diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs
index ec08032..25738d1 100644
--- a/grasp-audit/src/specs/grasp01/push_authorization.rs
+++ b/grasp-audit/src/specs/grasp01/push_authorization.rs
@@ -29,7 +29,7 @@
29/// 29///
30/// Run `test_pr_test_commit_hash_discovery` to discover/verify this value. 30/// Run `test_pr_test_commit_hash_discovery` to discover/verify this value.
31#[allow(dead_code)] 31#[allow(dead_code)]
32const PR_TEST_COMMIT_HASH: &str = "5d40fb1555a0c28bf4d650515a73aaa54d4d9bfb"; 32const PR_TEST_COMMIT_HASH: &str = "8935183ff722bf04e861928c6a7e50868c6ca4a6";
33 33
34use crate::{ 34use crate::{
35 clone_repo, create_commit, create_deterministic_commit_with_variant, try_push, try_push_to_ref, 35 clone_repo, create_commit, create_deterministic_commit_with_variant, try_push, try_push_to_ref,
diff --git a/src/main.rs b/src/main.rs
index 6d8b4dd..ddb198e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,7 +47,7 @@ async fn main() -> Result<()> {
47 47
48 // Create Nostr relay with NIP-34 validation 48 // Create Nostr relay with NIP-34 validation
49 // Returns both the relay and database for direct queries in handlers 49 // Returns both the relay and database for direct queries in handlers
50 if let Ok(relay_with_db) = nostr::builder::create_relay(&config) { 50 if let Ok(relay_with_db) = nostr::builder::create_relay(&config).await {
51 info!( 51 info!(
52 "Relay created with NIP-34 validation for domain: {}", 52 "Relay created with NIP-34 validation for domain: {}",
53 config.domain 53 config.domain
diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs
index 84d8ab4..8dd6291 100644
--- a/src/nostr/builder.rs
+++ b/src/nostr/builder.rs
@@ -3,11 +3,12 @@
3/// This module integrates nostr-relay-builder with NIP-34 validation logic 3/// This module integrates nostr-relay-builder with NIP-34 validation logic
4/// using modular sub-policies for each event type. 4/// using modular sub-policies for each event type.
5use std::net::SocketAddr; 5use std::net::SocketAddr;
6use std::num::NonZeroUsize;
6use std::path::Path; 7use std::path::Path;
7use std::sync::Arc; 8use std::sync::Arc;
8 9
9use nostr::nips::nip19::ToBech32; 10use nostr::nips::nip19::ToBech32;
10use nostr_lmdb::NostrLMDB; 11use nostr_lmdb::NostrLmdb;
11use nostr_relay_builder::prelude::*; 12use nostr_relay_builder::prelude::*;
12 13
13use crate::config::{Config, DatabaseBackend}; 14use crate::config::{Config, DatabaseBackend};
@@ -68,7 +69,7 @@ impl Nip34WritePolicy {
68 } 69 }
69 70
70 /// Handle repository announcement event 71 /// Handle repository announcement event
71 async fn handle_announcement(&self, event: &Event) -> PolicyResult { 72 async fn handle_announcement(&self, event: &Event) -> WritePolicyResult {
72 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); 73 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex());
73 74
74 match self.announcement_policy.validate(event).await { 75 match self.announcement_policy.validate(event).await {
@@ -90,7 +91,7 @@ impl Nip34WritePolicy {
90 } 91 }
91 92
92 tracing::debug!("Accepted repository announcement: {}", event_id_str); 93 tracing::debug!("Accepted repository announcement: {}", event_id_str);
93 PolicyResult::Accept 94 WritePolicyResult::Accept
94 } 95 }
95 Err(e) => { 96 Err(e) => {
96 tracing::warn!( 97 tracing::warn!(
@@ -98,7 +99,7 @@ impl Nip34WritePolicy {
98 event_id_str, 99 event_id_str,
99 e 100 e
100 ); 101 );
101 PolicyResult::Reject(format!("Failed to parse announcement: {}", e)) 102 WritePolicyResult::reject(format!("Failed to parse announcement: {}", e))
102 } 103 }
103 } 104 }
104 } 105 }
@@ -113,7 +114,7 @@ impl Nip34WritePolicy {
113 announcement.identifier 114 announcement.identifier
114 ); 115 );
115 // Don't create bare repository for external announcements 116 // Don't create bare repository for external announcements
116 PolicyResult::Accept 117 WritePolicyResult::Accept
117 } 118 }
118 Err(e) => { 119 Err(e) => {
119 tracing::warn!( 120 tracing::warn!(
@@ -121,7 +122,7 @@ impl Nip34WritePolicy {
121 event_id_str, 122 event_id_str,
122 e 123 e
123 ); 124 );
124 PolicyResult::Reject(format!("Failed to parse announcement: {}", e)) 125 WritePolicyResult::reject(format!("Failed to parse announcement: {}", e))
125 } 126 }
126 } 127 }
127 } 128 }
@@ -131,13 +132,13 @@ impl Nip34WritePolicy {
131 event_id_str, 132 event_id_str,
132 reason 133 reason
133 ); 134 );
134 PolicyResult::Reject(reason) 135 WritePolicyResult::reject(reason)
135 } 136 }
136 } 137 }
137 } 138 }
138 139
139 /// Handle repository state event 140 /// Handle repository state event
140 async fn handle_state(&self, event: &Event) -> PolicyResult { 141 async fn handle_state(&self, event: &Event) -> WritePolicyResult {
141 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); 142 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex());
142 143
143 match self.state_policy.validate(event) { 144 match self.state_policy.validate(event) {
@@ -151,25 +152,25 @@ impl Nip34WritePolicy {
151 } 152 }
152 153
153 tracing::debug!("Accepted repository state: {}", event_id_str); 154 tracing::debug!("Accepted repository state: {}", event_id_str);
154 PolicyResult::Accept 155 WritePolicyResult::Accept
155 } 156 }
156 Err(e) => { 157 Err(e) => {
157 tracing::warn!("Failed to parse repository state {}: {}", event_id_str, e); 158 tracing::warn!("Failed to parse repository state {}: {}", event_id_str, e);
158 // Still accept the event even if we can't parse it 159 // Still accept the event even if we can't parse it
159 // The validation passed, so it's structurally valid 160 // The validation passed, so it's structurally valid
160 PolicyResult::Accept 161 WritePolicyResult::Accept
161 } 162 }
162 } 163 }
163 } 164 }
164 StateResult::Reject(reason) => { 165 StateResult::Reject(reason) => {
165 tracing::warn!("Rejected repository state {}: {}", event_id_str, reason); 166 tracing::warn!("Rejected repository state {}: {}", event_id_str, reason);
166 PolicyResult::Reject(reason) 167 WritePolicyResult::reject(reason)
167 } 168 }
168 } 169 }
169 } 170 }
170 171
171 /// Handle PR or PR Update event 172 /// Handle PR or PR Update event
172 async fn handle_pr_event(&self, event: &Event) -> PolicyResult { 173 async fn handle_pr_event(&self, event: &Event) -> WritePolicyResult {
173 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); 174 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex());
174 175
175 // Validate refs/nostr refs for this PR event 176 // Validate refs/nostr refs for this PR event
@@ -188,7 +189,7 @@ impl Nip34WritePolicy {
188 } 189 }
189 190
190 /// Handle events that must reference accepted repositories or events 191 /// Handle events that must reference accepted repositories or events
191 async fn handle_related_event(&self, event: &Event, event_type: &str) -> PolicyResult { 192 async fn handle_related_event(&self, event: &Event, event_type: &str) -> WritePolicyResult {
192 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); 193 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex());
193 194
194 match self.related_event_policy.check_references(event).await { 195 match self.related_event_policy.check_references(event).await {
@@ -199,7 +200,7 @@ impl Nip34WritePolicy {
199 event_id_str, 200 event_id_str,
200 addr_ref 201 addr_ref
201 ); 202 );
202 PolicyResult::Accept 203 WritePolicyResult::Accept
203 } 204 }
204 Ok(ReferenceResult::ReferencesEvent(event_ref)) => { 205 Ok(ReferenceResult::ReferencesEvent(event_ref)) => {
205 tracing::debug!( 206 tracing::debug!(
@@ -208,7 +209,7 @@ impl Nip34WritePolicy {
208 event_id_str, 209 event_id_str,
209 event_ref 210 event_ref
210 ); 211 );
211 PolicyResult::Accept 212 WritePolicyResult::Accept
212 } 213 }
213 Ok(ReferenceResult::ReferencedByAccepted) => { 214 Ok(ReferenceResult::ReferencedByAccepted) => {
214 tracing::debug!( 215 tracing::debug!(
@@ -216,7 +217,7 @@ impl Nip34WritePolicy {
216 event_type, 217 event_type,
217 event_id_str 218 event_id_str
218 ); 219 );
219 PolicyResult::Accept 220 WritePolicyResult::Accept
220 } 221 }
221 Ok(ReferenceResult::Orphan) => { 222 Ok(ReferenceResult::Orphan) => {
222 let (addressable_refs, event_refs) = 223 let (addressable_refs, event_refs) =
@@ -228,7 +229,7 @@ impl Nip34WritePolicy {
228 addressable_refs.len(), 229 addressable_refs.len(),
229 event_refs.len() 230 event_refs.len()
230 ); 231 );
231 PolicyResult::Reject(format!( 232 WritePolicyResult::reject(format!(
232 "{} event must reference an accepted repository or accepted event", 233 "{} event must reference an accepted repository or accepted event",
233 event_type 234 event_type
234 )) 235 ))
@@ -240,7 +241,7 @@ impl Nip34WritePolicy {
240 event_id_str, 241 event_id_str,
241 e 242 e
242 ); 243 );
243 PolicyResult::Reject(format!("Database query failed: {}", e)) 244 WritePolicyResult::reject(format!("Database query failed: {}", e))
244 } 245 }
245 } 246 }
246 } 247 }
@@ -251,7 +252,7 @@ impl WritePolicy for Nip34WritePolicy {
251 &'a self, 252 &'a self,
252 event: &'a nostr_relay_builder::prelude::Event, 253 event: &'a nostr_relay_builder::prelude::Event,
253 _addr: &'a SocketAddr, 254 _addr: &'a SocketAddr,
254 ) -> BoxedFuture<'a, PolicyResult> { 255 ) -> BoxedFuture<'a, WritePolicyResult> {
255 Box::pin(async move { 256 Box::pin(async move {
256 match event.kind.as_u16() { 257 match event.kind.as_u16() {
257 KIND_REPOSITORY_ANNOUNCEMENT => self.handle_announcement(event).await, 258 KIND_REPOSITORY_ANNOUNCEMENT => self.handle_announcement(event).await,
@@ -265,7 +266,7 @@ impl WritePolicy for Nip34WritePolicy {
265 author = %event.pubkey.to_hex(), 266 author = %event.pubkey.to_hex(),
266 "Accepted kind 10317 user grasp list" 267 "Accepted kind 10317 user grasp list"
267 ); 268 );
268 PolicyResult::Accept 269 WritePolicyResult::Accept
269 } 270 }
270 _ => self.handle_related_event(event, "Event").await, 271 _ => self.handle_related_event(event, "Event").await,
271 } 272 }
@@ -288,7 +289,7 @@ pub struct RelayWithDatabase {
288/// Returns a `RelayWithDatabase` struct containing: 289/// Returns a `RelayWithDatabase` struct containing:
289/// - The `LocalRelay` for handling WebSocket connections 290/// - The `LocalRelay` for handling WebSocket connections
290/// - The `SharedDatabase` for direct database queries (e.g., push authorization) 291/// - The `SharedDatabase` for direct database queries (e.g., push authorization)
291pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> { 292pub async fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
292 tracing::info!("Configuring nostr relay with GRASP-01 validation..."); 293 tracing::info!("Configuring nostr relay with GRASP-01 validation...");
293 294
294 // Determine database path 295 // Determine database path
@@ -300,7 +301,7 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
300 tracing::info!("Using in-memory database (no persistence)"); 301 tracing::info!("Using in-memory database (no persistence)");
301 Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions { 302 Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions {
302 events: true, 303 events: true,
303 max_events: Some(100_000), 304 max_events: Some(NonZeroUsize::new(100_000).unwrap()),
304 })) 305 }))
305 } 306 }
306 DatabaseBackend::NostrDb => { 307 DatabaseBackend::NostrDb => {
@@ -310,7 +311,7 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
310 tracing::warn!("NostrDB backend not yet implemented, using in-memory database"); 311 tracing::warn!("NostrDB backend not yet implemented, using in-memory database");
311 Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions { 312 Arc::new(MemoryDatabase::with_opts(MemoryDatabaseOptions {
312 events: true, 313 events: true,
313 max_events: Some(100_000), 314 max_events: Some(NonZeroUsize::new(100_000).unwrap()),
314 })) 315 }))
315 } 316 }
316 DatabaseBackend::Lmdb => { 317 DatabaseBackend::Lmdb => {
@@ -323,7 +324,7 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
323 e 324 e
324 ) 325 )
325 })?; 326 })?;
326 Arc::new(NostrLMDB::open(db_path).map_err(|e| { 327 Arc::new(NostrLmdb::open(db_path).await.map_err(|e| {
327 anyhow::anyhow!( 328 anyhow::anyhow!(
328 "Failed to open LMDB database at {}: {}", 329 "Failed to open LMDB database at {}: {}",
329 db_path.display(), 330 db_path.display(),
@@ -338,9 +339,10 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
338 let git_data_path = config.effective_git_data_path(); 339 let git_data_path = config.effective_git_data_path();
339 let write_policy = Nip34WritePolicy::new(&config.domain, database.clone(), &git_data_path); 340 let write_policy = Nip34WritePolicy::new(&config.domain, database.clone(), &git_data_path);
340 341
341 let builder = RelayBuilder::default() 342 let relay = LocalRelayBuilder::default()
342 .database(database.clone()) 343 .database(database.clone())
343 .write_policy(write_policy.clone()); 344 .write_policy(write_policy.clone())
345 .build();
344 346
345 tracing::info!( 347 tracing::info!(
346 "Relay configured with GRASP-01 validation for domain: {}", 348 "Relay configured with GRASP-01 validation for domain: {}",
@@ -348,7 +350,7 @@ pub fn create_relay(config: &Config) -> Result<RelayWithDatabase> {
348 ); 350 );
349 351
350 Ok(RelayWithDatabase { 352 Ok(RelayWithDatabase {
351 relay: LocalRelay::new(builder), 353 relay,
352 database, 354 database,
353 write_policy, 355 write_policy,
354 }) 356 })
diff --git a/src/sync/mod.rs b/src/sync/mod.rs
index d315939..6ec39e8 100644
--- a/src/sync/mod.rs
+++ b/src/sync/mod.rs
@@ -260,11 +260,11 @@ async fn run_daily_timer(
260 sync_manager: Arc<Mutex<SyncManager>>, 260 sync_manager: Arc<Mutex<SyncManager>>,
261 mut shutdown_rx: broadcast::Receiver<()>, 261 mut shutdown_rx: broadcast::Receiver<()>,
262) { 262) {
263 use rand::Rng; 263 use ::rand::Rng;
264 264
265 loop { 265 loop {
266 // Random interval between 23-25 hours 266 // Random interval between 23-25 hours
267 let hours = 23.0 + rand::thread_rng().gen::<f64>() * 2.0; 267 let hours = 23.0 + ::rand::thread_rng().gen::<f64>() * 2.0;
268 let seconds = (hours * 3600.0) as u64; 268 let seconds = (hours * 3600.0) as u64;
269 269
270 tracing::info!( 270 tracing::info!(
@@ -1599,7 +1599,7 @@ impl SyncManager {
1599 write_policy: &Nip34WritePolicy, 1599 write_policy: &Nip34WritePolicy,
1600 local_relay: &LocalRelay, 1600 local_relay: &LocalRelay,
1601 ) -> ProcessResult { 1601 ) -> ProcessResult {
1602 use nostr_relay_builder::prelude::{PolicyResult, WritePolicy}; 1602 use nostr_relay_builder::prelude::{WritePolicyResult, WritePolicy};
1603 use std::net::{IpAddr, Ipv4Addr, SocketAddr}; 1603 use std::net::{IpAddr, Ipv4Addr, SocketAddr};
1604 // Check if event already exists 1604 // Check if event already exists
1605 match database.event_by_id(&event.id).await { 1605 match database.event_by_id(&event.id).await {
@@ -1619,7 +1619,7 @@ impl SyncManager {
1619 let result = write_policy.admit_event(event, &dummy_addr).await; 1619 let result = write_policy.admit_event(event, &dummy_addr).await;
1620 1620
1621 match result { 1621 match result {
1622 PolicyResult::Accept => { 1622 WritePolicyResult::Accept => {
1623 // Save event to database 1623 // Save event to database
1624 if let Err(e) = database.save_event(event).await { 1624 if let Err(e) = database.save_event(event).await {
1625 tracing::error!( 1625 tracing::error!(
@@ -1644,11 +1644,11 @@ impl SyncManager {
1644 ); 1644 );
1645 ProcessResult::Saved 1645 ProcessResult::Saved
1646 } 1646 }
1647 PolicyResult::Reject(reason) => { 1647 WritePolicyResult::Reject { message, .. } => {
1648 tracing::debug!( 1648 tracing::debug!(
1649 event_id = %event.id, 1649 event_id = %event.id,
1650 relay = %relay_url, 1650 relay = %relay_url,
1651 reason = %reason, 1651 reason = %message,
1652 "Event rejected by write policy" 1652 "Event rejected by write policy"
1653 ); 1653 );
1654 ProcessResult::Rejected 1654 ProcessResult::Rejected