@@ -3,39 +3,63 @@ gnoland start
33
44# Deploy realm without comments
55gnokey maketx addpkg -pkgdir $WORK/nocomment -pkgpath gno.land/r/test/nocomment -gas-fee 100000ugnot -gas-wanted 50000000 -broadcast -chainid=tendermint_test test1
6- # stdout 'GAS USED:'
6+ # stdout 'GAS USED: 328452 '
77
88# Deploy realm with comments (same logic)
99gnokey maketx addpkg -pkgdir $WORK/withcomment -pkgpath gno.land/r/test/withcomment -gas-fee 100000ugnot -gas-wanted 50000000 -broadcast -chainid=tendermint_test test1
10- # stdout 'GAS USED:'
10+ # stdout 'GAS USED: 343204 '
1111
1212# Deploy realm with heavy comments (lots of comments)
1313gnokey maketx addpkg -pkgdir $WORK/heavycomment -pkgpath gno.land/r/test/heavycomment -gas-fee 100000ugnot -gas-wanted 50000000 -broadcast -chainid=tendermint_test test1
14- # stdout 'GAS USED:'
14+ # stdout 'GAS USED: 390698'
15+
16+ # Deploy caller realm
17+ gnokey maketx addpkg -pkgdir $WORK/caller -pkgpath gno.land/r/test/caller -gas-fee 100000ugnot -gas-wanted 50000000 -broadcast -chainid=tendermint_test test1
18+ # stdout 'GAS USED: 754645'
1519
1620### Call each realm to check runtime load cost ###
1721
18- # Call no comment realm
19- gnokey maketx call -pkgpath gno.land/r/test/nocomment -func DoAdd -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
20- # stdout 'GAS USED:'
22+ # Call no comment realm (single)
23+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallNoCommentOnce -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
24+ # stdout 'GAS USED: 308405'
25+
26+ # Call with comment realm (single)
27+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallWithCommentOnce -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
28+ # stdout 'GAS USED: 309863'
29+
30+ # Call heavy comment realm (single)
31+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallHeavyCommentOnce -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
32+ # stdout 'GAS USED: 310669'
33+
34+ ### Call twice in same transaction (cached) ###
35+
36+ # Call no comment realm twice in one tx
37+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallNoCommentTwice -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
38+ # stdout 'GAS USED: 309915'
2139
22- # Call with comment realm
23- gnokey maketx call -pkgpath gno.land/r/test/withcomment -func DoAdd -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
24- # stdout 'GAS USED:'
40+ # Call with comment realm twice in one tx
41+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallWithCommentTwice -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
42+ # stdout 'GAS USED: 311367 '
2543
26- # Call heavy comment realm
27- gnokey maketx call -pkgpath gno.land/r/test/heavycomment -func DoAdd -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
28- # stdout 'GAS USED:'
44+ # Call heavy comment realm twice in one tx
45+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallHeavyCommentTwice -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
46+ # stdout 'GAS USED: 312173 '
2947
30- ### Second call (cached) ###
48+ ### Call 5 times in same transaction ###
3149
32- # Call no comment realm again
33- gnokey maketx call -pkgpath gno.land/r/test/nocomment -func DoAdd -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
34- # stdout 'GAS USED:'
50+ # Call no comment realm 5x in one tx
51+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallNoComment5x -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
52+ # stdout 'GAS USED: 314367 '
3553
36- # Call heavy comment realm again
37- gnokey maketx call -pkgpath gno.land/r/test/heavycomment -func DoAdd -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
38- # stdout 'GAS USED:'
54+ # Call heavy comment realm 5x in one tx
55+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallHeavyComment5x -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
56+ # stdout 'GAS USED: 316625'
57+
58+ ### Call with comment and heavy comment ###
59+
60+ # Call with comment and heavy comment realm in one tx
61+ gnokey maketx call -pkgpath gno.land/r/test/caller -func CallDiffentFunctionTwiceInSameTx -insecure-password-stdin=true -broadcast=true -chainid=tendermint_test -gas-fee 1000000ugnot -gas-wanted 1000000000 -memo "" test1
62+ # stdout 'GAS USED: 311488'
3963
4064-- nocomment/gnomod.toml --
4165module = "gno.land/r/test/nocomment"
@@ -62,10 +86,6 @@ func Divide(a, b int) int {
6286 return a / b
6387}
6488
65- func DoAdd(cur realm) int {
66- return Add(1, 2)
67- }
68-
6989-- withcomment/gnomod.toml --
7090module = "gno.land/r/test/withcomment"
7191gno = "0.9"
@@ -100,11 +120,6 @@ func Divide(a, b int) int {
100120 return a / b
101121}
102122
103- // DoAdd is an exported function that calls Add internally.
104- func DoAdd(cur realm) int {
105- return Add(1, 2)
106- }
107-
108123-- heavycomment/gnomod.toml --
109124module = "gno.land/r/test/heavycomment"
110125gno = "0.9"
@@ -214,22 +229,65 @@ func Divide(a, b int) int {
214229 return a / b
215230}
216231
217- // DoAdd is an exported function that demonstrates internal function calls.
218- //
219- // This function serves as an entry point for external callers.
220- // It internally calls the Add function with predefined parameters.
221- //
222- // Parameters:
223- // - cur: The current realm context (required for cross-realm calls)
224- //
225- // Returns:
226- // - int: The result of Add(1, 2), which is 3
227- //
228- // Example:
229- // result := DoAdd() // result = 3
230- func DoAdd(cur realm) int {
231- // Call the internal Add function with test values
232- // This demonstrates how internal functions can be wrapped
233- // for external access
234- return Add(1, 2)
232+ -- caller/gnomod.toml --
233+ module = "gno.land/r/test/caller"
234+ gno = "0.9"
235+ -- caller/caller.gno --
236+ package caller
237+
238+ import (
239+ "gno.land/r/test/nocomment"
240+ "gno.land/r/test/withcomment"
241+ "gno.land/r/test/heavycomment"
242+ )
243+
244+ // Single calls
245+ func CallNoCommentOnce(cur realm) {
246+ nocomment.Add(1, 2)
247+ }
248+
249+ func CallWithCommentOnce(cur realm) {
250+ withcomment.Add(1, 2)
251+ }
252+
253+ func CallHeavyCommentOnce(cur realm) {
254+ heavycomment.Add(1, 2)
255+ }
256+
257+ // Double calls (same tx - test caching)
258+ func CallNoCommentTwice(cur realm) {
259+ nocomment.Add(1, 2)
260+ nocomment.Add(3, 4)
261+ }
262+
263+ func CallWithCommentTwice(cur realm) {
264+ withcomment.Add(1, 2)
265+ withcomment.Add(3, 4)
266+ }
267+
268+ func CallHeavyCommentTwice(cur realm) {
269+ heavycomment.Add(1, 2)
270+ heavycomment.Add(3, 4)
271+ }
272+
273+ // 5x calls (same tx)
274+ func CallNoComment5x(cur realm) {
275+ nocomment.Add(1, 2)
276+ nocomment.Add(2, 3)
277+ nocomment.Add(3, 4)
278+ nocomment.Add(4, 5)
279+ nocomment.Add(5, 6)
280+ }
281+
282+ func CallHeavyComment5x(cur realm) {
283+ heavycomment.Add(1, 2)
284+ heavycomment.Add(2, 3)
285+ heavycomment.Add(3, 4)
286+ heavycomment.Add(4, 5)
287+ heavycomment.Add(5, 6)
288+ }
289+
290+ func CallDiffentFunctionTwiceInSameTx(cur realm) {
291+ withcomment.Add(1, 2)
292+ withcomment.Multiply(3, 4)
235293}
0 commit comments