forked from sei-protocol/sei-chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
193 lines (153 loc) · 5.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/make -f
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
export PROJECT_HOME=$(shell git rev-parse --show-toplevel)
export GO_PKG_PATH=$(HOME)/go/pkg
export GO111MODULE = on
NITRO_RELEASE_PATH := $(PROJECT_HOME)/nitro-replayer/target/release
NITRO_LIB_PATH := $(PROJECT_HOME)/x/nitro/
# process build tags
LEDGER_ENABLED ?= true
build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sei \
-X github.com/cosmos/cosmos-sdk/version.ServerName=seid \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
# BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' -race
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
#### Command List ####
all: lint install
install: go.sum
go install $(BUILD_FLAGS) ./cmd/seid
# In case when running seid fails with nitro issue or if you make changes to nitro, please use install-all
install-all: build-nitro install
install-price-feeder: go.sum
go install $(BUILD_FLAGS) ./oracle/price-feeder
loadtest: go.sum
go build $(BUILD_FLAGS) -o ./build/loadtest ./loadtest/
price-feeder: go.sum
go build $(BUILD_FLAGS) -o ./build/price-feeder ./oracle/price-feeder
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
lint:
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
build:
go build $(BUILD_FLAGS) -o ./build/seid ./cmd/seid
build-price-feeder:
go build $(BUILD_FLAGS) -o ./build/price-feeder ./oracle/price-feeder
# In case running seid fails with nitro issue or if you make changes to nitro, please use build-all
build-all: build-nitro build
build-nitro:
@cd $(PROJECT_HOME)/nitro-replayer && cargo build --release
if [ -f "$(NITRO_RELEASE_PATH)/libnitro_replayer.dylib" ]; then \
cp $(NITRO_RELEASE_PATH)/libnitro_replayer.dylib $(NITRO_LIB_PATH)/replay; \
fi
if [ -f "$(NITRO_RELEASE_PATH)/libnitro_replayer.x86_64.so" ]; then \
cp $(NITRO_RELEASE_PATH)/libnitro_replayer.x86_64.so $(NITRO_LIB_PATH)/replay; \
fi
clean:
rm -rf ./build
###############################################################################
### Local testing using docker container ###
###############################################################################
# To start a 4-node cluster from scratch:
# make clean && make docker-cluster-start
# To stop the 4-node cluster:
# make docker-cluster-stop
# If you have already built the binary, you can skip the build:
# make docker-cluster-start-skipbuild
###############################################################################
# Build linux binary on other platforms
build-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-linux-gnu-gcc make build
.PHONY: build-linux
build-price-feeder-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-linux-gnu-gcc make build-price-feeder
.PHONY: build-price-feeder-linux
# Build docker image
build-docker-node:
@cd docker && docker build --tag sei-chain/localnode localnode --platform linux/x86_64
.PHONY: build-docker-node
build-rpc-node:
@cd docker && docker build --tag sei-chain/rpcnode rpcnode --platform linux/x86_64
.PHONY: build-rpc-node
# Run a single node docker container
run-local-node: kill-sei-node build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
docker run --rm \
--name sei-node \
--network host \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
--platform linux/x86_64 \
sei-chain/localnode
.PHONY: run-local-node
# Run a single rpc state sync node docker container
run-rpc-node: kill-rpc-node build-rpc-node
docker run --rm \
--name sei-rpc-node \
--network docker_localnet \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(PROJECT_HOME)/../sei-tendermint:/sei-protocol/sei-tendermint:Z \
-v $(PROJECT_HOME)/../sei-cosmos:/sei-protocol/sei-cosmos:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
-p 26668-26670:26656-26658 \
--platform linux/x86_64 \
sei-chain/rpcnode
.PHONY: run-rpc-node
kill-sei-node:
docker ps --filter name=sei-node --filter status=running -aq | xargs docker kill
kill-rpc-node:
docker ps --filter name=sei-rpc-node --filter status=running -aq | xargs docker kill
# Run a 4-node docker containers
docker-cluster-start: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 docker-compose up
.PHONY: localnet-start
# Use this to skip the seid build process
docker-cluster-start-skipbuild: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 SKIP_BUILD=true docker-compose up
.PHONY: localnet-start
# Stop 4-node docker containers
docker-cluster-stop:
@cd docker && docker-compose down
.PHONY: localnet-stop