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: kyvejs runtime containerization and enhancements #80

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e835e2f
feat: implement tendermint gRPC PoC
kchrist-rocketfueldev Aug 11, 2023
cc4e675
chore: rework Docker interface
troykessler Sep 12, 2023
acf4289
feat: implement tendermint migration to grpc architecture
kchrist-rocketfueldev Sep 18, 2023
0b254d0
refactor: cleanup early implementation refactoring and second interface
kchrist-rocketfueldev Sep 26, 2023
aea2f4e
chore: redefine project file structure
troykessler Sep 28, 2023
23fcc86
chore: transpile docker integration runtime to TS
kchrist-rocketfueldev Oct 2, 2023
fe47a30
refactor: enhance runtime.ts and protobufs
kchrist-rocketfueldev Oct 10, 2023
50dbe17
fix: remove dependency on importing 'runtime.proto'
harrytou Oct 10, 2023
fab9fd9
refactor: Refactor proxies/docker to initialise client with stubs
kchrist-rocketfueldev Oct 12, 2023
5b0cd30
chore: add linter to 'docker-integrations/tendermint'
harrytou Oct 12, 2023
3ae3da1
refactor: move proxies/docker to common/docker
kchrist-rocketfueldev Oct 13, 2023
e5426be
fix: add function to gracefully stop the gRPC server
harrytou Oct 16, 2023
25401c3
refactor: fix linting
kchrist-rocketfueldev Oct 17, 2023
c7797b0
fix: made core buildable and removed unused deps
troykessler Oct 20, 2023
0c02986
fix: updated every integration except docker
troykessler Oct 20, 2023
de2cbb2
refactor: update code to support latest IRuntime interface
kchrist-rocketfueldev Oct 25, 2023
983ed5c
chore: dockerize kyve core
kchrist-rocketfueldev Oct 26, 2023
9d3f170
chore: create script that compiles runtime.proto
kchrist-rocketfueldev Oct 31, 2023
1bbc2e9
fix: simplify core docker build
kchrist-rocketfueldev Oct 31, 2023
779ecdb
fix: build Docker image depending on platform
harrytou Nov 1, 2023
d4479e6
chore: update README files to reflect latest changes
kchrist-rocketfueldev Nov 2, 2023
d48997f
fix: increase gRPC server message size
kchrist-rocketfueldev Nov 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dist
.yarn/install-state.gz
.pnp.*
.DS_Store/

### Node Patch ###
# Serverless Webpack directories
.webpack/
Expand Down
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
################## Build Stage 1 ##################
# Create a staging Docker image with build dependencies and compile the app
################# Build Stage 1 #################
FROM node:lts AS build

# Set the architecture argument
ARG TARGETARCH

# Determine the binary architecture based on the target architecture and write it to a temporary file
RUN if [ "$TARGETARCH" = "arm64" ]; then \
echo BINARYARCH="arm64" >> /etc/environment; \
elif [ "$TARGETARCH" = "amd64" ]; then \
echo BINARYARCH="x86" >> /etc/environment; \
fi

# Set the working directory
WORKDIR /usr/src/app

# Copy necessary files for installing dependencies
COPY package.json yarn.lock lerna.json ./

# Install dependencies
RUN yarn install --frozen-lockfile

# Copy common files
COPY common ./common

# Build the docker core
RUN TARGET=latest-${TARGETOS}-${BINARYARCH} yarn run build:binaries:docker-core

################## Build Stage 2 ##################
#Create a slim runtime image with only the necessary files for execution
################# Build Stage 2 #################
FROM node:slim AS runtime

# Export environment variable which is used in the code
ENV RUNTIME_SERVER_ADDR=runtime:50051

# Set the working directory
WORKDIR /usr/src/app

# Copy the compiled output from the build stage
COPY --from=build /usr/src/app/common/docker/out/kyve* ./

# Set the command to run when the container starts
CMD ["./kyve"]
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ KYVE, the Web3 data lake solution, is a protocol that enables data providers to
- [@kyvejs/types](common/types/README.md) - holds all types for the KYVE application in typescript
- [@kyvejs/sdk](common/sdk/README.md) - development kit for communicating with the KYVE blockchain
- [@kyvejs/protocol](common/protocol/README.md) - core functionality for running validators on the KYVE network
- [@kyvejs/docker](common/docker/README.md) - core functionality facilitating dockerising KYVE functionality and communicating with dockerised runtimes via gRPC

**Tools:**

Expand All @@ -52,6 +53,7 @@ KYVE, the Web3 data lake solution, is a protocol that enables data providers to

- [@kyvejs/tendermint](integrations/tendermint/README.md) - The official KYVE Tendermint sync integration
- [@kyvejs/tendermint-bsync](integrations/tendermint-bsync/README.md) - The official KYVE Tendermint block sync integration
- [@kyvejs/tendermint-ssync](integrations/tendermint-ssync/README.md) - The official KYVE Tendermint block sync integration

## Build Integration Binaries

Expand Down Expand Up @@ -85,6 +87,61 @@ yarn build:binaries

The binaries can then be found in the `/out` folder

## Dockerized Execution

In the Kyve project, the binaries can now be easily executed within a Docker container. This allows for simplified deployment and consistent runtime environments. Before running the Kyve binaries in a Docker container, please ensure that you have set up a Docker network. If you haven't already, you can create a Docker network using the following command:

```
docker network create --driver bridge kyve
```

**Building the Docker Image**

To build a Docker image for Kyve Core, you can use the provided Dockerfile. Use the following command to build the image, while being in the root directory:

```
docker build -t kyve-core -f Dockerfile .
```

**Running Kyve Core in a Docker Container**

Once you have built the Docker image, you can run Kyve Core in a Docker container. Below are the instructions for running Kyve Core as a node:

1. Set your recovery phrase as the VALACCOUNT environment variable:

```
export VALACCOUNT="<recovery phrase>"
```

2. Run the Kyve Core container, replacing the placeholders with your specific parameters:

```
docker run --rm --name kyve-core --network kyve -e VALACCOUNT=$VALACCOUNT kyve-core ./kyve start --pool <pool id> --valaccount "$VALACCOUNT" --cache memory --rpc <rpc address> --rest <rest address> --chain-id=<chain id> --request-backoff 50 --debug
```
- `<recovery phrase>`: Replace this with your recovery phrase.
- `<pool id>`: Specify the pool ID you want to join.
- `<rpc address>`: Provide the RPC address of the network.
- `<rest address>`: Provide the REST API address.
- `<chain id>`: Specify the chain ID you want to interact with.

**Development and Testing**

For development and testing purposes, you can also run specific runtime methods in the Dockerized Kyve Core. Here's how to do it:

Run the Kyve Core container for a specific runtime method and arguments:
```
docker run --rm --name kyve-core --network kyve kyve-core ./kyve runtime <method> <args>
```
- `<method>`: Replace this with the name of the runtime method you want to test.
- `<args>`: Provide any required arguments for the runtime method.

By following these instructions, you can easily dockerize and run Kyve Core and perform testing and development tasks. The Dockerized runtime provides a convenient and isolated environment for your Kyve project.






## How to contribute

Checkout new branch to implement new features/fixes there
Expand Down
9 changes: 9 additions & 0 deletions common/docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/node_modules/
**/dist
**/out
.git
npm-debug.log
.coverage
.coverage.*
.env
.aws
190 changes: 190 additions & 0 deletions common/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# Created by https://www.toptal.com/developers/gitignore/api/node

# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*
.DS_Store/

### Node Patch

# Serverless Webpack directories

.webpack/

# Optional stylelint cache

# SvelteKit build / generate output

.svelte-kit
.idea
/common/types/client/
/common/types/lcd/

# End of https://www.toptal.com/developers/gitignore/api/node
4 changes: 4 additions & 0 deletions common/docker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
Loading
Loading