Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New healthcheck #547

Merged
merged 52 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0b4fe28
refactor(): rewrite healthcheck `AdmNode`
bludnic Oct 27, 2023
cf43568
feat(Web3): add custom HttpProvider
bludnic Oct 29, 2023
bfa496f
refactor(): rewrite AdmApiClient to TS
bludnic Oct 29, 2023
4f01cfa
refactor(AdmClient): refactor promises
bludnic Oct 29, 2023
2293af5
refactor(AdmClient): add `filterSyncedNodes` helper
bludnic Oct 30, 2023
26e188f
feat(AdmClient): add `isNodeOfflineError` helper
bludnic Oct 30, 2023
085588a
feat: add healthcheck for ETH nodes
bludnic Oct 31, 2023
a6bf360
feat: add healthcheck for BTC nodes
bludnic Nov 1, 2023
c97f916
feat: add healthcheck for DOGE and DASH nodes
bludnic Nov 1, 2023
71869e3
feat(abstract.node): provider current `height`
bludnic Nov 1, 2023
56ad0b0
feat: add healthcheck for LSK nodes
bludnic Nov 1, 2023
3f530d6
fix(Nodes): use default minNodeVersion
bludnic Nov 1, 2023
7f56cfe
feat(Nodes): increase healthcheck interval
bludnic Nov 1, 2023
fbbd257
fix(Nodes): check health immediately when navigate to Nodes page
bludnic Nov 1, 2023
96f6eab
feat(NodeTable): add blockchain label
bludnic Nov 2, 2023
f7fd9eb
refactor(`EthNode`): use `HttpProvider` from `web3-providers-http`
bludnic Nov 2, 2023
5201c0e
refactor(`AdmClient`): remove unused method
bludnic Nov 2, 2023
16f15fe
refactor(`AdmClient`): fix minNodeVersion
bludnic Nov 2, 2023
efa74b4
feat(NodesTable): add additional info to node status
bludnic Nov 2, 2023
160cad8
refactor(AdmClient): remove unused import
bludnic Nov 2, 2023
e07065d
fix(locales, ru): change "unsupported_reason_protocol"
bludnic Nov 2, 2023
a5e75a6
fix(locales, en): uppercase http "unsupported_reason_protocol"
bludnic Nov 2, 2023
a4bf233
fix(nodes): add union type for Node.protocol
bludnic Nov 2, 2023
1d5f072
refactor(AdmNode): add generic type to request response
bludnic Nov 2, 2023
6657380
refactor(nodes): remove .ts extension
bludnic Nov 2, 2023
9513c16
refactor(NodesTableItem): move NodeType enum to ``@/lib/nodes/types`
bludnic Nov 2, 2023
efc470f
refactor(nodes): add `createBtcLikeClient` helper
bludnic Nov 2, 2023
648912c
refactor(nodes, Vuex): dry
bludnic Nov 2, 2023
fc4be08
refactor(store, nodes): dry
bludnic Nov 3, 2023
5054db2
fix(NodesTable): reposition node status label
bludnic Nov 6, 2023
2b46248
fix(ADM node): set initial node `version` as `minNodeVersion` until r…
bludnic Nov 8, 2023
0c6f5d0
refactor(NodesTable): split component into `NodesStatus` and `SocketS…
bludnic Nov 8, 2023
40c7758
refactor(NodesTable): meaningful class names
bludnic Nov 8, 2023
2cfbc21
refactor(NodesTableItem): remove unused import
bludnic Nov 8, 2023
956a270
refactor(NodesTable): decompose into `NodeVersion` component
bludnic Nov 8, 2023
083d3a7
feat(NodesTable): display node height
bludnic Nov 8, 2023
0d11758
refactor(nodes): rename `BlockchainLabel` -> `NodeLabel`
bludnic Nov 9, 2023
2b92f82
refactor(nodes): reuse `NodesTable` and `NodesTableHead`
bludnic Nov 9, 2023
b40427b
feat(nodes): add "Type" column
bludnic Nov 9, 2023
2b99752
refactor(nodes): reuse `NodeColumn` component
bludnic Nov 9, 2023
e44010e
refactor(nodes): reuse `NodeStatusCheckbox` component
bludnic Nov 9, 2023
f10169d
feat: add Coin nodes
bludnic Nov 9, 2023
9cf3318
fix(Coin nodes): align label to right
bludnic Nov 9, 2023
3adb039
feat: add node type labels
bludnic Nov 9, 2023
05fa815
fix(NodesTable): decrease label column size
bludnic Nov 9, 2023
dcff8a4
feat(nodes): pass label to node instance
bludnic Nov 9, 2023
4cdcb44
feat(NodesTable): sort coin nodes
bludnic Nov 9, 2023
5db1350
Merge branch 'dev' into feat/new-healthcheck
bludnic Nov 9, 2023
c4a9a5c
fix(BtcNode): missing height
bludnic Nov 10, 2023
7e1766b
refactor(btc-base-api): remove unused code
bludnic Nov 10, 2023
15310d7
feat(NodesTable): show cube icon before node height
bludnic Nov 11, 2023
a999eeb
Merge branch 'dev' into feat/new-healthcheck
bludnic Nov 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@
"vuetify": "^3.3.17",
"vuex": "^4.1.0",
"vuex-persist": "^3.1.3",
"web3-errors": "^1.1.3",
"web3-eth": "^4.2.0",
"web3-eth-abi": "^4.1.3",
"web3-eth-accounts": "^4.0.6",
"web3-eth-contract": "^4.1.0",
"web3-providers-http": "^4.1.0",
"web3-utils": "^4.0.6"
},
"devDependencies": {
Expand Down
30 changes: 30 additions & 0 deletions src/components/NodesTable/BlockchainLabel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<v-chip :class="className" label>{{ label }}</v-chip>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

const className = 'blockchain-label'

export default defineComponent({
props: {
label: {
type: String,
required: true
}
},
setup() {
return {
className
}
}
})
</script>

<style lang="scss" scoped>
.blockchain-label {
--v-chip-height: 18px;
padding: 0 4px;
}
</style>
23 changes: 19 additions & 4 deletions src/components/NodesTable/NodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<nodes-table-head />

<tbody>
<nodes-table-item v-for="node in nodes" :key="node.name" :node="node" />
<nodes-table-item v-for="node in admNodes" :key="node.url" blockchain="adm" :node="node" />
<nodes-table-item v-for="node in ethNodes" :key="node.url" blockchain="eth" :node="node" />
<nodes-table-item v-for="node in btcNodes" :key="node.url" blockchain="btc" :node="node" />
<nodes-table-item v-for="node in dogeNodes" :key="node.url" blockchain="doge" :node="node" />
<nodes-table-item v-for="node in dashNodes" :key="node.url" blockchain="dash" :node="node" />
<nodes-table-item v-for="node in lskNodes" :key="node.url" blockchain="lsk" :node="node" />
</tbody>
</v-table>
</template>
Expand All @@ -21,8 +26,8 @@ export default defineComponent({
},
setup() {
const store = useStore()
const nodes = computed(() => {
const arr = store.getters['nodes/list']
const admNodes = computed(() => {
const arr = store.getters['nodes/adm']

return [...arr].sort((a, b) => {
if (/^http:\/\//.test(a.url) || /^http:\/\//.test(b.url)) {
Expand All @@ -32,14 +37,24 @@ export default defineComponent({
return a.url > b.url ? 1 : b.url > a.url ? -1 : 0
})
})
const ethNodes = computed(() => store.getters['nodes/eth'])
const btcNodes = computed(() => store.getters['nodes/btc'])
const dogeNodes = computed(() => store.getters['nodes/doge'])
const dashNodes = computed(() => store.getters['nodes/dash'])
const lskNodes = computed(() => store.getters['nodes/lsk'])

const className = 'nodes-table'
const classes = {
root: className
}

return {
nodes,
admNodes,
ethNodes,
btcNodes,
dogeNodes,
dashNodes,
lskNodes,
classes
}
}
Expand Down
90 changes: 67 additions & 23 deletions src/components/NodesTable/NodesTableItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@
:model-value="active"
:class="[classes.checkbox, classes.statusIconGrey]"
@input="toggleActiveStatus"
:disabled="blockchain !== 'adm'"
/>
</td>

<td :class="classes.td" class="pl-0 pr-2">
{{ url }}
<blockchain-label v-if="blockchain !== 'adm'" :label="blockchain" />
<div v-if="version" :class="classes.version">
{{ 'v' + version }}
</div>
</td>

<td :class="classes.td" class="pl-0 pr-2">
<span>
<td :class="classes.td" class="pl-0 pr-2" :colspan="unsupported ? 2 : 1">
<div :class="classes.status">
{{ nodeStatus }}
</span>
<v-icon
:class="{
[classes.statusIcon]: true,
[classes.statusIconGreen]: nodeStatusColor === 'green',
[classes.statusIconRed]: nodeStatusColor === 'red',
[classes.statusIconOrange]: nodeStatusColor === 'orange',
[classes.statusIconGrey]: nodeStatusColor === 'grey'
}"
:color="nodeStatusColor"
icon="mdi-checkbox-blank-circle"
size="small"
/>
<v-icon
:class="{
[classes.statusIcon]: true,
[classes.statusIconGreen]: nodeStatusColor === 'green',
bludnic marked this conversation as resolved.
Show resolved Hide resolved
[classes.statusIconRed]: nodeStatusColor === 'red',
[classes.statusIconOrange]: nodeStatusColor === 'orange',
[classes.statusIconGrey]: nodeStatusColor === 'grey'
}"
:color="nodeStatusColor"
icon="mdi-checkbox-blank-circle"
size="small"
/>
</div>
<span v-if="nodeStatusReason" :class="classes.statusSubtitle">{{ nodeStatusReason }}</span>
</td>

<td :class="classes.td" class="pl-0 pr-2">
<td v-if="!unsupported" :class="classes.td" class="pl-0 pr-2">
<v-icon
:icon="socketSupport ? 'mdi-check' : 'mdi-close'"
:class="socketSupport ? classes.statusIconGreen : classes.statusIconRed"
Expand All @@ -48,12 +51,16 @@
</tr>
</template>

<script>
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
<script lang="ts">
import { computed, PropType } from 'vue'
import { useI18n, type VueI18nTranslation } from 'vue-i18n'
import { useStore } from 'vuex'
import type { NodeStatusResult } from '@/lib/nodes/abstract.node'
import type { NodeType } from '@/lib/nodes/types'

function getNodeStatus(node, t) {
import BlockchainLabel from './BlockchainLabel.vue'

function getNodeStatus(node: NodeStatusResult, t: VueI18nTranslation) {
if (!node.hasMinNodeVersion || !node.hasSupportedProtocol) {
return t('nodes.unsupported')
} else if (!node.active) {
Expand All @@ -67,7 +74,15 @@ function getNodeStatus(node, t) {
return node.ping + ' ' + t('nodes.ms')
}

function getNodeStatusColor(node) {
function getNodeStatusReason(node: NodeStatusResult, t: VueI18nTranslation) {
if (!node.hasMinNodeVersion) {
return t('nodes.unsupported_reason_api_version')
} else if (!node.hasSupportedProtocol) {
return t('nodes.unsupported_reason_protocol')
}
}

function getNodeStatusColor(node: NodeStatusResult) {
let color = 'green'

if (!node.hasMinNodeVersion || !node.hasSupportedProtocol) {
Expand All @@ -84,9 +99,14 @@ function getNodeStatusColor(node) {
}

export default {
components: { BlockchainLabel },
props: {
node: {
type: Object,
type: Object as PropType<NodeStatusResult>,
required: true
},
blockchain: {
type: String as PropType<NodeType>,
required: true
}
},
Expand All @@ -100,6 +120,8 @@ export default {
td: `${className}__td`,
checkbox: `${className}__checkbox`,
version: `${className}__version`,
status: `${className}__status`,
statusSubtitle: `${className}__status-subtitle`,
statusIcon: `${className}__status-icon`,
statusIconGreen: `${className}__status-icon--green`,
statusIconRed: `${className}__status-icon--red`,
Expand All @@ -114,8 +136,13 @@ export default {
const socketSupport = computed(() => props.node.socketSupport)

const nodeStatus = computed(() => getNodeStatus(props.node, t))
const nodeStatusReason = computed(() => getNodeStatusReason(props.node, t))
const nodeStatusColor = computed(() => getNodeStatusColor(props.node))

const unsupported = computed(
() => !props.node.hasMinNodeVersion || !props.node.hasSupportedProtocol || !props.node.online
)

const toggleActiveStatus = () => {
store.dispatch('nodes/toggle', {
url: url.value,
Expand All @@ -131,8 +158,10 @@ export default {
active,
socketSupport,
nodeStatus,
nodeStatusReason,
toggleActiveStatus,
nodeStatusColor
nodeStatusColor,
unsupported
}
}
}
Expand All @@ -150,9 +179,17 @@ export default {
&__version {
@include a-text-explanation-small();
}
&__status {
line-height: 17px;
display: flex;
}
&__status-icon {
margin-inline-start: 4px;
}
&__status-subtitle {
font-size: 12px;
font-weight: 300;
}
&__td-checkbox {
width: 64px;
max-width: 64px;
Expand Down Expand Up @@ -183,6 +220,9 @@ export default {
&__td {
color: map-get($adm-colors, 'regular');
}
&__status-subtitle {
color: map-get($adm-colors, 'regular');
}
&__status-icon {
&--green {
color: map-get($adm-colors, 'good') !important;
Expand All @@ -205,6 +245,10 @@ export default {
&__version {
opacity: 0.7;
}
&__status-subtitle {
color: map-get($shades, 'white');
opacity: 0.7;
}
&__status-icon {
&--green {
color: map-get($adm-colors, 'good') !important;
Expand Down
Loading