Skip to content

Commit b1bba65

Browse files
authored
Improve error logging in toCeloFn (#2157)
This might help us debug #2134 if it happens again.
1 parent 4860e01 commit b1bba65

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

contracts/currency/currency.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package currency
1818

1919
import (
20+
"fmt"
2021
"math/big"
2122

2223
"github.com/celo-org/celo-blockchain/common"
@@ -113,10 +114,10 @@ type ExchangeRate struct {
113114
// Requires numerator >=0 && denominator >= 0
114115
func NewExchangeRate(numerator *big.Int, denominator *big.Int) (*ExchangeRate, error) {
115116
if numerator == nil || common.Big0.Cmp(numerator) >= 0 {
116-
return nil, contracts.ErrExchangeRateZero
117+
return nil, fmt.Errorf("numerator zero: %w", contracts.ErrExchangeRateZero)
117118
}
118119
if denominator == nil || common.Big0.Cmp(denominator) >= 0 {
119-
return nil, contracts.ErrExchangeRateZero
120+
return nil, fmt.Errorf("denominator zero: %w", contracts.ErrExchangeRateZero)
120121
}
121122
return &ExchangeRate{numerator, denominator}, nil
122123
}

miner/block.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ func createConversionFunctions(sysCtx *core.SysContractCallCtx, chain *core.Bloc
387387
return sysCtx.GetGasPriceMinimum(feeCurrency)
388388
}
389389
toCeloFn := func(amount *big.Int, feeCurrency *common.Address) *big.Int {
390-
curr, _ := currencyManager.GetCurrency(feeCurrency)
390+
curr, err := currencyManager.GetCurrency(feeCurrency)
391+
if err != nil {
392+
log.Error("toCeloFn: could not get currency", "err", err)
393+
}
391394
return curr.ToCELO(amount)
392395
}
393396

0 commit comments

Comments
 (0)