remove connect from contract-watcher (#1398)

* remove polygon connect from contract-watcher

Co-authored-by: ftocal <fert1335@gmail.com>

* remove bsc and fantom connect from contract-watcher

Co-authored-by: ftocal <fert1335@gmail.com>

* remove avalanche and moonbeam from contract-watcher

* remove ethereum and celo from contract-watcher

---------

Co-authored-by: ftocal <fert1335@gmail.com>
This commit is contained in:
walker-16 2024-05-13 12:10:42 -03:00 committed by GitHub
parent c3950c4fb9
commit bcb1f0e71b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 339 deletions

View File

@ -69,22 +69,8 @@ func Run(config *config.BackfillerConfiguration) {
func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Repository, metrics metrics.Metrics, logger *zap.Logger) watcher.ContractWatcher {
var watcher watcher.ContractWatcher
switch cfg.ChainName {
case config.ETHEREUM_MAINNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_MAINNET, repo, metrics, logger)
case config.POLYGON_MAINNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_MAINNET, repo, metrics, logger)
case config.BSC_MAINNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_MAINNET, repo, metrics, logger)
case config.FANTOM_MAINNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_MAINNET, repo, metrics, logger)
case config.AVALANCHE_MAINNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_MAINNET, repo, metrics, logger)
case config.TERRA_MAINNET.ChainID.String():
watcher = builder.CreateTerraWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.TERRA_MAINNET, logger, repo, metrics)
case config.MOONBEAM_MAINNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_MAINNET, logger, repo, metrics)
case config.CELO_MAINNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_MAINNET, logger, repo, metrics)
case config.BASE_MAINNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BASE_MAINNET, logger, repo, metrics)
default:
@ -96,20 +82,6 @@ func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
func newWatcherForTestnet(cfg *config.BackfillerConfiguration, repo *storage.Repository, metrics metrics.Metrics, logger *zap.Logger) watcher.ContractWatcher {
var watcher watcher.ContractWatcher
switch cfg.ChainName {
case config.ETHEREUM_TESTNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_TESTNET, repo, metrics, logger)
case config.POLYGON_TESTNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_TESTNET, repo, metrics, logger)
case config.BSC_TESTNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_TESTNET, repo, metrics, logger)
case config.FANTOM_TESTNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_TESTNET, repo, metrics, logger)
case config.AVALANCHE_TESTNET.ChainID.String():
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_TESTNET, repo, metrics, logger)
case config.MOONBEAM_TESTNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_TESTNET, logger, repo, metrics)
case config.CELO_TESTNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_TESTNET, logger, repo, metrics)
case config.BASE_TESTNET.ChainID.String():
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BASE_TESTNET, logger, repo, metrics)
default:

View File

@ -19,13 +19,11 @@ import (
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/http/infrastructure"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/http/redeem"
cwAlert "github.com/wormhole-foundation/wormhole-explorer/contract-watcher/internal/alert"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/internal/ankr"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/internal/metrics"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/processor"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/storage"
"github.com/wormhole-foundation/wormhole-explorer/contract-watcher/watcher"
"go.mongodb.org/mongo-driver/mongo"
"go.uber.org/ratelimit"
"go.uber.org/zap"
)
@ -41,27 +39,15 @@ func handleExit() {
}
type watchersConfig struct {
ankr []config.WatcherBlockchainAddresses
avalanche *config.WatcherBlockchainAddresses
base *config.WatcherBlockchainAddresses
baseSepolia *config.WatcherBlockchainAddresses
ethereum *config.WatcherBlockchainAddresses
celo *config.WatcherBlockchainAddresses
moonbeam *config.WatcherBlockchainAddresses
polygon *config.WatcherBlockchainAddresses
terra *config.WatcherBlockchain
rateLimit rateLimitConfig
}
type rateLimitConfig struct {
ankr int
avalanche int
base int
baseSepolia int
celo int
ethereum int
moonbeam int
polygon int
terra int
}
@ -164,45 +150,12 @@ func newWatchers(config *config.ServiceConfiguration, testnetConfig *config.Test
result := make([]watcher.ContractWatcher, 0)
// add evm watchers
evmLimiter := ratelimit.New(watchers.rateLimit.ankr, ratelimit.Per(time.Second))
ankrClient := ankr.NewAnkrSDK(config.AnkrUrl, evmLimiter, metrics)
for _, w := range watchers.ankr {
params := watcher.EVMParams{ChainID: w.ChainID, Blockchain: w.Name, SizeBlocks: w.SizeBlocks,
WaitSeconds: w.WaitSeconds, InitialBlock: w.InitialBlock, MethodsByAddress: w.MethodsByAddress}
result = append(result, watcher.NewEVMWatcher(ankrClient, repo, params, metrics, logger))
}
// add ethereum watcher
if watchers.ethereum != nil {
ethereumWatcher := builder.CreateEvmWatcher(watchers.rateLimit.ethereum, config.EthereumUrl, *watchers.ethereum, logger, repo, metrics)
result = append(result, ethereumWatcher)
}
// 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)
result = append(result, terraWatcher)
}
// add moonbeam watcher
if watchers.moonbeam != nil {
moonbeamWatcher := builder.CreateEvmWatcher(watchers.rateLimit.moonbeam, config.MoonbeamUrl, *watchers.moonbeam, logger, repo, metrics)
result = append(result, moonbeamWatcher)
}
// add celo watcher
if watchers.celo != nil {
celoWatcher := builder.CreateEvmWatcher(watchers.rateLimit.celo, config.CeloUrl, *watchers.celo, logger, repo, metrics)
result = append(result, celoWatcher)
}
// add base watcher
if watchers.base != nil {
baseWatcher := builder.CreateEvmWatcher(watchers.rateLimit.base, config.BaseUrl, *watchers.base, logger, repo, metrics)
@ -215,64 +168,28 @@ func newWatchers(config *config.ServiceConfiguration, testnetConfig *config.Test
result = append(result, baseSepoliaWatcher)
}
// add polygon watcher
if watchers.polygon != nil {
polygonWatcher := builder.CreateEvmWatcher(watchers.rateLimit.polygon, config.PolygonUrl, *watchers.polygon, logger, repo, metrics)
result = append(result, polygonWatcher)
}
return result
}
func newWatchersForMainnet(cfg *config.ServiceConfiguration) *watchersConfig {
return &watchersConfig{
ankr: []config.WatcherBlockchainAddresses{
config.BSC_MAINNET,
config.FANTOM_MAINNET,
},
avalanche: &config.AVALANCHE_MAINNET,
base: &config.BASE_MAINNET,
celo: &config.CELO_MAINNET,
ethereum: &config.ETHEREUM_MAINNET,
moonbeam: &config.MOONBEAM_MAINNET,
polygon: &config.POLYGON_MAINNET,
terra: &config.TERRA_MAINNET,
base: &config.BASE_MAINNET,
terra: &config.TERRA_MAINNET,
rateLimit: rateLimitConfig{
ankr: cfg.AnkrRequestsPerSecond,
avalanche: cfg.AvalancheRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
polygon: cfg.PolygonRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
},
}
}
func newWatchersForTestnet(cfg *config.ServiceConfiguration, testnetCfg *config.TestnetConfiguration) *watchersConfig {
return &watchersConfig{
ankr: []config.WatcherBlockchainAddresses{
config.BSC_TESTNET,
config.FANTOM_TESTNET,
},
avalanche: &config.AVALANCHE_TESTNET,
celo: &config.CELO_TESTNET,
base: &config.BASE_TESTNET,
baseSepolia: &config.BASE_SEPOLIA_TESTNET,
ethereum: &config.ETHEREUM_TESTNET,
moonbeam: &config.MOONBEAM_TESTNET,
polygon: &config.POLYGON_TESTNET,
rateLimit: rateLimitConfig{
ankr: cfg.AnkrRequestsPerSecond,
avalanche: cfg.AvalancheRequestsPerSecond,
base: cfg.BaseRequestsPerSecond,
baseSepolia: testnetCfg.BaseSepoliaRequestsPerMinute,
celo: cfg.CeloRequestsPerSecond,
ethereum: cfg.EthereumRequestsPerSecond,
moonbeam: cfg.MoonbeamRequestsPerSecond,
polygon: cfg.PolygonRequestsPerSecond,
terra: cfg.TerraRequestsPerSecond,
},
}

View File

@ -6,70 +6,6 @@ import (
"github.com/wormhole-foundation/wormhole/sdk/vaa"
)
var ETHEREUM_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDEthereum,
Name: "eth",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 16820790,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var POLYGON_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDPolygon,
Name: "polygon",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 40307020,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var BSC_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDBSC,
Name: "bsc",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 26436320,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var FANTOM_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDFantom,
Name: "fantom",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 57525624,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var TERRA_MAINNET = WatcherBlockchain{
ChainID: vaa.ChainIDTerra,
Name: "terra",
@ -79,54 +15,6 @@ var TERRA_MAINNET = WatcherBlockchain{
InitialBlock: 3911168,
}
var AVALANCHE_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDAvalanche,
Name: "avalanche",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 8237181,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var MOONBEAM_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDMoonbeam,
Name: "moonbeam",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 1853330,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var CELO_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDCelo,
Name: "celo",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 12947239,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var BASE_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDBase,
Name: "base",

View File

@ -6,118 +6,6 @@ import (
"github.com/wormhole-foundation/wormhole/sdk/vaa"
)
var ETHEREUM_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDEthereum,
Name: "eth_goerli",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 8660321,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var POLYGON_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDPolygon,
Name: "polygon_mumbai",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 33151522,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var BSC_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDBSC,
Name: "bsc_testnet_chapel",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 28071327,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var FANTOM_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDFantom,
Name: "fantom_testnet",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 14524466,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var AVALANCHE_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDAvalanche,
Name: "avalanche_fuji",
SizeBlocks: 100,
WaitSeconds: 10,
InitialBlock: 11014526,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var MOONBEAM_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDMoonbeam,
Name: "moonbeam",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 2097310,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var CELO_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDCelo,
Name: "celo",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 10625129,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}
var BASE_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDBase,
Name: "base_goerli",