validator

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyEventOutputSubmitted  = "OutputSubmitted"
	KeyEventChallengeCreated = "ChallengeCreated"
	KeyEventReadyToProve     = "ReadyToProve"
)

Variables

View Source
var PublicRoundAddress = common.HexToAddress(publicRoundHex)

Functions

func IsOutputDeleted

func IsOutputDeleted(outputRoot [32]byte) bool

IsOutputDeleted checks if the output is deleted.

func Main

func Main(version string, cliCtx *cli.Context) error

Main is the entrypoint into the Validator. This method executes the service and blocks until the service exits.

func SubmitL2OutputTxData

func SubmitL2OutputTxData(abi *abi.ABI, output *eth.OutputResponse) ([]byte, error)

SubmitL2OutputTxData creates the transaction data for the submitL2OutputTx function.

Types

type CLIConfig

type CLIConfig struct {
	// L1EthRpc is the Websocket provider URL for L1.
	L1EthRpc string

	// L2EthRpc is the HTTP provider URL for the L2 execution engine.
	L2EthRpc string

	// RollupRpc is the HTTP provider URL for the rollup node.
	RollupRpc string

	// L2OOAddress is the L2OutputOracle contract address.
	L2OOAddress string

	// ColosseumAddress is the Colosseum contract address.
	ColosseumAddress string

	// SecurityCouncilAddress is the SecurityCouncil contract address.
	SecurityCouncilAddress string

	// ValPoolAddress is the ValidatorPool contract address.
	ValPoolAddress string

	// ChallengerPollInterval is how frequently to poll L2 for new finalized outputs.
	ChallengerPollInterval time.Duration

	// ProverRPC is the URL of prover jsonRPC server.
	ProverRPC string

	// AllowNonFinalized can be set to true to submit outputs
	// for L2 blocks derived from non-finalized L1 data.
	AllowNonFinalized bool

	OutputSubmitterEnabled bool

	OutputSubmitterAllowPublicRound bool

	// OutputSubmitterRetryInterval is how frequently to retry output submission.
	OutputSubmitterRetryInterval time.Duration

	// OutputSubmitterRoundBuffer is how many blocks before each round to start trying submission.
	OutputSubmitterRoundBuffer uint64

	ChallengerEnabled bool

	GuardianEnabled bool

	FetchingProofTimeout time.Duration

	TxMgrConfig   txmgr.CLIConfig
	RPCConfig     oprpc.CLIConfig
	LogConfig     oplog.CLIConfig
	MetricsConfig opmetrics.CLIConfig
	PprofConfig   pprof.CLIConfig
}

CLIConfig is a well typed config that is parsed from the CLI params. This also contains config options for auxiliary services. It is transformed into a `Config` before the Validator is started.

func NewConfig

func NewConfig(ctx *cli.Context) CLIConfig

NewConfig parses the Config from the provided flags or environment variables.

func (CLIConfig) Check

func (c CLIConfig) Check() error

type ChallengeCreatedEvent

type ChallengeCreatedEvent struct {
	OutputIndex *big.Int
	Asserter    common.Address
	Challenger  common.Address
}

func NewChallengeCreatedEvent

func NewChallengeCreatedEvent(log types.Log) ChallengeCreatedEvent

type Challenger

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

func NewChallenger

func NewChallenger(cfg Config, l log.Logger, m metrics.Metricer) (*Challenger, error)

func (*Challenger) Bisect

func (c *Challenger) Bisect(ctx context.Context, outputIndex *big.Int, challenger common.Address) (*types.Transaction, error)

func (*Challenger) BuildSegments

func (c *Challenger) BuildSegments(ctx context.Context, turn uint8, segStart, segSize uint64) (*chal.Segments, error)

func (*Challenger) CancelChallenge

func (c *Challenger) CancelChallenge(ctx context.Context, outputIndex *big.Int) (*types.Transaction, error)

func (*Challenger) ChallengerTimeout

func (c *Challenger) ChallengerTimeout(ctx context.Context, outputIndex *big.Int, challenger common.Address) (*types.Transaction, error)

func (*Challenger) CreateChallenge

func (c *Challenger) CreateChallenge(ctx context.Context, outputRange *OutputRange) (*types.Transaction, error)

func (*Challenger) GetChallenge

func (c *Challenger) GetChallenge(ctx context.Context, outputIndex *big.Int, challenger common.Address) (bindings.TypesChallenge, error)

func (*Challenger) GetChallengeStatus

func (c *Challenger) GetChallengeStatus(ctx context.Context, outputIndex *big.Int, challenger common.Address) (uint8, error)

func (*Challenger) HasEnoughDeposit

func (c *Challenger) HasEnoughDeposit(ctx context.Context) (bool, error)

HasEnoughDeposit checks if challenger has enough deposit to bond when creating challenge.

func (*Challenger) InitConfig

func (c *Challenger) InitConfig(ctx context.Context) error

func (*Challenger) IsInChallengeCreationPeriod

func (c *Challenger) IsInChallengeCreationPeriod(ctx context.Context, outputIndex *big.Int) (bool, error)

func (*Challenger) IsOutputFinalized

func (c *Challenger) IsOutputFinalized(ctx context.Context, outputIndex *big.Int) (bool, error)

func (*Challenger) OutputAtBlockSafe

func (c *Challenger) OutputAtBlockSafe(ctx context.Context, blockNumber uint64) (*eth.OutputResponse, error)

func (*Challenger) OutputWithProofAtBlockSafe

func (c *Challenger) OutputWithProofAtBlockSafe(ctx context.Context, blockNumber uint64) (*eth.OutputResponse, error)

func (*Challenger) OutputsAtIndex

func (c *Challenger) OutputsAtIndex(ctx context.Context, outputIndex *big.Int) (*Outputs, error)

func (*Challenger) ProveFault

func (c *Challenger) ProveFault(ctx context.Context, outputIndex *big.Int, challenger common.Address, skipSelectFaultPosition bool) (*types.Transaction, error)

ProveFault creates proveFault transaction for invalid output root. TODO: ProveFault will take long time, so that we may have to handle it carefully.

func (*Challenger) PublicInputProof

func (c *Challenger) PublicInputProof(ctx context.Context, blockNumber uint64) (bindings.TypesPublicInputProof, error)

func (*Challenger) Start

func (c *Challenger) Start(ctx context.Context) error

func (*Challenger) Stop

func (c *Challenger) Stop() error

func (*Challenger) ValidateOutput

func (c *Challenger) ValidateOutput(outputIndex *big.Int, outputs *Outputs) *OutputRange

ValidateOutput validates the output for the given outputIndex.

type Config

type Config struct {
	L2OutputOracleAddr              common.Address
	ColosseumAddr                   common.Address
	SecurityCouncilAddr             common.Address
	ValidatorPoolAddr               common.Address
	ChallengerPollInterval          time.Duration
	NetworkTimeout                  time.Duration
	TxManager                       *txmgr.BufferedTxManager
	L1Client                        *ethclient.Client
	L2Client                        *ethclient.Client
	RollupClient                    *sources.RollupClient
	RollupConfig                    *rollup.Config
	AllowNonFinalized               bool
	OutputSubmitterEnabled          bool
	OutputSubmitterAllowPublicRound bool
	OutputSubmitterRetryInterval    time.Duration
	OutputSubmitterRoundBuffer      uint64
	ChallengerEnabled               bool
	GuardianEnabled                 bool
	ProofFetcher                    ProofFetcher
}

Config contains the well typed fields that are used to initialize the output submitter. It is intended for programmatic use.

func NewValidatorConfig

func NewValidatorConfig(cfg CLIConfig, l log.Logger, m metrics.Metricer) (*Config, error)

NewValidatorConfig creates a validator config with given the CLIConfig

func (*Config) Check

func (c *Config) Check() error

Check ensures that the Config is valid.

type Guardian

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

Guardian is responsible for validating outputs.

func NewGuardian

func NewGuardian(cfg Config, l log.Logger) (*Guardian, error)

NewGuardian creates a new Guardian.

func (*Guardian) CheckConfirmCondition added in v1.3.3

func (g *Guardian) CheckConfirmCondition(ctx context.Context, transactionId *big.Int, outputIndex *big.Int) (bool, error)

func (*Guardian) ConfirmTransaction

func (g *Guardian) ConfirmTransaction(ctx context.Context, transactionId *big.Int) (*types.Transaction, error)

func (*Guardian) InitConfig

func (g *Guardian) InitConfig(ctx context.Context) error

func (*Guardian) OutputRootAtBlock

func (g *Guardian) OutputRootAtBlock(ctx context.Context, l2BlockNumber uint64) (eth.Bytes32, error)

func (*Guardian) RequestDeletion

func (g *Guardian) RequestDeletion(ctx context.Context, outputIndex *big.Int) (*types.Transaction, error)

func (*Guardian) Start

func (g *Guardian) Start(ctx context.Context) error

func (*Guardian) Stop

func (g *Guardian) Stop() error

func (*Guardian) ValidateL2Output

func (g *Guardian) ValidateL2Output(ctx context.Context, outputRoot eth.Bytes32, l2BlockNumber uint64) (bool, error)

type L2OutputSubmitter

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

L2OutputSubmitter is responsible for submitting outputs.

func NewL2OutputSubmitter

func NewL2OutputSubmitter(cfg Config, l log.Logger, m metrics.Metricer) (*L2OutputSubmitter, error)

NewL2OutputSubmitter creates a new L2OutputSubmitter.

func (*L2OutputSubmitter) CalculateWaitTime

func (l *L2OutputSubmitter) CalculateWaitTime(ctx context.Context, nextBlockNumber *big.Int) time.Duration

CalculateWaitTime checks the conditions for submitting L2Output and calculates the required latency. Returns time 0 if the conditions are such that submission is possible immediately.

func (*L2OutputSubmitter) FetchCurrentBlockNumber

func (l *L2OutputSubmitter) FetchCurrentBlockNumber(ctx context.Context) (*big.Int, error)

func (*L2OutputSubmitter) FetchNextBlockNumber

func (l *L2OutputSubmitter) FetchNextBlockNumber(ctx context.Context) (*big.Int, error)

func (*L2OutputSubmitter) FetchOutput

func (l *L2OutputSubmitter) FetchOutput(ctx context.Context, blockNumber *big.Int) (*eth.OutputResponse, error)

FetchOutput gets the output information to the corresponding block number. It returns the output info if the output can be made, otherwise error.

func (*L2OutputSubmitter) InitConfig

func (l *L2OutputSubmitter) InitConfig(ctx context.Context) error

func (*L2OutputSubmitter) L2ooAbi

func (l *L2OutputSubmitter) L2ooAbi() *abi.ABI

func (*L2OutputSubmitter) Start

func (l *L2OutputSubmitter) Start(ctx context.Context) error

func (*L2OutputSubmitter) Stop

func (l *L2OutputSubmitter) Stop() error

type OutputRange

type OutputRange struct {
	OutputIndex *big.Int
	StartBlock  uint64
	EndBlock    uint64
	L1Origin    eth.BlockID
}

type OutputSubmittedEvent

type OutputSubmittedEvent struct {
	ExpectedOutputRoot string
	OutputIndex        *big.Int
	L2BlockNumber      *big.Int
}

func NewOutputSubmittedEvent

func NewOutputSubmittedEvent(log types.Log) OutputSubmittedEvent

type Outputs

type Outputs struct {
	RemoteOutput bindings.TypesCheckpointOutput
	LocalOutput  *eth.OutputResponse
}

type ProofFetcher

type ProofFetcher interface {
	FetchProofAndPair(ctx context.Context, trace string) (*chal.ProofAndPair, error)
}

type Validator

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

func NewValidator

func NewValidator(cfg Config, l log.Logger, m metrics.Metricer) (*Validator, error)

func (*Validator) Start

func (v *Validator) Start() error

func (*Validator) Stop

func (v *Validator) Stop() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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