diff --git a/core/chains/legacyevm/chain.go b/core/chains/legacyevm/chain.go index 245c8971110..835e749bb8e 100644 --- a/core/chains/legacyevm/chain.go +++ b/core/chains/legacyevm/chain.go @@ -271,8 +271,6 @@ func newChain(cfg *config.ChainScoped, nodes []*toml.Node, opts ChainRelayOpts, //nolint:gocritic // ignoring suggestion to convert to switch statement if !opts.ChainConfigs.RPCEnabled() { txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)} - } else if cfg.EVM().ChainType() == chaintype.ChainTron { - txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("EVM TXM disabled for tron based chains %d, using Tron TXM instead", chainID)} } else if !cfg.EVM().Transactions().Enabled() { txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("TXM disabled for chain %d", chainID)} } else { @@ -356,7 +354,6 @@ func (c *chain) Start(ctx context.Context) error { } if c.cfg.EVM().ChainType() == chaintype.ChainTron { - c.gasEstimator.Start(ctx) // Still need gas estimator to be working for the OCR2 plugin c.tronTxm.Start(ctx) } @@ -389,7 +386,6 @@ func (c *chain) Close() error { // Tron doesn't use the EVM TXM but still uses the gas estimator, we'll close it here if c.cfg.EVM().ChainType() == chaintype.ChainTron { - merr = multierr.Combine(merr, c.gasEstimator.Close()) merr = multierr.Combine(merr, c.tronTxm.Close()) } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go index d7e0d1a73e5..58b71022888 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go @@ -298,6 +298,7 @@ func (p *PriceRegistry) GetTokensDecimals(ctx context.Context, tokenAddresses [] return rpclib.ParseOutput[uint8](d, 0) }) if err != nil { + p.lggr.Error("failed to parse decimals outputs", "error", err, "batchCalls", evmCalls, "results", results) return nil, fmt.Errorf("parse outputs: %w", err) } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdb/price_service.go b/core/services/ocr2/plugins/ccip/internal/ccipdb/price_service.go index 03c81e0f404..8877ffd696e 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdb/price_service.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdb/price_service.go @@ -133,17 +133,23 @@ func (p *priceService) run() { defer gasUpdateTicker.Stop() defer tokenUpdateTicker.Stop() + p.lggr.Info("Starting PriceService background updates", "gasUpdateInterval", p.gasUpdateInterval, "tokenUpdateInterval", p.tokenUpdateInterval) + for { select { case <-ctx.Done(): return case <-gasUpdateTicker.C: + p.lggr.Info("Updating gas prices in the background") err := p.runGasPriceUpdate(ctx) + p.lggr.Info("Gas prices updated in the background") if err != nil { p.lggr.Errorw("Error when updating gas prices in the background", "err", err) } case <-tokenUpdateTicker.C: + p.lggr.Info("Updating token prices in the background") err := p.runTokenPriceUpdate(ctx) + p.lggr.Info("Token prices updated in the background") if err != nil { p.lggr.Errorw("Error when updating token prices in the background", "err", err) } @@ -160,6 +166,7 @@ func (p *priceService) UpdateDynamicConfig(ctx context.Context, gasPriceEstimato // Config update may substantially change the prices, refresh the prices immediately, this also makes testing easier // for not having to wait to the full update interval. + p.lggr.Info("Updating gas prices after dynamic config update") if err := p.runGasPriceUpdate(ctx); err != nil { p.lggr.Errorw("Error when updating gas prices after dynamic config update", "err", err) } @@ -224,22 +231,27 @@ func (p *priceService) runGasPriceUpdate(ctx context.Context) error { p.dynamicConfigMu.RLock() defer p.dynamicConfigMu.RUnlock() + p.lggr.Info("Running gas price update") + // There may be a period of time between service is started and dynamic config is updated if p.gasPriceEstimator == nil { p.lggr.Info("Skipping gas price update due to gasPriceEstimator not ready") return nil } + p.lggr.Info("Observing gas price updates") sourceGasPriceUSD, err := p.observeGasPriceUpdates(ctx, p.lggr) if err != nil { return fmt.Errorf("failed to observe gas price updates: %w", err) } + p.lggr.Info("Writing gas prices to db") err = p.writeGasPricesToDB(ctx, sourceGasPriceUSD) if err != nil { return fmt.Errorf("failed to write gas prices to db: %w", err) } + p.lggr.Info("Gas prices written to db") return nil } @@ -249,22 +261,28 @@ func (p *priceService) runTokenPriceUpdate(ctx context.Context) error { p.dynamicConfigMu.RLock() defer p.dynamicConfigMu.RUnlock() + p.lggr.Info("Running token price update") + // There may be a period of time between service is started and dynamic config is updated if p.destPriceRegistryReader == nil { p.lggr.Info("Skipping token price update due to destPriceRegistry not ready") return nil } + p.lggr.Info("Observing token price updates") tokenPricesUSD, err := p.observeTokenPriceUpdates(ctx, p.lggr) if err != nil { return fmt.Errorf("failed to observe token price updates: %w", err) } + p.lggr.Info("Writing token prices to db") err = p.writeTokenPricesToDB(ctx, tokenPricesUSD) if err != nil { return fmt.Errorf("failed to write token prices to db: %w", err) } + p.lggr.Info("Token prices written to db") + return nil } @@ -281,6 +299,7 @@ func (p *priceService) observeGasPriceUpdates( ChainSelector: p.sourceChainSelector, } + lggr.Infow("Observing gas price updates", "sourceNativeTokenID", sourceNativeTokenID) // Include wrapped native to identify the source native USD price, notice USD is in 1e18 scale, i.e. $1 = 1e18 rawTokenPricesUSD, err := p.priceGetter.GetTokenPricesUSD(ctx, []ccipcommon.TokenID{sourceNativeTokenID}) if err != nil { @@ -292,6 +311,7 @@ func (p *priceService) observeGasPriceUpdates( return nil, fmt.Errorf("missing source native (%v) price", sourceNativeTokenID) } + lggr.Infow("Fetching gas price", "sourceNativePriceUSD", sourceNativePriceUSD) sourceGasPrice, err := p.gasPriceEstimator.GetGasPrice(ctx) if err != nil { return nil, err @@ -299,6 +319,8 @@ func (p *priceService) observeGasPriceUpdates( if sourceGasPrice == nil { return nil, errors.New("missing gas price") } + + lggr.Infow("Denoting gas price in USD", "sourceGasPrice", sourceGasPrice, "sourceNativePriceUSD", sourceNativePriceUSD) sourceGasPriceUSD, err = p.gasPriceEstimator.DenoteInUSD(ctx, sourceGasPrice, sourceNativePriceUSD) if err != nil { return nil, err @@ -330,16 +352,19 @@ func (p *priceService) observeTokenPriceUpdates( if err != nil { return nil, fmt.Errorf("failed to fetch token prices: %w", err) } + lggr.Infow("Fetched token prices", "rawTokenPricesUSD", rawTokenPricesUSD) missingDestNativePrice, err := p.findMissingDestNativeTokenPrice(ctx, rawTokenPricesUSD) if err != nil { return nil, fmt.Errorf("find missing dest native token price: %w", err) } + lggr.Infow("Found missing dest native token price", "missingDestNativePrice", missingDestNativePrice) if missingDestNativePrice != nil { destNativeTokenID := ccipcommon.TokenID{TokenAddress: p.sourceNative, ChainSelector: p.destChainSelector} rawTokenPricesUSD[destNativeTokenID] = missingDestNativePrice } + lggr.Infow("Verifying no price returned by price getter is nil") // Verify no price returned by price getter is nil for tokenID, price := range rawTokenPricesUSD { if price == nil { @@ -358,16 +383,23 @@ func (p *priceService) observeTokenPriceUpdates( destTokens = append(destTokens, tokenID.TokenAddress) } } + + lggr.Infow("Sorting destination tokens", "destTokens", destTokens) sort.Slice(destTokens, func(i, j int) bool { return destTokens[i] < destTokens[j] }) + lggr.Infow("Sorted destination tokens", "destTokens", destTokens) + + lggr.Infow("Getting tokens decimals") destTokensDecimals, err := p.destPriceRegistryReader.GetTokensDecimals(ctx, destTokens) if err != nil { return nil, fmt.Errorf("get tokens decimals: %w", err) } + lggr.Infow("Got tokens decimals", "destTokensDecimals", destTokensDecimals) if len(destTokensDecimals) != len(destTokens) { return nil, errors.New("mismatched token decimals and tokens") } + lggr.Infow("Calculating token prices per 1e18") tokenPricesUSDPer1e18 := make(map[cciptypes.Address]*big.Int, len(rawTokenPricesUSD)) for i, token := range destTokens { tokenID := ccipcommon.TokenID{TokenAddress: token, ChainSelector: p.destChainSelector} @@ -377,7 +409,7 @@ func (p *priceService) observeTokenPriceUpdates( } tokenPricesUSDPer1e18[token] = calculateUsdPer1e18TokenAmount(tokenPriceUSD, destTokensDecimals[i]) } - + lggr.Infow("Calculated token prices per 1e18", "tokenPricesUSDPer1e18", tokenPricesUSDPer1e18) lggr.Infow("PriceService observed latest token prices", "sourceChainSelector", p.sourceChainSelector, "destChainSelector", p.destChainSelector,