Skip to content

Commit 976c756

Browse files
committed
Initial commit
First version of the MUN Blockchain Mainnet Node binary
0 parents  commit 976c756

File tree

145 files changed

+82788
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+82788
-0
lines changed

.github/workflows/build.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Compile MUN
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
name: build
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Setup go
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: 1.19.0
21+
- run: make build
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
name: test
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v3
29+
with:
30+
go-version: 1.19.0
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
- name: Test
34+
run: go test ./...

.github/workflows/golangcli-lint.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: golangci-lint
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- master
9+
- main
10+
pull_request:
11+
paths:
12+
- '**.go'
13+
14+
permissions:
15+
contents: read
16+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
17+
# pull-requests: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
golangci:
25+
name: lint
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/setup-go@v3
29+
with:
30+
go-version: 1.19.0
31+
- uses: actions/checkout@v3
32+
33+
- name: golangci-lint-mund
34+
uses: golangci/golangci-lint-action@v3
35+
with:
36+
version: latest
37+
args: --timeout 10m

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
vue/
2+
ts-client/
3+
release/
4+
build/
5+
.idea/
6+
.vscode/
7+
.DS_Store

.golangci.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
run:
2+
tests: false
3+
timeout: 5m
4+
5+
linters:
6+
disable-all: true
7+
# Enable specific linter
8+
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
9+
enable:
10+
- asciicheck
11+
- bidichk
12+
# - depguard
13+
- durationcheck
14+
- errcheck
15+
- errname
16+
- exportloopref
17+
- forcetypeassert
18+
- goconst
19+
- gofmt
20+
- goimports
21+
- goheader
22+
- gomodguard
23+
- goprintffuncname
24+
- gosimple
25+
- govet
26+
- importas
27+
- ineffassign
28+
- makezero
29+
- misspell
30+
- nakedret
31+
- nilnil
32+
- paralleltest
33+
- promlinter
34+
- staticcheck
35+
- stylecheck
36+
- tenv
37+
- testpackage
38+
- typecheck
39+
- unconvert
40+
- unused
41+
- whitespace

Makefile

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
VERSION := 1.0.0
2+
COMMIT := $(shell git log -1 --format='%H')
3+
GOPATH ?= $(shell go env GOPATH)
4+
BINDIR ?= $(GOPATH)/bin
5+
CURRENT_DIR = $(shell pwd)
6+
APP = ./app
7+
8+
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=mun \
9+
-X github.com/cosmos/cosmos-sdk/version.ServerName=mund \
10+
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
11+
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
12+
13+
BUILD_FLAGS := -ldflags '$(ldflags)'
14+
DOCKER := $(shell which docker)
15+
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
16+
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
17+
18+
all: install
19+
20+
install: go.sum
21+
go install -mod=readonly $(BUILD_FLAGS) ./cmd/mund-manager
22+
go install -mod=readonly $(BUILD_FLAGS) ./cmd/mund
23+
24+
build: go.sum clean
25+
go build -mod=mod $(BUILD_FLAGS) -o build/mund-manager ./cmd/mund-manager
26+
go build -mod=mod $(BUILD_FLAGS) -o build/mund ./cmd/mund
27+
28+
build-linux:
29+
GOOS=linux GOARCH=amd64 $(MAKE) build
30+
31+
go.sum: go.mod
32+
@echo "--> Ensure dependencies have not been modified"
33+
GO111MODULE=on go mod verify
34+
35+
# look into .golangci.yml for enabling / disabling linters
36+
lint:
37+
@echo "--> Running linter"
38+
@golangci-lint run
39+
@go mod verify
40+
41+
# devnet
42+
43+
devnet: clean install devnet-prepare devnet-start
44+
45+
devnet-prepare:
46+
./scripts/prepare-devnet.sh
47+
48+
devnet-start:
49+
DAEMON_NAME=diversifid DAEMON_HOME=~/.diversifid DAEMON_ALLOW_DOWNLOAD_BINARIES=true DAEMON_RESTART_AFTER_UPGRADE=true \
50+
diversifid start --pruning="nothing" --inv-check-period 5
51+
52+
# Clean up the build directory
53+
clean:
54+
rm -rf build/
55+
rm -rf vue/
56+
rm -rf ts-client/
57+
58+
59+
# Localnet
60+
61+
# Build nodes using Docker
62+
build-docker:
63+
$(MAKE) -C networks/local
64+
65+
# Run a 4-node testnet locally
66+
localnet-start: build-linux localnet-stop
67+
@if ! [ -f build/node0/diversifid/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/diversifid:Z lottery/core testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test --chain-id test ; fi
68+
./scripts/import-localnet-seeds.sh
69+
docker-compose up
70+
71+
# Stop testnet
72+
localnet-stop:
73+
docker-compose down
74+
75+
localnet: clean build-linux build-docker localnet-start
76+
77+
###############################################################################
78+
### Tests & Simulation ###
79+
###############################################################################
80+
81+
runsim:
82+
go install github.com/cosmos/tools/cmd/runsim@latest
83+
84+
PACKAGES_SIM=$(shell go list ./... | grep '/app')
85+
86+
test-sim-suite:
87+
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_SIM)
88+
89+
test-sim-app:
90+
@VERSION=$(VERSION) go test -mod=readonly -run ^TestFullAppSimulation ./app -Enabled=true -v -NumBlocks=10 -BlockSize=200 -Commit=true -Period=0
91+
92+
test-sim-full-app: runsim
93+
@echo "Running short multi-seed application simulation. This may take awhile!"
94+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 10 TestFullAppSimulation
95+
96+
test-sim-multi-seed-long: runsim
97+
@echo "Running long multi-seed application simulation. This may take awhile!"
98+
@cd ${CURRENT_DIR}/simapp && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 500 50 TestFullAppSimulation
99+
100+
test-sim-nondeterminism:
101+
@echo "Running non-determinism test..."
102+
go test -mod=readonly -run ^TestAppStateDeterminism ./app -Enabled=true -NumBlocks=10 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
103+
104+
test-sim-import-export: runsim
105+
@echo "Running application import/export simulation. This may take several minutes..."
106+
@cd ${CURRENT_DIR}/app && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppImportExport
107+
108+
test-sim-after-import: runsim
109+
@echo "Running application simulation-after-import. This may take several minutes..."
110+
@cd ${CURRENT_DIR}/app && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppSimulationAfterImport
111+
112+
test-sim-bench:
113+
@VERSION=$(VERSION) go test -benchmem -run ^BenchmarkFullAppSimulation -bench ^BenchmarkFullAppSimulation -cpuprofile cpu.out $(PACKAGES_SIM)
114+
115+
116+
###############################################################################
117+
### Protobuf ###
118+
###############################################################################
119+
120+
protoVer=v0.3
121+
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
122+
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
123+
containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer)
124+
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
125+
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer)
126+
127+
proto-all: proto-format proto-lint proto-gen
128+
129+
proto-gen:
130+
docker run --rm -v $(CURDIR):/workspace --workdir /workspace bharvest/liquidity-proto-gen sh ./scripts/protocgen.sh
131+
go mod tidy
132+
133+
# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
134+
proto-gen-js:
135+
@echo "Generating Protobuf Typescript"
136+
bash ./scripts/protocgen-js.sh
137+
138+
proto-swagger-gen:
139+
@echo "Generating Protobuf Swagger"
140+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
141+
sh ./scripts/protoc-swagger-gen.sh; fi
142+
143+
proto-format:
144+
@echo "Formatting Protobuf files"
145+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
146+
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
147+
148+
proto-lint:
149+
@$(DOCKER_BUF) lint --error-format=json
150+
151+
proto-check-breaking:
152+
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master
153+
154+
# Create log files
155+
log-files:
156+
sudo mkdir -p /var/log/mund && sudo touch /var/log/mund/mund.log && sudo touch /var/log/mund/mund_error.log

0 commit comments

Comments
 (0)