-
Notifications
You must be signed in to change notification settings - Fork 443
Open
Labels
🐞 bugSomething isn't workingSomething isn't working
Description
Description
If we have a variable stored on a realm X and another realm uses that variable casting it to another value for example []byte -> string or string -> bytes. The Vm panics and abort the transaction as if the second realm is trying to modify the variable. The panic message: illegal conversion of readonly or externally stored value.
The problem is that the second realm is not really trying to modify the value store on the realm as there is not reasignation of the variable.
Steps to reproduce:
loadpkg gno.land/r/demo/crossrealm $WORK/crossrealm
loadpkg gno.land/r/demo/main $WORK/main
gnoland start
gnokey maketx call -pkgpath gno.land/r/demo/main -func Exec -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1
stdout 'OK!'
-- crossrealm/gnomod.toml --
module = "gno.land/r/demo/crossrealm"
gno = "0.9"
-- crossrealm/crossrealm.gno --
package crossrealm
var msg []byte = []byte{104, 101, 108, 108, 111, 32, 98, 117, 103}
func Message() []byte {
return msg
}
-- main/gnomod.toml --
module = "gno.land/r/demo/main"
gno = "0.9"
-- main/main.gno --
package main
import (
"gno.land/r/demo/crossrealm"
"bytes"
)
var msgLocal []byte = []byte{104, 101, 108, 108, 111, 32, 98, 117, 103}
func Exec(cur realm) {
msg := crossrealm.Message()
//msgString := string(msg)
if bytes.Equal(msg, msgLocal){
println("Equals")
}
}
Credit: @n0izn0iz
n0izn0iz
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't working
Type
Projects
Status
Todo