-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
242 lines (172 loc) · 9.56 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
include .env
export
USER_HOME := $(HOME)
PRIVKEY ?=
AMOUNT ?= 0.5
PRICE ?= 10.05
COMPOSE_ALL_FILES := -f docker-compose.yml -f docker-compose.oracle.yml -f docker-compose.node-exporter.yml
COMPOSE_OPERATOR := -f docker-compose.yml
COMPOSE_ORACLE := -f docker-compose.oracle.yml
COMPOSE_NODE_EXPORTER := -f docker-compose.node-exporter.yml
SERVICES := autonity autonity_oracle
compose_v2_not_supported = $(shell command docker compose 2> /dev/null)
ifeq (,$(compose_v2_not_supported))
DOCKER_COMPOSE_COMMAND = docker-compose
else
DOCKER_COMPOSE_COMMAND = docker compose
endif
# --------------------------
.PHONY: dir pipx aut autrc rpc validator all up down up-oracle log log-o clean acc get-acc acc-balance oracle-balance acc-oracle get-oracle-acc sign get-enode get-priv save-priv genOwnershipProof add-validator compute register bond unbond list get-comm import sign-onboard sign-rpc send val-info test
dir:
@mkdir -p $$(echo ${DATADIR})/keystore/ $$(echo ${DATADIR})/signs/
pipx:
@chmod +x ./scripts/pipx-install.sh
@/bin/bash -c 'source $(USER_HOME)/.bashrc' && bash ./scripts/pipx-install.sh && /bin/bash -c 'source $(USER_HOME)/.bashrc'
httpie:
@chmod +x ./scripts/httpie-install.sh
@./scripts/httpie-install.sh
aut:
@chmod +x ./scripts/aut-install.sh
@./scripts/aut-install.sh
autrc:
@chmod +x ./scripts/autrc.sh
@./scripts/autrc.sh
rpc:
@chmod +x ./scripts/sign-rpc.sh
@./scripts/sign-rpc.sh
validator:
@chmod +x ./scripts/sign-validator.sh
@./scripts/sign-validator.sh
all:
@make dir
@make pipx
@make aut
@make autrc && /bin/bash -c 'source $(USER_HOME)/.bashrc'
pull:
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_OPERATOR) pull
up:
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_OPERATOR) up -d autonity
down:
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_OPERATOR) down -v
down-a:
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_OPERATOR) down autonity
up-oracle:
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_OPERATOR) up -d autonity_oracle
log:
sudo docker logs --follow autonity -f --tail 100
log-o:
sudo docker logs --follow autonity_oracle -f --tail 100
clean:
@make down
@chmod +x ./scripts/clean.sh
@./scripts/clean.sh
acc:
@mkdir -p $$(echo ${DATADIR})/keystore
@aut account new --keyfile $$(echo ${DATADIR})/keystore/$(KEYNAME).key
get-acc:
@aut account info --keyfile $$(echo ${DATADIR})/keystore/$(KEYNAME).key
acc-balance:
@aut account balance $(if $(NTN),--ntn) $(if $(TOKEN),--token $(TOKEN)) --keyfile $$(echo ${DATADIR})/keystore/$(KEYNAME).key
oracle-balance:
@aut account balance $(if $(NTN),--ntn) $(if $(TOKEN),--token $(TOKEN)) --keyfile $$(echo ${DATADIR})/keystore/$(ORACLE_KEYNAME).key
acc-oracle:
@mkdir -p $$(echo ${DATADIR})/keystore
@aut account new --keyfile $$(echo ${DATADIR})/keystore/$(ORACLE_KEYNAME).key
get-oracle-acc:
@aut account info --keyfile $$(echo ${DATADIR})/keystore/$(ORACLE_KEYNAME).key
acc-sign:
@aut account sign-message "I confirm that I own the above address and will use it to take part in on-chain tasks for the Piccadilly Circus Games Competition" --keyfile $$(echo ${DATADIR})/keystore/$(KEYNAME).key --password $(KEYPASS) | tee /dev/tty | grep -o '0x[0-9a-fA-F]*' > $$(echo ${DATADIR})/signs/acc-sign
sign:
@aut account sign-message "I have read and agree to comply with the Piccadilly Circus Games Competition Terms and Conditions published on IPFS with CID QmVghJVoWkFPtMBUcCiqs7Utydgkfe19wkLunhS5t57yEu" --keyfile $$(echo ${DATADIR})/keystore/$(KEYNAME).key --password $(KEYPASS) | tee /dev/tty | grep -o '0x[0-9a-fA-F]*' > $$(echo ${DATADIR})/signs/sign
get-enode:
@aut node info | jq -r '.admin_enode'
get-priv:
@chmod +x ./bin/ethkey
@/bin/bash -c './bin/ethkey inspect --json --private $(ORACLE_KEYFILE)'
save-priv:
@echo "$(PRIVKEY)" >> $(ORACLE_PRIV_KEYFILE)
genOwnershipProof:
@sudo docker run -t -i --volume $$(echo ${DATADIR}):/autonity-chaindata --volume $(ORACLE_PRIV_KEYFILE):/oracle.key --name autonity-proof --rm ghcr.io/autonity/autonity:latest genOwnershipProof --autonitykeys ./autonity-chaindata/autonity/autonitykeys --oraclekey oracle.key $(shell aut account info | jq -r '.[].account')
add-validator:
@sed -i '/^validator=/d' $(USER_HOME)/.autrc
@echo "validator=$$(aut validator compute-address $$(aut node info | jq -r '.admin_enode'))" >> $(USER_HOME)/.autrc
compute:
@aut validator compute-address $(shell aut node info | jq -r '.admin_enode')
@make add-validator
register:
@aut validator register $(shell aut node info | jq -r '.admin_enode') $(shell aut account info --keyfile $$(echo ${DATADIR})/keystore/$(ORACLE_KEYNAME).key | jq -r '.[].account') $(shell jq -r '.ConsensusPublicKey' $$(echo ${DATADIR})/signs/consensus-key) $(shell cat $$(echo ${DATADIR})/signs/proof) | aut tx sign - | aut tx send - | tee /dev/tty | grep -o '0x[0-9a-fA-F]*' > $$(echo ${DATADIR})/signs/register
bond:
@aut validator bond --validator $(shell aut validator compute-address $(shell aut node info | jq -r '.admin_enode')) $(AMOUNT) | aut tx sign - | aut tx send -
unbond:
@aut validator unbond --validator $(shell aut validator compute-address $(shell aut node info | jq -r '.admin_enode')) $(AMOUNT) | aut tx sign - | aut tx send -
get-ckey:
@chmod +x ./bin/ethkey
@/bin/bash -c './bin/ethkey autinspect $(NODEKEY_PATH) --json' | tee $$(echo ${DATADIR})/signs/consensus-key
ckey-test:
@echo $(shell jq -r '.ConsensusPublicKey' $$(echo ${DATADIR})/signs/consensus-key)
list:
@aut validator list | grep $(shell aut validator compute-address $(shell aut node info | jq -r '.admin_enode'))
get-comm:
@aut protocol get-committee | grep $(shell aut validator compute-address $(shell aut node info | jq -r '.admin_enode'))
get-val-list:
aut protocol get-committee \
| jq -r '.[] | [(.voting_power|tonumber / pow(10;18)), .address] | @csv' \
| column -t -s"," | tr -d '"' | sort -k1 -n -r | nl
import:
@echo $(shell head -c 64 $(NODEKEY_PATH)) > $$(echo ${DATADIR})/node.priv
@aut account import-private-key ${DATADIR}/node.priv | tee /dev/tty | awk '{print $$2}' > $$(echo ${DATADIR})/signs/import
sign-onboard:
@aut account sign-message "validator onboarded" --keyfile $(shell cat $$(echo ${DATADIR})/signs/import) --password $(KEYPASS) | tee /dev/tty | grep -o '0x[0-9a-fA-F]*' > $$(echo ${DATADIR})/signs/sign-onboard
sign-rpc:
@aut account sign-message "public rpc" --keyfile $(shell cat $$(echo ${DATADIR})/signs/import) --password $(KEYPASS) | tee /dev/tty | grep -o '0x[0-9a-fA-F]*' > $$(echo ${DATADIR})/signs/sign-rpc
send:
@aut tx make --to $(RECEPIENT) --value $(AMOUNT) $(if $(NTN),--ntn) $(if $(TOKEN),--token $(TOKEN)) | aut tx sign - | aut tx send -
val-info:
@aut validator info
val-pause:
@aut validator pause | aut tx sign - | aut tx send -
val-activate:
@aut validator activate | aut tx sign - | aut tx send -
node-info:
@aut node info
claim:
@aut validator claim-rewards | aut tx sign - | aut tx send -
api:
@chmod +x ./scripts/api.sh
@./scripts/api.sh
usdc-transfer:
@aut token transfer --token 0x3a60C03a86eEAe30501ce1af04a6C04Cf0188700 0x11F62c273dD23dbe4D1713C5629fc35713Aa5a94 $(AMOUNT) | aut tx sign - | aut tx send -
cex-balance:
@https GET https://cax.piccadilly.autonity.org/api/balances/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
get-orderbooks:
@https GET https://cax.piccadilly.autonity.org/api/orderbooks/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
ntn-quote:
@https GET https://cax.piccadilly.autonity.org/api/orderbooks/NTN-USDC/quote API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
atn-quote:
@https GET https://cax.piccadilly.autonity.org/api/orderbooks/ATN-USDC/quote API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
buy-ntn:
@https POST https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') pair=NTN-USDC side=bid price=$(PRICE) amount=$(AMOUNT)
sell-ntn:
@https POST https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') pair=NTN-USDC side=ask price=$(PRICE) amount=$(AMOUNT)
ntn-withdraw:
@https POST https://cax.piccadilly.autonity.org/api/withdraws/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') symbol=NTN amount=$(AMOUNT)
buy-atn:
@https POST https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') pair=ATN-USDC side=bid price=$(PRICE) amount=$(AMOUNT)
sell-atn:
@https POST https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') pair=ATN-USDC side=ask price=$(PRICE) amount=$(AMOUNT)
atn-withdraw:
@https POST https://cax.piccadilly.autonity.org/api/withdraws/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') symbol=ATN amount=$(AMOUNT)
get-orders:
@https GET https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey') | jq '.[] | select(.status=="open")'
get-orders-all:
@https GET https://cax.piccadilly.autonity.org/api/orders/ API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
get-order-id:
@https GET https://cax.piccadilly.autonity.org/api/orders/$(ID) API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
delete-order-id:
@https DELETE https://cax.piccadilly.autonity.org/api/orders/$(ID) API-Key:$(shell cat $$(echo ${DATADIR})/api-key | jq -r '.apikey')
test:
@echo $(shell cat $$(echo ${DATADIR})/signs/proof)
version:
@sudo docker run -t -i --volume $$(echo ${DATADIR}):/autonity-chaindata --name autonity-proof --rm $$(echo ${TAG}) version
oracle-version:
@sudo docker run -t -i --volume $$(echo ${DATADIR}):/autonity-chaindata --name autonity-proof --rm $$(echo ${ORACLE_TAG}) version