Add `Base` support to the contract-watcher service (#617)
### Description This pull request adds support for the `Base` blockchain in the `contract-watcher` service. Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/605
This commit is contained in:
parent
2de5b9e970
commit
a01304e324
|
@ -17,7 +17,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CreateEVMWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, repo *storage.Repository,
|
||||
func CreateAnkrEvmWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, repo *storage.Repository,
|
||||
metrics metrics.Metrics, logger *zap.Logger) watcher.ContractWatcher {
|
||||
evmLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
ankrClient := ankr.NewAnkrSDK(chainURL, evmLimiter, metrics)
|
||||
|
@ -58,67 +58,25 @@ func CreateAptosWatcher(rateLimit int, chainURL string, wb config.WatcherBlockch
|
|||
return watcher.NewAptosWatcher(aptosClient, params, repo, metrics, logger)
|
||||
}
|
||||
|
||||
func CreateOasisWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository, metrics metrics.Metrics) watcher.ContractWatcher {
|
||||
oasisLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
oasisClient := evm.NewEvmSDK(chainURL, oasisLimiter, metrics)
|
||||
params := watcher.EVMParams{
|
||||
ChainID: wb.ChainID,
|
||||
Blockchain: wb.Name,
|
||||
SizeBlocks: wb.SizeBlocks,
|
||||
WaitSeconds: wb.WaitSeconds,
|
||||
InitialBlock: wb.InitialBlock,
|
||||
MethodsByAddress: wb.MethodsByAddress}
|
||||
return watcher.NewEvmStandarWatcher(oasisClient, params, repo, metrics, logger)
|
||||
}
|
||||
func CreateEvmWatcher(
|
||||
rateLimit int,
|
||||
chainURL string,
|
||||
wb config.WatcherBlockchainAddresses,
|
||||
logger *zap.Logger,
|
||||
repo *storage.Repository,
|
||||
metrics metrics.Metrics,
|
||||
) watcher.ContractWatcher {
|
||||
|
||||
func CreateMoonbeamWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository, metrics metrics.Metrics) watcher.ContractWatcher {
|
||||
moonbeamLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
moonbeamClient := evm.NewEvmSDK(chainURL, moonbeamLimiter, metrics)
|
||||
limiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
client := evm.NewEvmSDK(chainURL, limiter, metrics)
|
||||
params := watcher.EVMParams{
|
||||
ChainID: wb.ChainID,
|
||||
Blockchain: wb.Name,
|
||||
SizeBlocks: wb.SizeBlocks,
|
||||
WaitSeconds: wb.WaitSeconds,
|
||||
InitialBlock: wb.InitialBlock,
|
||||
MethodsByAddress: wb.MethodsByAddress}
|
||||
return watcher.NewEvmStandarWatcher(moonbeamClient, params, repo, metrics, logger)
|
||||
}
|
||||
MethodsByAddress: wb.MethodsByAddress,
|
||||
}
|
||||
|
||||
func CreateCeloWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository, metrics metrics.Metrics) watcher.ContractWatcher {
|
||||
celoLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
celoClient := evm.NewEvmSDK(chainURL, celoLimiter, metrics)
|
||||
params := watcher.EVMParams{
|
||||
ChainID: wb.ChainID,
|
||||
Blockchain: wb.Name,
|
||||
SizeBlocks: wb.SizeBlocks,
|
||||
WaitSeconds: wb.WaitSeconds,
|
||||
InitialBlock: wb.InitialBlock,
|
||||
MethodsByAddress: wb.MethodsByAddress}
|
||||
return watcher.NewEvmStandarWatcher(celoClient, params, repo, metrics, logger)
|
||||
}
|
||||
|
||||
func CreateOptimismWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository, metrics metrics.Metrics) watcher.ContractWatcher {
|
||||
optimismLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
optimismClient := evm.NewEvmSDK(chainURL, optimismLimiter, metrics)
|
||||
params := watcher.EVMParams{
|
||||
ChainID: wb.ChainID,
|
||||
Blockchain: wb.Name,
|
||||
SizeBlocks: wb.SizeBlocks,
|
||||
WaitSeconds: wb.WaitSeconds,
|
||||
InitialBlock: wb.InitialBlock,
|
||||
MethodsByAddress: wb.MethodsByAddress}
|
||||
return watcher.NewEvmStandarWatcher(optimismClient, params, repo, metrics, logger)
|
||||
}
|
||||
|
||||
func CreateArbitrumWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository, metrics metrics.Metrics) watcher.ContractWatcher {
|
||||
arbitrumLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
|
||||
arbitrumClient := evm.NewEvmSDK(chainURL, arbitrumLimiter, metrics)
|
||||
params := watcher.EVMParams{
|
||||
ChainID: wb.ChainID,
|
||||
Blockchain: wb.Name,
|
||||
SizeBlocks: wb.SizeBlocks,
|
||||
WaitSeconds: wb.WaitSeconds,
|
||||
InitialBlock: wb.InitialBlock,
|
||||
MethodsByAddress: wb.MethodsByAddress}
|
||||
return watcher.NewEvmStandarWatcher(arbitrumClient, params, repo, metrics, logger)
|
||||
return watcher.NewEvmStandardWatcher(client, params, repo, metrics, logger)
|
||||
}
|
||||
|
|
|
@ -70,15 +70,15 @@ func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
|
|||
var watcher watcher.ContractWatcher
|
||||
switch cfg.ChainName {
|
||||
case config.ETHEREUM_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_MAINNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_MAINNET, repo, metrics, logger)
|
||||
case config.POLYGON_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_MAINNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_MAINNET, repo, metrics, logger)
|
||||
case config.BSC_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_MAINNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_MAINNET, repo, metrics, logger)
|
||||
case config.FANTOM_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_MAINNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_MAINNET, repo, metrics, logger)
|
||||
case config.AVALANCHE_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_MAINNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_MAINNET, repo, metrics, logger)
|
||||
case config.SOLANA_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateSolanaWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.SOLANA_MAINNET, logger, repo, metrics)
|
||||
case config.TERRA_MAINNET.ChainID.String():
|
||||
|
@ -86,15 +86,17 @@ func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
|
|||
case config.APTOS_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateAptosWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.APTOS_MAINNET, logger, repo, metrics)
|
||||
case config.OASIS_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_MAINNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_MAINNET, logger, repo, metrics)
|
||||
case config.MOONBEAM_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_MAINNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_MAINNET, logger, repo, metrics)
|
||||
case config.CELO_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_MAINNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_MAINNET, logger, repo, metrics)
|
||||
case config.ARBITRUM_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateArbitrumWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ARBITRUM_MAINNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ARBITRUM_MAINNET, logger, repo, metrics)
|
||||
case config.OPTIMISM_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateOptimismWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OPTIMISM_MAINNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OPTIMISM_MAINNET, logger, repo, metrics)
|
||||
case config.BASE_MAINNET.ChainID.String():
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BASE_MAINNET, logger, repo, metrics)
|
||||
default:
|
||||
logger.Fatal("chain not supported")
|
||||
}
|
||||
|
@ -105,29 +107,31 @@ func newWatcherForTestnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
|
|||
var watcher watcher.ContractWatcher
|
||||
switch cfg.ChainName {
|
||||
case config.ETHEREUM_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_TESTNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ETHEREUM_TESTNET, repo, metrics, logger)
|
||||
case config.POLYGON_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_TESTNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.POLYGON_TESTNET, repo, metrics, logger)
|
||||
case config.BSC_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_TESTNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BSC_TESTNET, repo, metrics, logger)
|
||||
case config.FANTOM_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_TESTNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.FANTOM_TESTNET, repo, metrics, logger)
|
||||
case config.AVALANCHE_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEVMWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_TESTNET, repo, metrics, logger)
|
||||
watcher = builder.CreateAnkrEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.AVALANCHE_TESTNET, repo, metrics, logger)
|
||||
case config.SOLANA_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateSolanaWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.SOLANA_TESTNET, logger, repo, metrics)
|
||||
case config.APTOS_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateAptosWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.APTOS_TESTNET, logger, repo, metrics)
|
||||
case config.OASIS_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_TESTNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_TESTNET, logger, repo, metrics)
|
||||
case config.MOONBEAM_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_TESTNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_TESTNET, logger, repo, metrics)
|
||||
case config.CELO_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_TESTNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_TESTNET, logger, repo, metrics)
|
||||
case config.ARBITRUM_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateArbitrumWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ARBITRUM_TESTNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.ARBITRUM_TESTNET, logger, repo, metrics)
|
||||
case config.OPTIMISM_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateOptimismWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OPTIMISM_TESTNET, logger, repo, metrics)
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OPTIMISM_TESTNET, logger, repo, metrics)
|
||||
case config.BASE_TESTNET.ChainID.String():
|
||||
watcher = builder.CreateEvmWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.BASE_TESTNET, logger, repo, metrics)
|
||||
default:
|
||||
logger.Fatal("chain not supported")
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ type watchersConfig struct {
|
|||
celo *config.WatcherBlockchainAddresses
|
||||
arbitrum *config.WatcherBlockchainAddresses
|
||||
optimism *config.WatcherBlockchainAddresses
|
||||
base *config.WatcherBlockchainAddresses
|
||||
rateLimit rateLimitConfig
|
||||
}
|
||||
|
||||
|
@ -61,6 +62,7 @@ type rateLimitConfig struct {
|
|||
celo int
|
||||
optimism int
|
||||
arbitrum int
|
||||
base int
|
||||
}
|
||||
|
||||
func Run() {
|
||||
|
@ -182,34 +184,40 @@ func newWatchers(config *config.ServiceConfiguration, repo *storage.Repository,
|
|||
|
||||
// add oasis watcher
|
||||
if watchers.oasis != nil {
|
||||
oasisWatcher := builder.CreateOasisWatcher(watchers.rateLimit.oasis, config.OasisUrl, *watchers.oasis, logger, repo, metrics)
|
||||
oasisWatcher := builder.CreateEvmWatcher(watchers.rateLimit.oasis, config.OasisUrl, *watchers.oasis, logger, repo, metrics)
|
||||
result = append(result, oasisWatcher)
|
||||
}
|
||||
|
||||
// add moonbeam watcher
|
||||
if watchers.moonbeam != nil {
|
||||
moonbeamWatcher := builder.CreateMoonbeamWatcher(watchers.rateLimit.moonbeam, config.MoonbeamUrl, *watchers.moonbeam, logger, repo, metrics)
|
||||
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.CreateCeloWatcher(watchers.rateLimit.celo, config.CeloUrl, *watchers.celo, logger, repo, metrics)
|
||||
celoWatcher := builder.CreateEvmWatcher(watchers.rateLimit.celo, config.CeloUrl, *watchers.celo, logger, repo, metrics)
|
||||
result = append(result, celoWatcher)
|
||||
}
|
||||
|
||||
// add optimism watcher
|
||||
if watchers.optimism != nil {
|
||||
optimismWatcher := builder.CreateOptimismWatcher(watchers.rateLimit.optimism, config.OptimismUrl, *watchers.optimism, logger, repo, metrics)
|
||||
optimismWatcher := builder.CreateEvmWatcher(watchers.rateLimit.optimism, config.OptimismUrl, *watchers.optimism, logger, repo, metrics)
|
||||
result = append(result, optimismWatcher)
|
||||
}
|
||||
|
||||
// add arbitrum watcher
|
||||
if watchers.arbitrum != nil {
|
||||
arbitrumWatcher := builder.CreateOptimismWatcher(watchers.rateLimit.arbitrum, config.ArbitrumUrl, *watchers.arbitrum, logger, repo, metrics)
|
||||
arbitrumWatcher := builder.CreateEvmWatcher(watchers.rateLimit.arbitrum, config.ArbitrumUrl, *watchers.arbitrum, logger, repo, metrics)
|
||||
result = append(result, arbitrumWatcher)
|
||||
}
|
||||
|
||||
// add base watcher
|
||||
if watchers.base != nil {
|
||||
baseWatcher := builder.CreateEvmWatcher(watchers.rateLimit.base, config.BaseUrl, *watchers.base, logger, repo, metrics)
|
||||
result = append(result, baseWatcher)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -228,6 +236,7 @@ func newWatchersForMainnet(cfg *config.ServiceConfiguration) *watchersConfig {
|
|||
oasis: &config.OASIS_MAINNET,
|
||||
moonbeam: &config.MOONBEAM_MAINNET,
|
||||
celo: &config.CELO_MAINNET,
|
||||
base: &config.BASE_MAINNET,
|
||||
rateLimit: rateLimitConfig{
|
||||
ankr: cfg.AnkrRequestsPerSecond,
|
||||
solana: cfg.SolanaRequestsPerSecond,
|
||||
|
@ -238,6 +247,7 @@ func newWatchersForMainnet(cfg *config.ServiceConfiguration) *watchersConfig {
|
|||
celo: cfg.CeloRequestsPerSecond,
|
||||
arbitrum: cfg.ArbitrumRequestsPerSecond,
|
||||
optimism: cfg.OptimismRequestsPerSecond,
|
||||
base: cfg.BaseRequestsPerSecond,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +266,7 @@ func newWatchersForTestnet(cfg *config.ServiceConfiguration) *watchersConfig {
|
|||
oasis: &config.OASIS_TESTNET,
|
||||
moonbeam: &config.MOONBEAM_TESTNET,
|
||||
celo: &config.CELO_TESTNET,
|
||||
base: &config.BASE_TESTNET,
|
||||
rateLimit: rateLimitConfig{
|
||||
ankr: cfg.AnkrRequestsPerSecond,
|
||||
solana: cfg.SolanaRequestsPerSecond,
|
||||
|
@ -266,6 +277,7 @@ func newWatchersForTestnet(cfg *config.ServiceConfiguration) *watchersConfig {
|
|||
celo: cfg.CeloRequestsPerSecond,
|
||||
optimism: cfg.OptimismRequestsPerSecond,
|
||||
arbitrum: cfg.ArbitrumRequestsPerSecond,
|
||||
base: cfg.BaseRequestsPerSecond,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ type ServiceConfiguration struct {
|
|||
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"`
|
||||
MoonbeamUrl string `env:"MOONBEAM_URL,required"`
|
||||
|
|
|
@ -336,3 +336,35 @@ var OPTIMISM_MAINNET = WatcherBlockchainAddresses{
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
var BASE_MAINNET = WatcherBlockchainAddresses{
|
||||
ChainID: vaa.ChainIDBase,
|
||||
Name: "base",
|
||||
SizeBlocks: 100,
|
||||
WaitSeconds: 10,
|
||||
InitialBlock: 1_422_314,
|
||||
MethodsByAddress: map[string][]BlockchainMethod{
|
||||
strings.ToLower("0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627"): {
|
||||
{
|
||||
ID: MethodIDCompleteTransfer,
|
||||
Name: MethodCompleteTransfer,
|
||||
},
|
||||
{
|
||||
ID: MethodIDCompleteAndUnwrapETH,
|
||||
Name: MethodCompleteAndUnwrapETH,
|
||||
},
|
||||
{
|
||||
ID: MethodIDCreateWrapped,
|
||||
Name: MethodCreateWrapped,
|
||||
},
|
||||
{
|
||||
ID: MethodIDUpdateWrapped,
|
||||
Name: MethodUpdateWrapped,
|
||||
},
|
||||
{
|
||||
ID: MetehodIDCompleteTransferWithRelay,
|
||||
Name: MetehodCompleteTransferWithRelay,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -327,3 +327,35 @@ var OPTIMISM_TESTNET = WatcherBlockchainAddresses{
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
var BASE_TESTNET = WatcherBlockchainAddresses{
|
||||
ChainID: vaa.ChainIDBase,
|
||||
Name: "base_goerli",
|
||||
SizeBlocks: 100,
|
||||
WaitSeconds: 10,
|
||||
InitialBlock: 902_385,
|
||||
MethodsByAddress: map[string][]BlockchainMethod{
|
||||
strings.ToLower("0xA31aa3FDb7aF7Db93d18DDA4e19F811342EDF780"): {
|
||||
{
|
||||
ID: MethodIDCompleteTransfer,
|
||||
Name: MethodCompleteTransfer,
|
||||
},
|
||||
{
|
||||
ID: MethodIDCompleteAndUnwrapETH,
|
||||
Name: MethodCompleteAndUnwrapETH,
|
||||
},
|
||||
{
|
||||
ID: MethodIDCreateWrapped,
|
||||
Name: MethodCreateWrapped,
|
||||
},
|
||||
{
|
||||
ID: MethodIDUpdateWrapped,
|
||||
Name: MethodUpdateWrapped,
|
||||
},
|
||||
{
|
||||
ID: MetehodIDCompleteTransferWithRelay,
|
||||
Name: MetehodCompleteTransferWithRelay,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ const (
|
|||
evmRetryDelay = 5 * time.Second
|
||||
)
|
||||
|
||||
type EvmStandarWatcher struct {
|
||||
type EvmStandardWatcher struct {
|
||||
client *evm.EvmSDK
|
||||
chainID vaa.ChainID
|
||||
blockchain string
|
||||
|
@ -36,12 +36,12 @@ type EvmStandarWatcher struct {
|
|||
metrics metrics.Metrics
|
||||
}
|
||||
|
||||
func NewEvmStandarWatcher(client *evm.EvmSDK, params EVMParams, repo *storage.Repository, metrics metrics.Metrics, logger *zap.Logger) *EvmStandarWatcher {
|
||||
func NewEvmStandardWatcher(client *evm.EvmSDK, params EVMParams, repo *storage.Repository, metrics metrics.Metrics, logger *zap.Logger) *EvmStandardWatcher {
|
||||
addresses := make([]string, 0, len(params.MethodsByAddress))
|
||||
for address := range params.MethodsByAddress {
|
||||
addresses = append(addresses, address)
|
||||
}
|
||||
return &EvmStandarWatcher{
|
||||
return &EvmStandardWatcher{
|
||||
client: client,
|
||||
chainID: params.ChainID,
|
||||
blockchain: params.Blockchain,
|
||||
|
@ -56,7 +56,7 @@ func NewEvmStandarWatcher(client *evm.EvmSDK, params EVMParams, repo *storage.Re
|
|||
}
|
||||
}
|
||||
|
||||
func (w *EvmStandarWatcher) Start(ctx context.Context) error {
|
||||
func (w *EvmStandardWatcher) Start(ctx context.Context) error {
|
||||
// get the current block for the chain.
|
||||
cBlock, err := w.repository.GetCurrentBlock(ctx, w.blockchain, w.initialBlock)
|
||||
if err != nil {
|
||||
|
@ -110,7 +110,7 @@ func (w *EvmStandarWatcher) Start(ctx context.Context) error {
|
|||
|
||||
}
|
||||
|
||||
func (w *EvmStandarWatcher) Backfill(ctx context.Context, fromBlock uint64, toBlock uint64, pageSize uint64, persistBlock bool) {
|
||||
func (w *EvmStandardWatcher) Backfill(ctx context.Context, fromBlock uint64, toBlock uint64, pageSize uint64, persistBlock bool) {
|
||||
totalBlocks := getTotalBlocks(toBlock, fromBlock, pageSize)
|
||||
for i := uint64(0); i < totalBlocks; i++ {
|
||||
fromBlock, toBlock := getPage(fromBlock, i, pageSize, toBlock)
|
||||
|
@ -120,7 +120,7 @@ func (w *EvmStandarWatcher) Backfill(ctx context.Context, fromBlock uint64, toBl
|
|||
}
|
||||
}
|
||||
|
||||
func (w *EvmStandarWatcher) processBlock(ctx context.Context, fromBlock uint64, toBlock uint64, updateWatcherBlock bool) {
|
||||
func (w *EvmStandardWatcher) processBlock(ctx context.Context, fromBlock uint64, toBlock uint64, updateWatcherBlock bool) {
|
||||
for block := fromBlock; block <= toBlock; block++ {
|
||||
w.logger.Debug("processing block", zap.Uint64("block", block))
|
||||
retry.Do(
|
||||
|
@ -196,7 +196,7 @@ func (w *EvmStandarWatcher) processBlock(ctx context.Context, fromBlock uint64,
|
|||
}
|
||||
}
|
||||
|
||||
func (w *EvmStandarWatcher) Close() {
|
||||
func (w *EvmStandardWatcher) Close() {
|
||||
close(w.close)
|
||||
w.wg.Wait()
|
||||
}
|
||||
|
|
|
@ -123,6 +123,13 @@ spec:
|
|||
key: arbitrum-url
|
||||
- name: ARBITRUM_REQUESTS_PER_SECOND
|
||||
value: "{{ .ARBITRUM_REQUESTS_PER_SECOND }}"
|
||||
- name: BASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blockchain
|
||||
key: base-url
|
||||
- name: BASE_REQUESTS_PER_SECOND
|
||||
value: "{{ .BASE_REQUESTS_PER_SECOND }}"
|
||||
- name: ALERT_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
@ -27,4 +27,6 @@ ARBITRUM_URL=
|
|||
ARBITRUM_REQUESTS_PER_SECOND=3
|
||||
OPTIMISM_URL=
|
||||
OPTIMISM_REQUESTS_PER_SECOND=3
|
||||
BASE_URL=
|
||||
BASE_REQUESTS_PER_SECOND=3
|
||||
ALERT_ENABLED=true
|
|
@ -27,4 +27,6 @@ ARBITRUM_URL=
|
|||
ARBITRUM_REQUESTS_PER_SECOND=1
|
||||
OPTIMISM_URL=
|
||||
OPTIMISM_REQUESTS_PER_SECOND=1
|
||||
BASE_URL=
|
||||
BASE_REQUESTS_PER_SECOND=1
|
||||
ALERT_ENABLED=false
|
|
@ -27,4 +27,6 @@ ARBITRUM_URL=
|
|||
ARBITRUM_REQUESTS_PER_SECOND=3
|
||||
OPTIMISM_URL=
|
||||
OPTIMISM_REQUESTS_PER_SECOND=3
|
||||
BASE_URL=
|
||||
BASE_REQUESTS_PER_SECOND=3
|
||||
ALERT_ENABLED=false
|
|
@ -27,4 +27,6 @@ ARBITRUM_URL=
|
|||
ARBITRUM_REQUESTS_PER_SECOND=1
|
||||
OPTIMISM_URL=
|
||||
OPTIMISM_REQUESTS_PER_SECOND=1
|
||||
BASE_URL=
|
||||
BASE_REQUESTS_PER_SECOND=1
|
||||
ALERT_ENABLED=false
|
Loading…
Reference in New Issue