chore_: add a status proxy to the nodefleet rpc as a primary service provider

fixes #5901
This commit is contained in:
Andrey Bocharnikov 2024-10-02 12:20:03 +04:00
parent 5c41e8211a
commit 66ee53175e
6 changed files with 40 additions and 22 deletions

View File

@ -29,8 +29,9 @@ func mainnet(stageName string) params.Network {
return params.Network{
ChainID: mainnetChainID,
ChainName: "Mainnet",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/mainnet/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/ethereum/mainnet/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/mainnet/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/mainnet/", stageName),
RPCURL: "https://eth-archival.rpc.grove.city/v1/",
FallbackURL: "https://mainnet.infura.io/v3/",
BlockExplorerURL: "https://etherscan.io/",
@ -71,8 +72,9 @@ func sepolia(stageName string) params.Network {
return params.Network{
ChainID: sepoliaChainID,
ChainName: "Mainnet",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/sepolia/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/ethereum/sepolia/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/sepolia/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/sepolia/", stageName),
RPCURL: "https://sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia.etherscan.io/",
@ -93,8 +95,9 @@ func optimism(stageName string) params.Network {
return params.Network{
ChainID: optimismChainID,
ChainName: "Optimism",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/mainnet/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/optimism/mainnet/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/mainnet/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/optimism/mainnet/", stageName),
RPCURL: "https://optimism-archival.rpc.grove.city/v1/",
FallbackURL: "https://optimism-mainnet.infura.io/v3/",
BlockExplorerURL: "https://optimistic.etherscan.io",
@ -135,8 +138,9 @@ func optimismSepolia(stageName string) params.Network {
return params.Network{
ChainID: optimismSepoliaChainID,
ChainName: "Optimism",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/sepolia/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/optimism/sepolia/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/sepolia/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/optimism/sepolia/", stageName),
RPCURL: "https://optimism-sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://optimism-sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia-optimism.etherscan.io/",
@ -157,8 +161,9 @@ func arbitrum(stageName string) params.Network {
return params.Network{
ChainID: arbitrumChainID,
ChainName: "Arbitrum",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/mainnet/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/arbitrum/mainnet/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/mainnet/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/mainnet/", stageName),
RPCURL: "https://arbitrum-one.rpc.grove.city/v1/",
FallbackURL: "https://arbitrum-mainnet.infura.io/v3/",
BlockExplorerURL: "https://arbiscan.io/",
@ -199,8 +204,9 @@ func arbitrumSepolia(stageName string) params.Network {
return params.Network{
ChainID: arbitrumSepoliaChainID,
ChainName: "Arbitrum",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/sepolia/", stageName),
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/arbitrum/sepolia/", stageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/sepolia/", stageName),
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/sepolia/", stageName),
RPCURL: "https://arbitrum-sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://arbitrum-sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia-explorer.arbitrum.io/",

View File

@ -31,6 +31,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[0].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[0].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[0].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[0].DefaultFallbackURL2, stageName))
require.Equal(t, goerliChainID, actualNetworks[1].ChainID)
@ -42,6 +43,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[2].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[2].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[2].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[2].DefaultFallbackURL2, stageName))
require.Equal(t, optimismChainID, actualNetworks[3].ChainID)
@ -49,6 +51,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[3].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[3].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[3].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[3].DefaultFallbackURL2, stageName))
require.Equal(t, optimismGoerliChainID, actualNetworks[4].ChainID)
@ -61,6 +64,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[5].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[5].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[5].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[5].DefaultFallbackURL2, stageName))
require.Equal(t, arbitrumChainID, actualNetworks[6].ChainID)
@ -68,6 +72,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[6].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[6].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[6].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[6].DefaultFallbackURL2, stageName))
require.Equal(t, arbitrumGoerliChainID, actualNetworks[7].ChainID)
@ -80,6 +85,7 @@ func TestBuildDefaultNetworks(t *testing.T) {
require.True(t, strings.Contains(actualNetworks[8].FallbackURL, infuraToken))
require.True(t, strings.Contains(actualNetworks[8].DefaultRPCURL, stageName))
require.True(t, strings.Contains(actualNetworks[8].DefaultFallbackURL, stageName))
require.True(t, strings.Contains(actualNetworks[8].DefaultFallbackURL2, stageName))
}

View File

@ -541,6 +541,7 @@ type Network struct {
ChainName string `json:"chainName"`
DefaultRPCURL string `json:"defaultRpcUrl"` // proxy rpc url
DefaultFallbackURL string `json:"defaultFallbackURL"` // proxy fallback url
DefaultFallbackURL2 string `json:"defaultFallbackURL2"` // second proxy fallback url
RPCURL string `json:"rpcUrl"`
OriginalRPCURL string `json:"originalRpcUrl"`
FallbackURL string `json:"fallbackURL"`

View File

@ -264,11 +264,14 @@ func (c *Client) getEthClients(network *params.Network) []ethclient.RPSLimitedEt
if proxyProvider.Enabled {
key := ProviderStatusProxy
keyFallback := ProviderStatusProxy + "-fallback"
keyFallback2 := ProviderStatusProxy + "-fallback2"
urls[key] = network.DefaultRPCURL
urls[keyFallback] = network.DefaultFallbackURL
keys = []string{key, keyFallback}
urls[keyFallback2] = network.DefaultFallbackURL2
keys = []string{key, keyFallback, keyFallback2}
authMap[key] = proxyProvider.User + ":" + proxyProvider.Password
authMap[keyFallback] = authMap[key]
authMap[keyFallback2] = authMap[key]
}
keys = append(keys, []string{"main", "fallback"}...)
urls["main"] = network.RPCURL

View File

@ -151,25 +151,25 @@ func TestGetClientsUsingCache(t *testing.T) {
providerConfigs := []params.ProviderConfig{providerConfig}
var wg sync.WaitGroup
wg.Add(2) // 2 providers
wg.Add(3) // 3 providers
// Create a new ServeMux
mux := http.NewServeMux()
path1 := "/foo"
path2 := "/bar"
// Register handlers for different URL paths
mux.HandleFunc(path1, func(w http.ResponseWriter, r *http.Request) {
authToken := base64.StdEncoding.EncodeToString([]byte(providerConfig.User + ":" + providerConfig.Password))
require.Equal(t, fmt.Sprintf("Basic %s", authToken), r.Header.Get("Authorization"))
wg.Done()
})
path3 := "/baz"
mux.HandleFunc(path2, func(w http.ResponseWriter, r *http.Request) {
authHandler := func(w http.ResponseWriter, r *http.Request) {
authToken := base64.StdEncoding.EncodeToString([]byte(providerConfig.User + ":" + providerConfig.Password))
require.Equal(t, fmt.Sprintf("Basic %s", authToken), r.Header.Get("Authorization"))
wg.Done()
})
}
// Register handlers for different URL paths
mux.HandleFunc(path1, authHandler)
mux.HandleFunc(path2, authHandler)
mux.HandleFunc(path3, authHandler)
// Create a new server with the mux as the handler
server := httptest.NewServer(mux)
@ -180,12 +180,13 @@ func TestGetClientsUsingCache(t *testing.T) {
ChainID: 1,
DefaultRPCURL: server.URL + path1,
DefaultFallbackURL: server.URL + path2,
DefaultFallbackURL2: server.URL + path3,
},
}
c, err := NewClient(nil, 1, params.UpstreamRPCConfig{}, networks, db, providerConfigs)
require.NoError(t, err)
// Networks from DB must pick up DefaultRPCURL and DefaultFallbackURL
// Networks from DB must pick up DefaultRPCURL, DefaultFallbackURL, DefaultFallbackURL2
chainClient, err := c.getClientUsingCache(networks[0].ChainID)
require.NoError(t, err)
require.NotNil(t, chainClient)

View File

@ -378,6 +378,7 @@ func findNetwork(networks []params.Network, chainID uint64) (params.Network, err
func addDefaultRPCURL(target *params.Network, source params.Network) {
target.DefaultRPCURL = source.DefaultRPCURL
target.DefaultFallbackURL = source.DefaultFallbackURL
target.DefaultFallbackURL2 = source.DefaultFallbackURL2
}
func setDefaultRPCURL(target []*params.Network, source []params.Network) {