Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error logging in toCeloFn #2157

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contracts/currency/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package currency

import (
"fmt"
"math/big"

"github.com/celo-org/celo-blockchain/common"
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion miner/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Comment on lines -390 to +393
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should help a lot, since we just discarded all the useful error information before.

return curr.ToCELO(amount)
}

Expand Down