Documentation
¶
Overview ¶
Package auditing provides auditing agents for the arbitrum-sequencer-decoder system
Package auditing provides auditing agents for the arbitrum-sequencer-decoder system ¶
Package auditing provides auditing agents for the arbitrum-sequencer-decoder system ¶
Package auditing provides examples of how to integrate auditing agents into the arbitrum-sequencer-decoder system ¶
Package auditing provides auditing agents for the arbitrum-sequencer-decoder system ¶
Package auditing provides auditing agents for the arbitrum-sequencer-decoder system
Index ¶
- func ExampleIntegration(ctx context.Context, reader *ExampleSequencerReader) error
- type ArbitrageAuditor
- func (aa *ArbitrageAuditor) AuditOpportunity(opportunity types.ArbitrageOpportunity) (*ValidationResult, error)
- func (aa *ArbitrageAuditor) GetNotificationChannel() <-chan AuditEvent
- func (aa *ArbitrageAuditor) GetPerformanceMetrics() *ArbitragePerformanceMetrics
- func (aa *ArbitrageAuditor) GetSecurityMetrics() *ArbitrageSecurityMetrics
- func (aa *ArbitrageAuditor) GetStats() *ArbitrageStats
- func (aa *ArbitrageAuditor) Start(ctx context.Context) error
- func (aa *ArbitrageAuditor) ValidateAndExecute(executor types.TransactionExecutor, opportunity types.ArbitrageOpportunity) error
- type ArbitragePerformanceMetrics
- type ArbitrageSecurityMetrics
- type ArbitrageStats
- type AuditConfig
- type AuditEvent
- type AuditManager
- func (am *AuditManager) AuditOpportunity(opportunity types.ArbitrageOpportunity) (*ValidationResult, error)
- func (am *AuditManager) AuditTransaction(txHash string, decodeFunc func() ([]types.DecodedAction, error)) ([]types.DecodedAction, error)
- func (am *AuditManager) GetAllComponentStatuses() map[string]*ComponentStatus
- func (am *AuditManager) GetArbitrageStats() *ArbitrageStats
- func (am *AuditManager) GetAuditMetrics() *AuditMetrics
- func (am *AuditManager) GetComponentStatus(componentName string) *ComponentStatus
- func (am *AuditManager) GetDecoderStats() map[string]*DecoderStats
- func (am *AuditManager) GetSystemHealthStats() *SystemHealthStats
- func (am *AuditManager) InitializeAuditors(decoder types.Decoder, oracle types.PoolOracle, ...)
- func (am *AuditManager) Start(ctx context.Context) error
- func (am *AuditManager) UpdateSystemStats(updateFunc func(*SystemHealthStats))
- func (am *AuditManager) ValidateAndExecute(executor types.TransactionExecutor, opportunity types.ArbitrageOpportunity) error
- type AuditMetrics
- type ComponentStatus
- type DecoderAuditor
- func (da *DecoderAuditor) AuditTransaction(txHash string, decodeFunc func() ([]types.DecodedAction, error)) ([]types.DecodedAction, error)
- func (da *DecoderAuditor) GetNotificationChannel() <-chan AuditEvent
- func (da *DecoderAuditor) GetPerformanceMetrics() *DecoderPerformanceMetrics
- func (da *DecoderAuditor) GetStats() map[string]*DecoderStats
- func (da *DecoderAuditor) Start(ctx context.Context) error
- type DecoderPerformanceMetrics
- type DecoderStats
- type ExampleSequencerReader
- type HealthCheckFunc
- type PerformanceMetrics
- type SecurityMetrics
- type SystemHealthAuditor
- func (sha *SystemHealthAuditor) GetAllComponentStatuses() map[string]*ComponentStatus
- func (sha *SystemHealthAuditor) GetAuditTrail() []AuditEvent
- func (sha *SystemHealthAuditor) GetComponentStatus(componentName string) *ComponentStatus
- func (sha *SystemHealthAuditor) GetNotificationChannel() <-chan AuditEvent
- func (sha *SystemHealthAuditor) GetPerformanceMetrics() *SystemHealthPerformanceMetrics
- func (sha *SystemHealthAuditor) GetSecurityMetrics() *SystemHealthSecurityMetrics
- func (sha *SystemHealthAuditor) GetStats() *SystemHealthStats
- func (sha *SystemHealthAuditor) MonitorArbitrageEngine(engine types.ArbitrageEngine)
- func (sha *SystemHealthAuditor) MonitorDecoder(decoder types.Decoder)
- func (sha *SystemHealthAuditor) MonitorPoolOracle(oracle types.PoolOracle)
- func (sha *SystemHealthAuditor) MonitorTransactionExecutor(executor types.TransactionExecutor)
- func (sha *SystemHealthAuditor) RegisterHealthCheck(componentName string, checkFunc HealthCheckFunc)
- func (sha *SystemHealthAuditor) Start(ctx context.Context) error
- func (sha *SystemHealthAuditor) UpdateStats(updateFunc func(*SystemHealthStats))
- type SystemHealthPerformanceMetrics
- type SystemHealthSecurityMetrics
- type SystemHealthStats
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleIntegration ¶
func ExampleIntegration(ctx context.Context, reader *ExampleSequencerReader) error
Example integration of auditing agents with the sequencer reader
Types ¶
type ArbitrageAuditor ¶
type ArbitrageAuditor struct {
// contains filtered or unexported fields
}
ArbitrageAuditor audits arbitrage opportunities to ensure they are valid and profitable Following the project's audit framework, security guidelines, and performance recommendations
func NewArbitrageAuditor ¶
func NewArbitrageAuditor(arbEngine types.ArbitrageEngine, config *AuditConfig) *ArbitrageAuditor
NewArbitrageAuditor creates a new arbitrage auditor Following security best practices and performance optimization guidelines
func (*ArbitrageAuditor) AuditOpportunity ¶
func (aa *ArbitrageAuditor) AuditOpportunity(opportunity types.ArbitrageOpportunity) (*ValidationResult, error)
AuditOpportunity audits a single arbitrage opportunity Following security best practices and performance monitoring recommendations
func (*ArbitrageAuditor) GetNotificationChannel ¶
func (aa *ArbitrageAuditor) GetNotificationChannel() <-chan AuditEvent
GetNotificationChannel returns the channel for audit notifications
func (*ArbitrageAuditor) GetPerformanceMetrics ¶
func (aa *ArbitrageAuditor) GetPerformanceMetrics() *ArbitragePerformanceMetrics
GetPerformanceMetrics returns performance metrics for monitoring Following performance audit recommendations
func (*ArbitrageAuditor) GetSecurityMetrics ¶
func (aa *ArbitrageAuditor) GetSecurityMetrics() *ArbitrageSecurityMetrics
GetSecurityMetrics returns security metrics for monitoring Following security audit recommendations
func (*ArbitrageAuditor) GetStats ¶
func (aa *ArbitrageAuditor) GetStats() *ArbitrageStats
GetStats returns the current arbitrage statistics
func (*ArbitrageAuditor) Start ¶
func (aa *ArbitrageAuditor) Start(ctx context.Context) error
Start begins auditing arbitrage opportunities in a separate goroutine
func (*ArbitrageAuditor) ValidateAndExecute ¶
func (aa *ArbitrageAuditor) ValidateAndExecute(executor types.TransactionExecutor, opportunity types.ArbitrageOpportunity) error
ValidateAndExecute validates an arbitrage opportunity and executes if valid
type ArbitragePerformanceMetrics ¶
type ArbitragePerformanceMetrics struct {
MaxValidationTime time.Duration
MinValidationTime time.Duration
TotalValidationTime time.Duration
ValidationCount int64
}
ArbitragePerformanceMetrics holds arbitrage auditor-specific performance metrics
type ArbitrageSecurityMetrics ¶
type ArbitrageSecurityMetrics struct {
RiskEventsDetected int64
InvalidOpportunities int64
SuspiciousActivities int64
LastSecurityEvent time.Time
}
ArbitrageSecurityMetrics holds arbitrage auditor-specific security metrics
type ArbitrageStats ¶
type ArbitrageStats struct {
TotalOpportunities int64
Validated int64
Invalid int64
Executed int64
Unprofitable int64
Expired int64
AvgProfit *big.Float
AvgRisk float64
LastUpdated time.Time
}
ArbitrageStats holds statistics about arbitrage opportunities
type AuditConfig ¶
type AuditConfig struct {
Interval time.Duration
EnableStats bool
EnableAlerts bool
MinSuccessRate float64
MaxDecodeTime time.Duration
}
AuditConfig holds configuration for the auditing system
type AuditEvent ¶
type AuditEvent struct {
Timestamp time.Time
EventType string
Decoder string
Message string
Data interface{}
Error error
}
AuditEvent represents an auditing event
type AuditManager ¶
type AuditManager struct {
// contains filtered or unexported fields
}
AuditManager coordinates all auditing activities in accordance with the project's audit framework
func NewAuditManager ¶
func NewAuditManager(config *AuditConfig) *AuditManager
NewAuditManager creates a new audit manager that coordinates all auditing agents
func (*AuditManager) AuditOpportunity ¶
func (am *AuditManager) AuditOpportunity(opportunity types.ArbitrageOpportunity) (*ValidationResult, error)
AuditOpportunity audits an arbitrage opportunity Following security and validation best practices
func (*AuditManager) AuditTransaction ¶
func (am *AuditManager) AuditTransaction(txHash string, decodeFunc func() ([]types.DecodedAction, error)) ([]types.DecodedAction, error)
AuditTransaction audits a transaction through the decoder auditor Implements the new audit framework requirements
func (*AuditManager) GetAllComponentStatuses ¶
func (am *AuditManager) GetAllComponentStatuses() map[string]*ComponentStatus
GetAllComponentStatuses returns the status of all components
func (*AuditManager) GetArbitrageStats ¶
func (am *AuditManager) GetArbitrageStats() *ArbitrageStats
GetArbitrageStats returns arbitrage statistics
func (*AuditManager) GetAuditMetrics ¶
func (am *AuditManager) GetAuditMetrics() *AuditMetrics
GetAuditMetrics returns aggregated audit metrics Implements the observability infrastructure recommendations
func (*AuditManager) GetComponentStatus ¶
func (am *AuditManager) GetComponentStatus(componentName string) *ComponentStatus
GetComponentStatus returns the status of a system component
func (*AuditManager) GetDecoderStats ¶
func (am *AuditManager) GetDecoderStats() map[string]*DecoderStats
GetDecoderStats returns decoder statistics
func (*AuditManager) GetSystemHealthStats ¶
func (am *AuditManager) GetSystemHealthStats() *SystemHealthStats
GetSystemHealthStats returns system health statistics
func (*AuditManager) InitializeAuditors ¶
func (am *AuditManager) InitializeAuditors(decoder types.Decoder, oracle types.PoolOracle, arbEngine types.ArbitrageEngine, executor types.TransactionExecutor)
InitializeAuditors sets up all auditing components with their dependencies Following security best practices and performance optimization recommendations
func (*AuditManager) Start ¶
func (am *AuditManager) Start(ctx context.Context) error
Start begins all auditing processes with comprehensive error handling
func (*AuditManager) UpdateSystemStats ¶
func (am *AuditManager) UpdateSystemStats(updateFunc func(*SystemHealthStats))
UpdateSystemStats updates the system health statistics
func (*AuditManager) ValidateAndExecute ¶
func (am *AuditManager) ValidateAndExecute(executor types.TransactionExecutor, opportunity types.ArbitrageOpportunity) error
ValidateAndExecute validates an arbitrage opportunity and executes it if valid Implements security-first approach with multiple validation layers
type AuditMetrics ¶
type AuditMetrics struct {
StartTime int64 // Unix timestamp for uptime calculation
TotalAuditsProcessed int64
AlertsGenerated int64
ErrorsDetected int64
PerformanceMetrics map[string]interface{} // For performance monitoring
}
AuditMetrics holds aggregated metrics from all auditors
type ComponentStatus ¶
type ComponentStatus struct {
Name string
Status string // "healthy", "degraded", "unhealthy", "unknown"
LastUpdate time.Time
ErrorMessage string
ResponseTime time.Duration
LastCheck time.Time
}
ComponentStatus represents the status of a system component
type DecoderAuditor ¶
type DecoderAuditor struct {
// contains filtered or unexported fields
}
DecoderAuditor audits the performance and accuracy of the decoder implementations Following the project's audit framework, code quality standards, and security guidelines
func NewDecoderAuditor ¶
func NewDecoderAuditor(decoder types.Decoder, oracle types.PoolOracle, config *AuditConfig) *DecoderAuditor
NewDecoderAuditor creates a new decoder auditor Following security best practices and code quality standards
func (*DecoderAuditor) AuditTransaction ¶
func (da *DecoderAuditor) AuditTransaction(txHash string, decodeFunc func() ([]types.DecodedAction, error)) ([]types.DecodedAction, error)
AuditTransaction audits a single transaction decoding
func (*DecoderAuditor) GetNotificationChannel ¶
func (da *DecoderAuditor) GetNotificationChannel() <-chan AuditEvent
GetNotificationChannel returns the channel for audit notifications
func (*DecoderAuditor) GetPerformanceMetrics ¶
func (da *DecoderAuditor) GetPerformanceMetrics() *DecoderPerformanceMetrics
GetPerformanceMetrics returns performance metrics for monitoring Following the performance monitoring recommendations
func (*DecoderAuditor) GetStats ¶
func (da *DecoderAuditor) GetStats() map[string]*DecoderStats
GetStats returns the current statistics for all decoders Following code quality and security recommendations
type DecoderPerformanceMetrics ¶
type DecoderPerformanceMetrics struct {
MaxDecodeTime time.Duration
MinDecodeTime time.Duration
TotalDecodeTime time.Duration
DecodeCount int64
}
DecoderPerformanceMetrics holds decoder-specific performance metrics
type DecoderStats ¶
type DecoderStats struct {
TotalDecoded int64
TotalFailed int64
AvgDecodeTime time.Duration
LastDecodeTime time.Duration
SuccessRate float64
LastUpdated time.Time
TotalLiquidity *big.Int // Track estimated liquidity processed (using big.Int to prevent overflow)
MaxDecodeTime time.Duration // Following performance metrics tracking
MinDecodeTime time.Duration // Following performance metrics tracking
ErrorDetails []string // For enhanced error tracking
}
DecoderStats holds statistics about a decoder's performance Updated to follow code quality and audit framework recommendations
type ExampleSequencerReader ¶
type ExampleSequencerReader struct {
// contains filtered or unexported fields
}
ExampleSequencerReader is a simplified example of how the sequencer reader might look with auditing
func (*ExampleSequencerReader) GetAuditStats ¶
func (r *ExampleSequencerReader) GetAuditStats() map[string]interface{}
GetAuditStats returns current audit statistics
type HealthCheckFunc ¶
HealthCheckFunc is a function that performs a health check
type PerformanceMetrics ¶
type PerformanceMetrics struct {
MaxTime time.Duration
MinTime time.Duration
TotalTime time.Duration
Count int64
}
PerformanceMetrics holds performance-related metrics (shared across auditors)
func NewPerformanceMetrics ¶
func NewPerformanceMetrics() *PerformanceMetrics
NewPerformanceMetrics creates a new PerformanceMetrics with default values
func (*PerformanceMetrics) AverageTime ¶
func (pm *PerformanceMetrics) AverageTime() time.Duration
AverageTime returns the average time or 0 if no measurements
func (*PerformanceMetrics) Copy ¶
func (pm *PerformanceMetrics) Copy() *PerformanceMetrics
Copy creates a deep copy of PerformanceMetrics
func (*PerformanceMetrics) Update ¶
func (pm *PerformanceMetrics) Update(duration time.Duration)
Update updates the performance metrics with a new measurement
type SecurityMetrics ¶
type SecurityMetrics struct {
RiskEventsDetected int64
InvalidOpportunities int64
SuspiciousActivities int64
LastSecurityEvent time.Time
}
SecurityMetrics holds security-related metrics (shared across auditors)
func NewSecurityMetrics ¶
func NewSecurityMetrics() *SecurityMetrics
NewSecurityMetrics creates a new SecurityMetrics with default values
func (*SecurityMetrics) Copy ¶
func (sm *SecurityMetrics) Copy() *SecurityMetrics
Copy creates a deep copy of SecurityMetrics
type SystemHealthAuditor ¶
type SystemHealthAuditor struct {
// contains filtered or unexported fields
}
SystemHealthAuditor monitors the overall health of the system Following the project's audit framework, security guidelines, and performance recommendations
func NewSystemHealthAuditor ¶
func NewSystemHealthAuditor(config *AuditConfig) *SystemHealthAuditor
NewSystemHealthAuditor creates a new system health auditor Following security best practices and performance optimization guidelines
func (*SystemHealthAuditor) GetAllComponentStatuses ¶
func (sha *SystemHealthAuditor) GetAllComponentStatuses() map[string]*ComponentStatus
GetAllComponentStatuses returns the status of all components
func (*SystemHealthAuditor) GetAuditTrail ¶
func (sha *SystemHealthAuditor) GetAuditTrail() []AuditEvent
GetAuditTrail returns the audit trail for review Following audit framework recommendations
func (*SystemHealthAuditor) GetComponentStatus ¶
func (sha *SystemHealthAuditor) GetComponentStatus(componentName string) *ComponentStatus
GetComponentStatus returns the status of a specific component
func (*SystemHealthAuditor) GetNotificationChannel ¶
func (sha *SystemHealthAuditor) GetNotificationChannel() <-chan AuditEvent
GetNotificationChannel returns the channel for audit notifications
func (*SystemHealthAuditor) GetPerformanceMetrics ¶
func (sha *SystemHealthAuditor) GetPerformanceMetrics() *SystemHealthPerformanceMetrics
GetPerformanceMetrics returns performance metrics for monitoring Following performance audit recommendations
func (*SystemHealthAuditor) GetSecurityMetrics ¶
func (sha *SystemHealthAuditor) GetSecurityMetrics() *SystemHealthSecurityMetrics
GetSecurityMetrics returns security metrics for monitoring Following security audit recommendations
func (*SystemHealthAuditor) GetStats ¶
func (sha *SystemHealthAuditor) GetStats() *SystemHealthStats
GetStats returns the current system health statistics
func (*SystemHealthAuditor) MonitorArbitrageEngine ¶
func (sha *SystemHealthAuditor) MonitorArbitrageEngine(engine types.ArbitrageEngine)
MonitorArbitrageEngine adds health monitoring for an ArbitrageEngine component
func (*SystemHealthAuditor) MonitorDecoder ¶
func (sha *SystemHealthAuditor) MonitorDecoder(decoder types.Decoder)
MonitorDecoder adds health monitoring for a Decoder component
func (*SystemHealthAuditor) MonitorPoolOracle ¶
func (sha *SystemHealthAuditor) MonitorPoolOracle(oracle types.PoolOracle)
MonitorPoolOracle adds health monitoring for a PoolOracle component
func (*SystemHealthAuditor) MonitorTransactionExecutor ¶
func (sha *SystemHealthAuditor) MonitorTransactionExecutor(executor types.TransactionExecutor)
MonitorTransactionExecutor adds health monitoring for a TransactionExecutor component
func (*SystemHealthAuditor) RegisterHealthCheck ¶
func (sha *SystemHealthAuditor) RegisterHealthCheck(componentName string, checkFunc HealthCheckFunc)
RegisterHealthCheck registers a health check function for a component
func (*SystemHealthAuditor) Start ¶
func (sha *SystemHealthAuditor) Start(ctx context.Context) error
Start begins auditing system health in a separate goroutine
func (*SystemHealthAuditor) UpdateStats ¶
func (sha *SystemHealthAuditor) UpdateStats(updateFunc func(*SystemHealthStats))
UpdateStats updates the system health statistics
type SystemHealthPerformanceMetrics ¶
type SystemHealthPerformanceMetrics struct {
MaxCheckTime time.Duration
MinCheckTime time.Duration
TotalCheckTime time.Duration
CheckCount int64
}
SystemHealthPerformanceMetrics holds system health-specific performance metrics
type SystemHealthSecurityMetrics ¶
type SystemHealthSecurityMetrics struct {
RiskEventsDetected int64
InvalidOpportunities int64
SuspiciousActivities int64
LastSecurityEvent time.Time
}
SystemHealthSecurityMetrics holds system health-specific security metrics