validator

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChainID string
View Source
var ErrTxnHashNotFound = rpc.RPCError{Code: 29, Message: "Transaction hash not found"}
View Source
var Sleep = time.Sleep

Created a function variable for mocking purposes in tests

View Source
var Version string = "dev"

The current version of the validator tool. This is set at build time

Functions

func CheckBalance added in v0.2.7

func CheckBalance[S signerP.Signer](
	signer S, threshold float64, logger *junoUtils.ZapLogger, tracer metrics.Tracer,
)

func CorrectEpochSwitch added in v0.2.0

func CorrectEpochSwitch(prevEpoch *types.EpochInfo, newEpoch *types.EpochInfo) bool

func FetchEpochAndAttestInfoWithRetry

func FetchEpochAndAttestInfoWithRetry[Signer signerP.Signer](
	signer Signer,
	logger *utils.ZapLogger,
	prevEpoch *types.EpochInfo,
	isEpochSwitchCorrect func(prevEpoch *types.EpochInfo, newEpoch *types.EpochInfo) bool,
	maxRetries types.Retries,
	newEpochId string,
) (types.EpochInfo, types.AttestInfo, error)

func MockRPCServer added in v0.2.0

func MockRPCServer(
	t *testing.T, operationalAddress *felt.Felt, serverInternalError string,
) *httptest.Server

func NewProvider

func NewProvider[Logger utils.Logger](providerUrl string, logger Logger) (*rpc.Provider, error)

Returns a new Starknet.Go RPC Provider

func ProcessBlockHeaders

func ProcessBlockHeaders[Account signerP.Signer](
	ctx context.Context,
	headersFeed chan *rpc.BlockHeader,
	account Account,
	logger *utils.ZapLogger,
	dispatcher *EventDispatcher[Account],
	maxRetries types.Retries,
	tracer metrics.Tracer,
) error

func RunBlockHeaderWatcher added in v0.1.2

func RunBlockHeaderWatcher[S signerP.Signer](
	ctx context.Context,
	wsProviderURL string,
	logger *utils.ZapLogger,
	signer S,
	dispatcher *EventDispatcher[S],
	maxRetries types.Retries,
	wg *conc.WaitGroup,
	tracer metrics.Tracer,
) error

func SepoliaValidationContracts added in v0.2.0

func SepoliaValidationContracts(t *testing.T) *types.ValidationContracts

func SetTargetBlockHashIfExists

func SetTargetBlockHashIfExists[Account signerP.Signer](
	account Account,
	logger *utils.ZapLogger,
	attestInfo *types.AttestInfo,
)

func SubscribeToBlockHeaders added in v0.1.2

func SubscribeToBlockHeaders[Logger utils.Logger](ctx context.Context, wsProviderUrl string, logger Logger) (
	*rpc.WsProvider,
	chan *rpc.BlockHeader,
	*client.ClientSubscription,
	error,
)

Returns a Go channel where BlockHeaders are received

Types

type AttestStatus

type AttestStatus uint8
const (
	Iddle AttestStatus = iota
	Ongoing
	Successful
	Failed
)

func TrackAttest

func TrackAttest[S signerP.Signer](
	signer S,
	logger *junoUtils.ZapLogger,
	txHash *felt.Felt,
) AttestStatus

type AttestTracker added in v0.1.1

type AttestTracker struct {
	Transaction AttestTransaction
	Hash        felt.Felt
	Status      AttestStatus
}

func NewAttestTracker added in v0.1.1

func NewAttestTracker() AttestTracker

func (*AttestTracker) UpdateStatus added in v0.2.4

func (a *AttestTracker) UpdateStatus(
	signer signerP.Signer,
	logger *junoUtils.ZapLogger,
)

type AttestTransaction added in v0.2.4

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

func (*AttestTransaction) Build added in v0.2.4

func (t *AttestTransaction) Build(signer signerP.Signer, blockHash *types.BlockHash) error

func (*AttestTransaction) Invoke added in v0.2.4

func (*AttestTransaction) UpdateNonce added in v0.2.4

func (t *AttestTransaction) UpdateNonce(signer signerP.Signer) error

func (*AttestTransaction) Valid added in v0.2.4

func (t *AttestTransaction) Valid() bool

I want to name this built or smth like that

type EnvVariable added in v0.2.0

type EnvVariable struct {
	HttpProviderUrl string
	WsProviderUrl   string
}

func LoadEnv added in v0.2.0

func LoadEnv(t *testing.T) (EnvVariable, error)

type EventDispatcher

type EventDispatcher[S signerP.Signer] struct {
	// Current epoch attest-related fields
	CurrentAttest AttestTracker
	// Event channels
	DoAttest      chan types.DoAttest
	PrepareAttest chan types.PrepareAttest
	EndOfWindow   chan struct{}
}

func NewEventDispatcher

func NewEventDispatcher[S signerP.Signer]() EventDispatcher[S]

func (*EventDispatcher[S]) Dispatch

func (d *EventDispatcher[S]) Dispatch(
	signer S, balanceThreshold float64, logger *junoUtils.ZapLogger, tracer metrics.Tracer,
)

type Method added in v0.2.0

type Method struct {
	Name   string `json:"method"`
	Params []any  `json:"params"`
}

type Validator added in v0.2.0

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

func New added in v0.2.0

func New(
	config *config.Config, snConfig *config.StarknetConfig, logger utils.ZapLogger, braavos bool,
) (Validator, error)

func (*Validator) Attest added in v0.2.0

func (v *Validator) Attest(
	ctx context.Context, maxRetries types.Retries, balanceThreshold float64, tracer metrics.Tracer,
) error

Main execution loop of the program. Listens to the blockchain and sends attest invoke when it's the right time

func (*Validator) ChainID added in v0.2.0

func (v *Validator) ChainID() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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