Skip to content

Commit 88ab1bd

Browse files
author
Woosang Son
authored
chore: param store doesn't use gas kv (#202)
* chore: param store doesn't use gas kv * chore: apply comment * chore: fix lint error
1 parent dc15595 commit 88ab1bd

File tree

4 files changed

+2
-52
lines changed

4 files changed

+2
-52
lines changed

store/types/gas_test.go

-14
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,3 @@ func TestAddUint64Overflow(t *testing.T) {
8888
)
8989
}
9090
}
91-
92-
func TestTransientGasConfig(t *testing.T) {
93-
t.Parallel()
94-
config := TransientGasConfig()
95-
require.Equal(t, config, GasConfig{
96-
HasCost: 1000,
97-
DeleteCost: 1000,
98-
ReadCostFlat: 1000,
99-
ReadCostPerByte: 3,
100-
WriteCostFlat: 2000,
101-
WriteCostPerByte: 30,
102-
IterNextCostFlat: 30,
103-
})
104-
}

x/params/keeper/keeper_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,10 @@ func TestSubspace(t *testing.T) {
189189
store := prefix.NewStore(ctx.KVStore(key), []byte("test/"))
190190
space := keeper.Subspace("test").WithKeyTable(table)
191191

192-
// Test space.Set, space.Modified
192+
// Test space.Set
193193
for i, kv := range kvs {
194194
i, kv := i, kv
195-
require.False(t, space.Modified(ctx, []byte(kv.key)), "space.Modified returns true before setting, tc #%d", i)
196195
require.NotPanics(t, func() { space.Set(ctx, []byte(kv.key), kv.param) }, "space.Set panics, tc #%d", i)
197-
require.True(t, space.Modified(ctx, []byte(kv.key)), "space.Modified returns false after setting, tc #%d", i)
198196
}
199197

200198
// Test space.Get, space.GetIfExists

x/params/types/subspace.go

+1-25
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,7 @@ func (s *Subspace) kvStore(ctx sdk.Context) sdk.KVStore {
7575
// this function can be called concurrently so we should not call append on s.name directly
7676
name := make([]byte, len(s.name))
7777
copy(name, s.name)
78-
return prefix.NewStore(ctx.KVStore(s.key), append(name, '/'))
79-
}
80-
81-
// Returns a transient store for modification
82-
func (s *Subspace) transientStore(ctx sdk.Context) sdk.KVStore {
83-
// this function can be called concurrently so we should not call append on s.name directly
84-
name := make([]byte, len(s.name))
85-
copy(name, s.name)
86-
return prefix.NewStore(ctx.TransientStore(s.tkey), append(name, '/'))
78+
return prefix.NewStore(ctx.MultiStore().GetKVStore(s.key), append(name, '/'))
8779
}
8880

8981
// Validate attempts to validate a parameter value by its key. If the key is not
@@ -156,13 +148,6 @@ func (s *Subspace) Has(ctx sdk.Context, key []byte) bool {
156148
return store.Has(key)
157149
}
158150

159-
// Modified returns true if the parameter key is set in the Subspace's transient
160-
// KVStore.
161-
func (s *Subspace) Modified(ctx sdk.Context, key []byte) bool {
162-
tstore := s.transientStore(ctx)
163-
return tstore.Has(key)
164-
}
165-
166151
// checkType verifies that the provided key and value are comptable and registered.
167152
func (s *Subspace) checkType(key []byte, value interface{}) {
168153
attr, ok := s.table.m[string(key)]
@@ -258,10 +243,6 @@ func (s *Subspace) Set(ctx sdk.Context, key []byte, value interface{}) {
258243
}
259244

260245
store.Set(key, bz)
261-
262-
tstore := s.transientStore(ctx)
263-
tstore.Set(key, []byte{})
264-
265246
s.cacheValue(key, value)
266247
}
267248

@@ -348,11 +329,6 @@ func (ros ReadOnlySubspace) Has(ctx sdk.Context, key []byte) bool {
348329
return ros.s.Has(ctx, key)
349330
}
350331

351-
// Modified delegates a read-only Modified call to the Subspace.
352-
func (ros ReadOnlySubspace) Modified(ctx sdk.Context, key []byte) bool {
353-
return ros.s.Modified(ctx, key)
354-
}
355-
356332
// Name delegates a read-only Name call to the Subspace.
357333
func (ros ReadOnlySubspace) Name() string {
358334
return ros.s.Name()

x/params/types/subspace_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ func (suite *SubspaceTestSuite) TestHas() {
102102
suite.Require().True(suite.ss.Has(suite.ctx, keyUnbondingTime))
103103
}
104104

105-
func (suite *SubspaceTestSuite) TestModified() {
106-
t := time.Hour * 48
107-
108-
suite.Require().False(suite.ss.Modified(suite.ctx, keyUnbondingTime))
109-
suite.Require().NotPanics(func() {
110-
suite.ss.Set(suite.ctx, keyUnbondingTime, t)
111-
})
112-
suite.Require().True(suite.ss.Modified(suite.ctx, keyUnbondingTime))
113-
}
114-
115105
func (suite *SubspaceTestSuite) TestUpdate() {
116106
suite.Require().Panics(func() {
117107
suite.ss.Update(suite.ctx, []byte("invalid_key"), nil) // nolint:errcheck

0 commit comments

Comments
 (0)