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: fetch pox constants from stacks-core /v2/pox and store in pg #7

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

zone117x
Copy link
Member

We need to be able to calculate pox reward cycle numbers in various areas which cannot be done reliably without knowing the pox constants first_burnchain_block_height and reward_cycle_length. These could be hardcoded for mainnet, but for other networks the only way to determine them is from a stacks-core RPC fetch to /v2/pox. Ideally these would be emitted from stacks-core in the future.

In order to avoid race conditions where the stacks-node RPC may not be available when this service starts, this is implemented as a background job that retries indefinitely.

}
await db.updatePoxInfo(rpcPoxInfo);
isDbMissingPoxInfo = false;
await sleep(POX_INFO_UPDATE_INTERVAL_MS, abortSignal);
Copy link
Member Author

Choose a reason for hiding this comment

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

This could return and end the background /v2/pox fetches, but I don't think it hurts and it can provide some possibly useful debugging data (we can see RPC connection error logs if something weird is happening later on).

Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt a chain can change phase lengths during operation, so probably not needed, but I don't see the problem with keeping it for logs/interest 😉

Copy link
Contributor

@janniks janniks left a comment

Choose a reason for hiding this comment

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

Copy link

Vercel deployment URL: https://signer-metrics-7mvgl0u8z-hirosystems.vercel.app 🚀

@zone117x zone117x merged commit f46536e into main Oct 25, 2024
2 checks passed
@zone117x zone117x deleted the feat/fetch-rpc-pox-info branch October 25, 2024 19:58
@blockstack-devops
Copy link

🎉 This PR is included in version 0.1.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@blockstack-devops
Copy link

🎉 This PR is included in version 0.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants