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

Fix overflow issue and add account metric #154

Merged
6 commits merged into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Application.Api.GraphQL.Blocks;
using Application.Common.Diagnostics;
using Application.Import;
using Application.Observability;
using Concordium.Sdk.Types;

namespace Application.Api.GraphQL.Import;
Expand All @@ -27,7 +28,8 @@ public async Task AddNewAccounts(
ulong blockHeight)
{
if (createdAccounts.Length == 0) return;

ApplicationMetrics.IncAccountCreated(createdAccounts.Length);

var accounts = _changeCalculator.MapCreatedAccounts(createdAccounts, blockSlotTime, blockHeight).ToArray();
await _writer.InsertAccounts(accounts);

Expand Down
2 changes: 1 addition & 1 deletion backend/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<Version>1.8.2</Version>
<Version>1.8.3</Version>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
Expand Down
11 changes: 11 additions & 0 deletions backend/Application/Observability/ApplicationMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text;
using Application.Aggregates.Contract.Types;
using Application.Exceptions;
using Concordium.Sdk.Types;
using HotChocolate.Execution;
using Microsoft.Extensions.ObjectPool;
using Prometheus;
Expand Down Expand Up @@ -53,6 +54,10 @@ internal static class ApplicationMetrics
}
);

private static readonly Counter TotalAccountCreated = Metrics.CreateCounter(
"accounts_created_total",
"Total number of accounts created");

private static void AddProcessDuration(TimeSpan elapsed, string process, ImportSource source, Exception? exception)
{
var exceptionName = exception != null ? PrettyPrintException(exception) : "";
Expand All @@ -61,6 +66,12 @@ private static void AddProcessDuration(TimeSpan elapsed, string process, ImportS
.WithLabels(process, source.ToStringCached(), exceptionName)
.Observe(elapsedSeconds);
}

internal static void IncAccountCreated(int accountsCreated)
{
TotalAccountCreated
.Inc(accountsCreated);
}

internal static void SetReadHeight(double value, string processIdentifier, ImportSource source)
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ccscan-frontend",
"description": "CCDScan frontend",
"version": "1.5.24",
"version": "1.5.25",
"engine": "16",
"type": "module",
"private": true,
Expand Down
25 changes: 15 additions & 10 deletions frontend/src/components/Contracts/ContractDetailsContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
<template #default>
{{ contract.contractName }}
</template>
</DetailsCard>
<ContractDetailsAmounts :contract="contract" />
</DetailsCard>
<ContractDetailsAmounts :contract="contract" />
<DetailsCard>
<template #title>Date</template>
<template #default>
{{ formatTimestamp(contract.blockSlotTime) }}
</template>
<template
v-if="breakpoint >= Breakpoint.LG"
#secondary>
<template v-if="breakpoint >= Breakpoint.LG" #secondary>
({{ convertTimestampToRelative(contract.blockSlotTime, NOW) }})
</template>
</DetailsCard>
<DetailsCard>
<template #title>
Module
<InfoTooltip text="Container which holds execution code for one or more contracts. The below references hold the current execution code of the contract."/>
<InfoTooltip
text="Container which holds execution code for one or more contracts. The below references hold the current execution code of the contract."
position="bottom"
/>
</template>
<template #default>
<ModuleLink :module-reference="contract.moduleReference" />
Expand All @@ -33,7 +34,9 @@
<DetailsCard>
<template #title>
Creator
<InfoTooltip text="Account address of the contract instance creator."/>
<InfoTooltip
text="Account address of the contract instance creator."
/>
</template>
<template #default>
<AccountLink :address="contract.creator.asString" />
Expand Down Expand Up @@ -89,16 +92,18 @@ import ContractDetailsEvents from './ContractDetailsEvents.vue'
import DrawerContent from '~/components/Drawer/DrawerContent.vue'
import DetailsCard from '~/components/DetailsCard.vue'
import { Contract } from '~~/src/types/generated'
import { convertTimestampToRelative, formatTimestamp } from '~~/src/utils/format'
import {
convertTimestampToRelative,
formatTimestamp,
} from '~~/src/utils/format'
import ContractDetailsRejectEvents from '~/components/Contracts/ContractDetailsRejectEvents.vue'
import { PaginationOffsetInfo } from '~~/src/composables/usePaginationOffset'
import { PageDropdownInfo } from '~~/src/composables/usePageDropdown'
import { Breakpoint } from '~~/src/composables/useBreakpoint'


const { NOW } = useDateNow()

const { breakpoint } = useBreakpoint();
const { breakpoint } = useBreakpoint()

type Props = {
contract: Contract
Expand Down
38 changes: 9 additions & 29 deletions frontend/src/components/Search/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
:has-more-results="!!data.search.blocks.pageInfo.hasNextPage"
>
<div
v-for="(block, index) in data.search.blocks.nodes"
v-for="block in data.search.blocks.nodes"
:key="block.blockHash"
:class="$style.searchColumns"
>
Expand All @@ -58,10 +58,7 @@
<div :class="$style.threeColumns">@ {{ block.blockHeight }}</div>
<div :class="$style.twoColumns">
Age
<Tooltip
:text="formatTimestamp(block.blockSlotTime)"
:position="getTooltipPosition(index)"
>
<Tooltip :text="formatTimestamp(block.blockSlotTime)">
{{
convertTimestampToRelative(block.blockSlotTime || '', NOW)
}}
Expand All @@ -76,7 +73,7 @@
:has-more-results="!!data.search.transactions.pageInfo.hasNextPage"
>
<div
v-for="(transaction, index) in data.search.transactions.nodes"
v-for="transaction in data.search.transactions.nodes"
:key="transaction.transactionHash"
:class="$style.searchColumns"
>
Expand All @@ -98,7 +95,6 @@
Age
<Tooltip
:text="formatTimestamp(transaction.block.blockSlotTime)"
:position="getTooltipPosition(index)"
>
{{
convertTimestampToRelative(
Expand All @@ -117,7 +113,7 @@
:has-more-results="data.search.accounts.pageInfo.hasNextPage"
>
<div
v-for="(account, index) in data.search.accounts.nodes"
v-for="account in data.search.accounts.nodes"
:key="account.address.asString"
:class="$style.searchColumns"
>
Expand All @@ -129,10 +125,7 @@
<div :class="$style.threeColumns"></div>
<div :class="$style.twoColumns">
Age
<Tooltip
:text="formatTimestamp(account.createdAt)"
:position="getTooltipPosition(index)"
>
<Tooltip :text="formatTimestamp(account.createdAt)">
{{ convertTimestampToRelative(account.createdAt || '', NOW) }}
</Tooltip>
</div>
Expand All @@ -145,7 +138,7 @@
:has-more-results="!!data.search.contracts.pageInfo.hasNextPage"
>
<div
v-for="(contract, index) in data.search.contracts.nodes"
v-for="contract in data.search.contracts.nodes"
:key="contract.contractAddress"
:class="$style.searchColumns"
>
Expand All @@ -162,10 +155,7 @@
/>
<div :class="$style.twoColumns">
Age
<Tooltip
:text="formatTimestamp(contract.blockSlotTime)"
:position="getTooltipPosition(index)"
>
<Tooltip :text="formatTimestamp(contract.blockSlotTime)">
{{ convertTimestampToRelative(contract.blockSlotTime, NOW) }}
</Tooltip>
</div>
Expand All @@ -177,7 +167,7 @@
:has-more-results="data.search.modules.pageInfo.hasNextPage"
>
<div
v-for="(module, index) in data.search.modules.nodes"
v-for="module in data.search.modules.nodes"
:key="module.moduleReference"
:class="$style.searchColumns"
>
Expand All @@ -189,10 +179,7 @@
<div :class="$style.threeColumns"></div>
<div :class="$style.twoColumns">
Age
<Tooltip
:text="formatTimestamp(module.blockSlotTime)"
:position="getTooltipPosition(index)"
>
<Tooltip :text="formatTimestamp(module.blockSlotTime)">
{{ convertTimestampToRelative(module.blockSlotTime, NOW) }}
</Tooltip>
</div>
Expand Down Expand Up @@ -262,14 +249,11 @@ import BakerLink from '~/components/molecules/BakerLink.vue'
import AccountLink from '~/components/molecules/AccountLink.vue'
import ContractLink from '~/components/molecules/ContractLink.vue'
import { useDateNow } from '~/composables/useDateNow'
import type { Position } from '~/composables/useTooltip'
import NodeLink from '~/components/molecules/NodeLink.vue'

const { NOW } = useDateNow()
const drawer = useDrawer()

const tooltipPositionBottom = 'bottom' as Position
const tooltipPositionTop = 'top' as Position
const searchValue = ref('')
const delayedSearchValue = ref('')
const isMaskVisible = ref(false)
Expand Down Expand Up @@ -362,10 +346,6 @@ const lostFocusOnSearch = (x: FocusEvent) => {
}, 100)
}

const getTooltipPosition = (index: number) => {
return index === 0 ? tooltipPositionBottom : tooltipPositionTop
}

const resultCount = computed(() => ({
modules: data.value?.search.modules.nodes.length,
contracts: data.value?.search.contracts.nodes.length,
Expand Down
33 changes: 22 additions & 11 deletions frontend/src/components/atoms/InfoTooltip.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<template>
<Tooltip
:text="text"
>
<svg class="icon" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.77989 10.6517C10.0579 10.2704 10.3801 9.92031 10.7468 9.60137L10.7485 9.59994C11.0445 9.33876 11.311 9.05933 11.5474 8.76155C11.8152 8.42439 11.95 8.03342 11.95 7.59999C11.95 7.11098 11.7565 6.69548 11.3837 6.37308C11.0196 6.05814 10.587 5.89999 10.1 5.89999C9.75378 5.89999 9.42161 5.97731 9.10661 6.13004C8.78695 6.28503 8.51987 6.50872 8.30805 6.79756L8.30587 6.80062C8.17753 6.98029 8.03192 7.07266 7.86616 7.10581C7.69343 7.14036 7.52716 7.11468 7.35532 7.01819C7.24969 6.94909 7.1844 6.85325 7.15748 6.70786C7.12907 6.55445 7.15331 6.41493 7.23423 6.27621L7.23836 6.26864C7.5072 5.77577 7.89627 5.41211 8.41371 5.17214C8.94919 4.9238 9.51029 4.79999 10.1 4.79999C10.9527 4.79999 11.6911 5.05025 12.3275 5.54868C12.9494 6.03571 13.25 6.64576 13.25 7.39999C13.25 7.87874 13.1275 8.30592 12.8842 8.68924C12.6229 9.10103 12.3096 9.48198 11.9437 9.83218C11.6692 10.0896 11.4117 10.36 11.1712 10.6434C10.9051 10.957 10.7322 11.3164 10.6556 11.7174C10.6169 11.9098 10.5331 12.0613 10.4056 12.1827C10.2885 12.2943 10.1509 12.35 9.97499 12.35C9.81698 12.35 9.6843 12.2991 9.56376 12.19C9.45081 12.0878 9.39999 11.9725 9.39999 11.825C9.39999 11.3878 9.52606 10.9999 9.77989 10.6517Z" fill="#48A2AE"/>
<path d="M10.4839 14.7839C10.3385 14.9294 10.1709 15 9.94995 15C9.72901 15 9.56142 14.9294 9.41601 14.7839C9.27059 14.6385 9.19995 14.4709 9.19995 14.25C9.19995 14.0291 9.27059 13.8615 9.416 13.7161C9.56142 13.5706 9.72901 13.5 9.94995 13.5C10.1709 13.5 10.3385 13.5706 10.4839 13.7161C10.6293 13.8615 10.7 14.0291 10.7 14.25C10.7 14.4709 10.6293 14.6385 10.4839 14.7839Z" fill="#48A2AE"/>
<path d="M10 20C8.61667 20 7.31667 19.7375 6.1 19.2125C4.88333 18.6875 3.825 17.975 2.925 17.075C2.025 16.175 1.3125 15.1167 0.7875 13.9C0.2625 12.6833 0 11.3833 0 10C0 8.61667 0.2625 7.31667 0.7875 6.1C1.3125 4.88333 2.025 3.825 2.925 2.925C3.825 2.025 4.88333 1.3125 6.1 0.7875C7.31667 0.2625 8.61667 0 10 0C11.3833 0 12.6833 0.2625 13.9 0.7875C15.1167 1.3125 16.175 2.025 17.075 2.925C17.975 3.825 18.6875 4.88333 19.2125 6.1C19.7375 7.31667 20 8.61667 20 10C20 11.3833 19.7375 12.6833 19.2125 13.9C18.6875 15.1167 17.975 16.175 17.075 17.075C16.175 17.975 15.1167 18.6875 13.9 19.2125C12.6833 19.7375 11.3833 20 10 20ZM10 18C12.2333 18 14.125 17.225 15.675 15.675C17.225 14.125 18 12.2333 18 10C18 7.76667 17.225 5.875 15.675 4.325C14.125 2.775 12.2333 2 10 2C7.76667 2 5.875 2.775 4.325 4.325C2.775 5.875 2 7.76667 2 10C2 12.2333 2.775 14.125 4.325 15.675C5.875 17.225 7.76667 18 10 18Z" fill="#48A2AE"/>
</svg>
<Tooltip :text="text">
<svg
class="icon"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.77989 10.6517C10.0579 10.2704 10.3801 9.92031 10.7468 9.60137L10.7485 9.59994C11.0445 9.33876 11.311 9.05933 11.5474 8.76155C11.8152 8.42439 11.95 8.03342 11.95 7.59999C11.95 7.11098 11.7565 6.69548 11.3837 6.37308C11.0196 6.05814 10.587 5.89999 10.1 5.89999C9.75378 5.89999 9.42161 5.97731 9.10661 6.13004C8.78695 6.28503 8.51987 6.50872 8.30805 6.79756L8.30587 6.80062C8.17753 6.98029 8.03192 7.07266 7.86616 7.10581C7.69343 7.14036 7.52716 7.11468 7.35532 7.01819C7.24969 6.94909 7.1844 6.85325 7.15748 6.70786C7.12907 6.55445 7.15331 6.41493 7.23423 6.27621L7.23836 6.26864C7.5072 5.77577 7.89627 5.41211 8.41371 5.17214C8.94919 4.9238 9.51029 4.79999 10.1 4.79999C10.9527 4.79999 11.6911 5.05025 12.3275 5.54868C12.9494 6.03571 13.25 6.64576 13.25 7.39999C13.25 7.87874 13.1275 8.30592 12.8842 8.68924C12.6229 9.10103 12.3096 9.48198 11.9437 9.83218C11.6692 10.0896 11.4117 10.36 11.1712 10.6434C10.9051 10.957 10.7322 11.3164 10.6556 11.7174C10.6169 11.9098 10.5331 12.0613 10.4056 12.1827C10.2885 12.2943 10.1509 12.35 9.97499 12.35C9.81698 12.35 9.6843 12.2991 9.56376 12.19C9.45081 12.0878 9.39999 11.9725 9.39999 11.825C9.39999 11.3878 9.52606 10.9999 9.77989 10.6517Z"
fill="#48A2AE"
/>
<path
d="M10.4839 14.7839C10.3385 14.9294 10.1709 15 9.94995 15C9.72901 15 9.56142 14.9294 9.41601 14.7839C9.27059 14.6385 9.19995 14.4709 9.19995 14.25C9.19995 14.0291 9.27059 13.8615 9.416 13.7161C9.56142 13.5706 9.72901 13.5 9.94995 13.5C10.1709 13.5 10.3385 13.5706 10.4839 13.7161C10.6293 13.8615 10.7 14.0291 10.7 14.25C10.7 14.4709 10.6293 14.6385 10.4839 14.7839Z"
fill="#48A2AE"
/>
<path
d="M10 20C8.61667 20 7.31667 19.7375 6.1 19.2125C4.88333 18.6875 3.825 17.975 2.925 17.075C2.025 16.175 1.3125 15.1167 0.7875 13.9C0.2625 12.6833 0 11.3833 0 10C0 8.61667 0.2625 7.31667 0.7875 6.1C1.3125 4.88333 2.025 3.825 2.925 2.925C3.825 2.025 4.88333 1.3125 6.1 0.7875C7.31667 0.2625 8.61667 0 10 0C11.3833 0 12.6833 0.2625 13.9 0.7875C15.1167 1.3125 16.175 2.025 17.075 2.925C17.975 3.825 18.6875 4.88333 19.2125 6.1C19.7375 7.31667 20 8.61667 20 10C20 11.3833 19.7375 12.6833 19.2125 13.9C18.6875 15.1167 17.975 16.175 17.075 17.075C16.175 17.975 15.1167 18.6875 13.9 19.2125C12.6833 19.7375 11.3833 20 10 20ZM10 18C12.2333 18 14.125 17.225 15.675 15.675C17.225 14.125 18 12.2333 18 10C18 7.76667 17.225 5.875 15.675 4.325C14.125 2.775 12.2333 2 10 2C7.76667 2 5.875 2.775 4.325 4.325C2.775 5.875 2 7.76667 2 10C2 12.2333 2.775 14.125 4.325 15.675C5.875 17.225 7.76667 18 10 18Z"
fill="#48A2AE"
/>
</svg>
<template #content>
<slot name="content" />
</template>
Expand All @@ -16,10 +28,9 @@
import Tooltip from '~~/src/components/atoms/Tooltip.vue'

type Props = {
text: string
text: string
}
defineProps<Props>();

defineProps<Props>()
</script>
<style>
.icon {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/atoms/TextCopy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Tooltip
:text="statusText || label"
:on-mouse-enter="handleOnMouseEnter"
:position="position"
:text-class="tooltipClass"
>
<button
Expand All @@ -22,7 +21,6 @@
<script lang="ts" setup>
import { ref } from 'vue'
import Tooltip from '~/components/atoms/Tooltip.vue'
import type { Position } from '~/composables/useTooltip'
import ClipboardIcon from '~/components/icons/ClipboardIcon.vue'

type Props = {
Expand All @@ -34,8 +32,6 @@ type Props = {

const props = defineProps<Props>()

const position = 'bottom' as Position

const statusText = ref('')

const handleOnMouseEnter = () => {
Expand Down
Loading
Loading