From 410be5321af4e10f0e942cb57abeb805d6abe7e2 Mon Sep 17 00:00:00 2001 From: Maximilian Langenfeld <15726643+ezdac@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:26:26 +0200 Subject: [PATCH] Add minor code improvements Co-authored-by: Paul Lange --- common/celo_types.go | 1 + contracts/fee_currencies.go | 4 ++-- core/bench_test.go | 3 +-- tests/transaction_test_util.go | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common/celo_types.go b/common/celo_types.go index 442d333438..44c59e857d 100644 --- a/common/celo_types.go +++ b/common/celo_types.go @@ -25,6 +25,7 @@ func MaxAllowedIntrinsicGasCost(i IntrinsicGasCosts, feeCurrency *Address) (uint // during execution return intrinsicGas * 3, true } + func CurrencyIntrinsicGasCost(i IntrinsicGasCosts, feeCurrency *Address) (uint64, bool) { if feeCurrency == nil { return 0, true diff --git a/contracts/fee_currencies.go b/contracts/fee_currencies.go index 66a04f589d..a92bd99d24 100644 --- a/contracts/fee_currencies.go +++ b/contracts/fee_currencies.go @@ -141,7 +141,7 @@ func GetRegisteredCurrencies(caller *abigen.FeeCurrencyDirectoryCaller) ([]commo return currencies, nil } -// GetExchangeRates returns the exchange rates for the provided gas currencies from CELO +// GetExchangeRates returns the exchange rates for the provided gas currencies func GetExchangeRates(caller bind.ContractCaller) (common.ExchangeRates, error) { exchangeRates := map[common.Address]*big.Rat{} directory, err := abigen.NewFeeCurrencyDirectoryCaller(addresses.FeeCurrencyDirectoryAddress, caller) @@ -150,7 +150,7 @@ func GetExchangeRates(caller bind.ContractCaller) (common.ExchangeRates, error) } currencies, err := GetRegisteredCurrencies(directory) if err != nil { - return map[common.Address]*big.Rat{}, err + return common.ExchangeRates{}, err } return getExchangeRatesForTokens(directory, currencies) } diff --git a/core/bench_test.go b/core/bench_test.go index 55a1a9104f..233287f7c8 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -83,8 +83,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - var feeIntrinsic common.IntrinsicGasCosts - gas, _ := IntrinsicGas(data, nil, false, false, false, false, nil, feeIntrinsic) + gas, _ := IntrinsicGas(data, nil, false, false, false, false, nil, common.IntrinsicGasCosts{}) signer := gen.Signer() gasPrice := big.NewInt(0) if gen.header.BaseFee != nil { diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index 22c60f7c57..956be1fc25 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -55,8 +55,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { return nil, nil, err } // Intrinsic gas - var feeIntrinsic common.IntrinsicGasCosts - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, false, nil, feeIntrinsic) + requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, false, nil, common.IntrinsicGasCosts{}) if err != nil { return nil, nil, err }