chainio

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRetries                        = 100
	RetryInterval                     = 1 * time.Second
	BlockInterval              uint64 = 1000
	PollLatestBatchInterval           = 5 * time.Second
	RemoveBatchFromSetInterval        = 5 * time.Minute
)

Variables

This section is empty.

Functions

func SubscribeToNewTasksV2Retryable added in v0.11.0

func SubscribeToNewTasksV2Retryable(
	opts *bind.WatchOpts,
	serviceManager *servicemanager.ContractAlignedLayerServiceManager,
	newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV2,
	batchMerkleRoot [][32]byte,
) (event.Subscription, error)

SubscribeToNewTasksV2Retryable Subscribe to NewBatchV2 logs from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func SubscribeToNewTasksV3Retryable added in v0.11.0

func SubscribeToNewTasksV3Retryable(
	opts *bind.WatchOpts,
	serviceManager *servicemanager.ContractAlignedLayerServiceManager,
	newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV3,
	batchMerkleRoot [][32]byte,
) (event.Subscription, error)

SubscribeToNewTasksV3Retryable Subscribe to NewBatchV3 logs from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

Types

type AvsReader

type AvsReader struct {
	*sdkavsregistry.ChainReader
	AvsContractBindings            *AvsServiceBindings
	AlignedLayerServiceManagerAddr ethcommon.Address
	// contains filtered or unexported fields
}

func NewAvsReaderFromConfig

func NewAvsReaderFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.EcdsaConfig) (*AvsReader, error)

func (*AvsReader) DisabledVerifiers added in v0.10.0

func (r *AvsReader) DisabledVerifiers() (*big.Int, error)

func (*AvsReader) GetErc20Mock

func (r *AvsReader) GetErc20Mock(tokenAddr ethcommon.Address) (*contractERC20Mock.ContractERC20Mock, error)

func (*AvsReader) GetNotRespondedTasksFrom added in v0.9.0

func (r *AvsReader) GetNotRespondedTasksFrom(fromBlock uint64) ([]servicemanager.ContractAlignedLayerServiceManagerNewBatchV3, error)

Returns all the "NewBatchV3" logs that have not been responded starting from the given block number

func (*AvsReader) GetOldTaskHash added in v0.10.0

func (r *AvsReader) GetOldTaskHash(nBlocksOld uint64, interval uint64) (*[32]byte, error)

This function is a helper to get a task hash of aproximately nBlocksOld blocks ago

func (*AvsReader) IsOperatorRegistered

func (r *AvsReader) IsOperatorRegistered(address ethcommon.Address) (bool, error)

type AvsServiceBindings

type AvsServiceBindings struct {
	ServiceManager         *csservicemanager.ContractAlignedLayerServiceManager
	ServiceManagerFallback *csservicemanager.ContractAlignedLayerServiceManager
	// contains filtered or unexported fields
}

func NewAvsServiceBindings

func NewAvsServiceBindings(serviceManagerAddr, blsOperatorStateRetrieverAddr gethcommon.Address, ethClient eth.InstrumentedClient, ethClientFallback eth.InstrumentedClient, logger logging.Logger) (*AvsServiceBindings, error)

type AvsSubscriber

type AvsSubscriber struct {
	AvsContractBindings            *AvsServiceBindings
	AlignedLayerServiceManagerAddr ethcommon.Address
	// contains filtered or unexported fields
}

Subscribers use a ws connection instead of http connection like Readers kind of stupid that the geth client doesn't have a unified interface for both... it takes a single url, so the bindings, even though they have watcher functions, those can't be used with the http connection... seems very very stupid. Am I missing something?

func NewAvsSubscriberFromConfig

func NewAvsSubscriberFromConfig(baseConfig *config.BaseConfig) (*AvsSubscriber, error)

func (*AvsSubscriber) BatchesStateRetryable added in v0.11.0

func (s *AvsSubscriber) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (struct {
	TaskCreatedBlock      uint32
	Responded             bool
	RespondToTaskFeeLimit *big.Int
}, error)

BatchesStateRetryable Get the state of a batch from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec

func (*AvsSubscriber) BlockNumberRetryable added in v0.11.0

func (s *AvsSubscriber) BlockNumberRetryable(ctx context.Context) (uint64, error)

BlockNumberRetryable Get the latest block number from Ethereum - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func (*AvsSubscriber) FilterBatchV2Retryable added in v0.11.0

func (s *AvsSubscriber) FilterBatchV2Retryable(opts *bind.FilterOpts, batchMerkleRoot [][32]byte) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV2Iterator, error)

FilterBatchV2Retryable Get NewBatchV2 logs from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func (*AvsSubscriber) FilterBatchV3Retryable added in v0.11.0

func (s *AvsSubscriber) FilterBatchV3Retryable(opts *bind.FilterOpts, batchMerkleRoot [][32]byte) (*servicemanager.ContractAlignedLayerServiceManagerNewBatchV3Iterator, error)

FilterBatchV3Retryable Get NewBatchV3 logs from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func (*AvsSubscriber) SubscribeNewHeadRetryable added in v0.11.0

func (s *AvsSubscriber) SubscribeNewHeadRetryable(ctx context.Context, c chan<- *types.Header) (ethereum.Subscription, error)

SubscribeNewHeadRetryable Subscribe to new heads from the Ethereum node. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func (*AvsSubscriber) SubscribeToNewTasksV2 added in v0.5.0

func (s *AvsSubscriber) SubscribeToNewTasksV2(newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV2) (chan error, error)

func (*AvsSubscriber) SubscribeToNewTasksV3 added in v0.7.0

func (s *AvsSubscriber) SubscribeToNewTasksV3(newTaskCreatedChan chan *servicemanager.ContractAlignedLayerServiceManagerNewBatchV3) (chan error, error)

func (*AvsSubscriber) WaitForOneBlock added in v0.5.0

func (s *AvsSubscriber) WaitForOneBlock(startBlock uint64) error

type AvsWriter

type AvsWriter struct {
	*avsregistry.ChainWriter
	AvsContractBindings *AvsServiceBindings

	Signer         signer.Signer
	Client         eth.InstrumentedClient
	ClientFallback eth.InstrumentedClient
	// contains filtered or unexported fields
}

func NewAvsWriterFromConfig

func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.EcdsaConfig, metrics *metrics.Metrics) (*AvsWriter, error)

func (*AvsWriter) BalanceAtRetryable added in v0.11.0

func (w *AvsWriter) BalanceAtRetryable(ctx context.Context, aggregatorAddress common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAtRetryable Get the balance of aggregatorAddress at blockNumber. If blockNumber is nil, it gets the latest balance. TODO: it gets the balance from an Address, not necessarily an aggregator. The name of the parameter should be changed. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec.

func (*AvsWriter) BatcherBalancesRetryable added in v0.11.0

func (w *AvsWriter) BatcherBalancesRetryable(opts *bind.CallOpts, senderAddress common.Address) (*big.Int, error)

BatcherBalancesRetryable Get the balance of a batcher from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec

func (*AvsWriter) BatchesStateRetryable added in v0.11.0

func (w *AvsWriter) BatchesStateRetryable(opts *bind.CallOpts, arg0 [32]byte) (struct {
	TaskCreatedBlock      uint32
	Responded             bool
	RespondToTaskFeeLimit *big.Int
}, error)

BatchesStateRetryable Get the state of a batch from the AVS contract. - All errors are considered Transient Errors - Retry times (3 retries): 1 sec, 2 sec, 4 sec

func (*AvsWriter) RespondToTaskV2Retryable added in v0.11.0

func (w *AvsWriter) RespondToTaskV2Retryable(opts *bind.TransactOpts, batchMerkleRoot [32]byte, senderAddress common.Address, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature) (*types.Transaction, error)

RespondToTaskV2Retryable Send a transaction to the AVS contract to respond to a task. - All errors are considered Transient Errors - Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks) - NOTE: Contract call reverts are not considered `PermanentError`'s as block reorg's may lead to contract call revert in which case the aggregator should retry.

func (*AvsWriter) SendAggregatedResponse

func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMerkleRoot [32]byte, senderAddress [20]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature, gasBumpPercentage uint, gasBumpIncrementalPercentage uint, timeToWaitBeforeBump time.Duration, onGasPriceBumped func(*big.Int)) (*types.Receipt, error)

SendAggregatedResponse continuously sends a RespondToTask transaction until it is included in the blockchain. This function:

  1. Simulates the transaction to calculate the nonce and initial gas price without broadcasting it.
  2. Repeatedly attempts to send the transaction, bumping the gas price after `timeToWaitBeforeBump` has passed.
  3. Monitors for the receipt of previously sent transactions or checks the state to confirm if the response has already been processed (e.g., by another transaction).
  4. Validates that the aggregator and batcher have sufficient balance to cover transaction costs before sending.

Returns:

  • A transaction receipt if the transaction is successfully included in the blockchain.
  • If no receipt is found, but the batch state indicates the response has already been processed, it exits without an error (returning `nil, nil`).
  • An error if the process encounters a fatal issue (e.g., permanent failure in verifying balances or state).

Jump to

Keyboard shortcuts

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