-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: live validator stats from L1 Rollup-contract (#251)
- Loading branch information
1 parent
e08ebfe
commit 52ff9c3
Showing
46 changed files
with
1,388 additions
and
207 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
k8s/local/ethereum-listener/remote_ethereum_deployment.yaml
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,47 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: ethereum-listener | ||
name: ethereum-listener | ||
namespace: chicmoz | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ethereum-listener | ||
strategy: {} | ||
template: | ||
metadata: | ||
labels: | ||
app: ethereum-listener | ||
spec: | ||
containers: | ||
- image: ethereum-listener:latest | ||
resources: | ||
limits: | ||
memory: 750Mi | ||
cpu: 250m | ||
name: ethereum-listener | ||
env: | ||
- name: NODE_ENV | ||
value: "development" | ||
- name: BLOCK_POLL_INTERVAL_MS | ||
value: "5000" | ||
- name: LISTENER_DISABLED | ||
value: "false" | ||
- name: GENESIS_CATCHUP | ||
value: "true" | ||
- name: LISTEN_FOR_BLOCKS | ||
value: "true" | ||
- name: ETHEREUM_HTTP_RPC_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: global | ||
key: CHICMOZ_ETHEREUM_RPC_HTTP | ||
- name: ETHEREUM_WS_RPC_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: global | ||
key: CHICMOZ_ETHEREUM_RPC_WS | ||
status: {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
import { AZTEC_MESSAGES } from "./aztec.js"; | ||
import { ETHEREUM_MESSAGES } from "./ethereum.js"; | ||
|
||
export * from "./aztec.js"; | ||
export * from "./ethereum.js"; | ||
export * from "./metric.js"; | ||
export * from "./subscription.js"; | ||
|
||
export const generateTopicName = ( | ||
networkId: string, | ||
topic: keyof AZTEC_MESSAGES | keyof ETHEREUM_MESSAGES | ||
): string => { | ||
return `${networkId}_${topic}`; | ||
}; |
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,12 @@ | ||
import { z } from "zod"; | ||
import { aztecAddressSchema } from "../index.js"; | ||
|
||
export const chicmozFeeRecipientSchema = z.object({ | ||
l2Address: aztecAddressSchema, | ||
feesReceived: z.coerce.bigint(), | ||
nbrOfBlocks: z.number(), | ||
calculatedForNumberOfBlocks: z.number(), | ||
partOfTotalFeesReceived: z.number().optional(), | ||
}); | ||
|
||
export type ChicmozFeeRecipient = z.infer<typeof chicmozFeeRecipientSchema>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ethAddressSchema } from "../general.js"; | ||
import { z } from "zod"; | ||
|
||
// NOTE: explaination copied from aztec-packages: l1-contracts/src/core/interfaces/IStaking.sol | ||
// None -> Does not exist in our setup | ||
// Validating -> Participating as validator | ||
// Living -> Not participating as validator, but have funds in setup, | ||
// hit if slashes and going below the minimum | ||
// Exiting -> In the process of exiting the system | ||
export enum L1L2ValidatorStatus { | ||
NONE, | ||
VALIDATING, | ||
LIVING, | ||
EXITING, | ||
} | ||
|
||
export const chicmozL1L2ValidatorSchema = z.object({ | ||
attester: ethAddressSchema, | ||
stake: z.coerce.bigint().nonnegative(), // TODO: this is not Fr but it might as well be. It is a uint256 | ||
withdrawer: ethAddressSchema, | ||
proposer: ethAddressSchema, | ||
status: z.nativeEnum(L1L2ValidatorStatus), | ||
// NOTE: we could use createdAt and updatedAt, but I want to emphasize that this is the first time we saw this validator. It can be way off from the actual creation time (on chain). | ||
firstSeenAt: z.coerce.date().default(() => new Date()), | ||
latestSeenChangeAt: z.coerce.date().default(() => new Date()), | ||
}); | ||
|
||
export type ChicmozL1L2Validator = z.infer<typeof chicmozL1L2ValidatorSchema>; | ||
|
||
const timestampSchema = z.coerce.date(); | ||
const keyChangedSchema = z.coerce.string(); | ||
const newValueSchema = z.coerce.string(); | ||
|
||
export const chicmozL1L2ValidatorHistoryEntrySchema = z.tuple([ | ||
timestampSchema, | ||
keyChangedSchema, | ||
newValueSchema, | ||
]); | ||
|
||
export type ChicmozL1L2ValidatorHistoryEntry = z.infer< | ||
typeof chicmozL1L2ValidatorHistoryEntrySchema | ||
>; | ||
|
||
export const chicmozL1L2ValidatorHistorySchema = z.array( | ||
chicmozL1L2ValidatorHistoryEntrySchema | ||
); | ||
|
||
export type ChicmozL1L2ValidatorHistory = z.infer< | ||
typeof chicmozL1L2ValidatorHistorySchema | ||
>; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./events.js"; | ||
export * from "./aztec/index.js"; | ||
export * from "./api/index.js"; | ||
export * from "./aztec/index.js"; | ||
export * from "./ethereum/index.js"; | ||
export * from "./events.js"; | ||
export * from "./general.js"; |
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.