forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk/vm)!: only allow using msgcall on realms (gnolang#2242)
<!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> Follow discussion in gnolang#2192 and [TheHowl's comment](gnolang#1538 (comment)), this PR aims to prohibit the use of `maketx call` with a `p/` entrypoint and force `maketx call` to call to a `gno.land/` pkgpath Behavior: ``` $ gnokey maketx call -broadcast -pkgpath gno.land/p/ -gas-wanted 10000000 -gas-fee 1000000ugnot -func Demo -remote localhost:26657 testKey --= Error =-- Data: forbidden/bad package called Msg Traces: 0 ....... deliver transaction failed: log: --= /Error =-- ``` ``` $ gnokey maketx call -broadcast -pkgpath gno.land/p -gas-wanted 10000000 -gas-fee 1000000ugnot -func Demo -remote localhost: 26657 testKey --= Error =-- Data: forbidden/bad package called Msg Traces: 0 ....... deliver transaction failed: log: --= /Error =-- ``` For `stdlibs`, force the pkgpath to begins with `gno.land/` ``` $ gnokey maketx call -broadcast -pkgpath strconv -gas-wanted 10000000 -gas-fee 1000000ugnot -func Itoa -args 11 testKey --= Error =-- Data: forbidden/bad package called Msg Traces: 0 ....... deliver transaction failed: log: --= /Error =-- ``` --------- Co-authored-by: Morgan Bazalgette <[email protected]>
- Loading branch information
Showing
5 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# load the package | ||
loadpkg gno.land/p/foo/call_package $WORK/package | ||
loadpkg gno.land/r/foo/call_realm $WORK/realm | ||
|
||
# start a new node | ||
gnoland start | ||
|
||
# 1. call to package ERROR | ||
! gnokey maketx call -pkgpath gno.land/p/foo/call_package -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stderr '"gnokey" error: --= Error =--\nData: invalid package path' | ||
|
||
# 2. call to stdlibs ERROR | ||
! gnokey maketx call -pkgpath strconv -func Itoa -args 11 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stderr '"gnokey" error: --= Error =--\nData: invalid package path' | ||
|
||
# 3. normal call to realm PASS | ||
gnokey maketx call -pkgpath gno.land/r/foo/call_realm -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
-- package/package.gno -- | ||
package call_package | ||
|
||
func Render() string { | ||
return "notok" | ||
} | ||
|
||
-- realm/realm.gno -- | ||
package call_realm | ||
|
||
func Render() string { | ||
return "ok" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters