Skip to content

fix: discovery dns#410

Merged
rebelArtists merged 3 commits intodan/sensor_dnsfrom
minhd-vu/sensor-dns
Oct 24, 2024
Merged

fix: discovery dns#410
rebelArtists merged 3 commits intodan/sensor_dnsfrom
minhd-vu/sensor-dns

Conversation

@minhd-vu
Copy link
Copy Markdown
Contributor

Description

  • Made some revisions to discovery dns implementation
  • Fix force add peer

Jira / Linear Tickets

Testing

  • 👀
go run main.go p2p sensor nodes.json \
  --network-id 137 \
  --sensor-id mvu \
  --write-blocks=false \
  --write-block-events=false \
  --write-txs=false \
  --write-tx-events=false \
  --rpc "https://polygon-rpc.com" \
  --discovery-dns "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@pos.polygon-peers.io" \
  --verbosity 700 --quick-start --key "d8168fb642add845920b91291ec8bbf7c4d5dd2aeaed330fb9e75d766b957f53"
  • Deployed

Comment thread cmd/p2p/sensor/sensor.go
}

// Instruct server to connect to the new peer
server.AddTrustedPeer(node)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this was the problem, I think AddTrustedPeer has to wait a little for the next "peering" cycle, where as AddPeer will add the peer immediately.

Comment thread cmd/p2p/sensor/sensor.go
// Add DNS-discovered peers
for _, node := range tree.Nodes() {
if _, ok := peers[node.ID()]; !ok {
peers[node.ID()] = node.URLv4()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We acutally don't need to add the peer here, since a message to the peers channel will be emitted whenever we actually connect to the peer.

Comment thread cmd/p2p/sensor/sensor.go
log.Debug().Msgf("Discovered new peer: %s", node.URLv4())

// Write peers to nodes file
if err := p2p.WritePeers(inputSensorParams.NodesFile, peers); err != nil {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't need to write the peers here. The other ticker will handle this.

Comment thread cmd/p2p/sensor/sensor.go
}

log.Info().
Str("discover-dns", inputSensorParams.DiscoveryDNS).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit spelling: discovery-dns

@rebelArtists rebelArtists merged commit a1238e1 into dan/sensor_dns Oct 24, 2024
@rebelArtists rebelArtists deleted the minhd-vu/sensor-dns branch October 24, 2024 07:13
minhd-vu added a commit that referenced this pull request Oct 24, 2024
* add dns discovery to sensor logic

* touch ups

* fix: discovery dns (#410)

* fix discovery dns

* update gen-doc

* fix error

* fix typo

---------

Co-authored-by: Minh Vu <minhd_vu@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants