Skip to content

Non-deterministic gas usage after node restart when writing to realm storage #4983

@omarsy

Description

@omarsy

Description

Gas usage for the same transaction that writes to realm storage is not deterministic and changes depending on whether the node has been restarted.

Steps to Reproduce

Test 1 (restart)

gnoland start

gnokey maketx addpkg -pkgdir $WORK/realm -pkgpath gno.land/r/foo -gas-fee 1000000ugnot -gas-wanted 20000000 -max-deposit 502500ugnot -broadcast -chainid=tendermint_test test1

gnoland restart

gnokey maketx call -pkgpath gno.land/r/foo -func NewFoo -args "foo"  -gas-fee 1000000ugnot -gas-wanted 10000000  -broadcast -chainid=tendermint_test test1
stdout OK!


-- realm/gnomod.toml --
module = "gno.land/r/foo"

gno = "0.9"

-- realm/storage.gno --
package foo

var record *Foo

type Foo struct{
  name string
}

func NewFoo(cur realm, name string){
  record = &Foo{name}
}

Result:

stdout OK!
GAS USED: 258357

Test 2 (without restart)

gnoland start

gnokey maketx addpkg -pkgdir $WORK/realm -pkgpath gno.land/r/foo -gas-fee 1000000ugnot -gas-wanted 20000000 -max-deposit 502500ugnot -broadcast -chainid=tendermint_test test1

gnokey maketx call -pkgpath gno.land/r/foo -func NewFoo -args "foo"  -gas-fee 1000000ugnot -gas-wanted 10000000  -broadcast -chainid=tendermint_test test1
stdout OK!


-- realm/gnomod.toml --
module = "gno.land/r/foo"

gno = "0.9"

-- realm/storage.gno --
package foo

var record *Foo

type Foo struct{
  name string
}

func NewFoo(cur realm, name string){
  record = &Foo{name}
}

Result:

stdout OK!
GAS USED: 252481

Expected Behavior

Gas usage should be identical for the same transaction

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions