Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions chainstate/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package types

import (
"math/big"
"time"

"github.com/Layr-Labs/eigenda/core"
"github.com/ethereum/go-ethereum/common"
)

// OperatorStatus represents the registration status filter for operators.
type OperatorStatus int

const (
// OperatorStatusAll returns both registered and deregistered operators
OperatorStatusAll OperatorStatus = iota

// OperatorStatusRegistered returns only registered operators
OperatorStatusRegistered

// OperatorStatusDeregistered returns only deregistered operators
OperatorStatusDeregistered
)

// Operator represents an EigenDA operator with their registration information.
type Operator struct {
// Unique operator identifier
OperatorID core.OperatorID

// Ethereum address of the operator
Address common.Address

// BLS public key (G1 point)
BLSPubKeyG1 *core.G1Point

// BLS public key (G2 point)
BLSPubKeyG2 *core.G2Point

// Socket address for connecting to the operator
Socket string

// Block number when the operator was registered
RegisteredAtBlockNumber uint64

// Block number when the operator was deregistered (nil if still registered)
DeregisteredAtBlockNumber *uint64

// List of quorum IDs the operator is part of
QuorumIDs []core.QuorumID

// Transaction hash of the registration
RegisteredTxHash common.Hash

// Transaction hash of the deregistration (nil if still registered)
DeregisteredTxHash *common.Hash
}

// IsRegistered returns true if the operator is currently registered.
func (o *Operator) IsRegistered() bool {
return o.DeregisteredAtBlockNumber == nil
}

// QuorumAPK represents the aggregate public key for a quorum at a specific block.
type QuorumAPK struct {
// Quorum identifier
QuorumID core.QuorumID

// Block number for this snapshot
BlockNumber uint64

// Aggregate public key for all operators in the quorum
APK *core.G1Point

// Total stake in the quorum
TotalStake *big.Int

// Timestamp when this was recorded
UpdatedAt time.Time
}

// OperatorSocketUpdate represents a socket address update for an operator.
type OperatorSocketUpdate struct {
// Operator identifier
OperatorID core.OperatorID

// New socket address
Socket string

// Block number of the update
BlockNumber uint64

// Transaction hash of the update
TxHash common.Hash

// Timestamp when this was recorded
UpdatedAt time.Time
}

// OperatorEjection represents an operator ejection event.
type OperatorEjection struct {
// Operator identifier
OperatorID core.OperatorID

// Quorums from which the operator was ejected
QuorumIDs []core.QuorumID

// Block number of the ejection
BlockNumber uint64

// Transaction hash of the ejection
TxHash common.Hash

// Timestamp when the ejection occurred
EjectedAt time.Time
}

// OperatorFilter is used to filter operators when querying.
type OperatorFilter struct {
// Filter by registration status (default: OperatorStatusAll)
Status OperatorStatus

// Filter by specific quorum ID (nil for all)
QuorumID *core.QuorumID

// Minimum block number (inclusive)
MinBlock uint64

// Maximum block number (inclusive, 0 for no limit)
MaxBlock uint64
}

// QuorumAPKQuery is used to get the APK for a specific block.
type QuorumAPKQuery struct {
// Quorum identifier
QuorumID core.QuorumID

// Block number for the snapshot (0 for latest)
BlockNumber uint64
}

// QuorumAPKHistoryFilter is used to filter quorum APK snapshots over a range.
type QuorumAPKHistoryFilter struct {
// Quorum identifier
QuorumID core.QuorumID

// Get all snapshots after this block (inclusive)
MinBlock uint64

// Get all snapshots before this block (inclusive, 0 for no limit)
MaxBlock uint64
}
Loading