Skip to content
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(nodebuilder/header): Bootstrap from previously seen peers #2507

Merged
merged 5 commits into from
Sep 5, 2023

Conversation

renaynay
Copy link
Member

@renaynay renaynay commented Jul 21, 2023

Provides PIDStore to header module so that it can be used in peerTracker and replaces mem peerstore.Peerstore with on-disk peerstore.Peerstore so that peerTracker can quickly bootstrap itself with previously-seen peers and allow syncer to initialise its sync target from tracked peers rather than trusted so long as it has a subjective head within the trusting period.

Overrides #2133

Closes #1851, mitigates issues resulting from #1623

Swamp integration tests to follow (tracked in #2506)

Future note:

This PR introduces a soon-to-be deprecated feature from libp2p (on-disk peerstore). Once libp2p deprecates and removes this feature, the PIDStore will have to become a PeerAddrStore such that it can save addr info of good peers to disk instead of just their IDs.

@renaynay renaynay added area:p2p kind:feat Attached to feature PRs labels Jul 21, 2023
@renaynay renaynay self-assigned this Jul 21, 2023
@renaynay
Copy link
Member Author

renaynay commented Aug 1, 2023

This is what it looks like to bootstrap from previously-seen peers:

2023-08-01T11:22:06.626+0200	INFO	module/header	header/config.go:58	No trusted peers in config, initializing with default bootstrappers as trusted peers
2023-08-01T11:22:06.630+0200	INFO	header/p2p	p2p/exchange.go:81	client: starting client	{"protocol ID": "/mocha-3/header-ex/v0.0.3"}
2023-08-01T11:22:06.789+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWDRSJMbH3PS4dRDa11H7Tk615aqTUgkeEKz4pwd4sS6fN"}
2023-08-01T11:22:06.789+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWEk7cxtjQCC7kC84Uhs2j6dAHjdbwYnPcvUAqmj6Zsry2"}
2023-08-01T11:22:06.929+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWBE4QcFXZzENf2VRo6Y5LBvp9gzmpYRHKCvgGzEYj7Hdn"}
2023-08-01T11:22:06.929+0200	INFO	pidstore	pidstore/pidstore.go:58	Loaded peers from disk	{"amount": 101}
2023-08-01T11:22:06.929+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWGQZ5Joykf6YSGXLMVVBtvwrivQydZHgVRsE9PhuHkNuZ"}
2023-08-01T11:22:06.929+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWK6G3P6NhjX2tB37ee3cLXdK31WYNzYgprUS3Qap11idS"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWSDFuWjDUUKFv69BUDXVDtuAZoYeR8ssC4rvfgWt4PdD3"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWSsfZRdQ7EmafNVEe9EN21faZTDyEZ9Rf9GdKQ5WwUuxr"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWLLZTVJ4mMKogSrkhiNs7K2WjVLQYbkF179UeobGh93CN"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWKUn9rkTKmT2DwhpzgGJyMPMWxx1HARxmmGAimzv4Ze1a"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWBE4QcFXZzENf2VRo6Y5LBvp9gzmpYRHKCvgGzEYj7Hdn"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWEk7cxtjQCC7kC84Uhs2j6dAHjdbwYnPcvUAqmj6Zsry2"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWCkp47ByvXHvsX9hm8UTyjzdyUxevVafdLYYbtc1mfVew"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWDRSJMbH3PS4dRDa11H7Tk615aqTUgkeEKz4pwd4sS6fN"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWL8xcw8ouxBhBsZbavG6DDjsy3msF15sL5ZvJ1GgaXpJk"}
2023-08-01T11:22:06.930+0200	INFO	fraudserv	fraudserv/helpers.go:29	joining topic	{"id": "/mocha-3/fraud-sub/badencoding/v0.0.1"}
2023-08-01T11:22:06.930+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWB8Y9og4qzSp3pbdVX2Sp1mvfj38K2rLnnqYYxBmqw4Mq"}
2023-08-01T11:22:06.930+0200	INFO	fraudserv	fraudserv/service.go:100	starting fraud proof service	{"protocol ID": "/mocha-3/fraud/v0.0.1"}
2023-08-01T11:22:06.932+0200	INFO	header/store	store/store.go:176	loaded head	{"height": 186625, "hash": "364F901CA809724712718032D5D307A1D02800F9485A60CE2151D2B35A0F7748"}
2023-08-01T11:22:06.932+0200	INFO	header/p2p	p2p/subscriber.go:40	joining topic	{"topic ID": "/mocha-3/header-sub/v0.0.1"}
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:106	requesting head
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:143	requesting head from tracked peers	{"amount": 4}
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:316	requesting peer	{"peer": "12D3KooWLLZTVJ4mMKogSrkhiNs7K2WjVLQYbkF179UeobGh93CN"}
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:316	requesting peer	{"peer": "12D3KooWDRSJMbH3PS4dRDa11H7Tk615aqTUgkeEKz4pwd4sS6fN"}
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:316	requesting peer	{"peer": "12D3KooWSsfZRdQ7EmafNVEe9EN21faZTDyEZ9Rf9GdKQ5WwUuxr"}
2023-08-01T11:22:06.937+0200	DEBUG	header/p2p	p2p/exchange.go:316	requesting peer	{"peer": "12D3KooWKUn9rkTKmT2DwhpzgGJyMPMWxx1HARxmmGAimzv4Ze1a"}
2023-08-01T11:22:06.971+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWBdbFpqxNFYiHwNDkNZf9pc5BD6gn57v7Qgtxn9RYg7hb"}
2023-08-01T11:22:06.992+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWLb1YvH9VMP91yyUcotATY1E5T4t2bbwA4pcXKVbijLAx"}
2023-08-01T11:22:06.994+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWMLvJpeBWS6tkZsFVBUJ58VuwLy6f78AsVXrzaq1mR6i9"}
2023-08-01T11:22:07.003+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWMwq4dmSZFcBbTzTat6xdcogxenqQ4ejvVwRXLd4L1JWk"}
2023-08-01T11:22:07.004+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWAds1S1MXFLqMo4PqcmSNRbL2RueKhsaXAPEBcTHnmH6Y"}
2023-08-01T11:22:07.004+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWJDQMmcpqq47E4bz76goCzBjVsHCHfcCPfqpXhpRy62ks"}
2023-08-01T11:22:07.004+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWAXrNrs83aJ6HrUE1n8xPRAebC2pJ1dY9KGcVyA5UkvxM"}
2023-08-01T11:22:07.019+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWG9PPLDdRNEwMXRzqstq1URvKbtDBEKHr9mCPnVjkPqtf"}
2023-08-01T11:22:07.019+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWPUhscayL76uwUbjZibasyGHReGvDKXWyXy3ibmuMSW9W"}
2023-08-01T11:22:07.041+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWHmGjbhctWFqpJUWxiwJz2ujXNeE8EEs11dGpbEHVTujc"}
2023-08-01T11:22:07.069+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWJvvACo1drUpckDsnqwLRbU8VufrVRinHUj58VQNA3qPE"}
2023-08-01T11:22:07.076+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWPuVHz6M484B7MuUnQNCN5LeAa5SE2nZcyTPnHkW7XFFK"}
2023-08-01T11:22:07.117+0200	INFO	canonical-log	swarm/swarm_dial.go:493	CANONICAL_PEER_STATUS: peer=12D3KooWJZ1P3tdXYQjPYzsVg6KmTdrPqYRaQpeSdHo3PMiGSyqJ addr=/ip4/89.117.57.27/udp/2121/quic-v1 sample_rate=100 connection_status="established" dir="outbound"
2023-08-01T11:22:07.135+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWRx8TH4Z7wLMc8p6utpyBdxM9eNMsR3puw3VyxEprrCDA"}
2023-08-01T11:22:07.163+0200	DEBUG	header/p2p	p2p/peer_tracker.go:107	connected to peer	{"id": "12D3KooWN3mT9oKMkFKs3XCJTuwmjnUVdcLAXnFUSFDTqzXBrKgp"}
2023-08-01T11:22:07.173+0200	INFO	header/sync	sync/sync_head.go:133	new network head	{"height": 186972, "hash": "D726229089A93E7472C428AE76D689F9C4C5AB746830297C6BA3E4BE8A882937"}

@renaynay
Copy link
Member Author

Blocked on release from go-header

@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2023

Codecov Report

Merging #2507 (4520590) into main (96388ea) will increase coverage by 0.02%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##             main    #2507      +/-   ##
==========================================
+ Coverage   51.00%   51.02%   +0.02%     
==========================================
  Files         158      158              
  Lines       10644    10657      +13     
==========================================
+ Hits         5429     5438       +9     
- Misses       4738     4740       +2     
- Partials      477      479       +2     
Files Changed Coverage Δ
libs/pidstore/pidstore.go 62.50% <75.00%> (+2.50%) ⬆️
nodebuilder/header/constructors.go 58.00% <100.00%> (+0.85%) ⬆️
nodebuilder/header/module.go 48.52% <100.00%> (+1.55%) ⬆️
nodebuilder/p2p/misc.go 65.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help me

The help brigade is OOO

libs/pidstore/pidstore.go Show resolved Hide resolved
nodebuilder/header/constructors.go Outdated Show resolved Hide resolved
nodebuilder/header/constructors.go Outdated Show resolved Hide resolved
@renaynay renaynay merged commit c146a0a into celestiaorg:main Sep 5, 2023
12 of 14 checks passed
@renaynay renaynay deleted the bootstrap-prev-seen branch September 5, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:p2p kind:feat Attached to feature PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Persist peers to disk such that nodes can bootstrap from previously seen peers
4 participants