liveness_expiration

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 13 Imported by: 0

README

Liveness Expiration Monitoring

This Liveness expiration module is a monitoring dedicated for the safes of the Optimism network. Ensuring that owners that operates the safes and performs any important actions are still actives enough.

ab27497cea05fbd51b7b1c2ecde5bc69307ac0f27349f6bba4f3f21423116071

CLI and Docs:

NAME:
   Monitorism liveness_expiration - Monitor the liveness expiration on Gnosis Safe.

USAGE:
   Monitorism liveness_expiration [command options] [arguments...]

DESCRIPTION:
   Monitor the liveness expiration on Gnosis Safe.

OPTIONS:
   --l1.node.url value             Node URL of L1 peer (default: "127.0.0.1:8545") [$LIVENESS_EXPIRATION_MON_L1_NODE_URL]
   --start.block.height value      Starting height to scan for events (still not implemented for now.. The monitoring will start at the last block number) (default: 0) [$LIVENESS_EXPIRATION_MON_START_BLOCK_HEIGHT]
   --livenessmodule.address value  Address of the LivenessModuleAddress contract [$LIVENESS_EXPIRATION_MON_LIVENESS_MODULE_ADDRESS]
   --livenessguard.address value   Address of the LivenessGuardAddress contract [$LIVENESS_EXPIRATION_MON_LIVENESS_GUARD_ADDRESS]
   --safe.address value            Address of the safe contract [$LIVENESS_EXPIRATION_MON_SAFE_ADDRESS]
   --log.level value               The lowest log level that will be output (default: INFO) [$MONITORISM_LOG_LEVEL]
   --log.format value              Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty', (default: text) [$MONITORISM_LOG_FORMAT]
   --log.color                     Color the log output if in terminal mode (default: false) [$MONITORISM_LOG_COLOR]
   --metrics.enabled               Enable the metrics server (default: false) [$MONITORISM_METRICS_ENABLED]
   --metrics.addr value            Metrics listening address (default: "0.0.0.0") [$MONITORISM_METRICS_ADDR]
   --metrics.port value            Metrics listening port (default: 7300) [$MONITORISM_METRICS_PORT]
   --loop.interval.msec value      Loop interval of the monitor in milliseconds (default: 60000) [$MONITORISM_LOOP_INTERVAL_MSEC]
   --help, -h                      show help
Informations

This tools allows the monitoring of multiples metrics like:

blockTimestamp: The block Timestamp of the latest block number on L1. highestBlockNumber: The lastest block number height on L1. lastLiveOfAOwner: Get the last activities for a given safe owner on L1. intervalLiveness: the interval (in seconds) from the LivenessModule on L1.

The logic for the rules detection is not inside the binary liveness_expiration as this is integrated with prometheus. The rules are located in the Prometheus/Grafana side.

Execution

To execute with a oneliner:

go run ../cmd/monitorism liveness_expiration --safe.address 0xc2819DC788505Aac350142A7A707BF9D03E3Bd03 --l1.node.url https://MySuperRPC --loop.interval.msec 12000 --livenessmodule.address 0x0454092516c9A4d636d3CAfA1e82161376C8a748 --livenessguard.address 0x24424336F04440b1c28685a38303aC33C9D14a25

Otherwise create an .env file with the environment variables present into the help section. This is useful to run without any CLI arguments.

Example:

LIVENESS_EXPIRATION_MON_SAFE_ADDRESS=0xc2819DC788505Aac350142A7A707BF9D03E3Bd03
LIVENESS_EXPIRATION_MON_LIVENESS_MODULE_ADDRESS=0x0454092516c9A4d636d3CAfA1e82161376C8a748
LIVENESS_EXPIRATION_MON_LIVENESS_GUARD_ADDRESS=0x24424336F04440b1c28685a38303aC33C9D14a25

Documentation

Index

Constants

View Source
const (
	L1NodeURLFlagName             = "l1.node.url"
	EventBlockRangeFlagName       = "event.block.range"
	StartingL1BlockHeightFlagName = "start.block.height"

	SafeAddressFlagName           = "safe.address"
	LivenessModuleAddressFlagName = "livenessmodule.address"
	LivenessGuardAddressFlagName  = "livenessguard.address"
)
View Source
const (
	MetricsNamespace = "liveness_expiration_mon"
)

Variables

This section is empty.

Functions

func CLIFlags

func CLIFlags(envVar string) []cli.Flag

Types

type CLIConfig

type CLIConfig struct {
	L1NodeURL             string
	EventBlockRange       uint64
	StartingL1BlockHeight uint64

	LivenessModuleAddress common.Address
	LivenessGuardAddress  common.Address
	SafeAddress           common.Address
}

func ReadCLIFlags

func ReadCLIFlags(ctx *cli.Context) (CLIConfig, error)

type Monitor

type Monitor struct {

	/** Contracts **/
	GnosisSafe            *bindings.GnosisSafe
	GnosisSafeAddress     common.Address
	LivenessGuard         *bindings.LivenessGuard
	LivenessGuardAddress  common.Address
	LivenessModule        *bindings.LivenessModule
	LivenessModuleAddress common.Address
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(ctx context.Context, log log.Logger, m metrics.Factory, cfg CLIConfig) (*Monitor, error)

NewMonitor creates a new monitor.

func (*Monitor) Close

func (m *Monitor) Close(_ context.Context) error

Close closes the monitor.

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context)

Run is the main loop of the monitor. This loop will update the metrics `blockTimestamp`, `highestBlockNumber`, `lastLiveOfAOwner`, `intervalLiveness`. Thanks to these metrics we can monitor the liveness expiration through (block.timestamp + BUFFER > lastLive(owner) + livenessInterval). NOTE: // Liveness module mainnet -> https://etherscan.io/address/0x0454092516c9A4d636d3CAfA1e82161376C8a748 Liveness guard mainnet -> https://etherscan.io/address/0x24424336F04440b1c28685a38303aC33C9D14a25 1. call the safe.owners() 2. livenessGuard.lastLive(owner) 3. save the livenessInterval() 4. Ensure that the invariant is not broken -> (block.timestamp + BUFFER > lastLive(owner) + livenessInterval) == true

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL