Skip to content

Commit 5d8e3c8

Browse files
authored
Merge pull request #1 from osmosis-labs/feat/add-goodies
Feat/add goodies
2 parents 41598f9 + 9fb20e6 commit 5d8e3c8

File tree

7 files changed

+218
-81
lines changed

7 files changed

+218
-81
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow creates a release using goreleaser
2+
# via the 'make release' command.
3+
4+
name: Create release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
name: Create release
17+
runs-on: buildjet-4vcpu-ubuntu-2204
18+
steps:
19+
-
20+
name: Check out repository code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ github.ref }}
25+
-
26+
name: Make release
27+
run: |
28+
make release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
build
2-
snapshots/
3-
here/
4-
vendor/
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum
23+
24+
# env file
25+
.env*
26+
27+
# Custom
28+
dist/
29+
build/

.goreleaser.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
project_name: cosmprund
2+
3+
env:
4+
- CGO_ENABLED=0
5+
6+
before:
7+
hooks:
8+
- go mod tidy
9+
10+
builds:
11+
- id: cosmprund
12+
binary: cosmprund
13+
flags:
14+
- -mod=readonly
15+
- -trimpath
16+
goos:
17+
- linux
18+
- darwin
19+
goarch:
20+
- amd64
21+
- arm64
22+
ldflags:
23+
- -s
24+
- -w
25+
26+
archives:
27+
- id: zipped
28+
builds:
29+
- cosmprund
30+
name_template: "{{.ProjectName}}-{{.Os}}-{{.Arch}}"
31+
format: tar.gz
32+
files:
33+
- none*
34+
- id: binaries
35+
builds:
36+
- cosmprund
37+
name_template: "{{.ProjectName}}-{{.Os}}-{{.Arch}}"
38+
format: binary
39+
files:
40+
- none*
41+
42+
release:
43+
github:
44+
owner: osmosis-labs
45+
name: cosmprund
46+
header: |
47+
osmprund release {{ .Version }}
48+
footer: |
49+
## 🐳 Docker
50+
51+
The following Docker images are available in our registry:
52+
53+
| Image | Tag |
54+
|-------------------------------------|----------------|
55+
| `osmolabs/cosmprund:{{ .Version }}` | {{ .Version }} |
56+
57+
name_template: "cosmprund v{{.Version}}"
58+
mode: replace
59+
draft: true

Dockerfile

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
# 1st stage, build app
2-
FROM golang:1.21-alpine as builder
1+
# ----------------------------------------------------------------
2+
# Builder Stage
3+
# ----------------------------------------------------------------
4+
ARG GO_VERSION="1.21"
35

4-
COPY . /app
6+
FROM golang:${GO_VERSION}-alpine AS builder
57

8+
# Download go dependencies
69
WORKDIR /app
10+
COPY go.mod go.sum ./
11+
RUN go mod download
712

8-
RUN go build -o cosmprund
13+
# Copy the remaining files
14+
COPY cmd /app/cmd
15+
COPY internal /app/internal
16+
COPY *.go /app/
917

18+
# Build binary
19+
RUN go build \
20+
-mod=readonly \
21+
-ldflags "-w -s" \
22+
-trimpath \
23+
-o /app/build/cosmprund
1024

11-
FROM alpine
25+
# ----------------------------------------------------------------
26+
# Final image for Running
27+
# ----------------------------------------------------------------
1228

13-
COPY --from=builder /app/cosmprund /usr/bin/cosmprund
29+
FROM alpine:3.19
30+
31+
COPY --from=builder /app/build/cosmprund /usr/bin/cosmprund
1432

1533
ENTRYPOINT [ "/usr/bin/cosmprund" ]

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
VERSION := $(shell git describe --tags)
2+
COMMIT := $(shell git log -1 --format='%H')
3+
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
4+
5+
all: install
6+
7+
build:
8+
@echo "Building cosmprund"
9+
@go build -mod readonly $(BUILD_FLAGS) -o build/cosmprund main.go
10+
11+
clean:
12+
rm -rf build
13+
14+
.PHONY: all lint test race msan tools clean build
15+
16+
###############################################################################
17+
### Docker ###
18+
###############################################################################
19+
20+
docker-build:
21+
docker build -t cosmprund:local .
22+
23+
docker-run:
24+
docker run cosmprund:local
25+
26+
###############################################################################
27+
### Release ###
28+
###############################################################################
29+
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION)
30+
31+
ifdef GITHUB_TOKEN
32+
release:
33+
docker run \
34+
--rm \
35+
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
36+
-v /var/run/docker.sock:/var/run/docker.sock \
37+
-v `pwd`:/go/src/diffusion \
38+
-w /go/src/diffusion \
39+
$(GORELEASER_IMAGE) \
40+
release \
41+
--clean
42+
else
43+
release:
44+
@echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'."
45+
endif
46+
47+
release-dry-run:
48+
docker run \
49+
--rm \
50+
-v /var/run/docker.sock:/var/run/docker.sock \
51+
-v `pwd`:/go/src/diffusion \
52+
-w /go/src/diffusion \
53+
$(GORELEASER_IMAGE) \
54+
release \
55+
--clean \
56+
--skip=publish
57+
58+
release-snapshot:
59+
docker run \
60+
--rm \
61+
-v /var/run/docker.sock:/var/run/docker.sock \
62+
-v `pwd`:/go/src/osmosisd \
63+
-w /go/src/osmosisd \
64+
$(GORELEASER_IMAGE) \
65+
release \
66+
--clean \
67+
--snapshot \
68+
--skip=validate \
69+
--skip=publish

README.md

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Cosmos-Pruner
22

3-
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.
3+
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.
44

5-
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.
5+
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.
66

77
## WARNING
88

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

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

1313
## How to use
1414

15-
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.
15+
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.
1616

17-
> Note: Application pruning can take a very long time dependent on the size of the db.
17+
> Note: Application pruning can take a very long time dependent on the size of the db.
1818
1919

2020
```
@@ -26,11 +26,11 @@ make build
2626
# stop daemon/cosmovisor
2727
sudo systemctl stop cosmovisor
2828
29-
# run cosmprund
29+
# run cosmprund
3030
./build/cosmprund prune ~/.gaiad/data --cosmos-sdk=false
3131
```
3232

33-
Flags:
33+
Flags:
3434

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

4343
#### Supported Apps:
4444
- osmosis: Osmosis
45-
- starname: Starname
46-
- regen: Regen
47-
- akash: Akash
48-
- cosmoshub: Gaia
49-
- sentinel: Sentinel
50-
- emoney: E-Money
51-
- ixo: Ixo
52-
- juno: Juno
53-
- sifchain: Sifchain
54-
- likecoin: Likecoin
55-
- kichain: Ki
56-
- cyber: Cyber
57-
- cheqd: Cheqd
58-
- stargaze: Stargaze
59-
- bandchain: Band
60-
- chihuahua: Chihuahua
61-
- kava: Kava
62-
- bitcanna: BitCanna
63-
- konstellation: Konstellation
64-
- omniflixhub: Omniflix
65-
- terra: Terra
66-
- vidulum: Vidulum
67-
- provenance: Provenance
68-
- dig: Dig
69-
- gravitybridge: Gravity-Bridge
70-
- comdex: Comdex
71-
- cerberus: Cerberus
72-
- bitsong: BitSong
73-
- assetmantle: AssetMantle
74-
- fetchhub: FetchAI
75-
- evmos: Evmos
76-
- persistent: Persistence
77-
- cryptoorgchain: Crypto.org
78-
- irisnet: IRISnet
79-
- axelar: Axelar
80-
- umee: Umee
81-
8245

8346
### Note
8447
To use this with RocksDB you must:

makefile

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)