Skip to content

Commit

Permalink
Store Pre-signatures and Triples using Redis, refactor managers (#869)
Browse files Browse the repository at this point in the history
* basic redis setup in the same container

* formatting

* basic presignature-storage using redis

* presignature storage wrapped in arc and ewlock

* presignature storage redis functions implemented

* redis presignature storage used in presignature manager

* serialization for presignature

* warnings fixed

* presignature bad parameters error check

* min refactoring

* added redis config file path to dockerfile, added tf to mount /data volume

* it fix

* rust 2024 requirements

* start redis in it

* pull redis in it

* lock file update

* redis unit test

* comments 1

* comments 2

* triple manager functions renamed to match presiganture manager

* serialization simlified

* comments 3

* added start command to mpc-node and added redis URL format

* use account id as a part of redis storage key

* added full redis config, modified dockerfile to use it

* unnecessary port expose removed

* remove local redis config

* redis config update

* redis file ownership change

* fix persistent data issue

* fix redis unit test

* extend redis lifecycle

* clippy

* datastore triple storage removed

* refactor triple storage

* use redis to store triples

* fix rust typing issue

* 2 triple pre-check added

* add link to redis in setup-env

* use redis connection pool

* fmt

* change info to debug in storage layer

* rename count to lem

* develop

* Fix locks being acquired incorrectly (#914)

* chore: removed Arc and RwLock for triple/presignature storage (#915)

* Removed Arc and RwLock for triple/presignature storage

* fix conflicts

* changing dev workflow file to target Sig.Network AR

---------

Co-authored-by: kmaus-near <kody.maus.bluepisces@near.org>
Co-authored-by: Phuong Nguyen <ChaoticTempest@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 922642c commit ce420d3
Show file tree
Hide file tree
Showing 31 changed files with 2,581 additions and 1,221 deletions.
31 changes: 5 additions & 26 deletions .github/workflows/multichain-deploy-dev-nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- chain-signatures/**

env:
IMAGE: "us-east1-docker.pkg.dev/pagoda-discovery-platform-dev/multichain-public/multichain-dev"
IMAGE: "europe-west1-docker.pkg.dev/near-cs-dev/multichain-public/multichain-dev"
TAG: ${{ github.sha }}

jobs:
Expand All @@ -21,11 +21,12 @@ jobs:
name: "Checkout mpc-recovery"

- name: Login to GCP Artifact Registry
run: echo "$GOOGLE_CREDENTIALS" | docker login -u _json_key --password-stdin https://us-east1-docker.pkg.dev
run: echo "$GOOGLE_CREDENTIALS" | docker login -u _json_key --password-stdin https://europe-west1-docker.pkg.dev
env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS_DEV }}
GOOGLE_CREDENTIALS: ${{ secrets.SIG_CREDENTIALS_DEV }}

- name: Build Docker image and push to Google Artifact Registry
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
id: docker-push-tagged
uses: docker/build-push-action@v4
with:
Expand All @@ -41,26 +42,4 @@ jobs:
- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS_DEV }}'

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: 'Set project'
run: 'gcloud config set project pagoda-discovery-platform-dev'

# This is not pretty, but this step needs to be updated every time a new node is added.
- name: 'Update Nodes'
run: |
gcloud compute instances update-container multichain-dev-0 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-1 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-2 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-3 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-4 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-5 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-6 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-7 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-8 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-9 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-10 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
gcloud compute instances update-container multichain-dev-11 --zone us-central1-a --container-image=${{ env.IMAGE }}:${{ env.TAG }} & \
credentials_json: '${{ secrets.SIG_CREDENTIALS_DEV }}'
4 changes: 2 additions & 2 deletions .github/workflows/multichain-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull Relayer & Sandbox Docker Images
- name: Pull Relayer, Sandbox, Redis Docker Images
run: |
docker pull ghcr.io/near/os-relayer:12ba6e35690df3979fce0b36a41d0ca0db9c0ab4
docker pull ghcr.io/near/near-lake-indexer:node-2.3.0
docker pull localstack/localstack:3.5.0
docker pull redis:7.0.15
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile.multichain
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ RUN sed -i 's#target-dir = "../target"#target-dir = "target"#' .cargo/config.tom
RUN cargo build --release --package mpc-node

FROM debian:stable-slim as runtime
RUN apt-get update && apt-get install --assume-yes libssl-dev ca-certificates curl
RUN apt-get update && apt-get install --assume-yes libssl-dev ca-certificates curl redis-server

RUN update-ca-certificates

COPY --from=builder /usr/src/app/target/release/mpc-node /usr/local/bin/mpc-node
COPY chain-signatures/node/redis.conf /etc/redis/redis.conf

# Create a script to start both Redis and the Rust app
RUN echo "#!/bin/bash\nchown redis:redis /data\nservice redis-server start &\nexec mpc-node start" > /start.sh \
&& chmod +x /start.sh

WORKDIR /usr/local/bin

ENTRYPOINT [ "mpc-node" ]
# Start Redis and the Rust application
ENTRYPOINT [ "/start.sh" ]
93 changes: 92 additions & 1 deletion chain-signatures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions chain-signatures/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ itertools = "0.12.0"
http = "1.1.0"
prometheus = { version = "0.13.3" }
once_cell = "1.13.1"
redis = "0.27.2"
deadpool-redis = "0.18.0"
sysinfo = "0.32.0"
Loading

0 comments on commit ce420d3

Please sign in to comment.