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

fix: Longer package Path Spend More Gas [investigate] #2736

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
18 changes: 18 additions & 0 deletions gno.land/cmd/gnoland/testdata/addpkg_long_pkg_path.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
loadpkg gno.land/p/demo/ufmt

# start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/p/demo/foo/aaaa -gas-fee 1ugnot -gas-wanted 1430000 -broadcast -chainid=tendermint_test test1
#stdout OK!

-- foo.gno --
package aaaa

import (
"gno.land/p/demo/ufmt"
)

func Foo() string {
return ufmt.Sprintf("foo")
}
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ type IndexExpr struct { // X[Index]
Attributes
X Expr // expression
Index Expr // index expression
HasOK bool // if true, is form: `value, ok := <X>[<Key>]
HasOK bool // if true, is form: `value, ok := <X>[<Key>]`
}

type SelectorExpr struct { // X.Sel
Expand Down
6 changes: 5 additions & 1 deletion tm2/pkg/sdk/auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ func NewAnteHandler(ak AccountKeeper, bank BankKeeperI, sigGasConsumer Signature
return newCtx, abciResult(err), true
}

newCtx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*store.Gas(len(newCtx.TxBytes())), "txSize")
txLen := len(newCtx.TxBytes())
println("newCtx.TxBytes() length: ", txLen, "\ncontent: ", string(newCtx.TxBytes()))
newCtx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*store.Gas(txLen), "txSize")
// newCtx.GasMeter().ConsumeGas(store.Gas(txLen), "txSize")
println("xxxxxxxx ante gas consumed", newCtx.GasMeter().GasConsumed())

if res := ValidateMemo(tx, params); !res.IsOK() {
return newCtx, res, true
Expand Down
2 changes: 2 additions & 0 deletions tm2/pkg/sdk/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ func (app *BaseApp) runTx(mode RunTxMode, txBytes []byte, tx Tx) (result Result)
ms := ctx.MultiStore()
if mode == RunTxModeDeliver {
gasleft := ctx.BlockGasMeter().Remaining()
println("runTx gas left", gasleft)
ctx = ctx.WithGasMeter(store.NewPassthroughGasMeter(
ctx.GasMeter(),
gasleft,
Expand Down Expand Up @@ -738,6 +739,7 @@ func (app *BaseApp) runTx(mode RunTxMode, txBytes []byte, tx Tx) (result Result)
result.Log = log
result.GasWanted = gasWanted
result.GasUsed = ctx.GasMeter().GasConsumed()
println("runTx gas consumed", result.GasUsed)
return
default:
log := fmt.Sprintf("recovered: %v\nstack:\n%v", r, string(debug.Stack()))
Expand Down
Loading