Skip to content

Commit

Permalink
Merge pull request #1 from osmosis-labs/feat/add-goodies
Browse files Browse the repository at this point in the history
Feat/add goodies
  • Loading branch information
niccoloraspa authored Jul 9, 2024
2 parents 41598f9 + 9fb20e6 commit 5d8e3c8
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 81 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow creates a release using goreleaser
# via the 'make release' command.

name: Create release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc

permissions:
contents: write

jobs:
release:
name: Create release
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
-
name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
-
name: Make release
run: |
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 29 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
build
snapshots/
here/
vendor/
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env*

# Custom
dist/
build/
59 changes: 59 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
project_name: cosmprund

env:
- CGO_ENABLED=0

before:
hooks:
- go mod tidy

builds:
- id: cosmprund
binary: cosmprund
flags:
- -mod=readonly
- -trimpath
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s
- -w

archives:
- id: zipped
builds:
- cosmprund
name_template: "{{.ProjectName}}-{{.Os}}-{{.Arch}}"
format: tar.gz
files:
- none*
- id: binaries
builds:
- cosmprund
name_template: "{{.ProjectName}}-{{.Os}}-{{.Arch}}"
format: binary
files:
- none*

release:
github:
owner: osmosis-labs
name: cosmprund
header: |
osmprund release {{ .Version }}
footer: |
## 🐳 Docker
The following Docker images are available in our registry:
| Image | Tag |
|-------------------------------------|----------------|
| `osmolabs/cosmprund:{{ .Version }}` | {{ .Version }} |
name_template: "cosmprund v{{.Version}}"
mode: replace
draft: true
30 changes: 24 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# 1st stage, build app
FROM golang:1.21-alpine as builder
# ----------------------------------------------------------------
# Builder Stage
# ----------------------------------------------------------------
ARG GO_VERSION="1.21"

COPY . /app
FROM golang:${GO_VERSION}-alpine AS builder

# Download go dependencies
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

RUN go build -o cosmprund
# Copy the remaining files
COPY cmd /app/cmd
COPY internal /app/internal
COPY *.go /app/

# Build binary
RUN go build \
-mod=readonly \
-ldflags "-w -s" \
-trimpath \
-o /app/build/cosmprund

FROM alpine
# ----------------------------------------------------------------
# Final image for Running
# ----------------------------------------------------------------

COPY --from=builder /app/cosmprund /usr/bin/cosmprund
FROM alpine:3.19

COPY --from=builder /app/build/cosmprund /usr/bin/cosmprund

ENTRYPOINT [ "/usr/bin/cosmprund" ]
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
VERSION := $(shell git describe --tags)
COMMIT := $(shell git log -1 --format='%H')
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)

all: install

build:
@echo "Building cosmprund"
@go build -mod readonly $(BUILD_FLAGS) -o build/cosmprund main.go

clean:
rm -rf build

.PHONY: all lint test race msan tools clean build

###############################################################################
### Docker ###
###############################################################################

docker-build:
docker build -t cosmprund:local .

docker-run:
docker run cosmprund:local

###############################################################################
### Release ###
###############################################################################
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION)

ifdef GITHUB_TOKEN
release:
docker run \
--rm \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/diffusion \
-w /go/src/diffusion \
$(GORELEASER_IMAGE) \
release \
--clean
else
release:
@echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'."
endif

release-dry-run:
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/diffusion \
-w /go/src/diffusion \
$(GORELEASER_IMAGE) \
release \
--clean \
--skip=publish

release-snapshot:
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/osmosisd \
-w /go/src/osmosisd \
$(GORELEASER_IMAGE) \
release \
--clean \
--snapshot \
--skip=validate \
--skip=publish
51 changes: 7 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Cosmos-Pruner

The goal of this project is to be able to prune a tendermint data base of blocks and an Cosmos-sdk application DB of all but the last X versions. This will allow people to not have to state sync every x days.
The goal of this project is to be able to prune a tendermint data base of blocks and an Cosmos-sdk application DB of all but the last X versions. This will allow people to not have to state sync every x days.

This tool works with a subset of modules. While an application may have modules outside the scope of this tool , this tool will prune the default sdk module, and osmosis added module.
This tool works with a subset of modules. While an application may have modules outside the scope of this tool , this tool will prune the default sdk module, and osmosis added module.

## WARNING

Due to inefficiencies of iavl and the simple approach of this tool, it can take ages to prune the data of a large node.
Due to inefficiencies of iavl and the simple approach of this tool, it can take ages to prune the data of a large node.

We are working on integrating this natively into the Cosmos-sdk and Tendermint

## How to use

Cosmprund works of a data directory that has the same structure of a normal cosmos-sdk/tendermint node. By default it will prune all but 10 blocks from tendermint, and all but 10 versions of application state.
Cosmprund works of a data directory that has the same structure of a normal cosmos-sdk/tendermint node. By default it will prune all but 10 blocks from tendermint, and all but 10 versions of application state.

> Note: Application pruning can take a very long time dependent on the size of the db.
> Note: Application pruning can take a very long time dependent on the size of the db.

```
Expand All @@ -26,11 +26,11 @@ make build
# stop daemon/cosmovisor
sudo systemctl stop cosmovisor
# run cosmprund
# run cosmprund
./build/cosmprund prune ~/.gaiad/data --cosmos-sdk=false
```

Flags:
Flags:

- `data-dir`: path to data directory if not default
- `blocks`: amount of blocks to keep on the node (Default 10)
Expand All @@ -42,43 +42,6 @@ Flags:

#### Supported Apps:
- osmosis: Osmosis
- starname: Starname
- regen: Regen
- akash: Akash
- cosmoshub: Gaia
- sentinel: Sentinel
- emoney: E-Money
- ixo: Ixo
- juno: Juno
- sifchain: Sifchain
- likecoin: Likecoin
- kichain: Ki
- cyber: Cyber
- cheqd: Cheqd
- stargaze: Stargaze
- bandchain: Band
- chihuahua: Chihuahua
- kava: Kava
- bitcanna: BitCanna
- konstellation: Konstellation
- omniflixhub: Omniflix
- terra: Terra
- vidulum: Vidulum
- provenance: Provenance
- dig: Dig
- gravitybridge: Gravity-Bridge
- comdex: Comdex
- cerberus: Cerberus
- bitsong: BitSong
- assetmantle: AssetMantle
- fetchhub: FetchAI
- evmos: Evmos
- persistent: Persistence
- cryptoorgchain: Crypto.org
- irisnet: IRISnet
- axelar: Axelar
- umee: Umee


### Note
To use this with RocksDB you must:
Expand Down
27 changes: 0 additions & 27 deletions makefile

This file was deleted.

0 comments on commit 5d8e3c8

Please sign in to comment.