Documentation ¶
Index ¶
- Constants
- Variables
- type Aggregator
- func (agg *Aggregator) Close() error
- func (agg *Aggregator) EnableMetrics(registry *prometheus.Registry) error
- func (agg *Aggregator) GetAggregatedCheckpointMessages(fromTimestamp, toTimestamp uint64) (*messages.CheckpointMessages, error)
- func (agg *Aggregator) GetCheckpointMessages(fromTimestamp, toTimestamp uint64) (*types.GetCheckpointMessagesResponse, error)
- func (agg *Aggregator) GetOperatorInfoById(ctx context.Context, operatorId eigentypes.OperatorId) (eigentypes.OperatorInfo, bool)
- func (agg *Aggregator) GetOperatorSetUpdateAggregation(id uint64) (*types.GetOperatorSetUpdateAggregationResponse, error)
- func (agg *Aggregator) GetRegistryCoordinatorAddress(reply *string) error
- func (agg *Aggregator) GetStateRootUpdateAggregation(rollupId uint32, blockHeight uint64) (*types.GetStateRootUpdateAggregationResponse, error)
- func (agg *Aggregator) ProcessSignedCheckpointTaskResponse(signedCheckpointTaskResponse *messages.SignedCheckpointTaskResponse) error
- func (agg *Aggregator) ProcessSignedOperatorSetUpdateMessage(signedOperatorSetUpdateMessage *messages.SignedOperatorSetUpdateMessage) error
- func (agg *Aggregator) ProcessSignedStateRootUpdateMessage(signedStateRootUpdateMessage *messages.SignedStateRootUpdateMessage) error
- func (agg *Aggregator) Start(ctx context.Context) error
- type AggregatorEventListener
- type OperatorRegistrationsService
- type OperatorRegistrationsServiceInMemory
- type RestAggregatorer
- type RollupBroadcaster
- type RollupBroadcasterer
- type RollupWriter
- type RpcAggregatorer
- type SelectiveAggregatorListener
- func (l *SelectiveAggregatorListener) IncAggregatorInitializations()
- func (l *SelectiveAggregatorListener) IncErroredSubmissions()
- func (l *SelectiveAggregatorListener) IncExpiredMessages()
- func (l *SelectiveAggregatorListener) IncExpiredTasks()
- func (l *SelectiveAggregatorListener) ObserveLastCheckpointReferenceSent(referenceId uint32)
- func (l *SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceAggregated(referenceId uint32)
- func (l *SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceReceived(referenceId uint32)
- func (l *SelectiveAggregatorListener) ObserveLastOperatorSetUpdateAggregated(operatorSetUpdateId uint64)
- func (l *SelectiveAggregatorListener) ObserveLastOperatorSetUpdateReceived(operatorSetUpdateId uint64)
- func (l *SelectiveAggregatorListener) ObserveLastStateRootUpdateAggregated(rollupId uint32, blockNumber uint64)
- func (l *SelectiveAggregatorListener) ObserveLastStateRootUpdateReceived(rollupId uint32, blockNumber uint64)
Constants ¶
const ( GET_OPERATOR_SET_RETRIES = 5 GET_OPERATOR_SET_RETRY_INTERVAL = time.Millisecond * 500 )
const ( INITIALIZE_OPERATOR_SET_RETRIES = 5 INITIALIZE_OPERATOR_SET_RETRY_INTERVAL = 500 * time.Millisecond UPDATE_OPERATOR_SET_RETRIES = 5 UPDATE_OPERATOR_SET_RETRY_INTERVAL = 500 * time.Millisecond )
const (
AggregatorNamespace = "sffl_aggregator"
)
Variables ¶
var ( // RPC errors DigestError = errors.New("Failed to get message digest") TaskResponseDigestError = errors.New("Failed to get task response digest") GetOperatorSetUpdateBlockError = errors.New("Failed to get operator set update block") OperatorNotFoundError = errors.New("Operator not found") InvalidSignatureError = errors.New("Invalid signature") UnsupportedMessageTypeError = errors.New("Unsupported message type") MessageTimeoutError = errors.New("Message timeout") // REST errors StateRootUpdateNotFoundError = errors.New("StateRootUpdate not found") StateRootAggNotFoundError = errors.New("StateRootUpdate aggregation not found") OperatorSetNotFoundError = errors.New("OperatorSetUpdate not found") OperatorAggNotFoundError = errors.New("OperatorSetUpdate aggregation not found") CheckpointNotFoundError = errors.New("CheckpointMessages not found") )
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator sends checkpoint tasks onchain, then listens for operator signed TaskResponses. It aggregates responses signatures, and if any of the TaskResponses reaches the QuorumThreshold for each quorum (currently we only use a single quorum of the ERC20Mock token), it sends the aggregated TaskResponse and signature onchain.
The signature is checked in the BLSSignatureChecker.sol contract, which expects a
struct NonSignerStakesAndSignature { uint32[] nonSignerQuorumBitmapIndices; BN254.G1Point[] nonSignerPubkeys; BN254.G1Point[] quorumApks; BN254.G2Point apkG2; BN254.G1Point sigma; uint32[] quorumApkIndices; uint32[] totalStakeIndices; uint32[][] nonSignerStakeIndices; // nonSignerStakeIndices[quorumNumberIndex][nonSignerIndex] }
A task can only be responded onchain by having enough operators sign on it such that their stake in each quorum reaches the QuorumThreshold. In order to verify this onchain, the Registry contracts store the history of stakes and aggregate pubkeys (apks) for each operators and each quorum. These are updated everytime an operator registers or deregisters with the BLSRegistryCoordinatorWithIndices.sol contract, or calls UpdateStakes() on the StakeRegistry.sol contract, after having received new delegated shares or having delegated shares removed by stakers queuing withdrawals. Each of these pushes to their respective datatype array a new entry.
This is true for quorumBitmaps (represent the quorums each operator is opted into), quorumApks (apks per quorum), totalStakes (total stake per quorum), and nonSignerStakes (stake per quorum per operator). The 4 "indices" in NonSignerStakesAndSignature basically represent the index at which to fetch their respective data, given a blockNumber at which the task was created. Note that different data types might have different indices, since for eg QuorumBitmaps are updated for operators registering/deregistering, but not for UpdateStakes. Thankfully, we have deployed a helper contract BLSOperatorStateRetriever.sol whose function getCheckSignaturesIndices() can be used to fetch the indices given a block number.
The 4 other fields nonSignerPubkeys, quorumApks, apkG2, and sigma, however, must be computed individually. apkG2 and sigma are just the aggregated signature and pubkeys of the operators who signed the task response (aggregated over all quorums, so individual signatures might be duplicated). quorumApks are the G1 aggregated pubkeys of the operators who signed the task response, but one per quorum, as opposed to apkG2 which is summed over all quorums. nonSignerPubkeys are the G1 pubkeys of the operators who did not sign the task response, but were opted into the quorum at the blocknumber at which the task was created. Upon sending a task onchain (or receiving a CheckpointTaskCreated Event if the tasks were sent by an external task generator), the aggregator can get the list of all operators opted into each quorum at that block number by calling the getOperatorState() function of the BLSOperatorStateRetriever.sol contract.
func NewAggregator ¶
func NewAggregator( ctx context.Context, config *config.Config, registry *prometheus.Registry, logger logging.Logger, ) (*Aggregator, error)
NewAggregator creates a new Aggregator with the provided config.
func (*Aggregator) Close ¶
func (agg *Aggregator) Close() error
func (*Aggregator) EnableMetrics ¶
func (agg *Aggregator) EnableMetrics(registry *prometheus.Registry) error
func (*Aggregator) GetAggregatedCheckpointMessages ¶
func (agg *Aggregator) GetAggregatedCheckpointMessages(fromTimestamp, toTimestamp uint64) (*messages.CheckpointMessages, error)
func (*Aggregator) GetCheckpointMessages ¶
func (agg *Aggregator) GetCheckpointMessages(fromTimestamp, toTimestamp uint64) (*types.GetCheckpointMessagesResponse, error)
func (*Aggregator) GetOperatorInfoById ¶
func (agg *Aggregator) GetOperatorInfoById(ctx context.Context, operatorId eigentypes.OperatorId) (eigentypes.OperatorInfo, bool)
func (*Aggregator) GetOperatorSetUpdateAggregation ¶
func (agg *Aggregator) GetOperatorSetUpdateAggregation(id uint64) (*types.GetOperatorSetUpdateAggregationResponse, error)
func (*Aggregator) GetRegistryCoordinatorAddress ¶
func (agg *Aggregator) GetRegistryCoordinatorAddress(reply *string) error
func (*Aggregator) GetStateRootUpdateAggregation ¶
func (agg *Aggregator) GetStateRootUpdateAggregation(rollupId uint32, blockHeight uint64) (*types.GetStateRootUpdateAggregationResponse, error)
Rest requests
func (*Aggregator) ProcessSignedCheckpointTaskResponse ¶
func (agg *Aggregator) ProcessSignedCheckpointTaskResponse(signedCheckpointTaskResponse *messages.SignedCheckpointTaskResponse) error
func (*Aggregator) ProcessSignedOperatorSetUpdateMessage ¶
func (agg *Aggregator) ProcessSignedOperatorSetUpdateMessage(signedOperatorSetUpdateMessage *messages.SignedOperatorSetUpdateMessage) error
func (*Aggregator) ProcessSignedStateRootUpdateMessage ¶
func (agg *Aggregator) ProcessSignedStateRootUpdateMessage(signedStateRootUpdateMessage *messages.SignedStateRootUpdateMessage) error
Rpc request handlers
type AggregatorEventListener ¶
type AggregatorEventListener interface { ObserveLastStateRootUpdateAggregated(rollupId uint32, blockNumber uint64) ObserveLastStateRootUpdateReceived(rollupId uint32, blockNumber uint64) ObserveLastOperatorSetUpdateAggregated(operatorSetUpdateId uint64) ObserveLastOperatorSetUpdateReceived(operatorSetUpdateId uint64) IncExpiredMessages() IncExpiredTasks() IncErroredSubmissions() IncAggregatorInitializations() ObserveLastCheckpointReferenceSent(referenceId uint32) ObserveLastCheckpointTaskReferenceReceived(referenceId uint32) ObserveLastCheckpointTaskReferenceAggregated(referenceId uint32) }
func MakeAggregatorMetrics ¶
func MakeAggregatorMetrics(registry *prometheus.Registry) (AggregatorEventListener, error)
type OperatorRegistrationsService ¶
type OperatorRegistrationsService interface { operatorsinfo.OperatorsInfoService GetOperatorInfoById(ctx context.Context, operatorId types.OperatorId) (operatorInfo types.OperatorInfo, operatorFound bool) }
type OperatorRegistrationsServiceInMemory ¶
type OperatorRegistrationsServiceInMemory struct {
// contains filtered or unexported fields
}
func NewOperatorRegistrationsServiceInMemory ¶
func NewOperatorRegistrationsServiceInMemory( ctx context.Context, avsRegistrySubscriber avsregistry.AvsRegistrySubscriber, avsRegistryReader avsregistry.AvsRegistryReader, logger logging.Logger, ) (*OperatorRegistrationsServiceInMemory, error)
func (*OperatorRegistrationsServiceInMemory) GetOperatorInfo ¶
func (ors *OperatorRegistrationsServiceInMemory) GetOperatorInfo(ctx context.Context, operator common.Address) (types.OperatorInfo, bool)
func (*OperatorRegistrationsServiceInMemory) GetOperatorInfoById ¶
func (ors *OperatorRegistrationsServiceInMemory) GetOperatorInfoById(ctx context.Context, operatorId types.OperatorId) (types.OperatorInfo, bool)
type RestAggregatorer ¶
type RestAggregatorer interface { GetStateRootUpdateAggregation(rollupId uint32, blockHeight uint64) (*types.GetStateRootUpdateAggregationResponse, error) GetOperatorSetUpdateAggregation(id uint64) (*types.GetOperatorSetUpdateAggregationResponse, error) GetCheckpointMessages(fromTimestamp, toTimestamp uint64) (*types.GetCheckpointMessagesResponse, error) }
type RollupBroadcaster ¶
type RollupBroadcaster struct {
// contains filtered or unexported fields
}
func NewRollupBroadcaster ¶
func NewRollupBroadcaster( ctx context.Context, avsReader chainio.AvsReaderer, avsSubscriber chainio.AvsSubscriberer, rollupsInfo map[uint32]config.RollupInfo, signerConfig signerv2.Config, address common.Address, logger logging.Logger, ) (*RollupBroadcaster, error)
func (*RollupBroadcaster) BroadcastOperatorSetUpdate ¶
func (b *RollupBroadcaster) BroadcastOperatorSetUpdate(ctx context.Context, message messages.OperatorSetUpdateMessage, signatureInfo registryrollup.RollupOperatorsSignatureInfo)
func (*RollupBroadcaster) Close ¶
func (b *RollupBroadcaster) Close()
func (*RollupBroadcaster) GetErrorChan ¶
func (b *RollupBroadcaster) GetErrorChan() <-chan error
type RollupBroadcasterer ¶
type RollupBroadcasterer interface { BroadcastOperatorSetUpdate(ctx context.Context, message messages.OperatorSetUpdateMessage, signatureInfo registryrollup.RollupOperatorsSignatureInfo) GetErrorChan() <-chan error Close() }
type RollupWriter ¶
type RollupWriter struct {
// contains filtered or unexported fields
}
func NewRollupWriter ¶
func (*RollupWriter) Close ¶
func (w *RollupWriter) Close()
func (*RollupWriter) InitializeOperatorSet ¶
func (w *RollupWriter) InitializeOperatorSet(ctx context.Context, operators []registryrollup.RollupOperatorsOperator, operatorSetUpdateId uint64) error
func (*RollupWriter) UpdateOperatorSet ¶
func (w *RollupWriter) UpdateOperatorSet(ctx context.Context, message messages.OperatorSetUpdateMessage, signatureInfo registryrollup.RollupOperatorsSignatureInfo) error
type RpcAggregatorer ¶
type RpcAggregatorer interface { ProcessSignedCheckpointTaskResponse(signedCheckpointTaskResponse *messages.SignedCheckpointTaskResponse) error ProcessSignedStateRootUpdateMessage(signedStateRootUpdateMessage *messages.SignedStateRootUpdateMessage) error ProcessSignedOperatorSetUpdateMessage(signedOperatorSetUpdateMessage *messages.SignedOperatorSetUpdateMessage) error GetAggregatedCheckpointMessages(fromTimestamp, toTimestamp uint64) (*messages.CheckpointMessages, error) GetRegistryCoordinatorAddress(reply *string) error GetOperatorInfoById(ctx context.Context, operatorId eigentypes.OperatorId) (eigentypes.OperatorInfo, bool) }
type SelectiveAggregatorListener ¶
type SelectiveAggregatorListener struct { ObserveLastStateRootUpdateAggregatedCb func(rollupId uint32, blockNumber uint64) ObserveLastStateRootUpdateReceivedCb func(rollupId uint32, blockNumber uint64) ObserveLastOperatorSetUpdateAggregatedCb func(operatorSetUpdateId uint64) ObserveLastOperatorSetUpdateReceivedCb func(operatorSetUpdateId uint64) IncExpiredMessagesCb func() IncExpiredTasksCb func() IncErroredSubmissionsCb func() IncAggregatorInitializationsCb func() ObserveLastCheckpointReferenceSentCb func(referenceId uint32) ObserveLastCheckpointTaskReferenceReceivedCb func(referenceId uint32) ObserveLastCheckpointTaskReferenceAggregatedCb func(referenceId uint32) }
func (*SelectiveAggregatorListener) IncAggregatorInitializations ¶
func (l *SelectiveAggregatorListener) IncAggregatorInitializations()
func (*SelectiveAggregatorListener) IncErroredSubmissions ¶
func (l *SelectiveAggregatorListener) IncErroredSubmissions()
func (*SelectiveAggregatorListener) IncExpiredMessages ¶
func (l *SelectiveAggregatorListener) IncExpiredMessages()
func (*SelectiveAggregatorListener) IncExpiredTasks ¶
func (l *SelectiveAggregatorListener) IncExpiredTasks()
func (*SelectiveAggregatorListener) ObserveLastCheckpointReferenceSent ¶
func (l *SelectiveAggregatorListener) ObserveLastCheckpointReferenceSent(referenceId uint32)
func (*SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceAggregated ¶
func (l *SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceAggregated(referenceId uint32)
func (*SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceReceived ¶
func (l *SelectiveAggregatorListener) ObserveLastCheckpointTaskReferenceReceived(referenceId uint32)
func (*SelectiveAggregatorListener) ObserveLastOperatorSetUpdateAggregated ¶
func (l *SelectiveAggregatorListener) ObserveLastOperatorSetUpdateAggregated(operatorSetUpdateId uint64)
func (*SelectiveAggregatorListener) ObserveLastOperatorSetUpdateReceived ¶
func (l *SelectiveAggregatorListener) ObserveLastOperatorSetUpdateReceived(operatorSetUpdateId uint64)
func (*SelectiveAggregatorListener) ObserveLastStateRootUpdateAggregated ¶
func (l *SelectiveAggregatorListener) ObserveLastStateRootUpdateAggregated(rollupId uint32, blockNumber uint64)
func (*SelectiveAggregatorListener) ObserveLastStateRootUpdateReceived ¶
func (l *SelectiveAggregatorListener) ObserveLastStateRootUpdateReceived(rollupId uint32, blockNumber uint64)