-
Notifications
You must be signed in to change notification settings - Fork 247
feat: get seed peers from http endpoint #7468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: get seed peers from http endpoint #7468
Conversation
Description --- When we have a valid PoW equal to or higher than what we have or what has been advertised by the sync peer, we need to commit the headers, so any downstream block sync error does not invalidate the headers that have been downloaded. _**Edit:** When block sync fails, we also make sure to swap to the best PoW chain, also preserving banked headers if we do not need to reorg._ Closes tari-project#7342 Motivation and Context --- See tari-project#7342 How Has This Been Tested? --- System-level tests passed: - Synching a previously synced node, a couple of days old. - Syncing from scratch, encountering multiple block-sync failures, but using the good PoW headers already banked. ```rust 51952: 2025-08-18 16:07:02.097680100 [c::bn::block_sync] DEBUG Validating block body #22624 (PoW = RandomXTari, input(s): 1, output(s): 54, kernel(s): 2, latency: 108.00µs) 51961: 2025-08-18 16:07:02.111648900 [c::bn::block_sync] DEBUG Validated in 14ms. Storing block body #22624 (PoW = RandomXTari, input(s): 1, output(s): 54, kernel(s): 2) 51962: 2025-08-18 16:07:02.111668100 [c::bn::block_sync] TRACE Hash: 91a1fbccc1f94e2aa93b6efdaf9c3fbf16d0588c3458b7ef444e605f62375077 54024: 2025-08-18 16:11:06.389482300 [c::bn::block_sync] WARN Peer did not supply all the blocks they claimed they had: Their claim - height: 74721, accumulated difficulty: 4089235547434023187024157117581153168163715651441378. Our status after block sync - height: 22624, accumulated difficulty: 1547640955349056263010512134240412613668889130919000 54028: 2025-08-18 16:11:06.390047900 [c::bn::block_sync] WARN Block sync failed - best header: 74723/1bcf29397a0d93a8bc37e328c7be14d42aa6f6c41df2d6c888a6589dca3a323b, best block: 22624/91a1fbccc1f94e2aa93b6efdaf9c3fbf16d0588c3458b7ef444e605f62375077. No more sync peers available: Block sync failed 54109: 2025-08-18 16:11:11.596105400 [c::bn::header_sync] DEBUG Starting header sync. 54110: 2025-08-18 16:11:11.596176700 [c::bn::header_sync] INFO Synchronizing headers (4 candidate peers selected) 54111: 2025-08-18 16:11:11.596199700 [c::bn::header_sync] INFO Attempting to sync headers (4 sync peers) 54112: 2025-08-18 16:11:11.596220000 [c::bn::header_sync] DEBUG Dialing f64bf9ff1d7a4118f47f4d7f04 sync peer 54113: 2025-08-18 16:11:11.596542500 [c::bn::header_sync] INFO Successfully dialed sync peer f64bf9ff1d7a4118f47f4d7f04 in 322.00µs 54114: 2025-08-18 16:11:11.609485100 [c::bn::header_sync] DEBUG Attempting to synchronize headers with `f64bf9ff1d7a4118f47f4d7f04` 54116: 2025-08-18 16:11:12.457361100 [c::bn::header_sync] DEBUG Sync peer latency is 847.21ms 54117: 2025-08-18 16:11:12.457385200 [c::bn::header_sync] DEBUG Initiating header sync with peer `f64bf9ff1d7a4118f47f4d7f04` (sync latency = 847ms) 54118: 2025-08-18 16:11:12.462776900 [c::bn::header_sync] DEBUG Determining if chain splits between 0 and 500 headers back from the tip (peer: `f64bf9ff1d7a4118f47f4d7f04`, 500 hashes sent) 56228: 2025-08-18 16:15:17.479381900 [c::bn::header_sync] WARN RPC error: Request failed: Timeout: Response timed out 56231: 2025-08-18 16:15:17.479971300 [c::bn::header_sync] DEBUG Dialing a28f3717c4ea032e358941f76a sync peer 56232: 2025-08-18 16:15:17.481441700 [c::bn::header_sync] INFO Successfully dialed sync peer a28f3717c4ea032e358941f76a in 1.47ms 56233: 2025-08-18 16:15:17.481505800 [c::bn::header_sync] DEBUG Attempting to synchronize headers with `a28f3717c4ea032e358941f76a` 56234: 2025-08-18 16:15:18.045995600 [c::bn::header_sync] DEBUG Sync peer latency is 564.03ms 56235: 2025-08-18 16:15:18.046016000 [c::bn::header_sync] DEBUG Initiating header sync with peer `a28f3717c4ea032e358941f76a` (sync latency = 564ms) 56236: 2025-08-18 16:15:18.050774800 [c::bn::header_sync] DEBUG Determining if chain splits between 0 and 500 headers back from the tip (peer: `a28f3717c4ea032e358941f76a`, 500 hashes sent) 56240: 2025-08-18 16:15:18.616977200 [c::bn::header_sync] DEBUG Setting header validator state (11 timestamp(s), target difficulties: 91 SHA3, 91 Monero RandomX, 91 Tari RandomX) 56241: 2025-08-18 16:15:18.638200800 [c::bn::header_sync] DEBUG Validating header #74724 (Pow: Sha3) with hash: (afadd22a8ebce7a1e7b15299ca9fd78991c928fa848e95bbc8466be9351c61bd) 56245: 2025-08-18 16:15:18.638308700 [c::bn::header_sync] DEBUG Validating header #74725 (Pow: Sha3) with hash: (f617bb757e005e97b1a95c79130953b4d99afc910ad8e2f17a79733065a1308e) 56249: 2025-08-18 16:15:18.638342500 [c::bn::header_sync] DEBUG Validating header #74726 (Pow: RandomXMonero) with hash: (b59e58afee1793410dcb63abc4913f2b40be835e3fa5ac98516a3e107d0bbb32) 56265: 2025-08-18 16:15:18.892509900 [c::bn::header_sync] DEBUG Validating header #74727 (Pow: RandomXTari) with hash: (5c36857d3bb98915dfdca08c6da81257f210d97332d851c0ef8f5782d6dfd946) 56270: 2025-08-18 16:15:19.167914200 [c::bn::header_sync] DEBUG Validating header #74728 (Pow: RandomXMonero) with hash: (7f6b5bba33191ad7ca32e433fcf4493b14d7675800dad299cc3481f6abd78806) 56286: 2025-08-18 16:15:19.209897500 [c::bn::header_sync] DEBUG Validating header #74729 (Pow: RandomXMonero) with hash: (8fdf8f0a2e9a8d52d1aee61ca809f06996f9c401ba1d3fe8d14f7731c2a8ebc6) 56302: 2025-08-18 16:15:19.234191700 [c::bn::header_sync] DEBUG Validating header #74730 (Pow: Sha3) with hash: (152dde156c4602c6d045ecc230c9796f09719881e7645147cf2bead67ff83e40) 56306: 2025-08-18 16:15:19.234254400 [c::bn::header_sync] DEBUG Validating header #74731 (Pow: RandomXTari) with hash: (6bc4a7e5731d8c75ddec988c92c90fe38c12f185c51cd6a81da854e3decb191f) 56311: 2025-08-18 16:15:19.270391000 [c::bn::header_sync] DEBUG Validating header #74732 (Pow: RandomXTari) with hash: (67a2f889a2da367535e743beaaa7f6be5b3c7369ccfc743a8bd8fcba73827c0e) 56316: 2025-08-18 16:15:19.292407400 [c::bn::header_sync] DEBUG Validating header #74733 (Pow: RandomXMonero) with hash: (4f308d9f007de119b842e08fd814bd7425702c7989bc3e264f3d6f332ba5d095) 56332: 2025-08-18 16:15:19.318211600 [c::bn::header_sync] DEBUG Validating header #74734 (Pow: RandomXMonero) with hash: (688a2409624db8eb3146a672385353697791d9247c4ce97abed9db4f9906d099) 56348: 2025-08-18 16:15:19.341298300 [c::bn::header_sync] DEBUG Validating header #74735 (Pow: Sha3) with hash: (cf442745cac3ba823cb77ba3cc8d654544f9bed8ad4ca9392926bbb368a276d3) 56352: 2025-08-18 16:15:19.341368500 [c::bn::header_sync] DEBUG Validating header #74736 (Pow: Sha3) with hash: (cfc41bc4b502954544400fd665b1c1f495bd119def6248024121c9f7d725da82) 56356: 2025-08-18 16:15:19.341416600 [c::bn::header_sync] DEBUG Validating header #74737 (Pow: RandomXMonero) with hash: (405b8974ee1b7bc5bfb61befd62057e3e87f8ae347568790f1a9f1a9457096cf) 56372: 2025-08-18 16:15:19.365490600 [c::bn::header_sync] DEBUG Validating header #74738 (Pow: Sha3) with hash: (8cf710016f39cd0d1b017ca0964858fa785ae45559c948e155ee706163c9652f) 56376: 2025-08-18 16:15:19.365642000 [c::bn::header_sync] DEBUG Validating header #74739 (Pow: RandomXMonero) with hash: (8e0580fadb71acbf54e4605bc1f79ea0d5936c46a6207ca2915b01e4abad95c3) 56392: 2025-08-18 16:15:19.393002800 [c::bn::header_sync] DEBUG Validating header #74740 (Pow: Sha3) with hash: (6584b360deadef2c5c4a1ae45c67f674949a26abbe99aa86540aade37819f171) 56396: 2025-08-18 16:15:19.393080700 [c::bn::header_sync] DEBUG Validating header #74741 (Pow: RandomXTari) with hash: (4569ef099574d438f213288d1feca5cfbed3617c44de9eedd191878e2de7a1da) 56401: 2025-08-18 16:15:19.416662200 [c::bn::header_sync] DEBUG Validating header #74742 (Pow: RandomXMonero) with hash: (9c7c71e5d75c67b3d6737d14de49aab24942e6fc594adf70f97fa212f311abaf) 56417: 2025-08-18 16:15:19.445699800 [c::bn::header_sync] DEBUG Validating header #74743 (Pow: RandomXMonero) with hash: (cc3e937c5e2e888a9774bd9381acbcb84702f7ec8f5e1f09f7c5b39b8ab02a5b) 56433: 2025-08-18 16:15:19.472385200 [c::bn::header_sync] DEBUG Validating header #74744 (Pow: RandomXMonero) with hash: (636f55111d3db4051caeea1b2bdb03ef3cda47a1736e0f79f569d87071490ebd) 56449: 2025-08-18 16:15:19.505503600 [c::bn::header_sync] DEBUG Validating header #74745 (Pow: Sha3) with hash: (b8fe83e8a5c57d48fcc99ebb0f03fbf2d718ce6fdff039443fdaf02265492765) 56453: 2025-08-18 16:15:19.505747700 [c::bn::header_sync] DEBUG Validating header #74746 (Pow: Sha3) with hash: (fd4c0777ec6858787e62b224624bc25323a3e720db01eccf89b04c0457441355) 56457: 2025-08-18 16:15:19.505887000 [c::bn::header_sync] DEBUG Validating header #74747 (Pow: Sha3) with hash: (52e145bc09c13cabfde9a77cff0ff0e1fe4c73db0aac0956cda2b020acd9e60a) 56461: 2025-08-18 16:15:19.506036900 [c::bn::header_sync] DEBUG Validating header #74748 (Pow: RandomXMonero) with hash: (37885ffb001c99c2fd8047227da7e58e769abbf82204e09516663e9e3a95fa80) 56477: 2025-08-18 16:15:19.543057100 [c::bn::header_sync] DEBUG Validating header #74749 (Pow: Sha3) with hash: (31112ded00ad6d9396e3b75866a70283aa8c9f370187a430cd0d64eac09c2d21) 56481: 2025-08-18 16:15:19.543113500 [c::bn::header_sync] DEBUG Peer `a28f3717c4ea032e358941f76a` has submitted 26 valid header(s) 56482: 2025-08-18 16:15:19.543127200 [c::bn::header_sync] INFO Starting header sync from peer Node ID: a28f3717c4ea032e358941f76a, Chain metadata: Best block height: 74747 56488: 2025-08-18 16:15:19.543296200 [c::bn::header_sync] DEBUG Comparing PoW on remote header #74749 and local header #22624 56489: 2025-08-18 16:15:19.543303400 [c::bn::header_sync] DEBUG Remote chain from peer a28f3717c4ea032e358941f76a has higher PoW. Switching 56529: 2025-08-18 16:15:19.547672800 [c::bn::header_sync] DEBUG 26 header(s) committed (tip = 74749) to the blockchain db in 4.35ms 56530: 2025-08-18 16:15:19.547752700 [c::bn::header_sync] INFO Headers synchronized from peer Node ID: a28f3717c4ea032e358941f76a, Chain metadata: Best block height: 74747 56545: 2025-08-18 16:15:19.548208300 [c::bn::block_sync] INFO Attempting to sync blocks(3 sync peers) 56549: 2025-08-18 16:15:20.144386200 [c::bn::block_sync] INFO Attempting to synchronize blocks with `a28f3717c4ea032e358941f76a` latency: 595.74ms 56550: 2025-08-18 16:15:20.144412900 [c::bn::block_sync] INFO Starting block sync from peer a28f3717c4ea032e358941f76a 56551: 2025-08-18 16:15:20.145260300 [c::bn::block_sync] DEBUG Starting block sync from peer `Node ID: a28f3717c4ea032e358941f76a, Chain metadata: Best block height: 74747 56559: 2025-08-18 16:15:22.282894500 [c::bn::block_sync] DEBUG Validating block body #22625 (PoW = RandomXTari, input(s): 292, output(s): 1298, kernel(s): 225, latency: 2.13s) ``` What process can a PR reviewer use to test or verify this change? --- Code review <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * More accurate chain selection and sync decisions; commit headers only when switching to a stronger chain. * Trim non-canonical headers to prevent stale/banked headers. * Stronger validation and ban logic for peers over-claiming work. * Enhanced error reporting during block sync; orphan cleanup on successful sync. * **Refactor** * Streamlined sync control flow and expanded logging. * **Tests** * Added tests to verify header trimming during reorgs. * **Chores** * Updated development dependency and cleaned Cargo configuration/lints. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Closing in favor of #7478 |
Description
Implements: #7470
Change getting seed peers from DNS TXT record to HTTP endpoint. DNS TXT records might be limited by it's size and in a case of larger list of seed peers this might be a problem.
How Has This Been Tested?
Build
minotari_nodeand attempted to connect with other peers.What process can a PR reviewer use to test or verify this change?
Same as above and passing tests.
Breaking Changes