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

v0.45.x #176

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7ef483e
fix: types/errors Wrap and Wrapf (backport #10674) (#10676)
mergify[bot] Dec 6, 2021
d404619
fix: Charge gas even when there are no entries in gaskv (backport #10…
mergify[bot] Dec 8, 2021
e01217c
feat: add configurable iavl cache size (backport #10561) (#10698)
mergify[bot] Dec 8, 2021
b9250f3
feat: Add `HasSupply` method to bank keeper (backport #10393) (#10699)
mergify[bot] Dec 9, 2021
16da4a4
fix!: Charge gas for key length in gas meter (backport #10247) (#10697)
mergify[bot] Dec 10, 2021
a8a1101
build(deps): upgrade rosetta to 0.7.0 (backport #10432) (#10716)
mergify[bot] Dec 10, 2021
ad443cb
perf: Speedup cachekv iterator on large deletions & IBC v2 upgrade lo…
mergify[bot] Dec 13, 2021
51f7d31
fix: populate ctx.ConsensusParams for begin blockers (backport #10725…
mergify[bot] Dec 16, 2021
f67928a
fix: nil pointer panic on `NewIntFromBigInt` (backport #9627) (#10845)
mergify[bot] Dec 29, 2021
8ad8d5d
perf: Improve the speed of coins.String() (backport #10076) (#10850)
mergify[bot] Dec 30, 2021
1321bc1
perf!: Add HasAccount to the AuthKeeper to save protobuf decoding tim…
mergify[bot] Dec 31, 2021
7115d3b
fix: enable setting sequence (nonce) for module account (backport #10…
mergify[bot] Jan 3, 2022
14cd943
perf: store/cachekv: avoid a map lookup if unnecessary, clear maps fa…
mergify[bot] Jan 3, 2022
19e924d
fix: adding checks to ensure coin denoms are sorted in `Balance` duri…
mergify[bot] Jan 3, 2022
44d3f4d
fix: register evidence regression (backport #10595) (#10775)
mergify[bot] Jan 3, 2022
a0503e5
fix: Panic if SetOrder* functions forgot modules (backport #10711) (#…
mergify[bot] Jan 3, 2022
0be9863
fix: create query context with requested block height (#10827) (#10866)
mergify[bot] Jan 4, 2022
71a168d
fix: recreate compat field, of null pubkeys in multisig (backport #10…
mergify[bot] Jan 5, 2022
6d44d71
fix!: tx result don't report block gas used as tx gas used (#10833)
yihuang Jan 5, 2022
8932338
feat: support in-place migration ordering (backport #10614) (#10890)
mergify[bot] Jan 6, 2022
05656a2
fix: use full gas on overflow (backport #10897) (#10912)
mergify[bot] Jan 7, 2022
a5c60b7
feat!: x/gov: raise max description length to 10k chars (backport #10…
mergify[bot] Jan 10, 2022
ba1e099
fix: revert tx when block gas limit exceeded (backport: #10770) (#10814)
yihuang Jan 12, 2022
c1c1ad7
chore: v0.45.0 Release Notes (#10760)
amaury1093 Jan 12, 2022
90ffbce
feat: support custom mnemonics in in-process testing network (backpor…
mergify[bot] Jan 13, 2022
8236b26
chore: move server.GenerateCoinKey and server.GenerateSaveCoinKey to …
robert-zaremba Jan 18, 2022
b6c77e6
chore: release v0.45 changelog (#10964)
robert-zaremba Jan 18, 2022
ced57ea
docs: guidelines for ValidateBasic (#10983) (#11001)
mergify[bot] Jan 23, 2022
7ecf4d4
fix: return 404 on non-existing tx (backport #10992) (#11014)
mergify[bot] Jan 25, 2022
dfd47f5
chore: update 0.45 migration and support notes (backport #10973) (#10…
mergify[bot] Jan 26, 2022
985d221
feat!: add protection against accidental downgrades (backport #10407)…
mergify[bot] Jan 27, 2022
0c9bbbc
fix: add iavl-cache-size config parsing to GetConfig (backport #10990…
mergify[bot] Jan 29, 2022
f69c82f
feat: extra logging in in-place store migrations (backport #10768) (#…
mergify[bot] Feb 3, 2022
2646b47
chore: 0.45.1 Release Notes (#11109)
robert-zaremba Feb 3, 2022
9bf8c9a
fix: add concurrency fence on traceContext to avoid data races (backp…
mergify[bot] Feb 8, 2022
4161d2b
feat: add get all versions (backport #11124) (#11144)
mergify[bot] Feb 9, 2022
7f949c0
support debug trace QueryResult (#11148)
yihuang Feb 18, 2022
4368a18
disable url parameter in swagger-ui page (backport #11202) (#11207)
mergify[bot] Feb 21, 2022
d862c66
feat: Allow to restrict MintCoins from app.go (backport #10771) (#11227)
mergify[bot] Feb 21, 2022
febcb92
refactor: prune everything (backport #11177) (#11258)
mergify[bot] Feb 23, 2022
147720c
feat: min and max operators on coins (backport #11200) (#11249)
mergify[bot] Feb 23, 2022
c7ddf4d
feat: include transactions in QueryBlockByHeight (backport #10880) (…
mergify[bot] Feb 24, 2022
d69a7b6
chore: fix changelog entry for #11177 (backport #11263) (#11264)
mergify[bot] Feb 24, 2022
12fffc1
fix: reject query with block height in the future (backport #11222) (…
mergify[bot] Feb 25, 2022
01711d9
Merge branch 'release/v0.45.x' of https://github.com/cosmos/cosmos-sd…
faddat Feb 28, 2022
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
Prev Previous commit
Next Next commit
fix: Charge gas even when there are no entries in gaskv (backport cos…
…mos#10218) (cosmos#10696)

* fix: Charge gas even when there are no entries in gaskv (cosmos#10218)

<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

Closes: cosmos#10127

Charge gas for seeks with empty ranges

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit 4c3aa4d)

# Conflicts:
#	CHANGELOG.md

* Fix conflicts

Co-authored-by: likhita-809 <78951027+likhita-809@users.noreply.github.com>
Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 8, 2021
commit d404619bda98d94c4344177fffb68741730ed528
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) - 2021-12-07

### State Machine Breaking

* (store) [#10218](https://github.com/cosmos/cosmos-sdk/pull/10218) Charge gas even when there are no entries while seeking.

## [v0.44.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.5) - 2021-12-02

### Improvements
Expand Down
15 changes: 6 additions & 9 deletions store/gaskv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ func (gs *Store) iterator(start, end []byte, ascending bool) types.Iterator {
}

gi := newGasIterator(gs.gasMeter, gs.gasConfig, parent)
if gi.Valid() {
gi.(*gasIterator).consumeSeekGas()
}
gi.(*gasIterator).consumeSeekGas()

return gi
}
Expand Down Expand Up @@ -143,10 +141,7 @@ func (gi *gasIterator) Valid() bool {
// in the iterator. It incurs a flat gas cost for seeking and a variable gas
// cost based on the current value's length if the iterator is valid.
func (gi *gasIterator) Next() {
if gi.Valid() {
gi.consumeSeekGas()
}

gi.consumeSeekGas()
gi.parent.Next()
}

Expand Down Expand Up @@ -177,8 +172,10 @@ func (gi *gasIterator) Error() error {
// consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost
// based on the current value's length.
func (gi *gasIterator) consumeSeekGas() {
value := gi.Value()
if gi.Valid() {
value := gi.Value()

gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc)
gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc)
}
gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc)
}
21 changes: 17 additions & 4 deletions store/gaskv/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/store/dbadapter"
"github.com/cosmos/cosmos-sdk/store/gaskv"
"github.com/cosmos/cosmos-sdk/store/types"

"github.com/stretchr/testify/require"
)

func bz(s string) []byte { return []byte(s) }
Expand Down Expand Up @@ -41,14 +40,18 @@ func TestGasKVStoreBasic(t *testing.T) {

func TestGasKVStoreIterator(t *testing.T) {
mem := dbadapter.Store{DB: dbm.NewMemDB()}
meter := types.NewGasMeter(10000)
meter := types.NewGasMeter(100000)
st := gaskv.NewStore(mem, meter, types.KVGasConfig())
require.False(t, st.Has(keyFmt(1)))
require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty")
require.Empty(t, st.Get(keyFmt(2)), "Expected `key2` to be empty")
require.Empty(t, st.Get(keyFmt(3)), "Expected `key3` to be empty")

st.Set(keyFmt(1), valFmt(1))
require.True(t, st.Has(keyFmt(1)))
st.Set(keyFmt(2), valFmt(2))
require.True(t, st.Has(keyFmt(2)))
st.Set(keyFmt(3), valFmt(0))

iterator := st.Iterator(nil, nil)
start, end := iterator.Domain()
Expand All @@ -71,8 +74,16 @@ func TestGasKVStoreIterator(t *testing.T) {
vb := iterator.Value()
require.Equal(t, vb, valFmt(2))
iterator.Next()
require.Equal(t, types.Gas(13377), meter.GasConsumed())
kc := iterator.Key()
require.Equal(t, kc, keyFmt(3))
vc := iterator.Value()
require.Equal(t, vc, valFmt(0))
iterator.Next()
require.Equal(t, types.Gas(13446), meter.GasConsumed())
require.False(t, iterator.Valid())
require.Panics(t, iterator.Next)
require.Equal(t, types.Gas(13476), meter.GasConsumed())
require.NoError(t, iterator.Error())

reverseIterator := st.ReverseIterator(nil, nil)
Expand All @@ -81,14 +92,16 @@ func TestGasKVStoreIterator(t *testing.T) {
t.Fatal(err)
}
})
require.Equal(t, reverseIterator.Key(), keyFmt(3))
reverseIterator.Next()
require.Equal(t, reverseIterator.Key(), keyFmt(2))
reverseIterator.Next()
require.Equal(t, reverseIterator.Key(), keyFmt(1))
reverseIterator.Next()
require.False(t, reverseIterator.Valid())
require.Panics(t, reverseIterator.Next)

require.Equal(t, types.Gas(9194), meter.GasConsumed())
require.Equal(t, types.Gas(13782), meter.GasConsumed())
}

func TestGasKVStoreOutOfGasSet(t *testing.T) {
Expand Down