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

test(bug): txtar to reproduce the VM hanging during Render #1736

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
64 changes: 64 additions & 0 deletions gno.land/cmd/gnoland/testdata/cpu-cycle-overrun1.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
loadpkg gno.land/p/demo/avl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we run this txtar conditionally, so it doesn't hang in the local suite, but is present in the codebase? cc @gfanton

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not have failing tests in the codebase unless we have a system that expects them to fail and checks that they are still failing

Ie. what we should do for the "challenges" directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the "bug" label so that this PR gets attention as demonstrating a bug.


# start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/cpu_cycle_overrun1 -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call AddData 3 times
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call AddData one more time. The call to Render hangs. If you comment this out, then the call to Render returns quickly.
gnokey maketx call -pkgpath gno.land/r/cpu_cycle_overrun1 -func AddData -gas-fee 1ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call Render
gnokey query vm/qrender --data "gno.land/r/cpu_cycle_overrun1\n"

-- cpu_cycle_overrun1.gno --
package cpu_cycle_overrun1

import (
"strconv"
"time"

"gno.land/p/demo/avl"
)

var gData = avl.Tree{} // id -> string

type MyData struct {
data avl.Tree
}

// Add a lot of data to gData (as much as we can do with the given maximum gas allowed).
func AddData() {
for i := 1; i <= 1000; i++ {
gData.Set(strconv.Itoa(gData.Size()), "hello")
}
}

func Render(path string) string {
// Put the data in allData.
subdata := &MyData{data: gData}
allData := avl.Tree{}
gData.Iterate("", "", func(key string, postI interface{}) bool {
allData.Set(strconv.Itoa(allData.Size()), subdata)
return false
})

// Iterate allData and make the render string.
now := time.Now()
str := ""
allData.Iterate("", "", func(key string, dataI interface{}) bool {
str += now.Format("2006-01-02 3:04pm MST")
return false
})
return "len " + strconv.Itoa(len(str))
}
Loading