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

Store pre-signatures using Redis #869

Draft
wants to merge 36 commits into
base: develop
Choose a base branch
from

Conversation

volovyks
Copy link
Collaborator

@volovyks volovyks commented Oct 2, 2024

This is the setup of Docker in the same container. Some people consider it a bad practice, but it may be a simpler solution for node validators. I have no strong opinion here.

It is expected to be executed with

docker run -d \
  --name my-redis-rust-app \
  -v /path/on/host/redis-data:/var/lib/redis \
  -p 6379:6379 \
  -p 8080:8080 \
  my-redis-rust-app

It will persist the apend file on the VM.

cc @kmaus-near @ppca

@volovyks volovyks changed the title basic redis setup in the same container basic redis setup Oct 2, 2024
@ppca
Copy link
Contributor

ppca commented Oct 2, 2024

@kmaus-near How does your draft redis setup work? Is it different or similar to this?

@kmaus-near
Copy link
Collaborator

@kmaus-near How does your draft redis setup work? Is it different or similar to this?

My homelab setup uses a dedicated VM running a Redis container vs. baking it into the multichain image, but other than that similar configuration. @volovyks and myself discussed this a bit yesterday, it's not exactly the "best practice" but if we are trying to simplify this for our partners, this may be a better route. Plus if we are to run it locally, we are then going to be running 3 containers on a single VM if we do not bake it into the image itself, which is not ideal resource wise or best practice wise. In short, both are not ideal, but for different reasons 😂.

I would suggest that we try to keep the code interacting with Redis as decoupled as possible, so if in the future we need to separate Redis from the base image, we can do so easily.

@volovyks
Copy link
Collaborator Author

volovyks commented Oct 4, 2024

@kmaus-near all we need in code is the Redis URL, so it is not coupled. If we change how we manage Redis storage, most of the complexity will be on the Terraform side.

Dockerfile.multichain Outdated Show resolved Hide resolved
@volovyks volovyks changed the title basic redis setup Stora pre-signatures using Redis Oct 14, 2024
@volovyks volovyks changed the title Stora pre-signatures using Redis Store pre-signatures using Redis Oct 14, 2024
@volovyks volovyks linked an issue Oct 16, 2024 that may be closed by this pull request
@volovyks volovyks requested a review from ppca October 16, 2024 17:42
Copy link
Contributor

@ppca ppca left a comment

Choose a reason for hiding this comment

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

presignature storage logic mostly look good to me.

.github/workflows/multichain-integration.yml Outdated Show resolved Hide resolved
# Expose Redis port (6379) and mpc node's port
EXPOSE 6379 8080
Copy link
Member

Choose a reason for hiding this comment

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

hmm, how come we didn't need to expose the node's port before

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also wondering why 8080 is now exposed. Port is set at 3000 for the mpc-node service by terraform. we will need to expose 6379 though for redis.

@@ -309,7 +309,7 @@ impl MessageHandler for RunningState {
}

let protocol = match presignature_manager
.get_or_generate(
.get_or_start_protocol(
Copy link
Member

Choose a reason for hiding this comment

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

hmm, generate is basically start protocol though. I would rather we keep it as what we had before, because we also have the generate function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to get_or_start_generation.
When you call presignature_manager.get_or_generate you are expecting a presignature, not a protocol.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, that's not right either though. get_or_generate never returned us the presignature, it always returned us the protocol

chain-signatures/node/src/protocol/presignature.rs Outdated Show resolved Hide resolved
chain-signatures/node/src/protocol/presignature.rs Outdated Show resolved Hide resolved
chain-signatures/node/src/protocol/presignature.rs Outdated Show resolved Hide resolved
chain-signatures/node/src/storage/presignature_storage.rs Outdated Show resolved Hide resolved
integration-tests/chain-signatures/src/lib.rs Outdated Show resolved Hide resolved
RUN apt-get update && apt-get install --assume-yes libssl-dev ca-certificates curl redis-server

RUN update-ca-certificates \
chown redis:redis /data
Copy link
Collaborator

Choose a reason for hiding this comment

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

I needed this /data directory to be owned by redis, so it can store data.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I needed to add the rest of the config. I have changed the AOF parameters as well as using the /data directory inside the container for persistence.

{
name = "host-path"
hostPath = {
path = "/var/redis"
Copy link
Collaborator

Choose a reason for hiding this comment

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

had to change this from /etc to /var. In container optimized OS, /etc is a stateless directory and ships with a default configuration. /var is persistent and gets mounted to /mnt/stateful-partition

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.

Persist pre-signatures
5 participants