Skip to content

Commit

Permalink
CDU (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliothllm committed Mar 21, 2024
1 parent cd198d5 commit ef6b748
Show file tree
Hide file tree
Showing 89 changed files with 116 additions and 147 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/CI-API.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: CI-API
name: CI-CDU

on:
pull_request:
branches: [ main ]
paths:
- '.github/workflows/CI-API.yml'
- 'api/**'
- '.github/workflows/CI-CDU.yml'
- 'cdu/**'
push:
branches: [ main ]
paths:
- '.github/workflows/CI-API.yml'
- 'api/**'
- '.github/workflows/CI-CDU.yml'
- 'cdu/**'
workflow_dispatch:

concurrency:
Expand All @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: api
working-directory: cdu

steps:
- name: Checkout code
Expand All @@ -39,7 +39,7 @@ jobs:
with:
version: latest
args: --issues-exit-code=1 --timeout=10m
working-directory: api
working-directory: cdu

- name: Build
run: go build ./...
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
default: all

all: cdk-envs
all: cdu

.PHONY: cdk-envs
cdk-envs:
@echo "Building APP"
.PHONY: cdu
cdu:
@echo "Building Chain Dev Utils..."
@export DATA_DIR_HOST=$(data) ; \
docker compose build && docker compose up -d
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# cdk-envs
# Chain Development Utilities

![CI-API](https://github.com/RevittConsulting/cdk-envs/actions/workflows/CI-API.yml/badge.svg)
![CI-Frontend](https://github.com/RevittConsulting/cdk-envs/actions/workflows/CI-Frontend.yml/badge.svg)
![CI-CDU](https://github.com/RevittConsulting/chain-dev-utils/actions/workflows/CI-CDU.yml/badge.svg)
![CI-Frontend](https://github.com/RevittConsulting/chain-dev-utils/actions/workflows/CI-Frontend.yml/badge.svg)

cdk-envs is a dockerized Polygon CDK app with a set of tools for developers.
Chain dev utils is a dockerized app with a set of tools for developers working in the crypto ecosystem.

The app currently has these services:

- Chains RPC API
- This takes all the chains in the chains.yaml file and displays them as a card on the front end. You can then run RPC calls to the chains, and it will update via websockets.
- Datacryp
- This is a DB viewer for the MDBX database files that are stored in the `/data` directory. You can view the data and search through it.
- MDBX Viewer
- This is a DB viewer for the MDBX database files that are stored in your mounted data directory. You can view the data and search through it.
- TxSender [WIP]
- This is a tool that will send a transaction on a chain. It will then display the transaction hash and the receipt.
- Datastreamer [WIP]
Expand All @@ -30,7 +30,7 @@ The app currently has these services:

## Config for chains

Set up a config file in the `/api` directory of the project called chains.yaml. There is an example of this config in the root. This must be put in the api folder. Add any amount of chains to this file.
Set up a config file in the `/cdu` directory of the project called chains.yaml. There is an example of this config in the root. This must be put in the cdu folder. Add any amount of chains to this file.

```yaml
Chains:
Expand Down Expand Up @@ -59,24 +59,24 @@ Chains:

***

## Datacryp
## MDBX Viewer

Datacryp is a frontend tool that allows you to perform various operations on the MDBX database files that are stored in the `/data` directory. You can view the data and search through it.
MDBX viewer is a frontend tool that allows you to perform various operations on the MDBX database files that are stored in your data directory that you can mount through the argument `data`. You can view the data and search through it.

To set up your data, you must create a `/data` directory in the root of the project. You can then add your MDBX files to this directory. The files must be named in the format `mdbx.dat`. You can create folders within that for the chain name for example `cardona/mdbx.dat`, then the frontend will display `cardona/mdbx.dat`.
To set up your data, you must build CDU with the argument `data=/Path/to/your/data`.

***

## Run the app

```bash
git clone https://github.com/RevittConsulting/cdk-envs
git clone https://github.com/RevittConsulting/chain-dev-utils
```

To build and run the containers:
To build and run the containers with a path to your data directory:

```bash
make cdk-envs
make cdu data=/Path/to/your/data
```

***
22 changes: 0 additions & 22 deletions api/chains.yaml

This file was deleted.

File renamed without changes.
10 changes: 5 additions & 5 deletions api/Dockerfile → cdu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM docker.io/library/golang:1.22.0-alpine3.19 AS base

RUN apk --no-cache add build-base linux-headers git bash ca-certificates libstdc++

RUN mkdir /api
WORKDIR /api
RUN mkdir /cdu
WORKDIR /cdu

ADD go.mod .
ADD go.sum .
Expand All @@ -13,7 +13,7 @@ RUN go mod download


FROM base as builder
WORKDIR /api
WORKDIR /cdu

RUN ls

Expand All @@ -26,8 +26,8 @@ RUN go build -o apiexecutable ./cmd/api

FROM docker.io/library/alpine:3.19

COPY --from=builder /api/apiexecutable /apiexecutable
COPY --from=builder /api/chains.yaml /chains.yaml
COPY --from=builder /cdu/apiexecutable /apiexecutable
COPY --from=builder /cdu/chains.yaml /chains.yaml

EXPOSE 8080

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/cmd/api/main.go → cdu/cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/RevittConsulting/cdk-envs/cmd"
"github.com/RevittConsulting/chain-dev-utils/cmd"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions api/cmd/root.go → cdu/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"context"
"fmt"
"github.com/RevittConsulting/cdk-envs/config"
"github.com/RevittConsulting/cdk-envs/internal/server"
"github.com/RevittConsulting/chain-dev-utils/config"
"github.com/RevittConsulting/chain-dev-utils/internal/server"
"github.com/spf13/cobra"
"os"
"os/signal"
Expand Down
2 changes: 1 addition & 1 deletion api/cmd/serve.go → cdu/cmd/serve.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/RevittConsulting/cdk-envs/internal/server"
"github.com/RevittConsulting/chain-dev-utils/internal/server"
"github.com/spf13/cobra"
)

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions api/config/scheme.go → cdu/config/scheme.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package config

import (
"github.com/RevittConsulting/cdk-envs/internal/buckets"
"github.com/RevittConsulting/cdk-envs/internal/jsonrpc"
"github.com/RevittConsulting/cdk-envs/internal/tx"
"github.com/RevittConsulting/cdk-envs/internal/datastream"
"github.com/RevittConsulting/chain-dev-utils/internal/buckets"
"github.com/RevittConsulting/chain-dev-utils/internal/jsonrpc"
"github.com/RevittConsulting/chain-dev-utils/internal/tx"
"github.com/RevittConsulting/chain-dev-utils/internal/datastream"
)

type Config struct {
Expand Down
4 changes: 2 additions & 2 deletions api/go.mod → cdu/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/RevittConsulting/cdk-envs
module github.com/RevittConsulting/chain-dev-utils

go 1.22.0

require (
github.com/0xPolygonHermez/zkevm-data-streamer v0.2.0
github.com/RevittConsulting/logger v1.0.0
github.com/boltdb/bolt v1.3.1
github.com/erigontech/mdbx-go v0.37.1
github.com/ethereum/go-ethereum v1.13.14
Expand All @@ -27,7 +28,6 @@ require (

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/RevittConsulting/logger v1.0.0 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions api/go.sum → cdu/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,10 @@ github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bolt

import (
"fmt"
"github.com/RevittConsulting/cdk-envs/internal/types"
"github.com/RevittConsulting/chain-dev-utils/internal/types"
"github.com/boltdb/bolt"
"log"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package level

import (
"github.com/RevittConsulting/cdk-envs/internal/types"
"github.com/RevittConsulting/chain-dev-utils/internal/types"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
"log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package mdbx
import (
"encoding/hex"
"errors"
"github.com/RevittConsulting/cdk-envs/internal/types"
"github.com/RevittConsulting/cdk-envs/pkg/utils"
"github.com/RevittConsulting/chain-dev-utils/internal/types"
"github.com/RevittConsulting/chain-dev-utils/pkg/utils"
"github.com/erigontech/mdbx-go/mdbx"
"log"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package buckets

import (
"github.com/RevittConsulting/cdk-envs/internal/types"
"github.com/RevittConsulting/cdk-envs/pkg/utils"
"github.com/RevittConsulting/chain-dev-utils/internal/types"
"github.com/RevittConsulting/chain-dev-utils/pkg/utils"
"github.com/RevittConsulting/logger"
"github.com/go-chi/chi/v5"
"net/http"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package buckets
import (
"encoding/hex"
"fmt"
"github.com/RevittConsulting/cdk-envs/internal/buckets/db/mdbx"
"github.com/RevittConsulting/cdk-envs/internal/types"
"github.com/RevittConsulting/chain-dev-utils/internal/buckets/db/mdbx"
"github.com/RevittConsulting/chain-dev-utils/internal/types"
"io/fs"
"math/big"
"os"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package chain_services

import (
"fmt"
"github.com/RevittConsulting/cdk-envs/internal/jsonrpc"
"github.com/RevittConsulting/chain-dev-utils/internal/jsonrpc"
"time"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package chain_services

import (
"fmt"
"github.com/RevittConsulting/cdk-envs/config"
"github.com/RevittConsulting/cdk-envs/internal/jsonrpc"
"github.com/RevittConsulting/cdk-envs/pkg/hexadecimal"
"github.com/RevittConsulting/chain-dev-utils/config"
"github.com/RevittConsulting/chain-dev-utils/internal/jsonrpc"
"github.com/RevittConsulting/chain-dev-utils/pkg/hexadecimal"
"log"
"math/big"
"time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package chain_services

import (
"github.com/RevittConsulting/cdk-envs/config"
"github.com/RevittConsulting/cdk-envs/internal/jsonrpc"
"github.com/RevittConsulting/chain-dev-utils/config"
"github.com/RevittConsulting/chain-dev-utils/internal/jsonrpc"
"log"
"net"
"time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package chains

import (
"github.com/RevittConsulting/cdk-envs/config"
"github.com/RevittConsulting/cdk-envs/internal/chains/chain_services"
"github.com/RevittConsulting/chain-dev-utils/config"
"github.com/RevittConsulting/chain-dev-utils/internal/chains/chain_services"
"strconv"
"time"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package chains

import (
"github.com/RevittConsulting/cdk-envs/pkg/utils"
"github.com/RevittConsulting/chain-dev-utils/pkg/utils"
"github.com/RevittConsulting/logger"
"github.com/go-chi/chi/v5"
"net/http"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package chains

import (
"context"
"github.com/RevittConsulting/cdk-envs/config"
"github.com/RevittConsulting/cdk-envs/internal/chains/chain_services"
"github.com/RevittConsulting/chain-dev-utils/config"
"github.com/RevittConsulting/chain-dev-utils/internal/chains/chain_services"
)

type HttpService struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/RevittConsulting/cdk-envs/internal/datastream/datastream/types"
"github.com/RevittConsulting/chain-dev-utils/internal/datastream/datastream/types"
"net"
"reflect"
"sync/atomic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net"
"testing"

"github.com/RevittConsulting/cdk-envs/internal/datastream/datastream/types"
"github.com/RevittConsulting/chain-dev-utils/internal/datastream/datastream/types"
"github.com/ledgerwatch/erigon-lib/common"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package datastream

import (
"github.com/RevittConsulting/chain-dev-utils/internal/datastream/datastream/client"
"github.com/RevittConsulting/chain-dev-utils/internal/datastream/datastream/types"
"github.com/pkg/errors"
"github.com/RevittConsulting/cdk-envs/internal/datastream/datastream/types"
"github.com/RevittConsulting/cdk-envs/internal/datastream/datastream/client"
)

// Download a set amount of blocks from datastream server to channel
Expand Down
Loading

0 comments on commit ef6b748

Please sign in to comment.