-
Notifications
You must be signed in to change notification settings - Fork 114
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
feat: automatic system alerts #141
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6a60119
feat: add automatic system alert banner
Romsters e390b52
fix: clean up alert styles
Romsters 7ddacc1
fix: e2e tests
Romsters 829e4d5
fix: update explorer link for alert banner
Romsters 41b1ec7
fix: explolers link
Romsters d7b1f08
fix: remove redundant check
Romsters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<SystemAlert v-if="isIndexerDelayed"> | ||
<span | ||
v-if="latestTPS > MIN_TPS_TO_SHOW_HEAVY_LOAD_ALERT" | ||
v-html="t('systemAlert.indexerDelayedDueToHeavyLoad', { indexerDelayInHours })" | ||
/> | ||
<span v-else v-html="t('systemAlert.indexerDelayed', { indexerDelayInHours })" /> | ||
</SystemAlert> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, ref } from "vue"; | ||
import { useI18n } from "vue-i18n"; | ||
|
||
import SystemAlert from "@/components/common/SystemAlert.vue"; | ||
|
||
import useBlocks from "@/composables/useBlocks"; | ||
import useContext from "@/composables/useContext"; | ||
|
||
import type { types } from "zksync-web3"; | ||
|
||
const { t } = useI18n(); | ||
const context = useContext(); | ||
|
||
const MIN_DELAY_TO_SHOW_ALERT = 900_000; // 15 mins | ||
const MIN_TPS_TO_SHOW_HEAVY_LOAD_ALERT = 70; | ||
|
||
const provider = context.getL2Provider(); | ||
const latestBlock = ref<types.Block | null>(null); | ||
(async () => { | ||
const block = await provider.getBlock("latest"); | ||
latestBlock.value = block; | ||
})(); | ||
|
||
const { load: getLatestIndexedBlocks, data: latestIndexedBlocks } = useBlocks(context); | ||
getLatestIndexedBlocks(1); | ||
|
||
const indexerDelay = computed(() => { | ||
if (!latestBlock.value?.number || !latestIndexedBlocks.value?.length) { | ||
return 0; | ||
} | ||
const latestBlockDate = new Date(latestBlock.value.timestamp * 1000); | ||
const latestIndexedBlockDate = new Date(latestIndexedBlocks.value[0].timestamp); | ||
const delay = latestBlockDate.getTime() - latestIndexedBlockDate.getTime(); | ||
return delay; | ||
}); | ||
|
||
const indexerDelayInHours = computed(() => (indexerDelay.value / (1000 * 60 * 60)).toFixed(1)); | ||
|
||
const isIndexerDelayed = computed(() => { | ||
if (indexerDelay.value > MIN_DELAY_TO_SHOW_ALERT) { | ||
return true; | ||
} | ||
return false; | ||
}); | ||
|
||
const latestTPS = computed(() => { | ||
if (!latestIndexedBlocks.value?.length) { | ||
return 0; | ||
} | ||
const numberOfTransactions = latestIndexedBlocks.value.reduce((acc, block) => acc + block.size, 0); | ||
const latestBlockDate = new Date(latestIndexedBlocks.value[0].timestamp); | ||
const firstBlockDate = new Date(latestIndexedBlocks.value[latestIndexedBlocks.value.length - 1].timestamp); | ||
const numberOfSeconds = Math.floor((latestBlockDate.getTime() - firstBlockDate.getTime()) / 1000); | ||
const tps = numberOfSeconds ? numberOfTransactions / numberOfSeconds : 0; | ||
return tps; | ||
}); | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<div class="system-alert"> | ||
<IconError class="icon" color="#FFC81A" /> | ||
<span class="system-alert-body"> | ||
<slot /> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import IconError from "@/components/icons/IconError.vue"; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.system-alert { | ||
@apply flex items-center text-white rounded-2xl border border-amber-400/50 bg-amber-400/10 mb-6 py-3 px-4; | ||
|
||
.system-alert-body { | ||
@apply ml-3 w-full; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hack was needed to increase the height of the header background (which has a fixed size) when a warning message is shown. Otherwise the header text is pushed down and is not visible:
Having dynamic error messages we will also need to change the height of the background image dynamically or rework the whole thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't support mobile, but this should be fixed properly. Out of scope of this PR I'd say.