Add celo to contract-watcher(token bridge, wormhole connect contracts) (#393)

This commit is contained in:
walker-16 2023-06-09 17:57:22 -03:00 committed by GitHub
parent 8679d9c211
commit 100e473c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 106 additions and 3 deletions

View File

@ -82,3 +82,16 @@ func CreateMoonbeamWatcher(rateLimit int, chainURL string, wb config.WatcherBloc
MethodsByAddress: wb.MethodsByAddress}
return watcher.NewEvmStandarWatcher(moonbeamClient, params, repo, logger)
}
func CreateCeloWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository) watcher.ContractWatcher {
celoLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second))
celoClient := evm.NewEvmSDK(chainURL, celoLimiter)
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, logger)
}

View File

@ -80,6 +80,8 @@ func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_MAINNET, logger, repo)
case config.MOONBEAM_MAINNET.ChainID.String():
watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_MAINNET, logger, repo)
case config.CELO_MAINNET.ChainID.String():
watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_MAINNET, logger, repo)
default:
logger.Fatal("chain not supported")
}
@ -107,6 +109,8 @@ func newWatcherForTestnet(cfg *config.BackfillerConfiguration, repo *storage.Rep
watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_TESTNET, logger, repo)
case config.MOONBEAM_TESTNET.ChainID.String():
watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_TESTNET, logger, repo)
case config.CELO_TESTNET.ChainID.String():
watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_TESTNET, logger, repo)
default:
logger.Fatal("chain not supported")
}

View File

@ -42,6 +42,7 @@ type watchersConfig struct {
aptos *config.WatcherBlockchain
oasis *config.WatcherBlockchainAddresses
moonbeam *config.WatcherBlockchainAddresses
celo *config.WatcherBlockchainAddresses
rateLimit rateLimitConfig
}
@ -52,6 +53,7 @@ type rateLimitConfig struct {
aptos int
oasis int
moonbeam int
celo int
}
func Run() {
@ -174,6 +176,10 @@ func newWatchers(config *config.ServiceConfiguration, repo *storage.Repository,
result = append(result, moonbeamWatcher)
}
if watchers.celo != nil {
celoWatcher := builder.CreateCeloWatcher(watchers.rateLimit.evm, config.CeloUrl, *watchers.celo, logger, repo)
result = append(result, celoWatcher)
}
return result
}
@ -191,6 +197,7 @@ func newWatchersForMainnet() *watchersConfig {
aptos: &config.APTOS_MAINNET,
oasis: &config.OASIS_MAINNET,
moonbeam: &config.MOONBEAM_MAINNET,
celo: &config.CELO_MAINNET,
rateLimit: rateLimitConfig{
evm: 1000,
solana: 3,
@ -215,6 +222,7 @@ func newWatchersForTestnet() *watchersConfig {
aptos: &config.APTOS_TESTNET,
oasis: &config.OASIS_TESTNET,
moonbeam: &config.MOONBEAM_TESTNET,
celo: &config.CELO_TESTNET,
rateLimit: rateLimitConfig{
evm: 10,
solana: 2,

View File

@ -20,6 +20,7 @@ type ServiceConfiguration struct {
AptosUrl string `env:"APTOS_URL,required"`
OasisUrl string `env:"OASIS_URL,required"`
MoonbeamUrl string `env:"MOONBEAM_URL,required"`
CeloUrl string `env:"CELO_URL,required"`
PprofEnabled bool `env:"PPROF_ENABLED,default=false"`
P2pNetwork string `env:"P2P_NETWORK,required"`
}

View File

@ -264,3 +264,37 @@ var MOONBEAM_MAINNET = WatcherBlockchainAddresses{
},
},
}
var CELO_MAINNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDCelo,
Name: "celo",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 12947239,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x796Dff6D74F3E27060B71255Fe517BFb23C93eed"): {
{
ID: MethodIDCompleteTransfer,
Name: MethodCompleteTransfer,
},
{
ID: MethodIDCompleteAndUnwrapETH,
Name: MethodCompleteAndUnwrapETH,
},
{
ID: MethodIDCreateWrapped,
Name: MethodCreateWrapped,
},
{
ID: MethodIDUpdateWrapped,
Name: MethodUpdateWrapped,
},
},
strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}

View File

@ -255,3 +255,37 @@ var MOONBEAM_TESTNET = WatcherBlockchainAddresses{
},
},
}
var CELO_TESTNET = WatcherBlockchainAddresses{
ChainID: vaa.ChainIDCelo,
Name: "celo",
SizeBlocks: 50,
WaitSeconds: 10,
InitialBlock: 10625129,
MethodsByAddress: map[string][]BlockchainMethod{
strings.ToLower("0x05ca6037eC51F8b712eD2E6Fa72219FEaE74E153"): {
{
ID: MethodIDCompleteTransfer,
Name: MethodCompleteTransfer,
},
{
ID: MethodIDCompleteAndUnwrapETH,
Name: MethodCompleteAndUnwrapETH,
},
{
ID: MethodIDCreateWrapped,
Name: MethodCreateWrapped,
},
{
ID: MethodIDUpdateWrapped,
Name: MethodUpdateWrapped,
},
},
strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): {
{
ID: MetehodIDCompleteTransferWithRelay,
Name: MetehodCompleteTransferWithRelay,
},
},
},
}

View File

@ -87,6 +87,11 @@ spec:
secretKeyRef:
name: blockchain
key: moonbeam-url
- name: CELO_URL
valueFrom:
secretKeyRef:
name: blockchain
key: celo-url
resources:
limits:
memory: {{ .RESOURCES_LIMITS_MEMORY }}

View File

@ -14,4 +14,5 @@ SOLANA_URL=
TERRA_URL=
APTOS_URL=
OASIS_URL=
MOONBEAM_URL=
MOONBEAM_URL=
CELO_URL=

View File

@ -14,4 +14,5 @@ SOLANA_URL=
TERRA_URL=
APTOS_URL=
OASIS_URL=
MOONBEAM_URL=
MOONBEAM_URL=
CELO_URL=

View File

@ -14,4 +14,5 @@ SOLANA_URL=
TERRA_URL=
APTOS_URL=
OASIS_URL=
MOONBEAM_URL=
MOONBEAM_URL=
CELO_URL=

View File

@ -11,4 +11,5 @@ data:
aptos-url: {{ .APTOS_URL | b64enc }}
oasis-url: {{ .OASIS_URL | b64enc }}
moonbeam-url: {{ .MOONBEAM_URL | b64enc }}
celo-url: {{ .CELO_URL | b64enc }}
type: Opaque