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: at startup, check to make sure provider seed phrase matches configured provider ID #444

Merged

Conversation

JoeCap08055
Copy link
Contributor

@JoeCap08055 JoeCap08055 commented Aug 26, 2024

  • Adds logic to startup in account, content-publishing, content-watcher to query the chain for the MSA ID associated with the public key derived from the configured seed phrase; throw an error if it does not match the configured Provider ID
  • Syncs initialization code for BlockchainService in graph-service with the rest of the services' implementations (missed in previous PR)

Closes #419


public async validateProviderSeedPhrase() {
const { providerPublicKeyAddress, providerId } = this.configService;
const resolvedProviderId = await this.publicKeyToMsaId(providerPublicKeyAddress || '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this not error out with the '' version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point--not sure what the chain state query does if you pass an empty string for the public key. Reworked to skip querying the chain entirely if there's no public key (ie, no seed phrase configured).

This behavior is intended for the upcoming "read-only" mode. Note that currently you MUST configure a seed phrase because it's required in the environment config; once that requirement is relaxed, this behavior will take effect.

Copy link
Contributor

@wilwade wilwade left a comment

Choose a reason for hiding this comment

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

One question and a test would be nice, but it is a small piece of code that is quite clear.

Copy link
Contributor

@mattheworris mattheworris left a comment

Choose a reason for hiding this comment

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

🚢 it!

Copy link
Contributor

@wilwade wilwade left a comment

Choose a reason for hiding this comment

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

Nice improvements

@JoeCap08055 JoeCap08055 merged commit c3f8c86 into main Aug 27, 2024
11 checks passed
@JoeCap08055 JoeCap08055 deleted the 419-services-should-validate-provider-seed-phrase-at-startup branch August 27, 2024 15:11
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.

Services should validate provider seed phrase at startup
3 participants