-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tm2): add sdk/params module (#2920)
- [x] port x/params -> sdk/params b930513 - [x] inject in vmkeeper + add std.SetConfig 602245d - [x] implement in `gnoland` 783a044 - [x] appchain - [x] rpc query - [x] txtar - [x] implement or add comment where we should use it in the existing codebase - [x] namespace's realm target - [ ] questions - [x] do we want a `std.GetConfig` from the contract part? -> No, it allows unsafe, complex, and implicit patterns. If you want to get a value from another contract, you can either import it or use a registry pattern. This approach preserves type safety and other GNOVM protections. - [ ] do we want to restrict the realms able to call `SetConfig` (only `r/sys`), or maybe set an expensive gas price? - [x] after discussion with jae - [x] Rename Config -> Param for consistency - [x] Remove `interface{}` from the setters and use specific types, including in the tm2 implementation (string, uint64, int64, bool, bytes) - [x] Remove the `.<type>` suffix addition, but ensure that the type is explicitly defined by the user; and remove the table. - [x] Remove the types table from the tm2 implementation Related #1418 Related #1856 --------- Signed-off-by: moul <[email protected]>
- Loading branch information
Showing
21 changed files
with
901 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# test for https://github.com/gnolang/gno/pull/2920 | ||
|
||
gnoland start | ||
|
||
# query before adding the package | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: $' | ||
|
||
gnokey maketx addpkg -pkgdir $WORK/setter -pkgpath gno.land/r/sys/setter -gas-fee 1000000ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1 | ||
|
||
# query after adding the package, but before setting values | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: $' | ||
|
||
|
||
# set foo (string) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetFoo -args foo1 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: "foo1"' | ||
|
||
# override foo | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetFoo -args foo2 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: "foo2"' | ||
|
||
|
||
# set bar (bool) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBar -args true -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: true' | ||
|
||
# override bar | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBar -args false -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: false' | ||
|
||
|
||
# set baz (bool) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBaz -args 1337 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: "1337"' | ||
|
||
# override baz | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBaz -args 31337 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: "31337"' | ||
|
||
-- setter/setter.gno -- | ||
package setter | ||
|
||
import ( | ||
"std" | ||
) | ||
|
||
func SetFoo(newFoo string) { std.SetParamString("foo.string", newFoo) } | ||
func SetBar(newBar bool) { std.SetParamBool("bar.bool", newBar) } | ||
func SetBaz(newBaz int64) { std.SetParamInt64("baz.int64", newBaz) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
43dd3f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Go Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.20
.BenchmarkBinary/EmptyStruct:encode
488.5
ns/op 96 B/op 2 allocs/op298
ns/op 96 B/op 2 allocs/op1.64
BenchmarkBinary/EmptyStruct:encode - ns/op
488.5
ns/op298
ns/op1.64
BenchmarkBinary/EmptyStruct:decode
275.8
ns/op 0 B/op 0 allocs/op141.6
ns/op 0 B/op 0 allocs/op1.95
BenchmarkBinary/EmptyStruct:decode - ns/op
275.8
ns/op141.6
ns/op1.95
BenchmarkBinary/ShortArraysStruct:encode
761.6
ns/op 192 B/op 4 allocs/op617.2
ns/op 192 B/op 4 allocs/op1.23
BenchmarkBinary/ShortArraysStruct:encode - ns/op
761.6
ns/op617.2
ns/op1.23
BenchmarkBinary/ShortArraysStruct:decode
378.5
ns/op 0 B/op 0 allocs/op217.4
ns/op 0 B/op 0 allocs/op1.74
BenchmarkBinary/ShortArraysStruct:decode - ns/op
378.5
ns/op217.4
ns/op1.74
BenchmarkDetaching
125.8
ns/op 0 B/op 0 allocs/op89.9
ns/op 0 B/op 0 allocs/op1.40
BenchmarkDetaching - ns/op
125.8
ns/op89.9
ns/op1.40
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
63636990
ns/op 5130 B/op 9 allocs/op31845950
ns/op 5125 B/op 9 allocs/op2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
63636990
ns/op31845950
ns/op2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
127546995
ns/op 5139 B/op 9 allocs/op31845950
ns/op 5125 B/op 9 allocs/op4.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
127546995
ns/op31845950
ns/op4.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
254401620
ns/op 5158 B/op 9 allocs/op31845950
ns/op 5125 B/op 9 allocs/op7.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
254401620
ns/op31845950
ns/op7.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
508524964
ns/op 5196 B/op 10 allocs/op31845950
ns/op 5125 B/op 9 allocs/op15.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
508524964
ns/op31845950
ns/op15.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
1016960441
ns/op 5736 B/op 15 allocs/op31845950
ns/op 5125 B/op 9 allocs/op31.93
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
1016960441
ns/op31845950
ns/op31.93
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op
15
allocs/op9
allocs/op1.67
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
2036537781
ns/op 5736 B/op 15 allocs/op31845950
ns/op 5125 B/op 9 allocs/op63.95
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
2036537781
ns/op31845950
ns/op63.95
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op
15
allocs/op9
allocs/op1.67
BenchmarkSigning
84684
ns/op 1856 B/op 36 allocs/op25715
ns/op 64 B/op 1 allocs/op3.29
BenchmarkSigning - ns/op
84684
ns/op25715
ns/op3.29
BenchmarkSigning - B/op
1856
B/op64
B/op29
BenchmarkSigning - allocs/op
36
allocs/op1
allocs/op36
BenchmarkSigning
84239
ns/op 1856 B/op 36 allocs/op25715
ns/op 64 B/op 1 allocs/op3.28
BenchmarkSigning - ns/op
84239
ns/op25715
ns/op3.28
BenchmarkSigning - B/op
1856
B/op64
B/op29
BenchmarkSigning - allocs/op
36
allocs/op1
allocs/op36
BenchmarkVerification
166113
ns/op 864 B/op 19 allocs/op60832
ns/op 0 B/op 0 allocs/op2.73
BenchmarkVerification - ns/op
166113
ns/op60832
ns/op2.73
BenchmarkVerification - B/op
864
B/op0
B/op+∞
BenchmarkVerification - allocs/op
19
allocs/op0
allocs/op+∞
BenchmarkVerification
173440
ns/op 864 B/op 19 allocs/op60832
ns/op 0 B/op 0 allocs/op2.85
BenchmarkVerification - ns/op
173440
ns/op60832
ns/op2.85
BenchmarkVerification - B/op
864
B/op0
B/op+∞
BenchmarkVerification - allocs/op
19
allocs/op0
allocs/op+∞
BenchmarkImmutableAvlTreeMemDB
4558651
ns/op 1038990 B/op 21141 allocs/op3316586
ns/op 877577 B/op 17833 allocs/op1.37
BenchmarkImmutableAvlTreeMemDB - ns/op
4558651
ns/op3316586
ns/op1.37
BenchmarkImmutableAvlTreeMemDB
4314491
ns/op 1053471 B/op 21437 allocs/op3316586
ns/op 877577 B/op 17833 allocs/op1.30
BenchmarkImmutableAvlTreeMemDB - ns/op
4314491
ns/op3316586
ns/op1.30
BenchmarkImmutableAvlTreeMemDB - B/op
1053471
B/op877577
B/op1.20
BenchmarkImmutableAvlTreeMemDB - allocs/op
21437
allocs/op17833
allocs/op1.20
BenchmarkRandomBytes/random
68.48
ns/op 16 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op2.05
BenchmarkRandomBytes/random - ns/op
68.48
ns/op33.46
ns/op2.05
BenchmarkRandomBytes/random - B/op
16
B/op4
B/op4
BenchmarkRandomBytes/random
104.2
ns/op 32 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op3.11
BenchmarkRandomBytes/random - ns/op
104.2
ns/op33.46
ns/op3.11
BenchmarkRandomBytes/random - B/op
32
B/op4
B/op8
BenchmarkRandomBytes/random
264.1
ns/op 112 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op7.89
BenchmarkRandomBytes/random - ns/op
264.1
ns/op33.46
ns/op7.89
BenchmarkRandomBytes/random - B/op
112
B/op4
B/op28
BenchmarkRandomBytes/random
2291
ns/op 1024 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op68.47
BenchmarkRandomBytes/random - ns/op
2291
ns/op33.46
ns/op68.47
BenchmarkRandomBytes/random - B/op
1024
B/op4
B/op256
BenchmarkSmall/boltdb-1000-100-16-40/update
1419642
ns/op 42690 B/op 389 allocs/op955964
ns/op 37903 B/op 373 allocs/op1.49
BenchmarkSmall/boltdb-1000-100-16-40/update - ns/op
1419642
ns/op955964
ns/op1.49
BenchmarkSmall/memdb-1000-100-16-40/block
17036884
ns/op 9216587 B/op 168062 allocs/op12866474
ns/op 6602347 B/op 117147 allocs/op1.32
BenchmarkSmall/memdb-1000-100-16-40/block - ns/op
17036884
ns/op12866474
ns/op1.32
BenchmarkSmall/memdb-1000-100-16-40/block - B/op
9216587
B/op6602347
B/op1.40
BenchmarkSmall/memdb-1000-100-16-40/block - allocs/op
168062
allocs/op117147
allocs/op1.43
BenchmarkMedium/boltdb-100000-100-16-40/update
6803616
ns/op 130372 B/op 1016 allocs/op5524256
ns/op 102214 B/op 865 allocs/op1.23
BenchmarkMedium/boltdb-100000-100-16-40/update - ns/op
6803616
ns/op5524256
ns/op1.23
BenchmarkMedium/boltdb-100000-100-16-40/update - B/op
130372
B/op102214
B/op1.28
BenchmarkMedium/memdb-100000-100-16-40/update
1248556
ns/op 382357 B/op 7578 allocs/op1026831
ns/op 252552 B/op 4870 allocs/op1.22
BenchmarkMedium/memdb-100000-100-16-40/update - ns/op
1248556
ns/op1026831
ns/op1.22
BenchmarkMedium/memdb-100000-100-16-40/update - B/op
382357
B/op252552
B/op1.51
BenchmarkMedium/memdb-100000-100-16-40/update - allocs/op
7578
allocs/op4870
allocs/op1.56
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - B/op
48933
B/op39704
B/op1.23
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - allocs/op
590
allocs/op457
allocs/op1.29
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - B/op
103670820
B/op78179120
B/op1.33
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - allocs/op
1237148
allocs/op955909
allocs/op1.29
BenchmarkHash/ripemd160
2835
ns/op 25 B/op 1 allocs/op700.1
ns/op 25 B/op 1 allocs/op4.05
BenchmarkHash/ripemd160 - ns/op
2835
ns/op700.1
ns/op4.05
BenchmarkHash/sha2-256
521.7
ns/op 33 B/op 1 allocs/op169.3
ns/op 33 B/op 1 allocs/op3.08
BenchmarkHash/sha2-256 - ns/op
521.7
ns/op169.3
ns/op3.08
BenchmarkHash/sha3-256
1837
ns/op 33 B/op 1 allocs/op690.4
ns/op 33 B/op 1 allocs/op2.66
BenchmarkHash/sha3-256 - ns/op
1837
ns/op690.4
ns/op2.66
BenchmarkWriteSecretConnection
6375
ns/op 0 B/op 0 allocs/op4028
ns/op 0 B/op 0 allocs/op1.58
BenchmarkWriteSecretConnection - ns/op
6375
ns/op4028
ns/op1.58
BenchmarkReadSecretConnection
3695
ns/op 0 B/op 0 allocs/op2364
ns/op 0 B/op 0 allocs/op1.56
BenchmarkReadSecretConnection - ns/op
3695
ns/op2364
ns/op1.56
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ajnavarro @thehowl @zivkovicmilos