guard

package
v0.22.5 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 33 Imported by: 0

README

Guard

The Guard is an agent responsible for verifying actions from other Agents in the optimistic messaging model. This includes polling for invalid states and attestations as well as submitting fraud reports.

Components

The Guard operates with four main components:

Run

streamLogs is the data-getter for the Guard. It works by instantiating a gRPC connection to Scribe, and puts logs in a channel for the origin and destination contracts on each chain in the config. From here, it verifies the logs' order since the order of logs are very important for merkle tree construction.
Additionally, if the Guard unexpectedly stops in the middle of streaming logs, it will use the current database state to reconstruct the tree up to where the last log was, then continue to use gRPC.

receiveLogs is the data-processor for the Guard. It works by taking the logs streamed from streamLogs and parsing the logs into either a Message on the Origin.sol contract, or a Attestation on the Destination.sol contract. It then stores the data into the Guard's database and builds the tree accordingly.

loadOriginLatestStates polls Origin states and caches them in order to make the latest data available.

submitLatestSnapshot fetches the latest snapshot from Origin and submits it on Summit.

updateAgentStatuses polls the database for RelayableAgentStatus entries and calls updateAgentStatus() once a sufficient agent root is passed to the given remote chain.

Fraud Reporting

The fraud reporting logic can be found in fraud.go, which consists mostly of handlers for various logs. The two major handlers are handleSnapshotAccepted and handleAttestationAccepted, both of which verify states corresponding to the incoming snapshot/attestation, initiate slashing if applicable, and submit state reports to eligible chains.

Usage

Navigate to sanguine/agents/agents/guard/main and run the following command to start the Guard:

$ go run main.go

Then the Guard command line will be exposed. The Guard requires a gRPC connection to a Scribe instance to stream logs. This can be done with either a remote Scribe or an embedded Scribe.

For more information on how to interact with Scribe see the Executor README.

Directory Structure

Guard
├── main: API server
├── cmd: CLI commands
├── db: Database interface
│   └── sql: Database writer, reader, and migrations
├── main: CLI entrypoint

Documentation

Overview

Package guard signs attestations and posts to attestation collector and destination.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard scans origins for latest state and submits snapshots to the Summit.

func NewGuard

func NewGuard(ctx context.Context, cfg config.AgentConfig, omniRPCClient omnirpcClient.RPCClient, scribeClient client.ScribeClient, guardDB db.GuardDB, handler metrics.Handler) (guard *Guard, err error)

NewGuard creates a new guard.

func (Guard) Start

func (g Guard) Start(parentCtx context.Context) error

Start starts the guard.

Directories

Path Synopsis
Package api contains the API for the guard.
Package api contains the API for the guard.
Package cmd provides the command line interface for the guard.
Package cmd provides the command line interface for the guard.
db
Package db defines the interface for the database.
Package db defines the interface for the database.
sql/base
Package base contains the base sql implementation
Package base contains the base sql implementation
sql/mysql
Package mysql contains a mysql db
Package mysql contains a mysql db
sql/sqlite
Package sqlite implements the sqlite package
Package sqlite implements the sqlite package
Package main provides the main function for the Guard.
Package main provides the main function for the Guard.
Package metadata provides metadata for Guard.
Package metadata provides metadata for Guard.

Jump to

Keyboard shortcuts

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