Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RPC limiters for some providers #5997

Open
friofry opened this issue Oct 28, 2024 · 0 comments
Open

Enable RPC limiters for some providers #5997

friofry opened this issue Oct 28, 2024 · 0 comments
Assignees

Comments

@friofry
Copy link
Contributor

friofry commented Oct 28, 2024

It requires refactoring the existing Network type and excluding RPC providers to a separate table.

// RpcProviderAuthType defines the different types of authentication for RPC providers
type RpcProviderAuthType int

const (
	NoAuth RpcProviderAuthType = iota // No authentication
	// Example: Used for public nodes or local nodes without any authentication.
	// Example: "http://localhost:8545"

	BasicAuth // Authentication via Basic Auth
	// Example: Uses a username and password encoded as a base64 string and passed in the request header.
	// Example: Header "Authorization: Basic base64(username:password)", URL: "https://api.example.com"

	URLPathAuth // Authentication via token in URL path
	// Example: The token is included directly in the URL path.
	// Example: "https://api.example.com/YOUR_TOKEN"
)

// RpcProvider represents an RPC provider configuration with various options
type RpcProvider struct {
	ChainID          uint64 `json:"chainId"`          // Chain ID of the network
	Name             string `json:"name"`             // Provider name for identification
	URL              string `json:"url"`              // Current Provider URL (may include overrides)
	OriginalURL      string `json:"originalUrl"`      // Original URL before any overrides
	EnableRPSLimiter bool   `json:"enableRpsLimiter"` // Enable RPC rate limiting for this provider
}

type Network struct {
	ChainID                uint64          `json:"chainId"`
	ChainName              string          `json:"chainName"`
	RpcProviders           []RpcProvider   `json:"rpcProviders"` // List of RPC providers, in the order in which they are accessed
	BlockExplorerURL       string          `json:"blockExplorerUrl,omitempty"`
	IconURL                string          `json:"iconUrl,omitempty"`
	NativeCurrencyName     string          `json:"nativeCurrencyName,omitempty"`
	NativeCurrencySymbol   string          `json:"nativeCurrencySymbol,omitempty"`
	NativeCurrencyDecimals uint64          `json:"nativeCurrencyDecimals"`
	IsTest                 bool            `json:"isTest"`
	Layer                  uint64          `json:"layer"`
	Enabled                bool            `json:"enabled"`
	ChainColor             string          `json:"chainColor"`
	ShortName              string          `json:"shortName"`
	TokenOverrides         []TokenOverride `json:"tokenOverrides"`
	RelatedChainID         uint64          `json:"relatedChainId"`
}

as discussed here: #5941 (comment)

@friofry friofry self-assigned this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant