-
Notifications
You must be signed in to change notification settings - Fork 183
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: dvm v2 monitor bots #4317
Conversation
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
* feat: update dvm2.0 upgrade script Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * feat: update starting index Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * refactor: update comments Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * feat: update starting index and starting id Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * fix: governor starting id Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * fix: add previous voting contracts events Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * fix: add previous voting contracts events docs Signed-off-by: Pablo Maldonado <pablo@umaproject.org> * refator: improve comment Signed-off-by: Pablo Maldonado <pablo@umaproject.org> Signed-off-by: Pablo Maldonado <pablo@umaproject.org> Co-authored-by: Pablo Maldonado <pablo@umaproject.org> Co-authored-by: chrismaree <christopher.maree@gmail.com> Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chrismaree <christopher.maree@gmail.com> Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Co-authored-by: chrismaree <christopher.maree@gmail.com> Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
…s-v2 (#4318) Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
* feat: new release Captures MerkleTree util change to match across-protocol/contracts-v2 * Update CHANGELOG.md * Update CHANGELOG.md * lint Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
… and implementation (#4324) Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Co-authored-by: Pablo Maldonado <pablo@umaproject.org> Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
This reverts commit e674408. Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
548b5e3
to
406b345
Compare
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.
very cool, nice design, couple small nits
spamRequestIndices: event.args.spamRequestIndices, | ||
})); | ||
deletionProposals.forEach((proposal) => { | ||
logDeletionProposed(logger, proposal, params.chainId); |
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.
small nit but not sure why you have the .map
, you could just change it to a .forEach
and log with one iteration and less code, alternatively you could chain the map into the for each without needing to store the extra variable deletionProposals
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.
I was not able to reduce lines of code as significant part of this deals with passing proposal
parameters to logDeletionProposed
.
- `UNSTAKES_ENABLED` is boolean enabling/disabling monitoring large unstake attempts (disabled by default). | ||
- `UNSTAKE_THRESHOLD` is UMA amount threshold to use when `UNSTAKES_ENABLED=true` (defaults to `"0"`). | ||
- `STAKES_ENABLED` is boolean enabling/disabling monitoring large amount of UMA staked (disabled by default). | ||
- `STAKE_THRESHOLD` is UMA amount threshold to use when `STAKES_ENABLED=true` (defaults to `"0"`). |
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.
need to specify units
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.
fixed in 201b24c
- `POLLING_DELAY` is value in seconds for delay between consecutive runs, defaults to 1 minute. If set to 0 then running in serverless mode will exit after the loop. | ||
- `STARTING_BLOCK_NUMBER` and `ENDING_BLOCK_NUMBER` defines block range to look for events on L1 network. These are mandatory when `POLLING_DELAY=0`. | ||
- `UNSTAKES_ENABLED` is boolean enabling/disabling monitoring large unstake attempts (disabled by default). | ||
- `UNSTAKE_THRESHOLD` is UMA amount threshold to use when `UNSTAKES_ENABLED=true` (defaults to `"0"`). |
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.
what units?
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.
fixed in 201b24c
botModes: BotModes; | ||
} | ||
|
||
export const initCommonEnvVars = async (env: NodeJS.ProcessEnv): Promise<MonitoringParams> => { |
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.
i really like this pattern, but prefer you would have parsed and validated all values here rather than leaving out UNSTAKE_THRESHOLD
and others to be referenced in the functions rather than the monitoring params
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.
fixed in 228982d
import type { MonitoringParams } from "./common"; | ||
|
||
export async function monitorMints(logger: typeof Logger, params: MonitoringParams): Promise<void> { | ||
const mintsThreshold = utils.parseEther(process.env.MINTS_THRESHOLD || "0"); |
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.
i would either turn this into a parameter or add it to monitoring params, same with all the other envs
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.
fixed in 228982d
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
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.
Looks great! A few minor comments
const identifiers = proposal.spamRequestIndices | ||
.map((range) => (range[0].eq(range[1]) ? range[0].toString() : `${range[0]}-${range[1]}`)) | ||
.join(", "); | ||
logger.warn({ |
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.
nit: should this be an error log since it's so rare?
}, | ||
roundId: BigNumber | ||
): void => { | ||
logger.warn({ |
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.
nit: similarly, I think this is rare enough to be an error log, no?
params.startingBlock = params.endingBlock + 1; | ||
params.endingBlock = latestBlockNumber; |
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.
nit: not a huge deal, but it can sometimes be confusing to modify POD that's passed into a method rather than returning the values to update or returning an updated copy. This is because readers often assume simple structs are considered immutable, especially in a method that's named "wait*" (which sounds like it just waits a certain amount of time based on the inputs!).
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.
agree, in 13108bb I updated waitNextBlockRange
method to return new block range and it is updated within params
only in index.ts
const botModes = { | ||
unstakesEnabled: env.UNSTAKES_ENABLED === "true", | ||
stakesEnabled: env.STAKES_ENABLED === "true", | ||
governanceEnabled: env.GOVERNANCE_ENABLED === "true", | ||
deletionEnabled: env.DELETION_ENABLED === "true", | ||
emergencyEnabled: env.EMERGENCY_ENABLED === "true", | ||
rolledEnabled: env.ROLLED_ENABLED === "true", | ||
governorTransfersEnabled: env.GOVERNOR_TRANSFERS_ENABLED === "true", | ||
mintsEnabled: env.MINTS_ENABLED === "true", | ||
}; |
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.
I could see us wanting to make some of these errors rather than warnings. Have you considered adding a config element to configure the log level? It also might just be obvious which ones should be errors, so configuration may be overkill, but I definitely think some are error-worthy events.
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.
agree, for now I just updated hard-coded log levels in b7cd55c. Now emergency proposal, spam deletion, rolled votes, large governor transfers and outsized UMA mints will error.
``` | ||
yarn ts-node packages/scripts/src/monitor-dvm/index.ts | ||
``` |
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.
nit: This is just my opinion, but I think we should prefer using tsc + node over ts-node in production:
- tsc is the official typescript implementation built by the typescript team. ts-node is a separate application maintained by a different group as far as I can tell.
- It ensures that all these files are compiled and checked by tsc in our build process. With ts-node, it's possible that we skip building these files entirely in ci or partially build them. If that were the case, we would not get the advantage of typescript checking the types automatically as a part of our development process.
- Performance reasons: see here and here.
IMO, it's totally fine to encourage ts-node for development purposes in the docs, but I think the default should always be tsc + node.
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.
agree, fixed
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
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.
lgtm
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
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.
LGTM
Signed-off-by: Reinis Martinsons reinis@umaproject.org
Motivation
Improve DVMv2 monitoring.
Summary
Adds DVMv2 monitor bots.
Details
Following monitor bot modules have been added to emit logs when:
Testing
Check a box to describe how you tested these changes and list the steps for reviewers to test.