Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(misc/loop): Setup the portal loop infra #1400

Merged
merged 116 commits into from
Mar 19, 2024
Merged

Conversation

albttx
Copy link
Member

@albttx albttx commented Nov 30, 2023

Portal loop infrastructure code.

Linked to: #1239

Contributors' checklist...
  • 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, if any. More info here.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find anything that jumps out to me, but I've pinged @ajnavarro and @gfanton as Docker wizards to give a look as well

Thank you for implementing this 🙏

Copy link
Member

@gfanton gfanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Perhaps you could add a Makefile with simple rules (start, down, switch, ...). As it stands, it can be a bit confusing to understand how to run everything locally. A Makefile would provide clearer visibility on how things work.

Personally, I'm not a big fan of using network host mode, but that's not a deal-breaker for me.

I didn't spend too much time on it, but I wasn't able to run the entire flow from scratch (run and switch) locally. From what I understand, it should be:

$ docker compose up -d
$ docker build -t snapshotter ./snapshotter # I know this one is for cron, but shouldn't I be able to run the script from it?
$ docker run -v ./scripts:/scripts snapshotter /scripts/switch.sh

@albttx
Copy link
Member Author

albttx commented Dec 1, 2023

Good idea @gfanton, i'll implement it

misc/loop/scripts/switch.sh Outdated Show resolved Hide resolved
misc/loop/scripts/switch.sh Outdated Show resolved Hide resolved
misc/loop/scripts/switch.sh Outdated Show resolved Hide resolved
misc/loop/scripts/switch.sh Outdated Show resolved Hide resolved
misc/loop/docker-compose.yml Outdated Show resolved Hide resolved
@zivkovicmilos
Copy link
Member

Pinging @albttx to take a look at @moul's comments so we can unblock this PR 🙏

@albttx
Copy link
Member Author

albttx commented Dec 6, 2023

Sorry @zivkovicmilos i should have replied earlier,
i've almost fixed everything on @moul comments yesterday, Just added last couple things required :)

albttx and others added 15 commits March 7, 2024 13:58
This PR sets `CGO_ENABLED=0` in all top-level makefiles. This comes as a
consequence of a rare occurrence where [bft is actually failing for a
valid
reason](https://github.com/gnolang/gno/actions/runs/8111419409/job/22170651604).
This is the relevant part of the logs:

```
2024-03-01T12:36:50.7818357Z ok  	github.com/gnolang/gno/tm2/pkg/bft/rpc/lib/types	0.004s	coverage: 33.3% of statements
2024-03-01T12:36:50.7853384Z 	github.com/gnolang/gno/tm2/pkg/bft/rpc/test		coverage: 0.0% of statements
2024-03-01T12:36:51.5524659Z # github.com/jmhodges/levigo
2024-03-01T12:36:51.5556601Z ##[error]../../../../go/pkg/mod/github.com/jmhodges/[email protected]/batch.go:4:11: fatal error: leveldb/c.h: No such file or directory
2024-03-01T12:36:51.5567246Z     4 | // #include "leveldb/c.h"
2024-03-01T12:36:51.5567886Z       |           ^~~~~~~~~~~~~
2024-03-01T12:36:51.5568424Z compilation terminated.
2024-03-01T12:36:59.3179828Z FAIL	github.com/gnolang/gno/tm2/pkg/bft/state [build failed]
```

This is likely a consequence of
gnolang#1602. I've additionally made it so
that `bft/state` doesn't require any database it doesn't need in its
tests, but personally I have been repeatedly bitten by finding out CGO
was enabled and compiling in unexpected places (including the Go stdlib)
that I think it makes sense to keep it disabled by default in our
makefiles.

This PR tackles that, and takes the chance to re-organise the overall
structure of makefiles to document prominently the available variables
that can be changed.
<!-- please provide a detailed description of the changes made in this
pull request. -->
This allows for the consensus state's WAL to be disabled. This is
desirable for testing against a running node when we don't care about
the WAL -- it avoids potential permissions issues by not writing
anything to disk. This allows for our integration testing package to be
imported and used outside of the gno repository.
<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>

---------

Co-authored-by: Morgan <[email protected]>
## Description

This PR updates the "Start" button at the navbar to lead to the Local
setup section in the docs. The reason for this is that the link has had
a change in a previous PR and doesn't take the user to where it was
intended - with this PR that is fixed.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] 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>
## Description

Based on discussions in gnolang#1593, this PR introduces the CLI suite for
manipulating the `config.toml`. Using this suite, we can build better
workflows for power users.

This PR is a series of lego blocks that are required for us to get a
normal user chain connection going:
- gnolang#1252 - solved `genesis.json` management and manipulation
- gnolang#1593 - solved node secrets management and manipulation
- this PR - solves `config.toml` management and manipulation

All of these PRs get us to a point where the user can run:
- `gnoland init`
- `gnoland start`

to get up and running with any Gno network. The added middle step is
fine-tuning the configuration and genesis, but it's worth noting this
step is optional.

New commands:
```shell
gnoland config --help             
USAGE
  config <subcommand> [flags]

Gno config manipulation suite, for editing base and module configurations

SUBCOMMANDS
  init  Initializes the Gno node configuration
  set   Edits the Gno node configuration
  get   Shows the Gno node configuration
```

In short, the `gnoland config init` command initializes a default
`config.toml`, while other subcommands allow editing
 viewing any field in the specific configuration.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] 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>
## Description

This PR replaces the "Start" button with the "Docs" button on the
gno.land home page navbar, and adds a "Home" button to the docs navbar
to interlink the websites in a nice manner. It also fixes a small typo
in the GoR page.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] 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>
I was taking a look at what packages we have in tm2/pkg and realised we
had an entire package to do what are, since go 1.21, builtin functions.

This PR removes tm2/pkg/maths in favour of the now standard and generic
go implementation of the same functionality.
# Description

Added the `Errorf` function to `ufmt` based on `ufmt.Sprintf`. 

Previously, formatting errors involved a method like using
`errors.New(ufmt.Sprintf(XXX))`, but this approach is not only
cumbersome but also, as using `Errorf` is recommended in Go, I have
newly incorporated it.

## Usage

### Simple Error

This example demonstrates the process of using `Errorf` to format and
print error messages.

```go
package main

import (
	"gno.land/p/demo/ufmt"
)

func foo() error {
	return fmt.Errorf("an error occurred in simpleFunction")
}

func main() {
	if err := foo(); err != nil {
             println("Error:", err)
	}
}
```

### With Panic

Using panic is the recommended practice in [effective
gno](<https://docs.gno.land/concepts/effective-gno/#embrace-panic>), In
this example, format the error and then output the error message with
`panic`.

```go
package main

import (
	"gno.land/p/demo/ufmt"
)


func foo() {
	msg := ufmt.Errorf("error: %s", "something went wrong")
	panic(msg)
}
```

---------

Co-authored-by: Morgan <[email protected]>
This PR removes the old faucet implementation to utilize the new
[gnolang/faucet](https://github.com/gnolang/faucet).

Additional things done:
- subnet throttler tidied, made thread safe
- gnoweb faucet page fixed (invalid template values)

Breaking change:
- Gnoweb now interacts with the faucet differently than it did before
(POST request instead of a form submission).

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] 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>
…rorf` (gnolang#1772)

## Description

Replace previouse formatted error creations with `fmt.Errof` (in gno,
`ufmt.Errorf`) to simplify error creation and formatting.

Follow up for PR gnolang#1767
add missing imports and modified the call to `AddressOrName()` by adding
an alias `pusers` to access the `users` package functions. And modified
calls to `Resolve()` by adding the prefix `users`.

<!-- 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>

Co-authored-by: Leon Hudak <[email protected]>
Specify that you need to import the `bytes` library

<!-- 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>

Co-authored-by: Leon Hudak <[email protected]>
## Description

This PR fixes the Blog link from the navbar. It was outdated, pointing
to test3 - now it points to the Portal Loop blog.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] 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>
@albttx albttx requested review from jaekwon, piux2 and a team as code owners March 15, 2024 16:22
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Mar 15, 2024
misc/loop/.gitignore Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration, at least the traefik server, doesn't seem to work on localhost. (Missing letsencrypt stuff)

I'm OK if we want to only support the production mode for simplicity, but if so we should make it clear (in README) and swap out the docker-compose file.

misc/loop/docker-compose.production.yml Show resolved Hide resolved
misc/loop/docker-compose.production.yml Show resolved Hide resolved
misc/loop/scripts/start.sh Show resolved Hide resolved
misc/loop/scripts/start.sh Show resolved Hide resolved
misc/loop/cmd/cmd_serve.go Show resolved Hide resolved
misc/loop/cmd/portal-loop.go Show resolved Hide resolved
"time"

"github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not conform on using slog + zap as the monorepo in general is?

Comment on lines +107 to +108
regex := regexp.MustCompile(`http://.*:[0-9]+`)
output := regex.ReplaceAllLiteral(input, []byte(url))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hack, but it works. One thing to note though...

This is modifying the file in a volume, modifying directly the files tracked by git. This has an implication: if the code updates on the traefik configuration on Git, git pull will fail if portalloopd has modified the traefik config file.

Suggestion: maybe make gno.yml a template which is modified by portalloopd, so we have a gno.yml.template (tracked with git) and a gno.yml (untracked)...

@moul moul merged commit b93032a into gnolang:master Mar 19, 2024
181 of 182 checks passed
@moul
Copy link
Member

moul commented Mar 19, 2024

Merged to create an initial version for easier iteration now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: 🚀 Needed for Launch
Status: Done
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants