Use rpc standard for avalanche (#622)

This commit is contained in:
walker-16 2023-08-10 15:51:12 -03:00 committed by GitHub
parent ab964a138c
commit 160f80018f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 72 deletions

View File

@ -42,6 +42,7 @@ type watchersConfig struct {
ankr []config.WatcherBlockchainAddresses
aptos *config.WatcherBlockchain
arbitrum *config.WatcherBlockchainAddresses
avalanche *config.WatcherBlockchainAddresses
base *config.WatcherBlockchainAddresses
ethereum *config.WatcherBlockchainAddresses
celo *config.WatcherBlockchainAddresses
@ -54,17 +55,18 @@ type watchersConfig struct {
}
type rateLimitConfig struct {
ankr int
aptos int
arbitrum int
base int
celo int
ethereum int
moonbeam int
oasis int
optimism int
solana int
terra int
ankr int
aptos int
arbitrum int
avalanche int
base int
celo int
ethereum int
moonbeam int
oasis int
optimism int
solana int
terra int
}
func Run() {
@ -178,6 +180,12 @@ func newWatchers(config *config.ServiceConfiguration, repo *storage.Repository,
result = append(result, solanaWatcher)
}
// add avalanche watcher
if watchers.avalanche != nil {
avalancheWatcher := builder.CreateEvmWatcher(watchers.rateLimit.avalanche, config.AvalancheUrl, *watchers.avalanche, logger, repo, metrics)
result = append(result, avalancheWatcher)
}
// add terra watcher
if watchers.terra != nil {
terraWatcher := builder.CreateTerraWatcher(watchers.rateLimit.terra, config.TerraUrl, *watchers.terra, logger, repo, metrics)
@ -235,28 +243,29 @@ func newWatchersForMainnet(cfg *config.ServiceConfiguration) *watchersConfig {
config.POLYGON_MAINNET,
config.BSC_MAINNET,
config.FANTOM_MAINNET,
config.AVALANCHE_MAINNET,
},
aptos: &config.APTOS_MAINNET,
base: &config.BASE_MAINNET,
celo: &config.CELO_MAINNET,
ethereum: &config.ETHEREUM_MAINNET,
moonbeam: &config.MOONBEAM_MAINNET,
oasis: &config.OASIS_MAINNET,
solana: &config.SOLANA_MAINNET,
terra: &config.TERRA_MAINNET,
avalanche: &config.AVALANCHE_MAINNET,
aptos: &config.APTOS_MAINNET,
base: &config.BASE_MAINNET,
celo: &config.CELO_MAINNET,
ethereum: &config.ETHEREUM_MAINNET,
moonbeam: &config.MOONBEAM_MAINNET,
oasis: &config.OASIS_MAINNET,
solana: &config.SOLANA_MAINNET,
terra: &config.TERRA_MAINNET,
rateLimit: rateLimitConfig{
ankr: cfg.AnkrRequestsPerSecond,
aptos: cfg.AptosRequestsPerSecond,
arbitrum: cfg.ArbitrumRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
oasis: cfg.OasisRequestsPerSecond,
optimism: cfg.OptimismRequestsPerSecond,
solana: cfg.SolanaRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
ankr: cfg.AnkrRequestsPerSecond,
avalanche: cfg.AvalancheRequestsPerSecond,
aptos: cfg.AptosRequestsPerSecond,
arbitrum: cfg.ArbitrumRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
oasis: cfg.OasisRequestsPerSecond,
optimism: cfg.OptimismRequestsPerSecond,
solana: cfg.SolanaRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
},
}
}
@ -267,27 +276,28 @@ func newWatchersForTestnet(cfg *config.ServiceConfiguration) *watchersConfig {
config.POLYGON_TESTNET,
config.BSC_TESTNET,
config.FANTOM_TESTNET,
config.AVALANCHE_TESTNET,
},
aptos: &config.APTOS_TESTNET,
celo: &config.CELO_TESTNET,
base: &config.BASE_TESTNET,
ethereum: &config.ETHEREUM_TESTNET,
moonbeam: &config.MOONBEAM_TESTNET,
oasis: &config.OASIS_TESTNET,
solana: &config.SOLANA_TESTNET,
avalanche: &config.AVALANCHE_TESTNET,
aptos: &config.APTOS_TESTNET,
celo: &config.CELO_TESTNET,
base: &config.BASE_TESTNET,
ethereum: &config.ETHEREUM_TESTNET,
moonbeam: &config.MOONBEAM_TESTNET,
oasis: &config.OASIS_TESTNET,
solana: &config.SOLANA_TESTNET,
rateLimit: rateLimitConfig{
ankr: cfg.AnkrRequestsPerSecond,
aptos: cfg.AptosRequestsPerSecond,
arbitrum: cfg.ArbitrumRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
oasis: cfg.OasisRequestsPerSecond,
optimism: cfg.OptimismRequestsPerSecond,
solana: cfg.SolanaRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
ankr: cfg.AnkrRequestsPerSecond,
avalanche: cfg.AvalancheRequestsPerSecond,
aptos: cfg.AptosRequestsPerSecond,
arbitrum: cfg.ArbitrumRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
oasis: cfg.OasisRequestsPerSecond,
optimism: cfg.OptimismRequestsPerSecond,
solana: cfg.SolanaRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
},
}
}

View File

@ -19,28 +19,30 @@ type ServiceConfiguration struct {
AlertEnabled bool `env:"ALERT_ENABLED,required"`
AlertApiKey string `env:"ALERT_API_KEY"`
AnkrUrl string `env:"ANKR_URL,required"`
AnkrRequestsPerSecond int `env:"ANKR_REQUESTS_PER_SECOND,required"`
AptosUrl string `env:"APTOS_URL,required"`
AptosRequestsPerSecond int `env:"APTOS_REQUESTS_PER_SECOND,required"`
ArbitrumUrl string `env:"ARBITRUM_URL,required"`
ArbitrumRequestsPerSecond int `env:"ARBITRUM_REQUESTS_PER_SECOND,required"`
BaseUrl string `env:"ARBITRUM_URL,required"`
BaseRequestsPerSecond int `env:"ARBITRUM_REQUESTS_PER_SECOND,required"`
CeloUrl string `env:"CELO_URL,required"`
CeloRequestsPerSecond int `env:"CELO_REQUESTS_PER_SECOND,required"`
EthereumUrl string `env:"ETHEREUM_URL,required"`
EthereumRequestsPerSecond int `env:"ETHEREUM_REQUESTS_PER_SECOND,required"`
MoonbeamUrl string `env:"MOONBEAM_URL,required"`
MoonbeamRequestsPerSecond int `env:"MOONBEAM_REQUESTS_PER_SECOND,required"`
OptimismUrl string `env:"OPTIMISM_URL,required"`
OptimismRequestsPerSecond int `env:"OPTIMISM_REQUESTS_PER_SECOND,required"`
OasisUrl string `env:"OASIS_URL,required"`
OasisRequestsPerSecond int `env:"OASIS_REQUESTS_PER_SECOND,required"`
SolanaUrl string `env:"SOLANA_URL,required"`
SolanaRequestsPerSecond int `env:"SOLANA_REQUESTS_PER_SECOND,required"`
TerraUrl string `env:"TERRA_URL,required"`
TerraRequestsPerSecond int `env:"TERRA_REQUESTS_PER_SECOND,required"`
AnkrUrl string `env:"ANKR_URL,required"`
AnkrRequestsPerSecond int `env:"ANKR_REQUESTS_PER_SECOND,required"`
AptosUrl string `env:"APTOS_URL,required"`
AptosRequestsPerSecond int `env:"APTOS_REQUESTS_PER_SECOND,required"`
ArbitrumUrl string `env:"ARBITRUM_URL,required"`
ArbitrumRequestsPerSecond int `env:"ARBITRUM_REQUESTS_PER_SECOND,required"`
AvalancheUrl string `env:"AVALANCHE_URL,required"`
AvalancheRequestsPerSecond int `env:"AVALANCHE_REQUESTS_PER_SECOND,required"`
BaseUrl string `env:"ARBITRUM_URL,required"`
BaseRequestsPerSecond int `env:"ARBITRUM_REQUESTS_PER_SECOND,required"`
CeloUrl string `env:"CELO_URL,required"`
CeloRequestsPerSecond int `env:"CELO_REQUESTS_PER_SECOND,required"`
EthereumUrl string `env:"ETHEREUM_URL,required"`
EthereumRequestsPerSecond int `env:"ETHEREUM_REQUESTS_PER_SECOND,required"`
MoonbeamUrl string `env:"MOONBEAM_URL,required"`
MoonbeamRequestsPerSecond int `env:"MOONBEAM_REQUESTS_PER_SECOND,required"`
OptimismUrl string `env:"OPTIMISM_URL,required"`
OptimismRequestsPerSecond int `env:"OPTIMISM_REQUESTS_PER_SECOND,required"`
OasisUrl string `env:"OASIS_URL,required"`
OasisRequestsPerSecond int `env:"OASIS_REQUESTS_PER_SECOND,required"`
SolanaUrl string `env:"SOLANA_URL,required"`
SolanaRequestsPerSecond int `env:"SOLANA_REQUESTS_PER_SECOND,required"`
TerraUrl string `env:"TERRA_URL,required"`
TerraRequestsPerSecond int `env:"TERRA_REQUESTS_PER_SECOND,required"`
}
// BackfillerConfiguration represents the application configuration when running as backfiller.

View File

@ -137,6 +137,13 @@ spec:
key: ethereum-url
- name: ETHEREUM_REQUESTS_PER_SECOND
value: "{{ .ETHEREUM_REQUESTS_PER_SECOND }}"
- name: AVALANCHE_URL
valueFrom:
secretKeyRef:
name: blockchain
key: avalanche-url
- name: AVALANCHE_REQUESTS_PER_SECOND
value: "{{ .AVALANCHE_REQUESTS_PER_SECOND }}"
- name: ALERT_API_KEY
valueFrom:
secretKeyRef:

View File

@ -15,6 +15,8 @@ APTOS_URL=
APTOS_REQUESTS_PER_SECOND=20
ARBITRUM_URL=
ARBITRUM_REQUESTS_PER_SECOND=3
AVALANCHE_URL=
AVALANCHE_REQUESTS_PER_SECOND=5
BASE_URL=
BASE_REQUESTS_PER_SECOND=3
CELO_URL=

View File

@ -15,6 +15,8 @@ APTOS_URL=
APTOS_REQUESTS_PER_SECOND=1
ARBITRUM_URL=
ARBITRUM_REQUESTS_PER_SECOND=1
AVALANCHE_URL=
AVALANCHE_REQUESTS_PER_SECOND=5
BASE_URL=
BASE_REQUESTS_PER_SECOND=1
CELO_URL=

View File

@ -15,6 +15,8 @@ APTOS_URL=
APTOS_REQUESTS_PER_SECOND=20
ARBITRUM_URL=
ARBITRUM_REQUESTS_PER_SECOND=3
AVALANCHE_URL=
AVALANCHE_REQUESTS_PER_SECOND=5
BASE_URL=
BASE_REQUESTS_PER_SECOND=3
CELO_URL=

View File

@ -15,6 +15,8 @@ APTOS_URL=
APTOS_REQUESTS_PER_SECOND=1
ARBITRUM_URL=
ARBITRUM_REQUESTS_PER_SECOND=1
AVALANCHE_URL=
AVALANCHE_REQUESTS_PER_SECOND=5
BASE_URL=
BASE_REQUESTS_PER_SECOND=1
CELO_URL=

View File

@ -15,4 +15,5 @@ data:
arbitrum-url: {{ .ARBITRUM_URL | b64enc }}
optimism-url: {{ .OPTIMISM_URL | b64enc }}
ethereum-url: {{ .ETHEREUM_URL | b64enc }}
avalanche-url: {{ .AVALANCHE_URL | b64enc }}
type: Opaque