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

feat: adding home realm for r/n2p5/home and supporting packages #3183

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

n2p5
Copy link
Contributor

@n2p5 n2p5 commented Nov 22, 2024

TLDR

There's no place like home. This PR is for gno code in /r/n2p5/home and its supporting packages and realms. This is a more extensive PR than I'd hoped, but it is because I ended up structuring out two new little packages chonk and group, as well as a config pattern that works for my home realm, but is reusable as well.

If you like this, vote for me on Leon's Hall of Fame

Summary of changes

/p/n2p5/chonk

chonk is a linked-list based string chunker. This allows for arbitrarily large strings to be stored on-chain across multiple transactions. The original idea for this was to be able to support large Render(path string) string calls. You can think of this as supporting a "static site generator" pattern, where Markdown can be broken up into chunks and then rendered as one large payload. It is used directly in /r/n2p5/home.

/p/n2p5/mgroup

mgroup (Managed Group) is a bit like authorizable, but the goals are a bit different. I wanted a "managed group" with a single ownable owner, but I wanted an arbitrary list of "backup owners," which are accounts that could "claim" ownership if the owner account became unavailable. I also wanted to be able to manage the group members themselves. Another difference here is has the ability to return information about the group such as

  • a list of all backup owners (there is a method for the complete list, but also a method for an offset and max count iterator for large groups)
  • a list of all members (there is a method for the complete list, but also a method for an offset and max count iterator for large groups)

/r/n2p5/config

Inspired by the config work done by @moul and @leohhhn for their home realms, I decided to take a crack at it as well. This config allows me to use mgroup to manage the config auth. This allows me to power cross-realm auth using this config realm, and it powers the auth for my home realm.

/r/n2p5/home

Bringing this all together, the home realm uses chonk and /r/n2p5/config to Render the Markdown stored in the chonk data store. Because you might submit data over multiple transactions, I've added the ability to "preview" and "promote" render data, you can see this in the two variations on the URL:

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

@n2p5 n2p5 requested review from wyhaines and leohhhn November 22, 2024 13:02
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

Looks cool! Thanks for adding more things to your namespace.

About mgroup; we currently have authorizable, but we also have acl. They serve different purposes, but it might make sense to unify them somehow, or not. WDYT?

Also please just check why the CI is failing.

@n2p5
Copy link
Contributor Author

n2p5 commented Nov 26, 2024

Looks cool! Thanks for adding more things to your namespace.

About mgroup; we currently have authorizable, but we also have acl. They serve different purposes, but it might make sense to unify them somehow, or not. WDYT?

Also please just check why the CI is failing.

Yeah, mgroup took a lot of inspiration from authorizable but I wanted the ability to list out who was in the group, etc. I'd love to chat about authz and ACL patterns at some point. Sounds fun. Something like Casbin could be cool, where there is a CONF language that could be saved as a variable and evaluated could be an interesting area to explore.

@n2p5 n2p5 merged commit 0e1016b into gnolang:master Nov 26, 2024
98 checks passed
r3v4s pushed a commit to gnoswap-labs/gno that referenced this pull request Dec 10, 2024
…ang#3183)

# TLDR

There's no place like [home](https://gno.land/r/n2p5/home). This PR is
for `gno` code in [/r/n2p5/home](https://gno.land/r/n2p5/home) and its
supporting packages and realms. This is a more extensive PR than I'd
hoped, but it is because I ended up structuring out two new little
packages [chonk]() and [group](), as well as a [config]() pattern that
works for my home realm, but is reusable as well.

If you like this, vote for me on [Leon's Hall of
Fame](https://gno.land/r/leon/hof)

# Summary of changes

## [/p/n2p5/chonk](https://gno.land/p/n2p5/chonk/)
`chonk` is a linked-list based string chunker. This allows for
arbitrarily large strings to be stored on-chain across multiple
transactions. The original idea for this was to be able to support large
`Render(path string) string` calls. You can think of this as supporting
a "static site generator" pattern, where Markdown can be broken up into
chunks and then rendered as one large payload. It is used directly in
`/r/n2p5/home`.

## [/p/n2p5/mgroup](https://gno.land/p/n2p5/mgroup/)
`mgroup` (Managed Group) is a bit like `authorizable,` but the goals are
a bit different. I wanted a "managed group" with a single `ownable`
owner, but I wanted an arbitrary list of "backup owners," which are
accounts that could "claim" ownership if the owner account became
unavailable. I also wanted to be able to manage the group members
themselves. Another difference here is has the ability to return
information about the group such as
- a list of all backup owners (there is a method for the complete list,
but also a method for an offset and max count iterator for large groups)
- a list of all members (there is a method for the complete list, but
also a method for an offset and max count iterator for large groups)

## [/r/n2p5/config](https://gno.land/r/n2p5/config)
Inspired by the config work done by @moul and @leohhhn for their home
realms, I decided to take a crack at it as well. This config allows me
to use `mgroup` to manage the config auth. This allows me to power
cross-realm auth using this config realm, and it powers the auth for my
home realm.

## [/r/n2p5/home](https://gno.land/r/n2p5/home)
Bringing this all together, the home realm uses `chonk` and
`/r/n2p5/config` to Render the Markdown stored in the chonk data store.
Because you might submit data over multiple transactions, I've added the
ability to "preview" and "promote" render data, you can see this in the
two variations on the URL:
- https://gno.land/r/n2p5/home
- https://gno.land/r/n2p5/home:preview


<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
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Development

Successfully merging this pull request may close these issues.

2 participants