Skip to content

Commit ad35154

Browse files
yakizaDionysi Ntreou
andauthored
Code refactor part 1 (erigontech#15)
* cmd package refactor, contains wiring up and exec * api layer (rest etc) * introduction of session logic, and decoupling * erigon node client service * general file/dir cleaning, Docker, Make and semantic erroring * git add all for any missed * use of bridge middleware and removal of break line * Update main.go * Update helpers.go * Update ui_handler.go * Update helpers.go --------- Co-authored-by: Dionysi Ntreou <[email protected]>
1 parent bb46f8b commit ad35154

Some content is hidden

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

58 files changed

+1649
-1072
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
1616

17-
diagnostics
1817

1918
# IDE configuration
2019
.idea

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.20-alpine
2+
3+
WORKDIR /app
4+
5+
RUN export GO111MODULE=on
6+
COPY go.mod ./
7+
COPY go.sum ./
8+
RUN go mod download
9+
10+
COPY . .
11+
12+
WORKDIR /app/cmd/diagnostics
13+
14+
RUN go build -o /
15+
16+
EXPOSE 8080
17+
18+
CMD ["/diagnostics"]

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BINARY_NAME := diagnostics
2+
BUILD_DIR := ./_bin
3+
DOCKER_IMAGE_NAME := diagnostics
4+
DOCKER_CONTAINER_NAME := diagnostics_container
5+
6+
build:
7+
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/diagnostics
8+
9+
test:
10+
go test ./...
11+
12+
run:
13+
go run ./cmd/diagnostics/main.go
14+
15+
clean:
16+
rm -rf $(BUILD_DIR)
17+
18+
build-docker:
19+
docker build -t $(DOCKER_IMAGE_NAME) .
20+
21+
run-docker:
22+
docker run -p 8080:8080 --name $(DOCKER_CONTAINER_NAME) $(DOCKER_IMAGE_NAME)
23+
24+
.PHONY: build test run clean

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ If metrics are exposed, textual representation of metrics will be displayed in t
183183
First, in the browser window, create a new operator session. Choose an arbitrary name. In real operations, one would choose the name
184184
that can be easily correlate to the node being supported, for example, name or pseudonym of the person or the company operating the node.
185185

186-
![create new operation session](/images/create_new_session.png)
186+
![create new operation session](/_images/create_new_session.png)
187187

188188
After new session is created, it will be allocated a unique 8-digit PIN number. The pin is then displayed together with the session number on the screen.
189189
Currently, generation of PIN numbers is not secure and always follows the same sequence, which makes testing easier. For example, the first
@@ -212,7 +212,7 @@ diagnostics system, start with `/support/` prefix, followed by the PIN of the se
212212
Operators (those who are trying to assist the Erigon node users) also access Diagnostics system, but in the form of User Interface, built using HTML
213213
and Javascript. The URLs used for such access, start with `ui/` prefix. In the code inside `cmd/root.go`, this corresponds to the `UiHandler` type.
214214

215-
![diagnostics system architecture](/images/diagnostics.drawio.png)
215+
![diagnostics system architecture](/_images/diagnostics.drawio.png)
216216

217217
# Currently implemented diagnostics
218218

@@ -224,7 +224,7 @@ The code on the side of the diagnostics system is spread across files `cmd/ui_ha
224224
the javascript handler), `assets/script/session.js` (function `fetchContent`), `assets/template/versions.html` (html template
225225
for the content fetched by the `fetchContent` javascript function and inserted into the HTML div element).
226226

227-
![versions](/images/versions.png)
227+
![versions](/_images/versions.png)
228228

229229
## Command line arguments
230230

@@ -234,14 +234,14 @@ The code on the side of the diagnostics system is spread across files `cmd/ui_ha
234234
the javascript handler), `assets/script/session.js` (function `fetchContent`), `assets/template/cmd_line.html` (html template
235235
for the content fetched by the `fetchContent` javascript function and inserted into the HTML div element).
236236

237-
![cmd line](/images/cmd_line.png)
237+
![cmd line](/_images/cmd_line.png)
238238

239239
## Flags
240240
Operator can look at the flags that are set in cli context by the user to launch Erigon node. The corresponding code in Erigon is in the file `diagnostics/flags.go`. This is particularly useful when user launches Erigon using a config file with `--config` and [Command line arguments](#command-line-arguments) cannot fully capture the true state of the 'launch setting'. The returned flags are the result after parsing command line argument and config file by Erigon.
241241

242242
The code on the side of the diagnostics system is spread across files `cmd/ui_handler.go` (invocation of `processFlags` function), `cmd/flags.go`, `assets/template/session.html` (html template the part where the button `Fetch Flags` is defined with the javascript handler), `assets/script/session.js` (function `fetchContent`), `assets/template/flags.html` (html template for the content fetched by the `fetchContent` javascript function and inserted into the HTML div element).
243243

244-
![flags](/images/flags.png)
244+
![flags](/_images/flags.png)
245245

246246

247247
## Logs
@@ -257,7 +257,7 @@ for the content fetched by the `fetchContent` javascript function and inserted i
257257
for the buttons `Head`, `Tail` and `Clear` with the invocations of `fetchLogPart` and `clearLog` javascript functions, as well as construction of the
258258
HTML link that activates the download of a log file). The download of a log file is implemented by the `transmitLogFile` function inside `cmd/logs.go`.
259259

260-
![logs](/images/logs.png)
260+
![logs](/_images/logs.png)
261261

262262
## Reorg scanner
263263

@@ -277,7 +277,7 @@ in file `assets/script/session.js`, which appends them to `innerHTML` field of t
277277
progress of the scanning for reorgs (with spacer html pieces, one for each 1000 blocks), and showing intermediate results of the scan (with block html pieces,
278278
one for each reorged block found).
279279

280-
![scan reorgs](/images/scan_reorgs.png)
280+
![scan reorgs](/_images/scan_reorgs.png)
281281

282282
## Sync stages
283283

@@ -289,7 +289,7 @@ The code on the side of the diagnostics system is spread across files `cmd/ui_ha
289289
(HTML template the part where the button `Fetch Sync Stages` is defined with the javascript handler), `assets/script/session.js` (function `fetchContent`), `assets/template/sync_stages.html`
290290
(HTML template for the content fetched by the `fetchContent` javascript function and inserted into the HTML table).
291291

292-
![sync_stage](/images/sync_stages.png)
292+
![sync_stage](/_images/sync_stages.png)
293293

294294
## Block Body Download
295295

@@ -306,7 +306,7 @@ consumed by the javascript function `bodiesDownload` in the `assets/script/sessi
306306
whenever the new HTML piece is available.
307307
Each state is represented by a distinct colour, with the colour legend is also defined in the template file.
308308

309-
![body download](/images/body_download.png)
309+
![body download](/_images/body_download.png)
310310

311311
# Ideas for possible improvements
312312

0 commit comments

Comments
 (0)