fix(multicall): resolve critical multicall parsing corruption issues
- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing - Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives - Added LRU caching system for address validation with 10-minute TTL - Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures - Fixed duplicate function declarations and import conflicts across multiple files - Added error recovery mechanisms with multiple fallback strategies - Updated tests to handle new validation behavior for suspicious addresses - Fixed parser test expectations for improved validation system - Applied gofmt formatting fixes to ensure code style compliance - Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot - Resolved critical security vulnerabilities in heuristic address extraction - Progress: Updated TODO audit from 10% to 35% complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -404,6 +404,38 @@ func (c *Config) CreateProviderConfigFile(tempPath string) error {
|
||||
}
|
||||
|
||||
// ConvertToProviderConfig converts ArbitrumConfig to transport.ProvidersConfig
|
||||
func (c *Config) createProviderConfig(endpoint EndpointConfig, features []string) map[string]interface{} {
|
||||
provider := map[string]interface{}{
|
||||
"name": endpoint.Name,
|
||||
"type": "standard",
|
||||
"http_endpoint": "",
|
||||
"ws_endpoint": "",
|
||||
"priority": endpoint.Priority,
|
||||
"rate_limit": map[string]interface{}{
|
||||
"requests_per_second": endpoint.RateLimit.RequestsPerSecond,
|
||||
"burst": endpoint.RateLimit.Burst,
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
"retry_delay": "1s",
|
||||
"max_retries": 3,
|
||||
},
|
||||
"features": features,
|
||||
"health_check": map[string]interface{}{
|
||||
"enabled": true,
|
||||
"interval": fmt.Sprintf("%ds", endpoint.HealthCheckInterval),
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
},
|
||||
}
|
||||
|
||||
// Determine endpoint type and assign to appropriate field
|
||||
if strings.HasPrefix(endpoint.URL, "ws") {
|
||||
provider["ws_endpoint"] = endpoint.URL
|
||||
} else {
|
||||
provider["http_endpoint"] = endpoint.URL
|
||||
}
|
||||
|
||||
return provider
|
||||
}
|
||||
|
||||
func (c *Config) ConvertToProviderConfig() map[string]interface{} {
|
||||
providerConfigs := make([]map[string]interface{}, 0)
|
||||
|
||||
@@ -543,68 +575,12 @@ func (c *Config) ConvertToProviderConfig() map[string]interface{} {
|
||||
|
||||
// Convert reading endpoints
|
||||
for _, endpoint := range c.Arbitrum.ReadingEndpoints {
|
||||
provider := map[string]interface{}{
|
||||
"name": endpoint.Name,
|
||||
"type": "standard",
|
||||
"http_endpoint": "",
|
||||
"ws_endpoint": "",
|
||||
"priority": endpoint.Priority,
|
||||
"rate_limit": map[string]interface{}{
|
||||
"requests_per_second": endpoint.RateLimit.RequestsPerSecond,
|
||||
"burst": endpoint.RateLimit.Burst,
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
"retry_delay": "1s",
|
||||
"max_retries": 3,
|
||||
},
|
||||
"features": []string{"reading", "real_time"},
|
||||
"health_check": map[string]interface{}{
|
||||
"enabled": true,
|
||||
"interval": fmt.Sprintf("%ds", endpoint.HealthCheckInterval),
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
},
|
||||
}
|
||||
|
||||
// Determine endpoint type and assign to appropriate field
|
||||
if strings.HasPrefix(endpoint.URL, "ws") {
|
||||
provider["ws_endpoint"] = endpoint.URL
|
||||
} else {
|
||||
provider["http_endpoint"] = endpoint.URL
|
||||
}
|
||||
|
||||
providerConfigs = append(providerConfigs, provider)
|
||||
providerConfigs = append(providerConfigs, c.createProviderConfig(endpoint, []string{"reading", "real_time"}))
|
||||
}
|
||||
|
||||
// Convert execution endpoints
|
||||
for _, endpoint := range c.Arbitrum.ExecutionEndpoints {
|
||||
provider := map[string]interface{}{
|
||||
"name": endpoint.Name,
|
||||
"type": "standard",
|
||||
"http_endpoint": "",
|
||||
"ws_endpoint": "",
|
||||
"priority": endpoint.Priority,
|
||||
"rate_limit": map[string]interface{}{
|
||||
"requests_per_second": endpoint.RateLimit.RequestsPerSecond,
|
||||
"burst": endpoint.RateLimit.Burst,
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
"retry_delay": "1s",
|
||||
"max_retries": 3,
|
||||
},
|
||||
"features": []string{"execution", "transaction_submission"},
|
||||
"health_check": map[string]interface{}{
|
||||
"enabled": true,
|
||||
"interval": fmt.Sprintf("%ds", endpoint.HealthCheckInterval),
|
||||
"timeout": fmt.Sprintf("%ds", endpoint.TimeoutSeconds),
|
||||
},
|
||||
}
|
||||
|
||||
// Determine endpoint type and assign to appropriate field
|
||||
if strings.HasPrefix(endpoint.URL, "ws") {
|
||||
provider["ws_endpoint"] = endpoint.URL
|
||||
} else {
|
||||
provider["http_endpoint"] = endpoint.URL
|
||||
}
|
||||
|
||||
providerConfigs = append(providerConfigs, provider)
|
||||
providerConfigs = append(providerConfigs, c.createProviderConfig(endpoint, []string{"execution", "transaction_submission"}))
|
||||
}
|
||||
|
||||
// Build provider pool configurations
|
||||
|
||||
@@ -62,8 +62,8 @@ database:
|
||||
require.NoError(t, err)
|
||||
|
||||
// Set environment variables for test
|
||||
os.Setenv("ARBITRUM_RPC_ENDPOINT", "wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870")
|
||||
os.Setenv("ARBITRUM_WS_ENDPOINT", "wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870")
|
||||
os.Setenv("ARBITRUM_RPC_ENDPOINT", "wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57")
|
||||
os.Setenv("ARBITRUM_WS_ENDPOINT", "wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57")
|
||||
defer func() {
|
||||
os.Unsetenv("ARBITRUM_RPC_ENDPOINT")
|
||||
os.Unsetenv("ARBITRUM_WS_ENDPOINT")
|
||||
@@ -74,8 +74,8 @@ database:
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify the loaded config
|
||||
assert.Equal(t, "wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870", cfg.Arbitrum.RPCEndpoint)
|
||||
assert.Equal(t, "wss://arbitrum-mainnet.core.chainstack.com/f69d14406bc00700da9b936504e1a870", cfg.Arbitrum.WSEndpoint)
|
||||
assert.Equal(t, "wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57", cfg.Arbitrum.RPCEndpoint)
|
||||
assert.Equal(t, "wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57", cfg.Arbitrum.WSEndpoint)
|
||||
assert.Equal(t, int64(42161), cfg.Arbitrum.ChainID)
|
||||
assert.Equal(t, 5, cfg.Arbitrum.RateLimit.RequestsPerSecond)
|
||||
assert.True(t, cfg.Bot.Enabled)
|
||||
|
||||
Reference in New Issue
Block a user