common

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeKeygen       = "KEYGEN"
	EventTypeKeyrefresh   = "KEYREFRESH"
	EventTypeQuorumChange = "QUORUM_CHANGE"
	EventTypeSign         = "SIGN"
	EventTypeInbound      = "INBOUND"
	EventTypeOutbound     = "OUTBOUND"
)

Event type enum values for event classification. These constants define the types of events that can be processed.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainClient

type ChainClient interface {
	// Start initializes and starts the chain client
	Start(ctx context.Context) error

	// Stop gracefully shuts down the chain client
	Stop() error

	// IsHealthy checks if the chain client is operational
	IsHealthy() bool

	// GetTxBuilder returns the OutboundTxBuilder for this chain
	// Returns an error if txBuilder is not supported for this chain (e.g., Push chain)
	GetTxBuilder() (OutboundTxBuilder, error)
}

ChainClient defines the interface for chain-specific implementations

type ChainStore added in v0.0.13

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

ChainStore provides database operations for chain state and events

func NewChainStore added in v0.0.13

func NewChainStore(database *db.DB) *ChainStore

NewChainStore creates a new chain store

func (*ChainStore) DeleteTerminalEvents added in v0.0.13

func (cs *ChainStore) DeleteTerminalEvents(updatedBefore interface{}) (int64, error)

DeleteTerminalEvents deletes events in terminal states (COMPLETED, REVERTED, EXPIRED) that were updated before the given time

func (*ChainStore) GetChainHeight added in v0.0.13

func (cs *ChainStore) GetChainHeight() (uint64, error)

GetChainHeight returns the last processed block height for the chain Creates a new entry with height 0 if it doesn't exist

func (*ChainStore) GetConfirmedEvents added in v0.0.13

func (cs *ChainStore) GetConfirmedEvents(limit int) ([]store.Event, error)

GetConfirmedEvents fetches confirmed events ordered by creation time

func (*ChainStore) GetPendingEvents added in v0.0.13

func (cs *ChainStore) GetPendingEvents(limit int) ([]store.Event, error)

GetPendingEvents fetches pending events ordered by creation time

func (*ChainStore) InsertEventIfNotExists added in v0.0.13

func (cs *ChainStore) InsertEventIfNotExists(event *store.Event) (bool, error)

InsertEventIfNotExists inserts an event if it doesn't already exist (by EventID) Returns (true, nil) if a new event was inserted, (false, nil) if it already existed, or (false, error) if insertion failed

func (*ChainStore) UpdateChainHeight added in v0.0.13

func (cs *ChainStore) UpdateChainHeight(blockHeight uint64) error

UpdateChainHeight updates the last processed block height for the chain Creates a new entry if it doesn't exist

func (*ChainStore) UpdateEventStatus added in v0.0.13

func (cs *ChainStore) UpdateEventStatus(eventID string, oldStatus, newStatus string) (int64, error)

UpdateEventStatus updates the status of an event by event ID

func (*ChainStore) UpdateStatusAndVoteTxHash added in v0.0.16

func (cs *ChainStore) UpdateStatusAndVoteTxHash(eventID, oldStatus, newStatus, voteTxHash string) (int64, error)

UpdateStatusAndVoteTxHash atomically flips the event status and records the vote tx hash in one DB write. The update is conditional on the event currently having oldStatus (compare-and-swap semantics). Returns the number of rows affected (0 means the event was already in a different status).

func (*ChainStore) UpdateVoteTxHash added in v0.0.13

func (cs *ChainStore) UpdateVoteTxHash(eventID string, voteTxHash string) error

UpdateVoteTxHash updates the vote_tx_hash field for an event

type EventCleaner added in v0.0.13

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

EventCleaner handles periodic cleanup of old confirmed events for a chain

func NewEventCleaner added in v0.0.13

func NewEventCleaner(
	database *db.DB,
	cleanupInterval time.Duration,
	retentionPeriod time.Duration,
	chainID string,
	logger zerolog.Logger,
) *EventCleaner

NewEventCleaner creates a new event cleaner for a chain

func (*EventCleaner) Start added in v0.0.13

func (ec *EventCleaner) Start(ctx context.Context) error

Start begins the periodic cleanup process

func (*EventCleaner) Stop added in v0.0.13

func (ec *EventCleaner) Stop()

Stop gracefully stops the event cleaner

type EventProcessor added in v0.0.13

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

EventProcessor processes events from the chain's database and votes on them

func NewEventProcessor added in v0.0.13

func NewEventProcessor(
	signer *pushsigner.Signer,
	database *db.DB,
	chainID string,
	logger zerolog.Logger,
) *EventProcessor

NewEventProcessor creates a new event processor

func (*EventProcessor) IsRunning added in v0.0.13

func (ep *EventProcessor) IsRunning() bool

IsRunning returns whether the processor is currently running

func (*EventProcessor) Start added in v0.0.13

func (ep *EventProcessor) Start(ctx context.Context) error

Start begins processing events

func (*EventProcessor) Stop added in v0.0.13

func (ep *EventProcessor) Stop() error

Stop gracefully stops the event processor

type OutboundEvent added in v0.0.13

type OutboundEvent struct {
	TxID          string `json:"tx_id"`           // bytes32 hex-encoded (0x...)
	UniversalTxID string `json:"universal_tx_id"` // bytes32 hex-encoded (0x...)
}

OutboundEvent represents an outbound observation event from the gateway contract Event structure: - txID at 1st indexed position (bytes32) - universalTxID at 2nd indexed position (bytes32)

type OutboundTxBuilder added in v0.0.13

type OutboundTxBuilder interface {
	// GetOutboundSigningRequest creates a signing request from outbound event data
	GetOutboundSigningRequest(ctx context.Context, data *uetypes.OutboundCreatedEvent, gasPrice *big.Int, nonce uint64) (*UnSignedOutboundTxReq, error)

	// GetNextNonce returns the next nonce for the given signer on this chain (for seeding local nonce).
	// useFinalized: for EVM, if true use finalized block nonce (aggressive/replace stuck); if false use pending. SVM ignores this.
	GetNextNonce(ctx context.Context, signerAddress string, useFinalized bool) (uint64, error)

	// BroadcastOutboundSigningRequest assembles and broadcasts a signed transaction from the signing request, event data, and signature
	BroadcastOutboundSigningRequest(ctx context.Context, req *UnSignedOutboundTxReq, data *uetypes.OutboundCreatedEvent, signature []byte) (string, error)

	// VerifyBroadcastedTx checks the status of a broadcasted transaction on the destination chain.
	// Returns (found, blockHeight, confirmations, status, error):
	// - found=false: tx not found or not yet mined
	// - found=true: tx exists on-chain
	//   - blockHeight: the block in which the tx was mined
	//   - confirmations: number of blocks since the tx was mined (0 = just mined)
	//   - status: 0 = failed/reverted, 1 = success
	VerifyBroadcastedTx(ctx context.Context, txHash string) (found bool, blockHeight uint64, confirmations uint64, status uint8, err error)
}

OutboundTxBuilder builds and broadcasts transactions for outbound transfers

type UnSignedOutboundTxReq added in v0.0.13

type UnSignedOutboundTxReq struct {
	SigningHash []byte   // Hash to be signed by TSS
	Nonce       uint64   // evm - TSS Address nonce | svm - PDA nonce
	GasPrice    *big.Int // evm - Gas price used | svm - Prioritization fee
}

UnSignedOutboundTxReq contains the request for signing an outbound transaction

type UniversalTx

type UniversalTx struct {
	SourceChain         string                   `json:"sourceChain"`
	LogIndex            uint                     `json:"logIndex"`
	Sender              string                   `json:"sender"`
	Recipient           string                   `json:"recipient"`
	Token               string                   `json:"bridgeToken"`
	Amount              string                   `json:"bridgeAmount"` // uint256 as decimal string
	Payload             uetypes.UniversalPayload `json:"universalPayload"`
	VerificationData    string                   `json:"verificationData"`
	RevertFundRecipient string                   `json:"revertFundRecipient,omitempty"`
	RevertMsg           string                   `json:"revertMsg,omitempty"` // hex-encoded bytes (0x…)
	TxType              uint                     `json:"txType"`              // enum backing uint as decimal string
}

UniversalTx Payload

Jump to

Keyboard shortcuts

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