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: verify ceramic-one network matches js-ceramic at startup #3259

Merged
merged 6 commits into from
Jul 26, 2024

Conversation

dav1do
Copy link
Contributor

@dav1do dav1do commented Jul 17, 2024

Description

We now query ceramic-one to make sure we're using the same network. We error if there's a mismatch and log a warning if the endpoint doesn't exist/respond. The default for both binaries is testnet-clay and we start successfully. Local is slightly odd as ceramic one has the concept of network ID, which we don't verify explicitly as it was either started for tests with the flag by us, or js-ceramic expects only local and the ID is specific to ceramic-one, so as long as we're both on local we're aok.

Uses the changes introduced in rust-ceramic #441.

How Has This Been Tested?

Tested locally, examples of mismatch and and old version:

[2024-07-17T18:24:05.578Z] ERROR: Error: Recon: failed to verify network as js-ceramic is using testnet-clay but ceramic-one is on local-0. Pass --network to the js-ceramic or ceramic-one daemon to make them match.
[2024-07-17T18:24:05.578Z] IMPORTANT: Closing Ceramic instance
[2024-07-17T18:24:05.580Z] IMPORTANT: Ceramic instance closed successfully
Ceramic daemon failed to start up:
Error: Recon: failed to verify network as js-ceramic is using testnet-clay but ceramic-one is on local-0. Pass --network to the js-ceramic or ceramic-one daemon to make them match.
    at ReconApi.verifyNetwork (file:///Users/david/3box/js-ceramic/packages/core/lib/recon.js:66:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ReconApi.init (file:///Users/david/3box/js-ceramic/packages/core/lib/recon.js:47:9)
    at async Repository.init (file:///Users/david/3box/js-ceramic/packages/core/lib/state-management/repository.js:100:9)
    at async Ceramic._init (file:///Users/david/3box/js-ceramic/packages/core/lib/ceramic.js:217:13)
    at async CeramicDaemon.create (file:///Users/david/3box/js-ceramic/packages/cli/lib/ceramic-daemon.js:181:9)
    at async CeramicCliUtils.createDaemon (file:///Users/david/3box/js-ceramic/packages/cli/lib/ceramic-cli-utils.js:148:24)
    at async Command.<anonymous> (file:///Users/david/3box/js-ceramic/packages/cli/lib/bin/ceramic.js:30:5)

# when running with an old version of ceramic-one
[2024-07-17T18:27:47.297Z] IMPORTANT: Connecting to ceramic network 'testnet-clay' using ceramic-one with Recon for data synchronization.
[2024-07-17T18:27:47.325Z] WARNING: Recon: failed to verify network with error Error: HTTP request to 'http://127.0.0.1:5101/ceramic/network' failed with status 'Not Found': . This is likely due to an older version of ceramic-one and you should upgrade.
[2024-07-17T18:27:47.331Z] IMPORTANT: Connecting to bootstrap peers for network testnet-clay
[2024-07-17T18:27:47.908Z] IMPORTANT: Connected to anchor service 'https://cas-clay.3boxlabs.com' with supported anchor chains ['eip155:100']
[2024-07-17T18:27:47.910Z] WARNING: No pinned streams detected. This is expected if this is the first time this node has been run, but may indicate a problem with the node's persistence setup if it should have pinned streams
[2024-07-17T18:27:47.917Z] IMPORTANT: Ceramic API running on 0.0.0.0:7007'

PR checklist

Before submitting this PR, please make sure:

  • I have tagged the relevant reviewers and interested parties
  • I have updated the READMEs of affected packages
  • I have made corresponding changes to the documentation

References:

Please list relevant documentation (e.g. tech specs, articles, related work etc.) relevant to this change, and note if the documentation has been updated.

Copy link

linear bot commented Jul 17, 2024

@dav1do dav1do force-pushed the feat/aes-209-verify-c1-network branch 2 times, most recently from 5eb636f to 28ace50 Compare July 18, 2024 19:57
Copy link
Contributor

@stbrody stbrody left a comment

Choose a reason for hiding this comment

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

lgtm

we only fail to start if c1 returns a response and we don't match. if it is an error like a 404, we log a warning and proceed assuming it's a version mismatch
not sure why there are whitespace issues, but so it goes
in my local testing I never hit this path but CI does somehow
@dav1do dav1do force-pushed the feat/aes-209-verify-c1-network branch from 28ace50 to ed87709 Compare July 25, 2024 23:04
@dav1do
Copy link
Contributor Author

dav1do commented Jul 25, 2024

lgtm

rebased and updated to use /ceramic/config/network based on changes in rust-ceramic PR.

@dav1do dav1do merged commit 1b1dc49 into develop Jul 26, 2024
7 checks passed
@dav1do dav1do deleted the feat/aes-209-verify-c1-network branch July 26, 2024 16:06
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