coordinator

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PerChainCap is the max in-flight SIGN events per destination chain (default 16; below EVM mempool accountqueue 64).
	PerChainCap = 16
	// ConsecutiveWaitThreshold: after this many consecutive polls where a chain has in-flight events,
	// use finalized nonce to recover from stuck nonces (~200s at 10s poll).
	ConsecutiveWaitThreshold = 20
)

Variables

This section is empty.

Functions

func CalculateThreshold

func CalculateThreshold(numParticipants int) int

CalculateThreshold calculates the threshold as > 2/3 of participants. Formula: threshold = floor((2 * n) / 3) + 1 This ensures threshold > 2/3 * n

func DeriveEVMAddressFromPubkey added in v0.0.28

func DeriveEVMAddressFromPubkey(pubkeyHex string) (string, error)

DeriveEVMAddressFromPubkey derives an EVM address from a hex-encoded compressed secp256k1 public key.

Types

type Coordinator

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

Coordinator handles coordinator logic for TSS events.

func NewCoordinator

func NewCoordinator(
	eventStore *eventstore.Store,
	pushCore *pushcore.Client,
	keyshareManager *keyshare.Manager,
	chains *chains.Chains,
	validatorAddress string,
	coordinatorRange uint64,
	pollInterval time.Duration,
	send SendFunc,
	logger zerolog.Logger,
) *Coordinator

NewCoordinator creates a new coordinator.

func (*Coordinator) GetCurrentTSSKey added in v0.0.13

func (c *Coordinator) GetCurrentTSSKey(ctx context.Context) (string, string, error)

GetCurrentTSSKey gets the current TSS key ID and public key from pushCore.

func (*Coordinator) GetEligibleUV

func (c *Coordinator) GetEligibleUV(protocolType string) []*types.UniversalValidator

GetEligibleUV returns ALL eligible validators for the given protocol type (no random selection). Used by the session manager to check whether a setup-message sender is eligible to participate. For SIGN coordinator setup the coordinator calls getSignParticipants (random threshold subset).

func (*Coordinator) GetLatestBlockNum

func (c *Coordinator) GetLatestBlockNum(ctx context.Context) (uint64, error)

GetLatestBlockNum gets the latest block number from pushCore.

func (*Coordinator) GetMultiAddrsFromPeerID

func (c *Coordinator) GetMultiAddrsFromPeerID(ctx context.Context, peerID string) ([]string, error)

GetMultiAddrsFromPeerID gets the multiaddrs for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPartyIDFromPeerID

func (c *Coordinator) GetPartyIDFromPeerID(ctx context.Context, peerID string) (string, error)

GetPartyIDFromPeerID gets the partyID (validator address) for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPeerIDFromPartyID

func (c *Coordinator) GetPeerIDFromPartyID(ctx context.Context, partyID string) (string, error)

GetPeerIDFromPartyID gets the peerID for a given partyID (validator address). Uses cached allValidators for performance.

func (*Coordinator) GetTSSAddress added in v0.0.13

func (c *Coordinator) GetTSSAddress(ctx context.Context) (string, error)

GetTSSAddress returns the TSS ECDSA address derived from the current TSS public key (compressed secp256k1).

func (*Coordinator) HandleACK

func (c *Coordinator) HandleACK(ctx context.Context, senderPeerID string, eventID string) error

HandleACK processes an ACK message from a participant. This is called by the session manager when coordinator receives an ACK.

func (*Coordinator) IsPeerCoordinator

func (c *Coordinator) IsPeerCoordinator(ctx context.Context, peerID string) (bool, error)

IsPeerCoordinator reports whether the given peerID is the coordinator for the current block. Used by the session manager to validate that an incoming setup message comes from the coordinator.

func (*Coordinator) Start

func (c *Coordinator) Start(ctx context.Context)

Start starts the coordinator loop.

func (*Coordinator) Stop

func (c *Coordinator) Stop()

Stop stops the coordinator loop.

type Message

type Message struct {
	Type         string   `json:"type"` // "setup", "ack", "begin", "step"
	EventID      string   `json:"eventId"`
	Payload      []byte   `json:"payload"`
	Participants []string `json:"participants"` // Array of PartyIDs (validator addresses) participating in this process

	// UnsignedSigningReq is included for SIGN protocol setup messages.
	// Participants use this to verify the signing hash before proceeding.
	UnsignedSigningReq *common.UnsignedSigningReq `json:"unsigned_outbound_tx_req,omitempty"`
}

Message represents a simple message with type, eventId, payload, and participants.

type SendFunc

type SendFunc func(ctx context.Context, peerID string, data []byte) error

SendFunc is a function type for sending messages to participants. peerID: The peer ID of the recipient data: The message bytes

Jump to

Keyboard shortcuts

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