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: Support Deployment of Block Streamer #516

Merged
merged 7 commits into from
Jan 25, 2024
Merged

Conversation

darunrs
Copy link
Collaborator

@darunrs darunrs commented Jan 18, 2024

Block Streamer needs a Dockerfile in order to build the image and be deployable either locally or in GCP. I've created one for the service and updated the compose file to set the correct env variables needed. This also sserves as a record for what ENV variables need to be set during Terraform deployments to GCP.

In addition, there's a small issue with running QueryApi locally where if the user runs Runner locally through yarn start, provisioning of resources through hasura fails because it populates the postgres host as 'localhost' whereas it should be 'postgres', as the calls are processed inside the hasura docker. This is due to PGHOST being both used and also passed to Hasura inside Runner. To fix this, I created a separate env variable called PGHOST_HASURA which can be set to 'postgres'. This way, Runner can use 'localhost' while it passes 'postgres' to hasura's docker.

@darunrs darunrs marked this pull request as ready for review January 22, 2024 19:04
@darunrs darunrs requested a review from a team as a code owner January 22, 2024 19:04
@darunrs
Copy link
Collaborator Author

darunrs commented Jan 22, 2024

The testing I did locally was relatively simple:

  1. I built the images using docker compose.
  2. I ran the resources, Coordinator V1, and block streamer image locally in Docker.
  3. I ran Runner V2 and Coordinator V2 locally through CLI.
  4. I hard coded Coordinator V2 to only init one indexer.
  5. Verified Block Stream and Executor were initialized, that blocks were in stream, and that Runner was running them alongside V1 executors.

There's probably some edge case testing needed as well. Open to ideas on what things I should try.

Something I noticed though is that I was getting a lot of S3 errors locally when running all current dev indexers in V2. Might be a problem with running locally and not in GCP, but its something to consider. Caching might help if the indexers are reasonably close in terms of what blocks they're querying.

@darunrs darunrs linked an issue Jan 22, 2024 that may be closed by this pull request
@darunrs
Copy link
Collaborator Author

darunrs commented Jan 22, 2024

Current plan for deployment:

  1. Get approval for code PR (This one)
  2. Publish PR for NearOps Infra.
  3. Merge this PR.
  4. Deploy dev infra and verify.
  5. Get approval for NearOps and merge it.

block-streamer/src/main.rs Outdated Show resolved Hide resolved
block-streamer/src/server/mod.rs Outdated Show resolved Hide resolved
block-streamer/Dockerfile Outdated Show resolved Hide resolved

FROM ubuntu:22.04
ARG CARGO_BUILD_MODE=debug
ENV RUST_LOG=info
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this still be overridden from the outside?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So that's a good point. I can look into that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can be overridden using docker compose file's ENV. I'm not sure about GCP deployment. But for GCP it oughta be release anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm referring to RUST_LOG here - let's remove, as it should be set in the terraform config anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh sorry you mean that. I had to put that in because leaving it out prevents tracing logs from appearing inside Docker. Now of course we can set that in docker compose and terraform too if we want. But I felt like it made sense to leave it here as we probably wouldn't override it unless we really wanted to, in which case we totally can by placing it there. Removing it means we need to specify it in deployment explicitly without any default.

Essentially, removing it here means we don't have a default setting. It's probably a minor change but if we want to be explicit about all env variables, doing so in the same place, I'm totally fine going with that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah i'd prefer to keep it in one place to avoid confusion

Copy link
Collaborator

@morgsmccauley morgsmccauley left a comment

Choose a reason for hiding this comment

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

LGTM just the RUST_LOG and 0.0.0.0 change to make :)

@darunrs
Copy link
Collaborator Author

darunrs commented Jan 24, 2024

Block Streamer currently uses [::] which is dual stack 0.0.0.0, meaning it works for both IPv4 and IPv6 addresses. I changed Runner's server to [::] and that seems to have worked as well.

@morgsmccauley
Copy link
Collaborator

morgsmccauley commented Jan 24, 2024

Block Streamer currently uses [::] which is dual stack 0.0.0.0, meaning it works for both IPv4 and IPv6 addresses. I changed Runner's server to [::] and that seems to have worked as well.

@darunrs I may be wrong, but it seems [::] and 0.0.0.0 are for ipv6 and ipv4 respectively, not the same. If they are, it might be worth checking if specifying ipv6 will conflict with the firewall config, which is set to 0.0.0.0. With this config, I wonder if GCP will only expose ipv4 traffic, and not ipv6.

@darunrs
Copy link
Collaborator Author

darunrs commented Jan 24, 2024

Block Streamer currently uses [::] which is dual stack 0.0.0.0, meaning it works for both IPv4 and IPv6 addresses. I changed Runner's server to [::] and that seems to have worked as well.

@darunrs I may be wrong, but it seems [::] and 0.0.0.0 are for ipv6 and ipv4 respectively, not the same. If they are, it might be worth checking if specifying ipv6 will conflict with the firewall config, which is set to 0.0.0.0. With this config, I wonder if GCP will only expose ipv4 traffic, and not ipv6.

Good catch. Our VPC Network currently only supports IPv4. We don't really have a reason to change that. I wasn't able to find anything after a short search that definitively said [::] works dual stack in conjunction with Dual Stack GCP networks. I'll update the addresses to expose on 0.0.0.0 explicitly instead!

@darunrs darunrs merged commit a431a77 into main Jan 25, 2024
7 checks passed
@darunrs darunrs deleted the blockStreamerDeployment branch January 25, 2024 00:17
@darunrs darunrs mentioned this pull request Feb 1, 2024
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.

Setup infra for Block Streamer
2 participants