Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/no-te…
Browse files Browse the repository at this point in the history
…sting-stdlibs-gnoland
  • Loading branch information
thehowl committed Feb 6, 2025
2 parents b95b084 + dd0360d commit 11ab256
Show file tree
Hide file tree
Showing 150 changed files with 3,500 additions and 805 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# generate Go docs and publish on gh-pages branch
# Live at: https://gnolang.github.io/gno
name: Go Reference Docs Deployment
name: GitHub pages (godoc & stdlib_diff) build and deploy

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

permissions:
Expand All @@ -19,29 +22,39 @@ concurrency:

jobs:
build:
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
if: github.repository == 'gnolang/gno' # Alternatively, validate based on provided tokens and permissions.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
- run: echo $GOROOT
# Use the goroot at the top of the project to compare with the GnoVM
# stdlib, rather than the one in stdlib_diff (which may have a go.mod with
# a different toolchain version).
- run: echo "GOROOT_SAVE=$(go env GOROOT)" >> $GITHUB_ENV
- run: "cd misc/stdlib_diff && make gen"
- run: "cd misc/gendocs && make install gen"
- run: "mkdir -p pages_output/stdlib_diff"
- run: |
cp -r misc/gendocs/godoc/* pages_output/
cp -r misc/stdlib_diff/stdlib_diff/* pages_output/stdlib_diff/
# These two last steps will be skipped on pull requests
- uses: actions/configure-pages@v5
id: pages
if: github.event_name != 'pull_request'

- uses: actions/upload-pages-artifact@v3
if: github.event_name != 'pull_request'
with:
path: ./pages_output

deploy:
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
if: >
github.repository == 'gnolang/gno' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: github-pages
Expand Down
19 changes: 14 additions & 5 deletions contribs/github-bot/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
auto := []AutomaticCheck{
{
Description: "Maintainers must be able to edit this pull request ([more info](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork))",
If: c.CreatedFromFork(),
Then: r.MaintainerCanModify(),
If: c.And(
c.BaseBranch("^master$"),
c.CreatedFromFork(),
),
Then: r.MaintainerCanModify(),
},
{
Description: "Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff",
If: c.FileChanged(gh, "^docs/"),
If: c.And(
c.BaseBranch("^master$"),
c.FileChanged(gh, "^docs/"),
),
Then: r.And(
r.Or(
r.AuthorInTeam(gh, "tech-staff"),
Expand All @@ -57,7 +63,10 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
},
{
Description: "Pending initial approval by a review team member, or review from tech-staff",
If: c.Not(c.AuthorInTeam(gh, "tech-staff")),
If: c.And(
c.BaseBranch("^master$"),
c.Not(c.AuthorInTeam(gh, "tech-staff")),
),
Then: r.
If(r.Or(
r.ReviewByOrgMembers(gh).WithDesiredState(utils.ReviewStateApproved),
Expand Down Expand Up @@ -91,7 +100,7 @@ func Config(gh *client.GitHub) ([]AutomaticCheck, []ManualCheck) {
{
Description: "Determine if infra needs to be updated before merging",
If: c.And(
c.BaseBranch("master"),
c.BaseBranch("^master$"),
c.Or(
c.FileChanged(gh, `Dockerfile`),
c.FileChanged(gh, `^misc/deployments`),
Expand Down
10 changes: 4 additions & 6 deletions docs/gno-tooling/cli/gnokey/state-changing-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ Next, let's configure the `addpkg` subcommand to publish this package to the
the `example/p/` folder, the command will look like this:

```bash
gnokey maketx addpkg \
gnokey maketx addpkg \
-pkgpath "gno.land/p/<your_namespace>/hello_world" \
-pkgdir "." \
-send "" \
-gas-fee 10000000ugnot \
-gas-wanted 8000000 \
-gas-wanted 200000 \
-broadcast \
-chainid portal-loop \
-remote "https://rpc.gno.land:443"
Expand All @@ -114,15 +113,14 @@ Once we have added a desired [namespace](../../../concepts/namespaces.md) to upl
a keypair name to use to execute the transaction:

```bash
gnokey maketx addpkg \
gnokey maketx addpkg \
-pkgpath "gno.land/p/examplenamespace/hello_world" \
-pkgdir "." \
-send "" \
-gas-fee 10000000ugnot \
-gas-wanted 200000 \
-broadcast \
-chainid portal-loop \
-remote "https://rpc.gno.land:443"
-remote "https://rpc.gno.land:443" \
mykey
```

Expand Down
12 changes: 0 additions & 12 deletions docs/reference/stdlibs/std/chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ id: chain

# Chain-related

## IsOriginCall
```go
func IsOriginCall() bool
```
Checks if the caller of the function is an EOA. Returns **true** if caller is an EOA, **false** otherwise.

#### Usage
```go
if !std.IsOriginCall() {...}
```
---

## AssertOriginCall
```go
func AssertOriginCall()
Expand Down
171 changes: 87 additions & 84 deletions examples/gno.land/p/demo/btree/btree_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -523,99 +523,22 @@ func TestBTree(t *testing.T) {
}
}

func TestStress(t *testing.T) {
// Loop through creating B-Trees with a range of degrees from 3 to 12, stepping by 3.
// Insert 1000 records into each tree, then search for each record.
// Delete half of the records, skipping every other one, then search for each record.

for degree := 3; degree <= 12; degree += 3 {
t.Logf("Testing B-Tree of degree %d\n", degree)
tree := New(WithDegree(degree))

// Insert 1000 records
t.Logf("Inserting 1000 records\n")
for i := 0; i < 1000; i++ {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
tree.Insert(content)
}

// Search for all records
for i := 0; i < 1000; i++ {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
val := tree.Get(content)
if val == nil {
t.Errorf("Expected key %v, but didn't find it", content.Key)
}
}

// Delete half of the records
for i := 0; i < 1000; i += 2 {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
tree.Delete(content)
}

// Search for all records
for i := 0; i < 1000; i++ {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
val := tree.Get(content)
if i%2 == 0 {
if val != nil {
t.Errorf("Didn't expect key %v, but found key:value %v:%v", content.Key, val.(Content).Key, val.(Content).Value)
}
} else {
if val == nil {
t.Errorf("Expected key %v, but didn't find it", content.Key)
}
}
}
}

// Now create a very large tree, with 100000 records
// Then delete roughly one third of them, using a very basic random number generation scheme
// (implement it right here) to determine which records to delete.
// Print a few lines using Logf to let the user know what's happening.

t.Logf("Testing B-Tree of degree 10 with 100000 records\n")
tree := New(WithDegree(10))

// Insert 100000 records
t.Logf("Inserting 100000 records\n")
for i := 0; i < 100000; i++ {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
tree.Insert(content)
}

// Implement a very basic random number generator
seed := 0
random := func() int {
seed = (seed*1103515245 + 12345) & 0x7fffffff
return seed
}

// Delete one third of the records
t.Logf("Deleting one third of the records\n")
for i := 0; i < 35000; i++ {
content := Content{Key: random() % 100000, Value: fmt.Sprintf("Value_%d", i)}
tree.Delete(content)
}
}

// Write a test that populates a large B-Tree with 10000 records.
// Write a test that populates a large B-Tree with 1000 records.
// It should then `Clone` the tree, make some changes to both the original and the clone,
// And then clone the clone, and make some changes to all three trees, and then check that the changes are isolated
// to the tree they were made in.

func TestBTreeCloneIsolation(t *testing.T) {
t.Logf("Creating B-Tree of degree 10 with 10000 records\n")
tree := genericSeeding(New(WithDegree(10)), 10000)
t.Logf("Creating B-Tree of degree 10 with 1000 records\n")
size := 1000
tree := genericSeeding(New(WithDegree(10)), size)

// Clone the tree
t.Logf("Cloning the tree\n")
clone := tree.Clone()

// Make some changes to the original and the clone
t.Logf("Making changes to the original and the clone\n")
for i := 0; i < 10000; i += 2 {
for i := 0; i < size; i += 2 {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
tree.Delete(content)
content = Content{Key: i + 1, Value: fmt.Sprintf("Value_%d", i+1)}
Expand All @@ -628,7 +551,7 @@ func TestBTreeCloneIsolation(t *testing.T) {

// Make some changes to all three trees
t.Logf("Making changes to all three trees\n")
for i := 0; i < 10000; i += 3 {
for i := 0; i < size; i += 3 {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
tree.Delete(content)
content = Content{Key: i, Value: fmt.Sprintf("Value_%d", i+1)}
Expand All @@ -639,7 +562,7 @@ func TestBTreeCloneIsolation(t *testing.T) {

// Check that the changes are isolated to the tree they were made in
t.Logf("Checking that the changes are isolated to the tree they were made in\n")
for i := 0; i < 10000; i++ {
for i := 0; i < size; i++ {
content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
val := tree.Get(content)

Expand Down Expand Up @@ -676,3 +599,83 @@ func TestBTreeCloneIsolation(t *testing.T) {
}
}
}

// --------------------
// Stress tests. Disabled for testing performance

//func TestStress(t *testing.T) {
// // Loop through creating B-Trees with a range of degrees from 3 to 12, stepping by 3.
// // Insert 1000 records into each tree, then search for each record.
// // Delete half of the records, skipping every other one, then search for each record.
//
// for degree := 3; degree <= 12; degree += 3 {
// t.Logf("Testing B-Tree of degree %d\n", degree)
// tree := New(WithDegree(degree))
//
// // Insert 1000 records
// t.Logf("Inserting 1000 records\n")
// for i := 0; i < 1000; i++ {
// content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
// tree.Insert(content)
// }
//
// // Search for all records
// for i := 0; i < 1000; i++ {
// content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
// val := tree.Get(content)
// if val == nil {
// t.Errorf("Expected key %v, but didn't find it", content.Key)
// }
// }
//
// // Delete half of the records
// for i := 0; i < 1000; i += 2 {
// content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
// tree.Delete(content)
// }
//
// // Search for all records
// for i := 0; i < 1000; i++ {
// content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
// val := tree.Get(content)
// if i%2 == 0 {
// if val != nil {
// t.Errorf("Didn't expect key %v, but found key:value %v:%v", content.Key, val.(Content).Key, val.(Content).Value)
// }
// } else {
// if val == nil {
// t.Errorf("Expected key %v, but didn't find it", content.Key)
// }
// }
// }
// }
//
// // Now create a very large tree, with 100000 records
// // Then delete roughly one third of them, using a very basic random number generation scheme
// // (implement it right here) to determine which records to delete.
// // Print a few lines using Logf to let the user know what's happening.
//
// t.Logf("Testing B-Tree of degree 10 with 100000 records\n")
// tree := New(WithDegree(10))
//
// // Insert 100000 records
// t.Logf("Inserting 100000 records\n")
// for i := 0; i < 100000; i++ {
// content := Content{Key: i, Value: fmt.Sprintf("Value_%d", i)}
// tree.Insert(content)
// }
//
// // Implement a very basic random number generator
// seed := 0
// random := func() int {
// seed = (seed*1103515245 + 12345) & 0x7fffffff
// return seed
// }
//
// // Delete one third of the records
// t.Logf("Deleting one third of the records\n")
// for i := 0; i < 35000; i++ {
// content := Content{Key: random() % 100000, Value: fmt.Sprintf("Value_%d", i)}
// tree.Delete(content)
// }
//}
13 changes: 7 additions & 6 deletions examples/gno.land/p/demo/diff/diff_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,13 @@ func TestMyersDiff(t *testing.T) {
new: strings.Repeat("b", 1000),
expected: "[-" + strings.Repeat("a", 1000) + "][+" + strings.Repeat("b", 1000) + "]",
},
{
name: "Very long strings",
old: strings.Repeat("a", 10000) + "b" + strings.Repeat("a", 10000),
new: strings.Repeat("a", 10000) + "c" + strings.Repeat("a", 10000),
expected: strings.Repeat("a", 10000) + "[-b][+c]" + strings.Repeat("a", 10000),
},
//{ // disabled for testing performance
// XXX: consider adding a flag to run such tests, not like `-short`, or switching to a `-bench`, maybe.
// name: "Very long strings",
// old: strings.Repeat("a", 10000) + "b" + strings.Repeat("a", 10000),
// new: strings.Repeat("a", 10000) + "c" + strings.Repeat("a", 10000),
// expected: strings.Repeat("a", 10000) + "[-b][+c]" + strings.Repeat("a", 10000),
//},
}

for _, tc := range tests {
Expand Down
Loading

0 comments on commit 11ab256

Please sign in to comment.