From a10ae257e0ef617bede0b0fe1f748b1ec710b952 Mon Sep 17 00:00:00 2001 From: Karl Bartel Date: Tue, 11 Jul 2023 15:28:10 +0200 Subject: [PATCH] Improve error logging in toCeloFn This might help us debug https://github.com/celo-org/celo-blockchain/issues/2134 if it happens again. --- contracts/currency/currency.go | 5 +++-- miner/block.go | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contracts/currency/currency.go b/contracts/currency/currency.go index c88476a6d7..b27177caca 100644 --- a/contracts/currency/currency.go +++ b/contracts/currency/currency.go @@ -17,6 +17,7 @@ package currency import ( + "fmt" "math/big" "github.com/celo-org/celo-blockchain/common" @@ -113,10 +114,10 @@ type ExchangeRate struct { // Requires numerator >=0 && denominator >= 0 func NewExchangeRate(numerator *big.Int, denominator *big.Int) (*ExchangeRate, error) { if numerator == nil || common.Big0.Cmp(numerator) >= 0 { - return nil, contracts.ErrExchangeRateZero + return nil, fmt.Errorf("numerator zero: %w", contracts.ErrExchangeRateZero) } if denominator == nil || common.Big0.Cmp(denominator) >= 0 { - return nil, contracts.ErrExchangeRateZero + return nil, fmt.Errorf("denominator zero: %w", contracts.ErrExchangeRateZero) } return &ExchangeRate{numerator, denominator}, nil } diff --git a/miner/block.go b/miner/block.go index 1e7e96228a..2d60260e10 100644 --- a/miner/block.go +++ b/miner/block.go @@ -387,7 +387,10 @@ func createConversionFunctions(sysCtx *core.SysContractCallCtx, chain *core.Bloc return sysCtx.GetGasPriceMinimum(feeCurrency) } toCeloFn := func(amount *big.Int, feeCurrency *common.Address) *big.Int { - curr, _ := currencyManager.GetCurrency(feeCurrency) + curr, err := currencyManager.GetCurrency(feeCurrency) + if err != nil { + log.Error("toCeloFn: could not get currency", "err", err) + } return curr.ToCELO(amount) }