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

adjust scripts for API v5's BNS import #90

Closed
rafaelcr opened this issue Sep 2, 2022 · 9 comments
Closed

adjust scripts for API v5's BNS import #90

rafaelcr opened this issue Sep 2, 2022 · 9 comments
Labels

Comments

@rafaelcr
Copy link

rafaelcr commented Sep 2, 2022

We're in the process of releasing Hiro API v5 which fixes a bunch of bugs related to BNS data.

One of those changes is that now we import BNS data (if available) before event replay, because the API needs to know which namespaces exist so it can calculate names' expiration block heights if it sees a name registered, updated or transferred in a tx during replay. Launching the API no longer imports BNS data as it did before.

This import is handled automatically i.e. there's no need for users to run a command other than import-events, however, this repo might need some adjusting (maybe just on docs) so it can consider the availability of BNS data before performing a replay.

@wileyj
Copy link
Collaborator

wileyj commented Sep 2, 2022

if i understand this correctly - the API env var BNS_IMPORT_DIR has no impact for v5 when launching the API?
and BNS_IMPORT_DIR has an effect when importing events?

maybe i'm a bit confused since your comment says we import BNS data (if available) before event replay, but then Launching the API no longer imports BNS data as it did before

are there docs you can share on how this is changing in the API rep?

@rafaelcr
Copy link
Author

rafaelcr commented Sep 6, 2022

if i understand this correctly - the API env var BNS_IMPORT_DIR has no impact for v5 when launching the API?
and BNS_IMPORT_DIR has an effect when importing events?

That is correct. The event replay process will now be the one to look at BNS_IMPORT_DIR and do the import.

are there docs you can share on how this is changing in the API rep?

I modified a part of the README here: https://github.com/hirosystems/stacks-blockchain-api/blob/ed8b6f5839c0c28339bb123e0411902ec78a0209/readme.md#event-replay-instructions

@wileyj
Copy link
Collaborator

wileyj commented Sep 6, 2022

I think i understand - functionally, i don't see any changes to this repo outside of docs.
the bns option just runs a script to download/extract the legacy bns data - the API is in control of how/when that data is imported.

It's not clear to me from the link though - if you download/extract the data, and define the BNS_IMPORT_DIR env var, starting the API normally will not import the bns data, correct? a user would need to first run an import, despite not having an event-replay file?

@rafaelcr
Copy link
Author

rafaelcr commented Sep 17, 2022

if you download/extract the data, and define the BNS_IMPORT_DIR env var, starting the API normally will not import the bns data, correct? a user would need to first run an import, despite not having an event-replay file?

That is correct. That is a good question, though, because IIRC the import will fail if you don't have a replay file even though you do have the BNS data.

@wileyj
Copy link
Collaborator

wileyj commented Sep 19, 2022

well, good thing i plan on testing this to see what happens!
I noticed the API docs are updated a bit too, i'll take a closer look there and see what adjustments need to be made

@wileyj
Copy link
Collaborator

wileyj commented Sep 20, 2022

if you download/extract the data, and define the BNS_IMPORT_DIR env var, starting the API normally will not import the bns data, correct? a user would need to first run an import, despite not having an event-replay file?

That is correct. That is a good question, though, because IIRC the import will fail if you don't have a replay file even though you do have the BNS data.

One issue i've found is if you're trying to run the import before having the tsv file...the process fails and the BNS data isn't imported. syncing for a few blocks, then re-running the import works as expected (with BNS data being imported).

I'm wondering if there can/should be a check in the API code if the tsv doesn't exist, but BNS_IMPORT_DIR is defined...import the bns data only and exit vs trying to import events.

@wileyj
Copy link
Collaborator

wileyj commented Sep 21, 2022

@rafaelcr

attaching a test i ran, where i built the API from master - downloaded the BNS data and defined the variable, with an empty postgres DB.
running the import fails as expected with a tsv file not found error (since the replay file doesn't exist yet).
touch file.tsv and then running the import (the goal being to only import BNS data) - still fails though.

 ➭ node ./lib/index.js import-events \
    --file file.tsv --wipe-db --force
{"level":"info","message":"Shutting down... received beforeExit.","timestamp":"2022-09-21T15:47:20.536Z"}
{"level":"info","message":"App shutdown successful.","timestamp":"2022-09-21T15:47:20.538Z"}

wileyj added a commit that referenced this issue Sep 26, 2022
minor updates to remove warnings
@stale
Copy link

stale bot commented Mar 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 25, 2023
@stale
Copy link

stale bot commented Apr 2, 2023

This issue has been automatically closed. Please reopen if needed.

@stale stale bot closed this as completed Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants