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

WIP book.gno #1224

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft

WIP book.gno #1224

wants to merge 28 commits into from

Conversation

jaekwon
Copy link
Contributor

@jaekwon jaekwon commented Oct 11, 2023

This is a concept for a book (basically a list).
A Book has a title, owner, etc.
A Book can be forked.
Books can be components of a virtual Person (where a Person is an interface).

TODO: maybe I should move these experiments to another repo.

@jaekwon jaekwon requested a review from a team as a code owner October 11, 2023 00:21
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Oct 11, 2023
@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b34816b) 47.82% compared to head (62b9196) 48.08%.
Report is 60 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1224      +/-   ##
==========================================
+ Coverage   47.82%   48.08%   +0.26%     
==========================================
  Files         369      368       -1     
  Lines       62710    62566     -144     
==========================================
+ Hits        29992    30086      +94     
+ Misses      30295    30054     -241     
- Partials     2423     2426       +3     

see 43 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@moul
Copy link
Member

moul commented Oct 11, 2023

TODO: maybe I should move these experiments to another repo.

It's up to you, but you're welcome to stay here. We're increasingly allowing "personal realms" in the repository, as mentioned in issue #1138.

I believe it's logical to keep most of the experiments, such as Carmel, books, Wikipedia, etc., in this repository by default. We can consider making them more autonomous to reduce noise, like when we have multiple pull requests.

Up to you!

@jaekwon
Copy link
Contributor Author

jaekwon commented Oct 15, 2023

manfred also mentioned #1244

@jaekwon
Copy link
Contributor Author

jaekwon commented Oct 16, 2023

Also see #1244 (comment)

func (book Book) Execute(action Action) error {
    // makes sure the action signatures, sequence, etc are valid.
    if err != book.Owner.Append(action); err != nil {
        return err
    }
    // the logic below could use permissions if it wanted to, or not.
    switch action.(type) {
    case: WriteAction:
    case: ReadAction:
    default: return UnrecognizedError()
    }
}

As long as it's assumed that the action will complete in one transaction, this is fine; although we are also assuming that the programmer programs such that ultimately there is a panic upon some error.

Or maybe this is desired sometimes:

func (book Book) Execute(action Action) error {
    // makes sure the action signatures, sequence, etc are valid.
    x, err := book.Owner.Reserve(action)
    if err != nil { 
        return err
    }
    // the logic below could use permissions if it wanted to, or not.
    switch action.(type) {
    case: WriteAction:
    case: ReadAction:
    default: return UnrecognizedError()
    }
    // signal that the execution reserved is complete.
    x.Done()
}

Or javascript closure like:

func (book Book) Execute(action Action) error {
    // first reserves, or panics if error
    book.Owner.Execute(action, func() {
        // if reservation was complete:
        // the logic below could use permissions if it wanted to, or not.
        switch action.(type) {
        case: WriteAction:
        case: ReadAction:
        default: return UnrecognizedError()
        }
    });
}

which feels wrong.


Some thoughts on Action...

// object has an action verb (method), which takes arguments
type Action struct {
    subject // is this an id? 
    verb // i guess a string or Name type?
    object // is this an id?
    arguments // are these primitive strings or any
}

// Authorization struct is only needed for Actions that require
// cryptographic authorization, where the Action's subject has
// a pubkey to verify signatures with.
//
// Presumably once Authorization is validated (signature checked)
// the Action becomes committed, and given a index number.
type Authorization struct {
    action Action
    signatures []Signature
}

type Signature struct {
    account number // or address with some extra data unknown
    sequence number // or alternative to sequence
    signature []byte
}

Msg:Tx :: Action:Authorization here, except

type Msg interface {
        Route() string
        Type() string
        ValidateBasic() error
        GetSignBytes() []byte
        GetSigners() []crypto.Address
}
type Tx struct {
        Msgs []Msg
        Fee Fee
        Signatures []Signature
        Memo string
}

Interesting correspondences

  • Action.subject corresponds to Msg.Route
  • Action.verb corresponds to Msg.Type
  • Action.object and Action.arguments are in the concrete fields of the Msg
  • Authorization.Signatures[].sequence and .account included for client convenience (optional?)

*/

// XXX open questions
// * Do we want a directory?
Copy link
Member

Choose a reason for hiding this comment

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

Yes, we need an equivalent of std.Address specifically for objects. The directory will function as the object catalog, similar to how the tm2 account module handles key-based accounts.

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Oct 25, 2023
Copy link

netlify bot commented Nov 13, 2023

Deploy Preview for gno-docs2 failed.

Name Link
🔨 Latest commit 62b9196
🔍 Latest deploy log https://app.netlify.com/sites/gno-docs2/deploys/65519a26eee9dc0008654f34

@moul moul marked this pull request as draft January 8, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: 🌟 Wanted for Launch
Development

Successfully merging this pull request may close these issues.

3 participants