Documentation
¶
Index ¶
- Constants
- Variables
- func LoggerHandler(logger aggkitcommon.Logger) gin.HandlerFunc
- func NewBridgeResponse(bridge *bridgesync.Bridge, networkID uint32) *bridgetypes.BridgeResponse
- func NewClaimResponse(claim *bridgesync.Claim, populateProofs bool) *bridgetypes.ClaimResponse
- func NewL1InfoTreeLeafResponse(leaf *l1infotreesync.L1InfoTreeLeaf) *bridgetypes.L1InfoTreeLeafResponse
- func NewTokenMappingResponse(tokenMapping *bridgesync.TokenMapping) *bridgetypes.TokenMappingResponse
- func NewTokenMigrationResponse(tokenMigration *bridgesync.LegacyTokenMigration) *bridgetypes.LegacyTokenMigrationResponse
- type BridgeService
- func (b *BridgeService) ClaimProofHandler(c *gin.Context)
- func (b *BridgeService) GetBridgesHandler(c *gin.Context)
- func (b *BridgeService) GetClaimsHandler(c *gin.Context)
- func (b *BridgeService) GetLastReorgEventHandler(c *gin.Context)
- func (b *BridgeService) GetLegacyTokenMigrationsHandler(c *gin.Context)
- func (b *BridgeService) GetSyncStatusHandler(c *gin.Context)
- func (b *BridgeService) GetTokenMappingsHandler(c *gin.Context)
- func (b *BridgeService) HealthCheckHandler(c *gin.Context)
- func (b *BridgeService) InjectedL1InfoLeafHandler(c *gin.Context)
- func (b *BridgeService) L1InfoTreeIndexForBridgeHandler(c *gin.Context)
- func (b *BridgeService) Start(ctx context.Context)
- type Bridger
- type Config
- type L1InfoTreeSyncer
- type L2GERSyncer
- type UintParam
Constants ¶
const ( // DefaultPageSize is the default number of records to be fetched DefaultPageSize = uint32(20) // MaxPageSize is the maximum number of records to be fetched MaxPageSize = 200 // DefaultPage is the default page number to be used when fetching records DefaultPage = uint32(1) // MaxNetworkIDs is the maximum number of network IDs allowed in a single request MaxNetworkIDs = 5 )
const (
// BridgeV1Prefix is the url prefix for the bridge service
BridgeV1Prefix = "/bridge/v1"
)
Variables ¶
var (
ErrNotOnL1Info = errors.New("this bridge has not been included on the L1 Info Tree yet")
)
Functions ¶
func LoggerHandler ¶
func LoggerHandler(logger aggkitcommon.Logger) gin.HandlerFunc
LoggerHandler returns a Gin middleware that logs HTTP requests using logger at DEBUG level.
func NewBridgeResponse ¶
func NewBridgeResponse(bridge *bridgesync.Bridge, networkID uint32) *bridgetypes.BridgeResponse
NewBridgeResponse creates a new BridgeResponse instance out of the provided Bridge instance
func NewClaimResponse ¶
func NewClaimResponse(claim *bridgesync.Claim, populateProofs bool) *bridgetypes.ClaimResponse
NewClaimResponse creates ClaimResponse instance out of the provided Claim
func NewL1InfoTreeLeafResponse ¶
func NewL1InfoTreeLeafResponse(leaf *l1infotreesync.L1InfoTreeLeaf) *bridgetypes.L1InfoTreeLeafResponse
NewL1InfoTreeLeafResponse creates L1InfoTreeLeafResponse instance out of the provided L1InfoTreeLeaf
func NewTokenMappingResponse ¶
func NewTokenMappingResponse(tokenMapping *bridgesync.TokenMapping) *bridgetypes.TokenMappingResponse
NewTokenMappingResponse creates TokenMappingResponse instance out of the provided TokenMapping
func NewTokenMigrationResponse ¶
func NewTokenMigrationResponse( tokenMigration *bridgesync.LegacyTokenMigration) *bridgetypes.LegacyTokenMigrationResponse
NewTokenMigrationResponse creates LegacyTokenMigrationResponse instance out of the provided LegacyTokenMigration
Types ¶
type BridgeService ¶
type BridgeService struct {
// contains filtered or unexported fields
}
BridgeService contains implementations for the bridge service endpoints
func New ¶
func New( cfg *Config, l1InfoTree L1InfoTreeSyncer, injectedGERs L2GERSyncer, bridgeL1 Bridger, bridgeL2 Bridger, ) *BridgeService
New returns instance of BridgeService
func (*BridgeService) ClaimProofHandler ¶
func (b *BridgeService) ClaimProofHandler(c *gin.Context)
ClaimProofHandler returns the Merkle proofs required to verify a claim on the target network.
@Summary Get claim proof @Description Returns the Merkle proofs (local and rollup exit root) and @Description the corresponding L1 info tree leaf needed to verify a claim. @Tags claims @Param network_id query uint32 true "Origin network ID" @Param leaf_index query uint32 true "Index in the L1 info tree" @Param deposit_count query uint32 true "Number of deposits in the bridge" @Produce json @Success 200 {object} types.ClaimProof "Merkle proofs and L1 info tree leaf" @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /claim-proof [get]
func (*BridgeService) GetBridgesHandler ¶
func (b *BridgeService) GetBridgesHandler(c *gin.Context)
GetBridgesHandler retrieves paginated bridge data for the specified network.
@Summary Get bridges @Description Returns a paginated list of bridge events for the specified network. @Tags bridges @Param network_id query uint32 true "Origin network ID" @Param page_number query uint32 false "Page number (default 1)" @Param page_size query uint32 false "Page size (default 100)" @Param deposit_count query uint64 false "Filter by deposit count" @Param from_address query string false "Filter by from address" @Param network_ids query []uint32 false "Filter by one or more destination network IDs (maximum 5 allowed)" @Produce json @Success 200 {object} types.BridgesResult @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /bridges [get]
func (*BridgeService) GetClaimsHandler ¶
func (b *BridgeService) GetClaimsHandler(c *gin.Context)
GetClaimsHandler retrieves paginated claims for a given network.
@Summary Get claims @Description Returns a paginated list of claims for the specified network. @Tags claims @Param network_id query uint32 true "Origin network ID" @Param page_number query uint32 false "Page number (default 1)" @Param page_size query uint32 false "Page size (default 100)" @Param network_ids query []uint32 false "Filter by one or more source network IDs (maximum 5 allowed)" @Param from_address query string false "Filter by from address" @Param include_all_fields query bool false "Whether to include full response fields (default false)" @Param global_index query uint32 false "Filter by global index" @Produce json @Success 200 {object} types.ClaimsResult @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /claims [get]
func (*BridgeService) GetLastReorgEventHandler ¶
func (b *BridgeService) GetLastReorgEventHandler(c *gin.Context)
GetLastReorgEventHandler returns the most recent reorganization event for the specified network.
@Summary Get last reorg event @Description Retrieves the last known reorg event for either L1 or L2, based on the provided network ID. @Tags reorgs @Param network_id query int true "Network ID (e.g., 0 for L1, or the ID of the L2 network)" @Produce json @Success 200 {object} bridgesync.LastReorg "Details of the last reorg event" @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /last-reorg-event [get]
func (*BridgeService) GetLegacyTokenMigrationsHandler ¶
func (b *BridgeService) GetLegacyTokenMigrationsHandler(c *gin.Context)
@Summary Get legacy token migrations @Description Returns legacy token migrations for the given network, paginated @Tags legacy-token-migrations @Param network_id query int true "Network ID" @Param page_number query int false "Page number" @Param page_size query int false "Page size" @Produce json @Success 200 {object} types.LegacyTokenMigrationsResult @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /legacy-token-migrations [get]
func (*BridgeService) GetSyncStatusHandler ¶
func (b *BridgeService) GetSyncStatusHandler(c *gin.Context)
GetSyncStatusHandler returns the bridge synchronization status for L1 and L2 networks.
@Summary Get bridge synchronization status @Description Returns bridge sync status by comparing on-chain bridge deposit counts with local database counts. @Description Shows if bridge syncers are active and whether they're keeping up with on-chain events. @Tags sync @Produce json @Success 200 {object} types.SyncStatus "Bridge synchronization status for L1 and L2 networks" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /sync-status [get]
func (*BridgeService) GetTokenMappingsHandler ¶
func (b *BridgeService) GetTokenMappingsHandler(c *gin.Context)
@Summary Get token mappings @Description Returns token mappings for the given network, paginated @Tags token-mappings @Param network_id query int true "Network ID" @Param page_number query int false "Page number" @Param page_size query int false "Page size" @Param origin_token_address query string false "Filter by origin token address" @Produce json @Success 200 {object} types.TokenMappingsResult @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /token-mappings [get]
func (*BridgeService) HealthCheckHandler ¶
func (b *BridgeService) HealthCheckHandler(c *gin.Context)
HealthCheckHandler returns the health status and version information of the bridge service.
@Summary Get health status @Description Returns the health status and version information of the bridge service @Tags health @Produce json @Success 200 {object} types.HealthCheckResponse "Health status and version information" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router / [get]
func (*BridgeService) InjectedL1InfoLeafHandler ¶
func (b *BridgeService) InjectedL1InfoLeafHandler(c *gin.Context)
@Summary Get injected L1 info tree leaf after a given L1 info tree index @Description Returns the L1 info tree leaf either at the given index (for L1) @Description or the first injected global exit root after the given index (for L2). @Tags l1-info-tree-leaf @Param network_id query int true "Network ID" @Param leaf_index query int true "L1 Info Tree Index" @Produce json @Success 200 {object} types.L1InfoTreeLeafResponse @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /injected-l1-info-leaf [get]
func (*BridgeService) L1InfoTreeIndexForBridgeHandler ¶
func (b *BridgeService) L1InfoTreeIndexForBridgeHandler(c *gin.Context)
@Summary Get L1 Info Tree index for a bridge @Description Returns the first L1 Info Tree index after a given deposit count for the specified network @Tags l1-info-tree-leaf @Param network_id query int true "Network ID" @Param deposit_count query int true "Deposit count" @Produce json @Success 200 {object} uint32 @Failure 400 {object} types.ErrorResponse "Bad Request" @Failure 500 {object} types.ErrorResponse "Internal Server Error" @Router /l1-info-tree-index [get]
func (*BridgeService) Start ¶
func (b *BridgeService) Start(ctx context.Context)
Start starts the HTTP bridge service
type Bridger ¶
type Bridger interface {
GetProof(ctx context.Context, depositCount uint32, localExitRoot common.Hash) (tree.Proof, error)
GetRootByLER(ctx context.Context, ler common.Hash) (*tree.Root, error)
GetLastRoot(ctx context.Context) (*tree.Root, error)
GetBridgesPaged(ctx context.Context, pageNumber, pageSize uint32,
depositCount *uint64, networkIDs []uint32, fromAddress string) ([]*bridgesync.Bridge, int, error)
GetTokenMappings(ctx context.Context, pageNumber, pageSize uint32,
originTokenAddress string) ([]*bridgesync.TokenMapping, int, error)
GetLegacyTokenMigrations(ctx context.Context,
pageNumber, pageSize uint32) ([]*bridgesync.LegacyTokenMigration, int, error)
GetClaimsPaged(ctx context.Context, page, pageSize uint32,
networkIDs []uint32, fromAddress string, globalIndex *big.Int) ([]*bridgesync.Claim, int, error)
GetLastReorgEvent(ctx context.Context) (*bridgesync.LastReorg, error)
GetContractDepositCount(ctx context.Context) (uint32, error)
GetLastProcessedBlock(ctx context.Context) (uint64, error)
GetLatestNetworkBlock(ctx context.Context) (uint64, error)
IsActive(ctx context.Context) bool
}
type L1InfoTreeSyncer ¶ added in v0.7.0
type L1InfoTreeSyncer interface {
GetInfoByIndex(ctx context.Context, index uint32) (*l1infotreesync.L1InfoTreeLeaf, error)
GetRollupExitTreeMerkleProof(ctx context.Context, networkID uint32, root common.Hash) (tree.Proof, error)
GetLocalExitRoot(ctx context.Context, networkID uint32, rollupExitRoot common.Hash) (common.Hash, error)
GetLastInfo() (*l1infotreesync.L1InfoTreeLeaf, error)
GetFirstInfo() (*l1infotreesync.L1InfoTreeLeaf, error)
GetFirstInfoAfterBlock(blockNum uint64) (*l1infotreesync.L1InfoTreeLeaf, error)
GetLastVerifiedBatches(rollupID uint32) (*l1infotreesync.VerifyBatches, error)
GetFirstVerifiedBatches(rollupID uint32) (*l1infotreesync.VerifyBatches, error)
GetFirstVerifiedBatchesAfterBlock(rollupID uint32, blockNum uint64) (*l1infotreesync.VerifyBatches, error)
GetFirstL1InfoWithRollupExitRoot(rollupExitRoot common.Hash) (*l1infotreesync.L1InfoTreeLeaf, error)
}