psp_executor

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 18 Imported by: 0

README

PSP Executor Service

The PSP Executor service is a service designed to execute PSP onchain faster to increase our readiness and speed in case of incident response.

The service is design to listen on a port and execute a PSP onchain when a request is received.

⚠️ The service as to use a authentification method before calling this API ⚠️

Options and Configuration

The current options are the following:

OPTIONS:
   --rpc-url value             Node URL of a peer (default: "http://127.0.0.1:8545") [$PSPEXECUTOR_MON_NODE_URL]
   --privatekey value          Private key of the account that will issue the pause () [$PSPEXECUTOR_MON_PRIVATE_KEY]
   --receiver.address value    The receiver address of the pause request. [$PSPEXECUTOR_MON_RECEIVER_ADDRESS]
   --port.api value            Port of the API server you want to listen on (e.g. 8080). (default: "8080") [$PSPEXECUTOR_MON_PORT_API]
   --data value                calldata to execute the pause on mainnet with the signatures. [$PSPEXECUTOR_MON_CALLDATA]
   --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

Usage

HTTP API service

To start the HTTP API service we can use the following oneliner command: f112841bad84c59ea3ed1ca380740f5694f553de8755b96b1a40ece4d1c26f81

go run ../cmd/defender psp_executor --privatekey XXXXXX --receiver.address 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF --rpc.url http://localhost:8545 --port.api 8080

cURL HTTP API

To use the HTTP API you can use the following curl command:

image

curl -X POST http://${HTTP_API_PSP}:${PORT}/api/psp_execution \-H "Content-Type: application/json" \-d '{"pause": true, "timestamp": 1719432011, "operator": "Tom"}'

Documentation

Index

Constants

View Source
const (
	NodeURLFlagName         = "rpc.url"
	PrivateKeyFlagName      = "privatekey"
	PortAPIFlagName         = "port.api"
	ReceiverAddressFlagName = "receiver.address"
	DataFlagName            = "data"
)
View Source
const (
	MetricsNamespace = "psp_executor"
	SepoliaRPC       = "https://proxyd-l1-consensus.primary.sepolia.prod.oplabs.cloud"
	MainnetRPC       = "https://proxyd-l1-consensus.primary.mainnet.prod.oplabs.cloud"
	LocalhostRPC     = "http://localhost:8545"
)

Variables

This section is empty.

Functions

func CLIFlags

func CLIFlags(envPrefix string) []cli.Flag

func FetchAndExecute

func FetchAndExecute()

FetchAndExecute() will fetch the privatekey, and correct PSP from GCP and execute it on the correct chain.

func FetchPSPInGCP

func FetchPSPInGCP() (string, string, []byte, error)

FetchPSPInGCP() will fetch the correct PSPs into GCP and return the Data.

func FetchPrivateKeyInGcp

func FetchPrivateKeyInGcp() (string, error)

FetchPrivateKey() will fetch the privatekey of the account that will execute the pause (from the GCP secret manager).

func GetTheL1Client

func GetTheL1Client() (*ethclient.Client, error)

GetTheL1Client() will return the L1 client based on the RPC provided in the config and ensure that the RPC is not production one.

func PspExecutionOnChain

func PspExecutionOnChain(ctx context.Context, l1client *ethclient.Client, superchainconfig_address string, privatekey string, safe_address string, data []byte)

PSPexecution(): PSPExecutionOnChain is a core function that will check that status of the superchain is not paused and then send onchain transaction to pause the superchain.

Types

type Account

type Account struct {
	Address  common.Address
	Nickname string
}

type CLIConfig

type CLIConfig struct {
	NodeUrl string
	// contains filtered or unexported fields
}

func ReadCLIFlags

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

type Defender

type Defender struct {
	SuperChainConfigAddress string
	// contains filtered or unexported fields
}

func NewDefender

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

NewAPI creates a new HTTP API Server for the PSP Executor and starts listening on the specified port from the args passed.

func (*Defender) Close

func (d *Defender) Close(_ context.Context) error

func (*Defender) Run

func (d *Defender) Run(ctx context.Context)

type RequestData

type RequestData struct {
	Pause     bool   `json:"pause"`
	Timestamp int64  `json:"timestamp"`
	Operator  string `json:"operator"`
	Calldata  string `json:"calldata"` //temporary field as the calldata will be fetched from the GCP in the future (so will be removed in the future PR).
}

type Response

type Response struct {
	Message string `json:"message"`
	Status  int    `json:"status"`
}

Define a struct that represents the data structure of your response

Jump to

Keyboard shortcuts

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