Skip to content

Commit

Permalink
Merge branch 'master' into gnovm-report-indexList-handling-explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl authored Feb 24, 2025
2 parents 59524ef + 300dcfd commit ae8820a
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 24 deletions.
6 changes: 3 additions & 3 deletions docs/concepts/namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ similar to GitHub's user and organization model.

:::warning Not enabled

This feature isn't enabled by default on the portal loop chain and is currently available only on test4.gno.land.
This feature isn't enabled by default on the Portal Loop chain and is currently available only on test5.gno.land.

:::

Expand Down Expand Up @@ -56,7 +56,7 @@ $ gnokey maketx call -pkgpath gno.land/r/demo/users \
-func Register \
-gas-fee 1000000ugnot -gas-wanted 2000000 \
-broadcast \
-chainid=test4 \
-chainid=test5 \
-send=20000000ugnot \
-args '' \
-args 'patrick' \
Expand Down Expand Up @@ -86,6 +86,6 @@ $ gnokey maketx addpkg \
--gas-fee 1000000ugnot \
--gas-wanted 2000000 \
--broadcast \
--chainid test4 \
--chainid test5 \
test1
```
22 changes: 7 additions & 15 deletions docs/concepts/testnets.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,6 @@ Test5 was launched in November 2024.
- **Versioning strategy**:
- Test5 is to be release-based, following releases of the Gno tech stack.

## Test4

Test4 is the first permanent multi-node testnet, launched in July 2024.

- **Persistence of state:**
- State is fully persisted unless there are breaking changes in a new release,
where persistence partly depends on implementing a migration strategy
- **Timeliness of code:**
- Versioning mechanisms for packages & realms will be implemented for test4
- **Intended purpose**
- Running a full node, testing validator coordination, deploying stable Gno
dApps, creating tools that require persisted state & transaction history
- **Versioning strategy**:
- Test4 is the first gno.land testnet to be release-based, following releases
of the Gno tech stack.

## Staging

Expand All @@ -98,6 +83,13 @@ Staging is a testnet that is reset once every 60 minutes.

These testnets are deprecated and currently serve as archives of previous progress.

## Test4

Test4 is the first permanent multi-node testnet. Archived data for test4 can be found [here](https://github.com/gnolang/tx-exports/tree/main/test4.gno.land).

Launch date: July 10th 2024
Release commit: [194903d](https://github.com/gnolang/gno/commit/194903db0350ace7d57910e6c34125d3aa9817da)

### Test3 (archive)

The third Gno testnet. Archived data for test3 can be found [here](https://github.com/gnolang/tx-exports/tree/main/test3.gno.land).
Expand Down
1 change: 0 additions & 1 deletion docs/reference/network-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ id: network-config
|-------------|----------------------------------|---------------|
| Portal Loop | https://rpc.gno.land:443 | `portal-loop` |
| Test5 | https://rpc.test5.gno.land:443 | `test5` |
| Test4 | https://rpc.test4.gno.land:443 | `test4` |
| Staging | https://rpc.staging.gno.land:443 | `staging` |

### WebSocket endpoints
Expand Down
3 changes: 3 additions & 0 deletions gno.land/pkg/sdk/vm/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ func (msg MsgCall) ValidateBasic() error {
if !gno.IsRealmPath(msg.PkgPath) {
return ErrInvalidPkgPath("pkgpath must be of a realm")
}
if _, isInt := gno.IsInternalPath(msg.PkgPath); isInt {
return ErrInvalidPkgPath("pkgpath must not be of an internal package")
}
if msg.Func == "" { // XXX
return ErrInvalidExpr("missing function to call")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ func TestMsgCall_ValidateBasic(t *testing.T) {
},
expectErr: InvalidPkgPathError{},
},
{
name: "pkgPath should not be an internal path",
msg: MsgCall{
Caller: caller,
PkgPath: "gno.land/r/demo/avl/internal/sort",
Func: funcName,
Args: args,
Send: std.Coins{std.Coin{
Denom: "ugnot",
Amount: 1000,
}},
},
expectErr: InvalidPkgPathError{},
},
{
name: "missing function name to call",
msg: MsgCall{
Expand Down
8 changes: 7 additions & 1 deletion gnovm/pkg/gnolang/gonative.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math"
"reflect"
"unsafe"

"github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat"
)
Expand Down Expand Up @@ -1133,7 +1134,12 @@ func gno2GoValue(tv *TypedValue, rv reflect.Value) (ret reflect.Value) {
if ftv.IsUndefined() {
continue
}
gno2GoValue(ftv, rv.Field(i))
fv := rv.Field(i)
if !fv.CanSet() {
// Normally private fields can not bet set via reflect. Override this limitation.
fv = reflect.NewAt(fv.Type(), unsafe.Pointer(fv.UnsafeAddr())).Elem()
}
gno2GoValue(ftv, fv)
}
case *MapType:
// If uninitialized map, return zero value.
Expand Down
16 changes: 16 additions & 0 deletions gnovm/pkg/gnolang/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ func IsRealmPath(pkgPath string) bool {
!ReGnoRunPath.MatchString(pkgPath)
}

// IsInternalPath determines whether the given pkgPath refers to an internal
// package, that may not be called directly or imported by packages that don't
// share the same root.
//
// If isInternal is true, base will be set to the root of the internal package,
// which must also be an ancestor or the same path that imports the given
// internal package.
func IsInternalPath(pkgPath string) (base string, isInternal bool) {
// Restrict imports to /internal packages to a package rooted at base.
var suff string
base, suff, isInternal = strings.Cut(pkgPath, "/internal")
// /internal should be either at the end, or be a part: /internal/
isInternal = isInternal && (suff == "" || suff[0] == '/')
return
}

// IsPurePackagePath determines whether the given pkgpath is for a published Gno package.
// It only considers "pure" those starting with gno.land/p/, so it returns false for
// stdlib packages and MsgRun paths.
Expand Down
5 changes: 1 addition & 4 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -4822,10 +4822,7 @@ func tryPredefine(store Store, pkg *PackageNode, last BlockNode, d Decl) (un Nam
panic("cannot import stdlib internal/ package outside of standard library")
}

// Restrict imports to /internal packages to a package rooted at base.
base, suff, isInternal := strings.Cut(d.PkgPath, "/internal")
// /internal should be either at the end, or be a part: /internal/
isInternal = isInternal && (suff == "" || suff[0] == '/')
base, isInternal := IsInternalPath(d.PkgPath)
if isInternal &&
pkg.PkgPath != base &&
!strings.HasPrefix(pkg.PkgPath, base+"/") {
Expand Down
15 changes: 15 additions & 0 deletions gnovm/tests/files/struct59.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import "fmt"

type X struct {
v string
}

func main() {
x := X{v: "a"}
fmt.Printf("test %#v\n", x)
}

// Output:
// test struct { v string }{v:"a"}

0 comments on commit ae8820a

Please sign in to comment.