executor

package
v0.0.78 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 26 Imported by: 0

README

Executor

The Executor is an agent responsible for executing messages on the Destination.sol contract. It verifies that the message has been accepted by verifying a merkle proof, as well as the message's optimistic period.

Components

The Executor operates with two main components:

Run

streamLogs is the data-getter for the Executor. 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 Executor 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 Executor. 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 Executor's database and builds the tree accordingly.

Execute

Execute works in 3 parts.

  1. Verify that the optimistic period for the message has passed. This is done by checking the timestamp that the attestation was accepted on the Destination, then checking the timestamp of the last block.
  2. Verify that the message is in the merkle tree.
  3. Call the Execute function on the Destination.sol contract.

Directory Structure

TODO: fill this out

Executor
├── config
├── db
│   ├── sql
├── types
├── config
└── consumer

Documentation

Overview

Package executor is the executor agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend added in v0.0.63

type Backend interface {
	// HeaderByNumber returns the block header with the given block number.
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
}

Backend is the backend for the executor.

type Executor

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

Executor is the executor agent.

func NewExecutor

func NewExecutor(ctx context.Context, config config.Config, executorDB db.ExecutorDB, scribeClient client.ScribeClient, clients map[uint32]Backend) (*Executor, error)

NewExecutor creates a new executor agent.

func (Executor) Execute added in v0.0.69

func (e Executor) Execute(ctx context.Context, message types.Message) (bool, error)

Execute calls execute on `destination.sol` on the destination chain, after verifying the message.

func (Executor) Run added in v0.0.78

func (e Executor) Run(ctx context.Context) error

Run starts the executor agent. It calls `Start` and `Listen`.

func (Executor) Stop

func (e Executor) Stop(chainID uint32)

Stop stops the executor agent.

Directories

Path Synopsis
Package config defines the config for the Executor.
Package config defines the config for the Executor.
db
Package db provides a database interface for the executor.
Package db provides a database interface for the executor.
datastore/sql
Package sql provides a datastore implementation for the executor.
Package sql provides a datastore implementation for the executor.
datastore/sql/base
Package base contains the base sql implementation
Package base contains the base sql implementation
datastore/sql/mysql
Package mysql implements the mysql package
Package mysql implements the mysql package
datastore/sql/sqlite
Package sqlite implements the sqlite package
Package sqlite implements the sqlite package
Package types contains the database types for the Executor.
Package types contains the database types for the Executor.

Jump to

Keyboard shortcuts

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