Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion gno.land/pkg/integration/testdata/gc.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gnoland start -no-parallel


gnokey maketx call -pkgpath gno.land/r/gc -func Alloc -gas-fee 17000000ugnot -gas-wanted 170_000_000 -simulate skip -chainid tendermint_test test1
stdout 'GAS USED: 151380803'
stdout 'GAS USED: 151321803'

-- r/gc/gc.gno --
package gc
Expand Down
18 changes: 9 additions & 9 deletions gno.land/pkg/integration/testdata/gnokey_gasfee.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ stdout '"coins": "10000000000000ugnot"'
# gas-wanted/gas-fee on the simulate call are generous; simulate reports
# the actual gas the real tx would consume.
gnokey maketx addpkg -pkgdir $WORK/hello -pkgpath gno.land/r/hello -gas-wanted 3_500_000 -gas-fee 350001ugnot -chainid tendermint_test -simulate only test1
stdout 'GAS USED:\s+2815592'
stdout 'INFO: estimated gas usage: 2815592 \(suggested, with 5% margin: 2956372\), gas fee: 2956ugnot, current gas price: 1ugnot/1000gas'
stdout 'GAS USED:\s+2756592'
stdout 'INFO: estimated gas usage: 2756592 \(suggested, with 5% margin: 2894422\), gas fee: 2894ugnot, current gas price: 1ugnot/1000gas'

## No fee was charged, and the sequence number did not change.
gnokey query auth/accounts/$test1_user_addr
Expand All @@ -25,33 +25,33 @@ stdout '"coins": "10000000000000ugnot"'
# This is the documented simulate->broadcast workflow; the values on this
# line MUST match the simulate output above (modulo a small gas-wanted
# headroom).
gnokey maketx addpkg -pkgdir $WORK/hello -pkgpath gno.land/r/hello -gas-wanted 2_816_000 -gas-fee 2956ugnot -chainid tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK/hello -pkgpath gno.land/r/hello -gas-wanted 2_757_000 -gas-fee 2894ugnot -chainid tendermint_test test1
stdout 'OK'
stdout 'EVENTS: \[.*"fee_delta":\{"denom":"ugnot","amount":206900\}.*\]'

## fee + storage deposit were charged; sequence number increased.
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "1"'
stdout '"coins": "9999999790144ugnot"'
stdout '"coins": "9999999790206ugnot"'

# Tx Call -simulate only, estimate gas used and gas fee.
gnokey maketx call -pkgpath gno.land/r/hello -func Hello -gas-wanted 1_800_000 -gas-fee 180001ugnot -chainid tendermint_test -simulate only test1
stdout 'GAS USED:\s+1271011'
stdout 'INFO: estimated gas usage: 1271011 \(suggested, with 5% margin: 1334562\), gas fee: 1335ugnot, current gas price: 1ugnot/1000gas'
stdout 'GAS USED:\s+1212011'
stdout 'INFO: estimated gas usage: 1212011 \(suggested, with 5% margin: 1272612\), gas fee: 1273ugnot, current gas price: 1ugnot/1000gas'

## No additional fee was charged, and the sequence number did not change.
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "1"'
stdout '"coins": "9999999790144ugnot"'
stdout '"coins": "9999999790206ugnot"'

# Using the simulated gas and estimated gas fee should ensure the transaction executes successfully.
gnokey maketx call -pkgpath gno.land/r/hello -func Hello -gas-wanted 1_335_000 -gas-fee 1335ugnot -chainid tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/hello -func Hello -gas-wanted 1_213_000 -gas-fee 1273ugnot -chainid tendermint_test test1
stdout 'OK'

## fee is charged and sequence number increased
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "2"'
stdout '"coins": "9999999788809ugnot"'
stdout '"coins": "9999999788933ugnot"'

-- hello/gnomod.toml --
module = "gno.land/r/hello"
Expand Down
6 changes: 3 additions & 3 deletions gno.land/pkg/integration/testdata/restart_gas.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
gnoland start

gnokey maketx addpkg -pkgdir $WORK/bar -pkgpath gno.land/r/$test1_user_addr/bar -gas-fee 360001ugnot -gas-wanted 3_600_000 -chainid=tendermint_test test1
stdout 'GAS USED:\s+2839188'
stdout 'GAS USED:\s+2780188'

gnokey maketx addpkg -pkgdir $WORK/bar -pkgpath gno.land/r/$test1_user_addr/foo -gas-fee 360001ugnot -gas-wanted 3_600_000 -chainid=tendermint_test test1
stdout 'GAS USED:\s+2841517'
stdout 'GAS USED:\s+2782517'

gnoland restart

gnokey maketx addpkg -pkgdir $WORK/baz -pkgpath gno.land/r/$test1_user_addr/baz -gas-fee 360001ugnot -gas-wanted 3_600_000 -chainid=tendermint_test test1
stdout 'GAS USED:\s+2841531'
stdout 'GAS USED:\s+2782531'

-- bar/gnomod.toml --
module = "bar"
Expand Down
10 changes: 5 additions & 5 deletions gno.land/pkg/integration/testdata/simulate_gas.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ stdout 'GAS USED: \d+' # same as simulate only

# simulate only (again) with default 5% margin
gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only test1
stdout 'gas fee: 1266ugnot'
stdout 'gas fee: 1204ugnot'

# simulate only with no gas fee margin. base gas fee is 1206ugnot
# simulate only with no gas fee margin. base gas fee is 1147ugnot
gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only -gas-fee-margin=0 test1
stdout 'gas fee: 1206ugnot'
stdout 'gas fee: 1147ugnot'

# the 5% margin was 60ugnot (1266 - 1206). the 10% margin should be about 120ugnot, total of 1326
# the 5% margin was 57ugnot (1204 - 1147). the 10% margin should be about 114ugnot, total of 1261
gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only -gas-fee-margin=10 test1
stdout 'gas fee: 1326ugnot,'
stdout 'gas fee: 1261ugnot,'

# -gas-fee-margin should be a number
! gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only -gas-fee-margin=zzz test1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

env ADDPKG_GAS=10_000_000
env CALL_GAS=10_000_000
env EXACT_GAS=2798422
env EXACT_GAS=2739422

gnoland start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

env ADDPKG_GAS=4_800_000
env SETUP_GAS=3_200_000
env EXACT_GAS=2235646
env EXACT_GAS=2176646

gnoland start

Expand Down
7 changes: 7 additions & 0 deletions gnovm/pkg/gnolang/mempackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ func IsEphemeralPath(pkgPath string) bool {
return match != nil && match.Get("LETTER") == "e"
}

// IsSyntheticPath determines whether the given pkgPath is a compiler-internal
// synthetic path (".uverse", ".dontcare", ...). Synthetic packages are never
// persisted to the store and cannot appear in user source.
func IsSyntheticPath(pkgPath string) bool {
return strings.HasPrefix(pkgPath, ".")
}

// IsGnoRunPath returns true if it's a run (MsgRun) package path.
// DerivePkgAddress() returns the embedded address such that the run package can
// receive coins on behalf of the user.
Expand Down
9 changes: 9 additions & 0 deletions gnovm/pkg/gnolang/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ func (ds *defaultStore) GetPackage(pkgPath string, isImport bool) *PackageValue
}

oid := ObjectIDFromPkgPath(pkgPath)
// Synthetic packages are never persisted: check only the cache — a
// backend read would be a guaranteed miss charged as a full I/O
// read, and the pkgGetter cannot resolve them either.
if IsSyntheticPath(pkgPath) {
if oo, exists := ds.cacheObjects[oid]; exists {
return oo.(*PackageValue)
}
return nil
}
// Get package from cache or baseStore
oo := ds.GetObjectSafe(oid)
if oo != nil {
Expand Down