Skip to content

Commit 97c73b5

Browse files
authored
BM-229: Broker Grafana (github#63)
This PR: * Adds broker DB data to grafana and a sample dashboard * Fixes a number of issues with the sccache builds for broker/exec_agent/rest_api * Improves rebuild times of docker containers - NOTE this still is not as fast as I would like and I might add `./target` cache mounts later in addition to sccache or just switch to directory cache mounts since sccache might not be ideal for docker builds. closes BM-229
1 parent 176475f commit 97c73b5

File tree

8 files changed

+268
-19
lines changed

8 files changed

+268
-19
lines changed

.env-compose

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ GRAFANA_IMG=grafana/grafana:11.0.0
2121

2222
PRIVATE_KEY=0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
2323

24-
PROOF_MARKET_ADDR=0x261D8c5e9742e6f7f1076Fa1F560894524e19cad
25-
SET_VERIFIER_ADDR=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
24+
PROOF_MARKET_ADDR=0xCE3478A9E0167a6Bc5716DC39DbbbfAc38F27623
25+
SET_VERIFIER_ADDR=0x261D8c5e9742e6f7f1076Fa1F560894524e19cad
2626

2727
SEGMENT_SIZE=20
2828
RPC_URL="http://localhost:8545"

compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ services:
5555
- POSTGRES_DB=${POSTGRES_DB}
5656
- POSTGRES_USER=${POSTGRES_USER}
5757
- POSTGRES_PASS=${POSTGRES_PASSWORD}
58+
- GF_INSTALL_PLUGINS=frser-sqlite-datasource
5859
volumes:
5960
- ./dockerfiles/grafana:/etc/grafana/provisioning/
6061
- grafana-data:/var/lib/grafana
62+
- broker-data:/db
6163
depends_on:
6264
- postgres
6365
- redis
@@ -245,6 +247,10 @@ services:
245247
source: ./broker.toml
246248
target: /app/broker.toml
247249
- broker-data:/db/
250+
# uncomment for local testing of broker in compose
251+
# - type: bind
252+
# source: ./target/
253+
# target: /target/
248254

249255
network_mode: host
250256

dockerfiles/agent.dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,24 @@ ENV NVCC_APPEND_FLAGS=${NVCC_APPEND_FLAGS}
3636
ENV RISC0_CUDA_OPT=${CUDA_OPT_LEVEL}
3737

3838
COPY ./dockerfiles/sccache-setup.sh .
39-
RUN ./sccache-setup.sh "x86_64-unknown-linux-musl" "v0.8.1"
39+
RUN ./sccache-setup.sh "x86_64-unknown-linux-musl" "v0.8.2"
4040
COPY ./dockerfiles/sccache-config.sh .
4141
SHELL ["/bin/bash", "-c"]
4242

43+
# Consider using if building and running on the same CPU
44+
# ENV RUSTFLAGS="-C target-cpu=native"
45+
46+
# Prevent sccache collision in compose-builds
47+
ENV SCCACHE_SERVER_PORT=4226
48+
4349
# This downloads and setups the rust-toolchain so docker can cache the layer
4450
RUN cargo
4551

46-
# Consider using if building and running on the same CPU
47-
# ENV RUSTFLAGS="-C target-cpu=native"
4852

4953
RUN \
50-
--mount=type=cache,target=/root/.cache/sccache/,id=bndlss_agent_sccache \
51-
--mount=type=cache,target=/usr/local/cargo/git/db \
52-
--mount=type=cache,target=/usr/local/cargo/registry/ \
54+
--mount=type=cache,target=/root/.cache/sccache/,id=bndlss_agent_sc \
5355
source ./sccache-config.sh && \
56+
ls /root/.cache/sccache/ && \
5457
cargo build --release -F cuda -p workflow --bin agent && \
5558
cp /src/target/release/agent /src/agent
5659

dockerfiles/broker.dockerfile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ RUN apt-get -qq update && \
44
apt-get install -y -q clang
55

66
COPY ./dockerfiles/sccache-setup.sh .
7-
RUN ./sccache-setup.sh "x86_64-unknown-linux-musl" "v0.8.1"
7+
RUN ./sccache-setup.sh "x86_64-unknown-linux-musl" "v0.8.2"
88
COPY ./dockerfiles/sccache-config.sh .
99
SHELL ["/bin/bash", "-c"]
1010

1111
RUN curl -L https://foundry.paradigm.xyz | bash && \
1212
source /root/.bashrc && \
1313
foundryup
1414

15-
# RUN curl -L https://risczero.com/install | bash
15+
# Prevent sccache collision in compose-builds
16+
ENV SCCACHE_SERVER_PORT=4227
17+
18+
RUN cargo
19+
1620
RUN \
17-
# --mount=type=cache,target=/root/.cache/sccache/,id=bndlss_broker_sccache \
18-
# --mount=type=cache,target=/usr/local/cargo/git/db \
19-
# --mount=type=cache,target=/usr/local/cargo/registry/ \
20-
# source ./sccache-config.sh && \
21+
--mount=type=cache,target=/root/.cache/sccache/,id=bndlss_broker_sc \
22+
source ./sccache-config.sh && \
23+
ls /root/.cache/sccache/ && \
2124
cargo install --version 1.6.9 cargo-binstall && \
2225
cargo binstall -y --force cargo-risczero --version 1.1 && \
2326
cargo risczero install
@@ -38,7 +41,15 @@ COPY foundry.toml .
3841
ENV PATH="$PATH:/root/.foundry/bin"
3942
RUN forge build
4043

44+
RUN cargo
45+
46+
# Prevent sccache collision in compose-builds
47+
ENV SCCACHE_SERVER_PORT=4227
48+
4149
RUN \
50+
--mount=type=cache,target=/root/.cache/sccache/,id=bndlss_broker_sc \
51+
source /sccache-config.sh && \
52+
ls /root/.cache/sccache/ && \
4253
cargo build --release --bin broker && \
4354
cp /src/target/release/broker /src/broker
4455

dockerfiles/grafana/dashboards/demo.json renamed to dockerfiles/grafana/dashboards/bento.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@
661661
"timeRangeUpdatedDuringEditOrView": false,
662662
"timepicker": {},
663663
"timezone": "browser",
664-
"title": "Demo",
664+
"title": "Bento",
665665
"uid": "ddolqpj8f47wgd",
666666
"version": 1,
667667
"weekStart": ""
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": {
7+
"type": "grafana",
8+
"uid": "-- Grafana --"
9+
},
10+
"enable": true,
11+
"hide": true,
12+
"iconColor": "rgba(0, 211, 255, 1)",
13+
"name": "Annotations & Alerts",
14+
"type": "dashboard"
15+
}
16+
]
17+
},
18+
"description": "Batch and Order status monitoring",
19+
"editable": true,
20+
"fiscalYearStartMonth": 0,
21+
"graphTooltip": 0,
22+
"id": 2,
23+
"links": [],
24+
"panels": [
25+
{
26+
"datasource": {
27+
"type": "frser-sqlite-datasource",
28+
"uid": "fe164ybfwsdmod"
29+
},
30+
"fieldConfig": {
31+
"defaults": {
32+
"color": {
33+
"mode": "thresholds"
34+
},
35+
"custom": {
36+
"align": "auto",
37+
"cellOptions": {
38+
"type": "auto"
39+
},
40+
"inspect": false
41+
},
42+
"mappings": [],
43+
"thresholds": {
44+
"mode": "absolute",
45+
"steps": [
46+
{
47+
"color": "green",
48+
"value": null
49+
},
50+
{
51+
"color": "red",
52+
"value": 80
53+
}
54+
]
55+
}
56+
},
57+
"overrides": []
58+
},
59+
"gridPos": {
60+
"h": 7,
61+
"w": 24,
62+
"x": 0,
63+
"y": 0
64+
},
65+
"id": 1,
66+
"options": {
67+
"cellHeight": "sm",
68+
"footer": {
69+
"countRows": false,
70+
"fields": "",
71+
"reducer": [
72+
"sum"
73+
],
74+
"show": false
75+
},
76+
"showHeader": true
77+
},
78+
"pluginVersion": "11.0.0",
79+
"targets": [
80+
{
81+
"datasource": {
82+
"type": "frser-sqlite-datasource",
83+
"uid": "fe164ybfwsdmod"
84+
},
85+
"queryText": "SELECT\n id,\n data->>'status' as status,\n data->>'target_block' as target_lockin_block,\n data->>'expire_block' as expire_block,\n data->>'error_msg' as error_msg\nFROM orders;",
86+
"queryType": "table",
87+
"rawQueryText": "SELECT\n id,\n data->>'status' as status,\n data->>'target_block' as target_lockin_block,\n data->>'expire_block' as expire_block,\n data->>'error_msg' as error_msg\nFROM orders;",
88+
"refId": "A",
89+
"timeColumns": [
90+
"time",
91+
"ts"
92+
]
93+
}
94+
],
95+
"title": "Panel Title",
96+
"type": "table"
97+
},
98+
{
99+
"datasource": {
100+
"type": "frser-sqlite-datasource",
101+
"uid": "fe164ybfwsdmod"
102+
},
103+
"fieldConfig": {
104+
"defaults": {
105+
"color": {
106+
"mode": "thresholds"
107+
},
108+
"custom": {
109+
"align": "auto",
110+
"cellOptions": {
111+
"type": "auto"
112+
},
113+
"inspect": false
114+
},
115+
"mappings": [],
116+
"thresholds": {
117+
"mode": "absolute",
118+
"steps": [
119+
{
120+
"color": "green",
121+
"value": null
122+
},
123+
{
124+
"color": "red",
125+
"value": 80
126+
}
127+
]
128+
}
129+
},
130+
"overrides": []
131+
},
132+
"gridPos": {
133+
"h": 7,
134+
"w": 24,
135+
"x": 0,
136+
"y": 7
137+
},
138+
"id": 2,
139+
"options": {
140+
"cellHeight": "sm",
141+
"footer": {
142+
"countRows": false,
143+
"fields": "",
144+
"reducer": [
145+
"sum"
146+
],
147+
"show": false
148+
},
149+
"showHeader": true
150+
},
151+
"pluginVersion": "11.0.0",
152+
"targets": [
153+
{
154+
"datasource": {
155+
"type": "frser-sqlite-datasource",
156+
"uid": "fe164ybfwsdmod"
157+
},
158+
"queryText": "SELECT\n id,\n data->>'status' as status,\n json_array_length(data->'orders') as order_count,\n data->>'fees' as fees_wei,\n data->>'orders', data->>'error_msg' as error_msg\nFROM batches;",
159+
"queryType": "table",
160+
"rawQueryText": "SELECT\n id,\n data->>'status' as status,\n json_array_length(data->'orders') as order_count,\n data->>'fees' as fees_wei,\n data->>'orders', data->>'error_msg' as error_msg\nFROM batches;",
161+
"refId": "A",
162+
"timeColumns": [
163+
"time",
164+
"ts"
165+
]
166+
}
167+
],
168+
"title": "Panel Title",
169+
"transformations": [
170+
{
171+
"id": "convertFieldType",
172+
"options": {
173+
"conversions": [
174+
{
175+
"destinationType": "number",
176+
"targetField": "fees"
177+
}
178+
],
179+
"fields": {}
180+
}
181+
},
182+
{
183+
"id": "calculateField",
184+
"options": {
185+
"alias": "fees_eth",
186+
"binary": {
187+
"left": "fees_wei",
188+
"operator": "/",
189+
"right": "1000000000000000000"
190+
},
191+
"mode": "binary",
192+
"reduce": {
193+
"reducer": "sum"
194+
},
195+
"replaceFields": false
196+
}
197+
}
198+
],
199+
"type": "table"
200+
}
201+
],
202+
"schemaVersion": 39,
203+
"tags": [],
204+
"templating": {
205+
"list": []
206+
},
207+
"time": {
208+
"from": "now-3h",
209+
"to": "now"
210+
},
211+
"timeRangeUpdatedDuringEditOrView": false,
212+
"timepicker": {},
213+
"timezone": "browser",
214+
"title": "Broker Status",
215+
"uid": "be16ar182rzswa",
216+
"version": 1,
217+
"weekStart": ""
218+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: broker-sqlite-datasource
5+
type: frser-sqlite-datasource
6+
access: proxy
7+
isDefault: false
8+
editable: true
9+
jsonData:
10+
path: /db/broker.db

dockerfiles/rest_api.dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ RUN ./sccache-setup.sh "x86_64-unknown-linux-musl" "v0.8.1"
1616
COPY ./dockerfiles/sccache-config.sh .
1717
SHELL ["/bin/bash", "-c"]
1818

19+
# Prevent sccache collision in compose-builds
20+
ENV SCCACHE_SERVER_PORT=4228
21+
1922
RUN cargo
2023

2124
RUN \
22-
# --mount=type=cache,target=/root/.cache/sccache/,id=bndlss_api_sccache \
23-
# --mount=type=cache,target=/usr/local/cargo/git/db \
24-
# --mount=type=cache,target=/usr/local/cargo/registry/ \
25-
# source ./sccache-config.sh && \
25+
--mount=type=cache,target=/root/.cache/sccache/,id=bndlss_api_sccache \
26+
source ./sccache-config.sh && \
2627
cargo build --release -p api --bin rest_api && \
2728
cp /src/target/release/rest_api /src/rest_api
2829

0 commit comments

Comments
 (0)