gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
839 stars 342 forks source link

[GnoVM]: Do not allow realms to store references to objects owned by other realms #2332

Open deelawn opened 2 weeks ago

deelawn commented 2 weeks ago

The issue title describes it pretty well. The following test should not pass because bbb is trying to save a reference to an object owned by aaa:

loadpkg gno.land/r/xx/aaa $WORK/aaa
loadpkg gno.land/r/xx/bbb $WORK/bbb

## start a new node
gnoland start

gnokey maketx call -pkgpath gno.land/r/xx/bbb -func SaveARef -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout 'OK!'

-- aaa/a.gno --
package aaa

var A int

-- bbb/b.gno --
package bbb

import "gno.land/r/xx/aaa"

var B *int

func SaveARef() {
    B = &aaa.A
}