forked from cerc-io/cosmos-explorer
improve concensus and uptime
This commit is contained in:
parent
3dc24113e8
commit
1ff6568d74
@ -195,12 +195,13 @@ export function consensusPubkeyToHexAddress(consensusPubkey) {
|
|||||||
let raw = null
|
let raw = null
|
||||||
if (typeof consensusPubkey === 'object') {
|
if (typeof consensusPubkey === 'object') {
|
||||||
if (consensusPubkey['@type'] === '/cosmos.crypto.ed25519.PubKey') {
|
if (consensusPubkey['@type'] === '/cosmos.crypto.ed25519.PubKey') {
|
||||||
raw = toBase64(fromHex(toHex(sha256(fromBase64(consensusPubkey.key))).slice(0, 40)))
|
// raw = toBase64(fromHex(toHex(sha256(fromBase64(consensusPubkey.key))).slice(0, 40)))
|
||||||
|
raw = toHex(sha256(fromBase64(consensusPubkey.key))).slice(0, 40).toUpperCase()
|
||||||
return raw
|
return raw
|
||||||
}
|
}
|
||||||
// /cosmos.crypto.secp256k1.PubKey
|
// /cosmos.crypto.secp256k1.PubKey
|
||||||
if (consensusPubkey['@type'] === '/cosmos.crypto.secp256k1.PubKey') {
|
if (consensusPubkey['@type'] === '/cosmos.crypto.secp256k1.PubKey') {
|
||||||
raw = toBase64(fromHex(new RIPEMD160().update(Buffer.from(sha256(fromBase64(consensusPubkey.key)))).digest('hex')))
|
raw = new RIPEMD160().update(Buffer.from(sha256(fromBase64(consensusPubkey.key)))).digest('hex')
|
||||||
return raw
|
return raw
|
||||||
}
|
}
|
||||||
if (consensusPubkey.type === 'tendermint/PubKeySecp256k1') {
|
if (consensusPubkey.type === 'tendermint/PubKeySecp256k1') {
|
||||||
|
@ -26,19 +26,64 @@
|
|||||||
{{ httpstatus }}: {{ httpStatusText }}
|
{{ httpstatus }}: {{ httpStatusText }}
|
||||||
</div>
|
</div>
|
||||||
</b-card>
|
</b-card>
|
||||||
|
<b-row v-if="roundState['height/round/step']">
|
||||||
|
<b-col
|
||||||
|
lg="3"
|
||||||
|
sm="6"
|
||||||
|
>
|
||||||
|
<dashboard-card-horizontal
|
||||||
|
icon="ArrowUpCircleIcon"
|
||||||
|
color="danger"
|
||||||
|
|
||||||
|
:statistic="rate"
|
||||||
|
statistic-title="Onboard Rate"
|
||||||
|
/>
|
||||||
|
</b-col>
|
||||||
|
<b-col
|
||||||
|
lg="3"
|
||||||
|
sm="6"
|
||||||
|
>
|
||||||
|
<dashboard-card-horizontal
|
||||||
|
icon="HashIcon"
|
||||||
|
color="success"
|
||||||
|
:statistic="height"
|
||||||
|
statistic-title="Height"
|
||||||
|
/>
|
||||||
|
</b-col>
|
||||||
|
<b-col
|
||||||
|
lg="3"
|
||||||
|
sm="6"
|
||||||
|
>
|
||||||
|
<dashboard-card-horizontal
|
||||||
|
icon="RepeatIcon"
|
||||||
|
:statistic="round"
|
||||||
|
statistic-title="Round"
|
||||||
|
/>
|
||||||
|
</b-col>
|
||||||
|
<b-col
|
||||||
|
lg="3"
|
||||||
|
sm="6"
|
||||||
|
>
|
||||||
|
<dashboard-card-horizontal
|
||||||
|
icon="CodeIcon"
|
||||||
|
color="info"
|
||||||
|
:statistic="step"
|
||||||
|
statistic-title="Step"
|
||||||
|
/>
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
<b-card v-if="roundState['height/round/step']">
|
<b-card v-if="roundState['height/round/step']">
|
||||||
<b-card-title class="d-flex justify-content-between">
|
<b-card-title class="d-flex justify-content-between">
|
||||||
<span>Height/Round/Step: {{ roundState['height/round/step'] }}</span>
|
|
||||||
<small class="text-danger">Updated at {{ format(updatetime) }}</small>
|
<small class="text-danger">Updated at {{ format(updatetime) }}</small>
|
||||||
</b-card-title>
|
</b-card-title>
|
||||||
<div
|
<div
|
||||||
v-for="item in roundState.height_vote_set"
|
v-for="item in roundState.height_vote_set"
|
||||||
:key="item.round"
|
:key="item.round"
|
||||||
>
|
>
|
||||||
Round: {{ item.round }} {{ item.precommits_bit_array }}
|
Round: {{ item.round }} {{ item.prevotes_bit_array }}
|
||||||
<b-card-body class="px-0">
|
<b-card-body class="px-0">
|
||||||
<b-button
|
<b-button
|
||||||
v-for="(pre, i) in item.precommits"
|
v-for="(pre, i) in item.prevotes"
|
||||||
:key="i"
|
:key="i"
|
||||||
size="sm"
|
size="sm"
|
||||||
style="margin: 2px;"
|
style="margin: 2px;"
|
||||||
@ -76,7 +121,9 @@
|
|||||||
Tips
|
Tips
|
||||||
</h4>
|
</h4>
|
||||||
<div class="alert-body">
|
<div class="alert-body">
|
||||||
<span>If you want to change the default rpc endpoint. make sure that "https" and "CORS" are enabled on your server.</span>
|
<ul>
|
||||||
|
<li>If you want to change the default rpc endpoint. make sure that "https" and "CORS" are enabled on your server.</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</b-alert>
|
</b-alert>
|
||||||
</div>
|
</div>
|
||||||
@ -92,6 +139,7 @@ import {
|
|||||||
consensusPubkeyToHexAddress, getLocalChains, getCachedValidators, toDay,
|
consensusPubkeyToHexAddress, getLocalChains, getCachedValidators, toDay,
|
||||||
} from '@/libs/utils'
|
} from '@/libs/utils'
|
||||||
import vSelect from 'vue-select'
|
import vSelect from 'vue-select'
|
||||||
|
import DashboardCardHorizontal from './components/dashboard/DashboardCardHorizontal.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -108,6 +156,7 @@ export default {
|
|||||||
BAvatar,
|
BAvatar,
|
||||||
BCardTitle,
|
BCardTitle,
|
||||||
vSelect,
|
vSelect,
|
||||||
|
DashboardCardHorizontal,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -122,6 +171,10 @@ export default {
|
|||||||
positions: [],
|
positions: [],
|
||||||
updatetime: new Date(),
|
updatetime: new Date(),
|
||||||
rpc: '',
|
rpc: '',
|
||||||
|
height: '-',
|
||||||
|
round: '-',
|
||||||
|
step: '-',
|
||||||
|
rate: '-',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -132,6 +185,8 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.validators()
|
this.validators()
|
||||||
this.rpc = `${this.chains[this.selected].rpc[0]}/consensus_state`
|
this.rpc = `${this.chains[this.selected].rpc[0]}/consensus_state`
|
||||||
|
this.fetchPosition()
|
||||||
|
this.update()
|
||||||
this.timer = setInterval(this.update, 6000)
|
this.timer = setInterval(this.update, 6000)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
@ -145,7 +200,18 @@ export default {
|
|||||||
}
|
}
|
||||||
return txt === 'nil-Vote' ? 'outline-secondary' : 'success'
|
return txt === 'nil-Vote' ? 'outline-secondary' : 'success'
|
||||||
},
|
},
|
||||||
|
fetchPosition() {
|
||||||
|
const dumpurl = this.rpc.replace('consensus_state', 'dump_consensus_state')
|
||||||
|
fetch(dumpurl).then(data => {
|
||||||
|
this.httpstatus = data.status
|
||||||
|
this.httpStatusText = data.httpStatusText
|
||||||
|
return data.json()
|
||||||
|
}).then(res => {
|
||||||
|
this.positions = res.result.round_state.validators.validators
|
||||||
|
})
|
||||||
|
},
|
||||||
update() {
|
update() {
|
||||||
|
this.rate = '0%'
|
||||||
this.updatetime = new Date()
|
this.updatetime = new Date()
|
||||||
if (this.httpstatus === 200) {
|
if (this.httpstatus === 200) {
|
||||||
fetch(this.rpc).then(data => {
|
fetch(this.rpc).then(data => {
|
||||||
@ -154,6 +220,21 @@ export default {
|
|||||||
return data.json()
|
return data.json()
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.roundState = res.result.round_state
|
this.roundState = res.result.round_state
|
||||||
|
const raw = this.roundState['height/round/step'].split('/')
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
this.height = raw[0]
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
this.round = raw[1]
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
this.step = raw[2]
|
||||||
|
|
||||||
|
// find the highest onboard rate
|
||||||
|
this.roundState.height_vote_set.forEach(element => {
|
||||||
|
const rate = Number(element.prevotes_bit_array.substring(element.prevotes_bit_array.length - 4))
|
||||||
|
if (rate > 0) {
|
||||||
|
this.rate = `${rate * 100}%`
|
||||||
|
}
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.httpstatus = 500
|
this.httpstatus = 500
|
||||||
this.httpStatusText = err
|
this.httpStatusText = err
|
||||||
|
@ -108,7 +108,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
consensusPubkeyToHexAddress, getCachedValidators, timeIn, toDay,
|
consensusPubkeyToHexAddress, getCachedValidators, timeIn, toDay,
|
||||||
} from '@/libs/utils'
|
} from '@/libs/utils'
|
||||||
import { fromBech32, toBase64 } from '@cosmjs/encoding'
|
import { fromBech32, fromHex, toBase64 } from '@cosmjs/encoding'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -150,7 +150,7 @@ export default {
|
|||||||
vals.sort((a, b) => b.delegator_shares - a.delegator_shares)
|
vals.sort((a, b) => b.delegator_shares - a.delegator_shares)
|
||||||
const rets = vals.map(x => ({
|
const rets = vals.map(x => ({
|
||||||
validator: x.description,
|
validator: x.description,
|
||||||
address: consensusPubkeyToHexAddress(x.consensus_pubkey),
|
address: this.hex2base64(consensusPubkeyToHexAddress(x.consensus_pubkey)),
|
||||||
}))
|
}))
|
||||||
if (this.missedFilter) {
|
if (this.missedFilter) {
|
||||||
return rets.filter(x => this.missing[x.address].missed_blocks_counter > 0)
|
return rets.filter(x => this.missing[x.address].missed_blocks_counter > 0)
|
||||||
@ -223,10 +223,13 @@ export default {
|
|||||||
initColor() {
|
initColor() {
|
||||||
const sigs = {}
|
const sigs = {}
|
||||||
this.validators.forEach(x => {
|
this.validators.forEach(x => {
|
||||||
sigs[consensusPubkeyToHexAddress(x.consensus_pubkey)] = 'bg-danger'
|
sigs[this.hex2base64(consensusPubkeyToHexAddress(x.consensus_pubkey))] = 'bg-danger'
|
||||||
})
|
})
|
||||||
return sigs
|
return sigs
|
||||||
},
|
},
|
||||||
|
hex2base64(v) {
|
||||||
|
return toBase64(fromHex(v))
|
||||||
|
},
|
||||||
fetch_status(height, resolve) {
|
fetch_status(height, resolve) {
|
||||||
const block = this.blocks.find(b => b.height === height)
|
const block = this.blocks.find(b => b.height === height)
|
||||||
if (block) {
|
if (block) {
|
||||||
|
Loading…
Reference in New Issue
Block a user