From e4239d924330e781448399a89a360e966dcb1df4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:35:41 -0500 Subject: [PATCH 1/3] chore(deps): Bump google.golang.org/grpc from 1.60.1 to 1.61.0 (#3039) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.1 to 1.61.0.
Release notes

Sourced from google.golang.org/grpc's releases.

Release 1.61.0

New Features

Performance Improvements

Bug Fixes

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/grpc&package-manager=go_modules&previous-version=1.60.1&new-version=1.61.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b47c03474e..597c98bdbf 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/tendermint/tm-db v0.6.7 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f - google.golang.org/grpc v1.60.1 + google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.32.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -205,7 +205,7 @@ require ( golang.org/x/crypto v0.17.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.13.0 // indirect + golang.org/x/oauth2 v0.14.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect diff --git a/go.sum b/go.sum index 880c503cf7..bf3c3dcf56 100644 --- a/go.sum +++ b/go.sum @@ -1525,8 +1525,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1985,8 +1985,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= +google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= From b1592c314d4dca77c477e62ee1890970c6ee6e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nina=20/=20=E1=83=9C=E1=83=98=E1=83=9C=E1=83=90?= Date: Wed, 24 Jan 2024 22:35:51 +0100 Subject: [PATCH 2/3] chore: move v2 consts to v2 directory (#3040) ## Overview moving GlobalMinGasPrice constant under v2 Fixes - #3035 --------- Co-authored-by: Rootul P --- app/ante/fee_checker.go | 12 +++++++++--- app/ante/min_fee_test.go | 11 +++++++---- go.work.sum | 6 ++++++ pkg/appconsts/initial_consts.go | 4 ---- pkg/appconsts/v2/app_consts.go | 7 ++++--- pkg/appconsts/versioned_consts.go | 13 +++++++++++++ 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/ante/fee_checker.go b/app/ante/fee_checker.go index 372e44b8ff..f38fdaf123 100644 --- a/app/ante/fee_checker.go +++ b/app/ante/fee_checker.go @@ -25,17 +25,23 @@ func CheckTxFeeWithGlobalMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, in fee := feeTx.GetFee().AmountOf(appconsts.BondDenom) gas := feeTx.GetGas() + appVersion := ctx.BlockHeader().Version.App // global minimum fee only applies to app versions greater than one - if ctx.BlockHeader().Version.App > v1.Version { + if appVersion > v1.Version { + globalMinGasPrice, err := appconsts.GlobalMinGasPrice(appVersion) + if err != nil { + return nil, 0, errors.Wrapf(err, "failed to get GlobalMinGasPrice for app version %d", appVersion) + } + // convert the global minimum gas price to a big.Int - globalMinGasPrice, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.GlobalMinGasPrice)) + globalMinGasPriceInt, err := sdk.NewDecFromStr(fmt.Sprintf("%f", globalMinGasPrice)) if err != nil { return nil, 0, errors.Wrap(err, "invalid GlobalMinGasPrice") } gasInt := sdk.NewIntFromUint64(gas) - minFee := globalMinGasPrice.MulInt(gasInt).RoundInt() + minFee := globalMinGasPriceInt.MulInt(gasInt).RoundInt() if !fee.GTE(minFee) { return nil, 0, errors.Wrapf(sdkerror.ErrInsufficientFee, "insufficient fees; got: %s required: %s", fee, minFee) diff --git a/app/ante/min_fee_test.go b/app/ante/min_fee_test.go index 303f23ec74..91d06946b7 100644 --- a/app/ante/min_fee_test.go +++ b/app/ante/min_fee_test.go @@ -31,6 +31,9 @@ func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) { ctx := sdk.Context{} + globalMinGasPrice, err := appconsts.GlobalMinGasPrice(appconsts.LatestVersion) + require.NoError(t, err) + testCases := []struct { name string fee sdk.Coins @@ -41,28 +44,28 @@ func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) { { name: "bad tx; fee below required minimum", fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount-1)), - gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice), + gasLimit: uint64(float64(feeAmount) / globalMinGasPrice), appVersion: uint64(2), expErr: true, }, { name: "good tx; fee equal to required minimum", fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)), - gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice), + gasLimit: uint64(float64(feeAmount) / globalMinGasPrice), appVersion: uint64(2), expErr: false, }, { name: "good tx; fee above required minimum", fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount+1)), - gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice), + gasLimit: uint64(float64(feeAmount) / globalMinGasPrice), appVersion: uint64(2), expErr: false, }, { name: "good tx; with no fee (v1)", fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)), - gasLimit: uint64(float64(feeAmount) / appconsts.GlobalMinGasPrice), + gasLimit: uint64(float64(feeAmount) / globalMinGasPrice), appVersion: uint64(1), expErr: false, }, diff --git a/go.work.sum b/go.work.sum index d9a0fc0928..3715ae962a 100644 --- a/go.work.sum +++ b/go.work.sum @@ -634,10 +634,12 @@ github.com/daixiang0/gci v0.10.1/go.mod h1:xtHP9N7AHdNvtRNfcx9gwTDfw7FRJx4bZUsiE github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 h1:qwcF+vdFrvPSEUDSX5RVoRccG8a5DhOdWdQ4zN62zzo= github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= @@ -650,6 +652,7 @@ github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHj github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= @@ -672,6 +675,7 @@ github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU= @@ -761,6 +765,7 @@ github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0t github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/junk1tm/musttag v0.5.0/go.mod h1:PcR7BA+oREQYvHwgjIDmw3exJeds5JzRcvEJTfjrA0M= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= +github.com/karalabe/usb v0.0.2 h1:M6QQBNxF+CQ8OFvxrT90BA0qBOXymndZnk5q235mFc4= github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= @@ -829,6 +834,7 @@ github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= +github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= diff --git a/pkg/appconsts/initial_consts.go b/pkg/appconsts/initial_consts.go index c8a47aa546..c74cc2ebaf 100644 --- a/pkg/appconsts/initial_consts.go +++ b/pkg/appconsts/initial_consts.go @@ -22,10 +22,6 @@ const ( // a nodes `CheckTx` and thus not be proposed by that node. DefaultMinGasPrice = 0.002 - // GlobalMinGasPrice is used in the processProposal to ensure - // that all transactions have a gas price greater than or equal to this value. - GlobalMinGasPrice = DefaultMinGasPrice - // DefaultUnbondingTime is the default time a validator must wait // to unbond in a proof of stake system. Any validator within this // time can be subject to slashing under conditions of misbehavior. diff --git a/pkg/appconsts/v2/app_consts.go b/pkg/appconsts/v2/app_consts.go index d5829e84c5..3760acf696 100644 --- a/pkg/appconsts/v2/app_consts.go +++ b/pkg/appconsts/v2/app_consts.go @@ -1,7 +1,8 @@ package v2 const ( - Version uint64 = 2 - SquareSizeUpperBound int = 128 - SubtreeRootThreshold int = 64 + Version uint64 = 2 + SquareSizeUpperBound int = 128 + SubtreeRootThreshold int = 64 + GlobalMinGasPrice float64 = 0.002 // same as DefaultMinGasPrice ) diff --git a/pkg/appconsts/versioned_consts.go b/pkg/appconsts/versioned_consts.go index f64b43e8c0..2067e775c9 100644 --- a/pkg/appconsts/versioned_consts.go +++ b/pkg/appconsts/versioned_consts.go @@ -1,6 +1,8 @@ package appconsts import ( + "fmt" + "github.com/celestiaorg/celestia-app/pkg/appconsts/testground" v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1" v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2" @@ -22,6 +24,17 @@ func SubtreeRootThreshold(_ uint64) int { return v1.SubtreeRootThreshold } +// GlobalMinGasPrice is used in the processProposal to ensure +// that all transactions have a gas price greater than or equal to this value. +func GlobalMinGasPrice(version uint64) (float64, error) { + switch version { + case v2.Version: + return v2.GlobalMinGasPrice, nil + default: + return 0, fmt.Errorf("global min gas price not defined for version %d", version) + } +} + // SquareSizeUpperBound is the maximum original square width possible // for a version of the state machine. The maximum is decided through // governance. See `DefaultGovMaxSquareSize`. From 5b8f71b0cb20cbe2b7547f879156739e8d0c3af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nina=20/=20=E1=83=9C=E1=83=98=E1=83=9C=E1=83=90?= Date: Thu, 25 Jan 2024 01:15:16 +0100 Subject: [PATCH 3/3] test: add unit test for global min gas price getter (#3041) --- go.work.sum | 2 + pkg/appconsts/versioned_consts_test.go | 88 ++++++++++++++++++++------ 2 files changed, 71 insertions(+), 19 deletions(-) diff --git a/go.work.sum b/go.work.sum index 3715ae962a..0f1f87f9f1 100644 --- a/go.work.sum +++ b/go.work.sum @@ -619,6 +619,7 @@ github.com/cloudflare/circl v1.3.1/go.mod h1:+CauBF6R70Jqcyl8N2hC8pAXYbWkGIezuSb github.com/cloudflare/cloudflare-go v0.79.0/go.mod h1:gkHQf9xEubaQPEuerBuoinR9P8bf8a05Lq0X6WKy1Oc= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM= @@ -982,6 +983,7 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go. google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U= google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870= +google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= google.golang.org/genproto/googleapis/bytestream v0.0.0-20231030173426-d783a09b4405/go.mod h1:GRUCuLdzVqZte8+Dl/D4N25yLzcGqqWaYkeVOwulFqw= google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index 811660d45c..46dda05c09 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/pkg/appconsts/testground" @@ -13,39 +13,89 @@ import ( ) func TestSubtreeRootThreshold(t *testing.T) { - type testCase struct { - version uint64 - want int - } - testCases := []testCase{ - {version: v1.Version, want: v1.SubtreeRootThreshold}, - {version: v2.Version, want: v2.SubtreeRootThreshold}, - {version: testground.Version, want: testground.SubtreeRootThreshold}, + testCases := []struct { + version uint64 + expected int + }{ + { + version: v1.Version, + expected: v1.SubtreeRootThreshold, + }, + { + version: v2.Version, + expected: v2.SubtreeRootThreshold, + }, + { + version: testground.Version, + expected: testground.SubtreeRootThreshold, + }, } + for _, tc := range testCases { name := fmt.Sprintf("version %v", tc.version) t.Run(name, func(t *testing.T) { got := appconsts.SubtreeRootThreshold(tc.version) - assert.Equal(t, tc.want, got) + require.Equal(t, tc.expected, got) }) } } -func TestSquareSizeUpperBound(t *testing.T) { - type testCase struct { - version uint64 - want int +func TestGlobalMinGasPrice(t *testing.T) { + testCases := []struct { + version uint64 + expected float64 + expErr bool + }{ + { + version: v2.Version, + expected: v2.GlobalMinGasPrice, + expErr: false, + }, + { + version: v1.Version, + expected: 0, + expErr: true, + }, } - testCases := []testCase{ - {version: v1.Version, want: v1.SquareSizeUpperBound}, - {version: v2.Version, want: v2.SquareSizeUpperBound}, - {version: testground.Version, want: testground.SquareSizeUpperBound}, + + for _, tc := range testCases { + name := fmt.Sprintf("version %v", tc.version) + t.Run(name, func(t *testing.T) { + got, err := appconsts.GlobalMinGasPrice(tc.version) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, got) + } + }) + } +} + +func TestSquareSizeUpperBound(t *testing.T) { + testCases := []struct { + version uint64 + expected int + }{ + { + version: v1.Version, + expected: v1.SquareSizeUpperBound, + }, + { + version: v2.Version, + expected: v2.SquareSizeUpperBound, + }, + { + version: testground.Version, + expected: testground.SquareSizeUpperBound, + }, } + for _, tc := range testCases { name := fmt.Sprintf("version %v", tc.version) t.Run(name, func(t *testing.T) { got := appconsts.SquareSizeUpperBound(tc.version) - assert.Equal(t, tc.want, got) + require.Equal(t, tc.expected, got) }) } }