Help us shape the future of Go! Take the 2026 Go Developer Survey

validator

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilCertificate        = errors.New("aggsender-validator nil certificate")
	ErrMetadataNotCompatible = errors.New("aggsender-validator metadata not compatible with the current version")
)

Functions

func DiffsBridgeExits

func DiffsBridgeExits(
	expected []*agglayertypes.BridgeExit,
	validating []*agglayertypes.BridgeExit) []string

DiffsBridgeExits compares two slices of BridgeExit and returns a slice of strings containing the differences between them.

func DiffsCertificate

func DiffsCertificate(
	expectedCertificate *agglayertypes.Certificate,
	validatingCertificate *agglayertypes.Certificate) []string

DiffsCertificate compares two certificates and returns a slice of strings containing the differences between them. If both certificates are nil, it returns an empty slice.

func DiffsImportedBridgeExits

func DiffsImportedBridgeExits(
	expected []*agglayertypes.ImportedBridgeExit,
	validating []*agglayertypes.ImportedBridgeExit) []string

DiffsImportedBridgeExits compares two slices of ImportedBridgeExit and returns a slice of strings containing the differences between them.

func HashCertificateToSign

func HashCertificateToSign(cert *agglayertypes.Certificate) (common.Hash, error)

HashCertificateToSign is the hash of the certificate that the validator will sign before returning result to the aggsender

Types

type CertificateValidator

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

CertificateValidator is a object to validate a certificate

func NewAggsenderValidator

func NewAggsenderValidator(logger aggkitcommon.Logger,
	flow types.AggsenderVerifierFlow,
	l1InfoTreeDataQuerier L1InfoTreeRootByLeafQuerier,
	certQuerier types.CertificateQuerier,
	initialLER common.Hash) *CertificateValidator

func (*CertificateValidator) ValidateCertificate

func (a *CertificateValidator) ValidateCertificate(ctx context.Context, params types.VerifyIncomingRequest) error

ValidateCertificate validates the incoming certificate against the previous one.

type Config

type Config struct {
	// EnableRPC is a flag to enable the RPC for validator
	EnableRPC bool `mapstructure:"EnableRPC"`
	// Signer is the key which is used to sign valid certificates
	Signer signertypes.SignerConfig `mapstructure:"Signer"`
	// ServerConfig contains the configuration for the gRPC server.
	ServerConfig aggkitgrpc.ServerConfig `mapstructure:"ServerConfig"`
	// MaxCertSize is the maximum size of the certificate (the emitted certificate cannot be bigger that this size)
	// 0 is infinite
	MaxCertSize uint `mapstructure:"MaxCertSize"`
	// MaxL2BlockNumber is the last L2 block number that is going to be included in a certificate
	// 0 means disabled
	MaxL2BlockNumber uint64 `mapstructure:"MaxL2BlockNumber"`
	// MaxL2BlockRange is the maximum L2 block range allowed in a certificate (ToBlock - FromBlock)
	// 0 means disabled
	MaxL2BlockRange uint64 `mapstructure:"MaxL2BlockRange"`
	// DelayBetweenRetries is the delay between retries:
	//  is used on store Certificate and also in initial check
	DelayBetweenRetries types.Duration `mapstructure:"DelayBetweenRetries"`
	// LerQuerier contains the configuration for the LER querier
	// which is used to query the LER data from the RollupManager contract
	LerQuerier LerQuerierConfig `mapstructure:"LerQuerierConfig"`
	// PPConfig specific configuration for Pessimistic mode
	PPConfig PPConfig `mapstructure:"PPConfig"`
	// FEPConfig specific configuration for FEP mode
	FEPConfig FEPConfig `mapstructure:"FEPConfig"`
	// AgglayerClient is the Agglayer gRPC client configuration
	AgglayerClient agglayer.ClientConfig `mapstructure:"AgglayerClient"`
	// Mode is the mode of the AggSender Validator (regular pessimistic proof mode or the aggchain proof mode)
	Mode aggsendertypes.AggsenderMode `jsonschema:"enum=PessimisticProof, enum=AggchainProof, enum=Auto" mapstructure:"Mode"` //nolint:lll
	// RequireCommitteeMembershipCheck indicates whether to check if the validator is part of the committee
	RequireCommitteeMembershipCheck bool `mapstructure:"RequireCommitteeMembershipCheck"`
	// AgglayerBridgeL2Addr is the address of the bridge L2 sovereign contract on L2 sovereign chain
	AgglayerBridgeL2Addr ethCommon.Address `mapstructure:"AgglayerBridgeL2Addr"`
	// UnsetClaimsMaxLogBlockRange is the proactive max block range for eth_getLogs queries when fetching unset claims.
	// 0 means disabled.
	UnsetClaimsMaxLogBlockRange uint64 `mapstructure:"UnsetClaimsMaxLogBlockRange"`
	// GlobalExitRootL1Addr is the address of the GlobalExitRootManager contract on L1
	GlobalExitRootL1Addr ethCommon.Address `mapstructure:"GlobalExitRootL1Addr"`
	// BlockFinalityForL1InfoTree indicates the block finality to use when querying for L1InfoRoot to use
	BlockFinalityForL1InfoTree aggkittypes.BlockNumberFinality `` //nolint:lll
	/* 147-byte string literal not displayed */

}

Config defines the configuration for the validator validator service.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type FEPConfig

type FEPConfig struct {
	// SovereignRollupAddr is the address of the sovereign rollup contract on L1
	SovereignRollupAddr ethCommon.Address `mapstructure:"SovereignRollupAddr"`
	// RequireNoBlockGap is true if the AggSender should not accept a gap between
	// lastBlock from lastCertificate and first block of FEP
	RequireNoBlockGap bool `mapstructure:"RequireNoBlockGap"`
	// OpNodeURL is the URL of the OP Node to query for op related data
	OpNodeURL string `mapstructure:"OpNodeURL"`
}

type L1InfoTreeRootByLeafQuerier

type L1InfoTreeRootByLeafQuerier interface {
	// GetL1InfoRootByLeafIndex returns the L1 Info tree root for the given leaf index
	GetL1InfoRootByLeafIndex(ctx context.Context, leafCount uint32) (*treetypes.Root, error)
}

type LerQuerierConfig

type LerQuerierConfig struct {
	// RollupManagerAddr is the address of the RollupManager contract on L1
	RollupManagerAddr ethCommon.Address `mapstructure:"RollupManagerAddr"`
	// RollupCreationBlockL1 is the block number when the rollup was created on L1
	RollupCreationBlockL1 uint64 `mapstructure:"RollupCreationBlockL1"`
}

type LocalValidator

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

LocalValidator is a struct that implements the types.Validator interface and is used to validate and sign certificates locally. This is a temporary check, in the future it will be replaced with a object that calls to aggsender-validator using grpc

func NewLocalValidator

func NewLocalValidator(
	log aggkitcommon.Logger,
	storage db.AggSenderStorage,
	validator types.CertificateValidator,
) *LocalValidator

NewLocalValidator creates a new LocalValidator instance.

func (*LocalValidator) Address

func (a *LocalValidator) Address() common.Address

Address returns the Ethereum address of the LocalValidator

func (*LocalValidator) HealthCheck

func (a *LocalValidator) HealthCheck(ctx context.Context) (*types.HealthCheckResponse, error)

func (*LocalValidator) Index

func (a *LocalValidator) Index() uint32

Index returns the index of the validator in the signers list For local validator it is always 0

func (*LocalValidator) String

func (a *LocalValidator) String() string

String returns a string representation of the LocalValidator.

func (*LocalValidator) URL

func (a *LocalValidator) URL() string

URL returns an URL for the LocalValidator

func (*LocalValidator) ValidateAndSignCertificate

func (a *LocalValidator) ValidateAndSignCertificate(
	ctx context.Context,
	certificate *agglayertypes.Certificate,
	lastL2BlockInCert uint64,
) ([]byte, error)

ValidateAndSignCertificate validates the certificate. LocalValidator does not sign the certificate, it just validates it.

type PPConfig

type PPConfig struct {
	// RequireOneBridgeInPPCertificate is a flag to force the validator to have at least one bridge exit
	// for the Pessimistic Proof certificates
	RequireOneBridgeInPPCertificate bool `mapstructure:"RequireOneBridgeInPPCertificate"`
}

type RemoteValidator

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

RemoteValidator encapsulates the gRPC client and configuration required to interact with the AggsenderValidator service.

func NewRemoteValidator

func NewRemoteValidator(
	cfg *grpc.ClientConfig,
	storage db.AggSenderStorage,
	address common.Address,
	index uint32,
) (*RemoteValidator, error)

NewRemoteValidator initializes a new RemoteValidator with the provided gRPC client configuration. It returns an error if the gRPC client cannot be created.

func (*RemoteValidator) Address

func (v *RemoteValidator) Address() common.Address

Address returns the Ethereum address of the remote validator

func (*RemoteValidator) HealthCheck

HealthCheck performs a health check on the AggsenderValidator service.

func (*RemoteValidator) Index

func (v *RemoteValidator) Index() uint32

Index is the index of the signer in the signers list on the Multisig contract

func (*RemoteValidator) String

func (v *RemoteValidator) String() string

String returns a string representation of the RemoteValidator.

func (*RemoteValidator) URL

func (v *RemoteValidator) URL() string

URL returns an URL for the remote validator

func (*RemoteValidator) ValidateAndSignCertificate

func (v *RemoteValidator) ValidateAndSignCertificate(
	ctx context.Context,
	certificate *agglayertypes.Certificate,
	lastL2BlockInCert uint64,
) ([]byte, error)

ValidateAndSignCertificate sends a certificate to the AggsenderValidator service for validation.

type ValidatorClient

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

ValidatorClient encapsulates the gRPC client and configuration required to interact with the AggsenderValidator service.

func NewValidatorClient

func NewValidatorClient(cfg *grpc.ClientConfig) (*ValidatorClient, error)

NewValidatorClient initializes a new ValidatorClient with the provided gRPC client configuration. It returns an error if the gRPC client cannot be created.

func (*ValidatorClient) HealthCheck

func (*ValidatorClient) ValidateCertificate

func (v *ValidatorClient) ValidateCertificate(
	ctx context.Context,
	previousCertificateID *common.Hash,
	certificate *agglayertypes.Certificate,
	lastL2BlockInCert uint64,
) ([]byte, error)

ValidateCertificate sends a certificate to the AggsenderValidator service for validation.

type ValidatorService

type ValidatorService struct {
	// Embed the generated server interface to ensure forward compatibility
	v1.UnimplementedAggsenderValidatorServer
	// contains filtered or unexported fields
}

ValidatorService implements the gRPC server for the AggsenderValidator service.

func (*ValidatorService) HealthCheck

HealthCheck implements the HealthCheck method of the AggsenderValidator service.

func (*ValidatorService) ValidateCertificate

ValidateCertificate validates a new certificate

Directories

Path Synopsis
proto
v1

Jump to

Keyboard shortcuts

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