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

refactor(protocol): slightly change defender monitors #18086

Merged
merged 23 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
37 changes: 37 additions & 0 deletions .github/workflows/protocol-monitors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Monitors

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "packages/monitors/**"

jobs:
deploy-protocol-monitors:
if: github.event.pull_request.draft == false
runs-on: [taiko-runner]
permissions:
# Give the necessary permissions for stefanzweifel/git-auto-commit-action.
contents: write
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install pnpm dependencies
uses: ./.github/actions/install-pnpm-dependencies

- name: Deploy Monitors on OZ Defender
working-directory: packages/monitors/defender/mainnet
env:
DEFENDER_API_KEY: ${{ secrets.DEFENDER_API_KEY }}
DEFENDER_API_SECRET: ${{ secrets.DEFENDER_API_SECRET }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
run: |
npx serverless deploy
4 changes: 4 additions & 0 deletions .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "packages/protocol/**"
- "!packages/protocol/audit/**"
- "!packages/protocol/docs/**"
- "!packages/protocol/simulation/**"
- "!packages/protocol/deployments/**"

jobs:
build-protocol:
Expand Down
1 change: 1 addition & 0 deletions packages/monitors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.defender

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/monitors/defender/mainnet/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEFENDER_API_SECRET=
DEFENDER_API_KEY=
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function findUnmatchedMessages(processedMessages, sentMessages) {
}

function alertOrg(notificationClient, missingCount) {
const outputMessage = `Bridge Health Alert! \nThere are ${missingCount} missing MessageSent events for the processed messages on the other chain.`;
const outputMessage = `@cyberhorsey @soylent_ @xiaodino007 Bridge Health Alert! \nThere are ${missingCount} missing MessageSent events for the processed messages on the other chain.`;

notificationClient.send({
channelAlias: "discord_bridging",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_configs",
channelAlias: "discord_bridging",
subject: "⚠️ GuardianProver: Approved Count",
message,
});
Expand All @@ -56,7 +56,7 @@ async function calculateBlockTime(provider) {
async function calculateBlockRange(provider) {
const currentBlockNumber = await getLatestBlockNumber(provider);
const blockTimeInSeconds = await calculateBlockTime(provider);
const blocksInOneHour = Math.floor((16 * 60) / blockTimeInSeconds);
const blocksInOneHour = Math.floor((15 * 60) / blockTimeInSeconds);

const fromBlock = currentBlockNumber - blocksInOneHour;
const toBlock = currentBlockNumber;
Expand Down Expand Up @@ -132,7 +132,7 @@ exports.handler = async function (event, context) {
if (logs.length > 0) {
alertOrg(
notificationClient,
`Detected ${logs.length} Approved events in the last 15 mins on Guardian!`,
`@taiko|guardians Detected ${logs.length} Approved events in the last 15 mins on Guardian!`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_configs",
channelAlias: "discord_bridging",
subject: "🚨 GuardianProver: ConflictingProofs Alert",
message,
});

notificationClient.send({
channelAlias: "tg_taiko_guardians",
subject: "🚨 GuardianProver: ConflictingProofs Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_configs",
channelAlias: "discord_bridging",
subject: "⚠️ GuardianProver: GuardiansUpdated Alert",
message,
});

notificationClient.send({
channelAlias: "tg_taiko_guardians",
subject: "⚠️ GuardianProver: GuardiansUpdated Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_configs",
channelAlias: "discord_bridging",
subject: "⚠️ GuardianProver: ProvingAutoPauseEnabled Alert",
message,
});
notificationClient.send({
channelAlias: "tg_taiko_guardians",
subject: "⚠️ GuardianProver: ProvingAutoPauseEnabled Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const verifyProofSelector = ethers.utils

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "⚠️ SGXVerifier: verifyProof Failure Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "🚨 TaikoL1: BlockProposed Alert",
message,
});

notificationClient.send({
channelAlias: "tg_taiko_guardians",
subject: "🚨 TaikoL1: BlockProposed Alert",
message,
});
Expand Down Expand Up @@ -340,7 +346,7 @@ exports.handler = async function (event, context) {

const currentBlockNumber = await getLatestBlockNumber(taikoL1Provider);
const blockTimeInSeconds = await calculateBlockTime(taikoL1Provider);
const blocksInFiveMinutes = Math.floor((5 * 60) / blockTimeInSeconds);
const blocksInFiveMinutes = Math.floor((15 * 60) / blockTimeInSeconds);

const fromBlock = currentBlockNumber - blocksInFiveMinutes;
const toBlock = currentBlockNumber;
Expand All @@ -359,7 +365,7 @@ exports.handler = async function (event, context) {
if (logs.length === 0) {
alertOrg(
notificationClient,
`No BlockProposed event detected in the last 5 mins on TaikoL1!`,
`No BlockProposed event detected in the last 15 mins on TaikoL1!`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "🚨 TaikoL1: BlockVerified Alert",
message,
});

notificationClient.send({
channelAlias: "tg_taiko_guardians",
subject: "🚨 TaikoL1: BlockVerified Alert",
message,
});
Expand Down Expand Up @@ -156,7 +162,7 @@ exports.handler = async function (event, context) {

const currentBlockNumber = await getLatestBlockNumber(taikoL1Provider);
const blockTimeInSeconds = await calculateBlockTime(taikoL1Provider);
const blocksInFiveMinutes = Math.floor((5 * 60) / blockTimeInSeconds);
const blocksInFiveMinutes = Math.floor((30 * 60) / blockTimeInSeconds);

const fromBlock = currentBlockNumber - blocksInFiveMinutes;
const toBlock = currentBlockNumber;
Expand All @@ -173,7 +179,7 @@ exports.handler = async function (event, context) {
if (logs.length === 0) {
alertOrg(
notificationClient,
`No BlockVerified event detected in the last 5 mins in TaikoL1!`,
`@davidcai @yuea7583 No BlockVerified event detected in the last 30 mins in TaikoL1!`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "ℹ️ TaikoL1: CalldataTxList Count",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_configs",
channelAlias: "discord_bridging",
subject: "⚠️ TaikoL1: ProvingPaused Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "ℹ️ TaikoL1: TransitionContested Count",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ABI = [

function alertOrg(notificationClient, message) {
notificationClient.send({
channelAlias: "discord_blocks",
channelAlias: "discord_bridging",
subject: "🚨 TaikoL1: TransitionProved Alert",
message,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ const ABIs = {
function alertOrg(notificationClient, subject, message) {
notificationClient.send({
channelAlias: "discord_bridging",
subject,
message,
subject: subject,
message: message,
});
}

Expand Down Expand Up @@ -226,9 +226,11 @@ async function monitorEvent(
const eventCount = logs.length;

if (eventCount > 0) {
const alertMessage = `Detected ${eventCount} ${subject} events on ${provider.network.name} in the last 24 hours!`;
const alertMessage = `ℹ️ Detected ${eventCount} ${subject} events on ${provider.network.name} in the last 24 hours!`;
alertOrg(notificationClient, subject, alertMessage);
}

return;
}

exports.handler = async function (event, context) {
Expand Down Expand Up @@ -260,15 +262,14 @@ exports.handler = async function (event, context) {
const { fromBlock: l2FromBlock, toBlock: l2ToBlock } =
await calculateBlockRange(l2Provider);

// Monitor ERC1155Vault events
await monitorEvent(
l1Provider,
"BridgedTokenDeployed",
l1FromBlock,
l1ToBlock,
"0xaf145913EA4a56BE22E120ED9C24589659881702", // L1
ABIs.ERC1155Vault,
"ℹ️ ERC1155Vault BridgedTokenDeployed",
" ERC1155Vault.BridgedTokenDeployed",
notificationClient,
);

Expand All @@ -279,19 +280,18 @@ exports.handler = async function (event, context) {
l2ToBlock,
"0x1670000000000000000000000000000000000004", // L2
ABIs.ERC1155Vault,
"ℹ️ ERC1155Vault BridgedTokenDeployed",
" ERC1155Vault.BridgedTokenDeployed",
notificationClient,
);

// Monitor ERC721Vault events
await monitorEvent(
l1Provider,
"BridgedTokenDeployed",
l1FromBlock,
l1ToBlock,
"0x0b470dd3A0e1C41228856Fb319649E7c08f419Aa", // L1
ABIs.ERC721Vault,
"ℹ️ ERC721Vault BridgedTokenDeployed",
" ERC721Vault.BridgedTokenDeployed",
notificationClient,
);

Expand All @@ -302,19 +302,18 @@ exports.handler = async function (event, context) {
l2ToBlock,
"0x1670000000000000000000000000000000000003", // L2
ABIs.ERC721Vault,
"ℹ️ ERC721Vault BridgedTokenDeployed",
" ERC721Vault.BridgedTokenDeployed",
notificationClient,
);

// Monitor ERC20Vault events
await monitorEvent(
l1Provider,
"BridgedTokenDeployed",
l1FromBlock,
l1ToBlock,
"0x996282cA11E5DEb6B5D122CC3B9A1FcAAD4415Ab", // L1
ABIs.ERC20Vault,
"ℹ️ ERC20 BridgedTokenDeployed",
" ERC20Vault.BridgedTokenDeployed",
notificationClient,
);

Expand All @@ -325,7 +324,7 @@ exports.handler = async function (event, context) {
l2ToBlock,
"0x1670000000000000000000000000000000000002", // L2
ABIs.ERC20Vault,
"ℹ️ ERC20Vault BridgedTokenDeployed",
" ERC20Vault.BridgedTokenDeployed",
notificationClient,
);

Expand Down
Loading
Loading