Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mopfel-winrux
Copy link
Collaborator

@mopfel-winrux mopfel-winrux commented Jan 24, 2023

I added the ability for the user pick two flags to pass to the eval subroutine.

The first is the --jam flag. This takes the result from the inputted hoon code , +jam's it and outputs it as a hexadecimal string.

The second is the --jamkhan flag. This takes the result from the inputted hoon code, +jam's it and outputs the noun wrapped in the proper %khan header (leading zero, noun size, noun) as binary data.

The proper use of the eval is as follows:
echo "(add 2 2)" | vere eval --jamkhan > test.jam

You can directly inject a |meld command to a running pier as follows:
echo "[1 %urth %meld]" | ./vere eval --jamkhan | nc -U ~/urbit/zod/.urb/conn.sock

This should be the easiest way to +jam a noun for %khan use

This is a clone commit of #6048 on urbit/urbit

@mopfel-winrux mopfel-winrux requested a review from a team as a code owner January 24, 2023 14:14
@jalehman
Copy link

jalehman commented Feb 3, 2023

@barter-simsum would you mind providing an approval if this looks good?

Are there any potential risks with this that you foresee?

@barter-simsum barter-simsum self-assigned this Feb 3, 2023
@barter-simsum
Copy link
Collaborator

Everything else lgtm, mostly nits

@mopfel-winrux
Copy link
Collaborator Author

Made changes and pushed them up

Copy link
Collaborator

@ashelkovnykov ashelkovnykov left a comment

Choose a reason for hiding this comment

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

More style nits

@ashelkovnykov
Copy link
Collaborator

Also, I just realized that --jamkhan is a misnomer, because it has nothing to do with the Khan vane. What it's doing is creating a newt encoded jammed noun; beyond that, the noun could be used for multiple purposes, even by conn.c.

For example, the [1 %urth %meld] from the description is a command to Vere.

@mopfel-winrux What's the use of the --jam option (i.e. who/where needs jammed nouns encoded as hex-strings)? It seems to be consensus that the thin waist of Urbit should be newt-encoded jammed nouns.

@mopfel-winrux
Copy link
Collaborator Author

@ashelkovnykov --jamkhan was the name Joe and I came up with while working on this. I can change it to whatever you'd like.

For example, the [1 %urth %meld] from the description is a command to Vere.

Can you elaborate on this? Doesn't the command still goes to khan and then back to Vere?

The idea of just using --jam and outputting as hex-strings was to use the utility to test out hoon scripts and be able to copy and paste something readable. Again part of my discussion with Joe about this. I'm fine removing it if people feel its necessary.

@jalehman
Copy link

jalehman commented Feb 7, 2023

@ashelkovnykov --jamkhan was the name Joe and I came up with while working on this. I can change it to whatever you'd like.

@joemfb want to weigh in here?

@ashelkovnykov
Copy link
Collaborator

I would remove --jam and rename --jamkhan to --jam. I'd also try to replace the logic in _cw_eval that replicates newt encoding with u3_newt_send. Both of these changes can be done in later commits, if merging this is a priority.

ashelkovnykov
ashelkovnykov previously approved these changes Feb 7, 2023
@joemfb
Copy link
Collaborator

joemfb commented Feb 7, 2023

#197 (comment) has some good context from @ashelkovnykov.

The noun is the exclusive, universal data type of urbit. Jam is universal noun serialization. And the "newt" wire-framing is how we pass around those serialized nouns in a streaming context. Everything in urbit is a noun, +jam is used anytime we want to convert an arbitrary noun to an atom or a byte buffer (nouns are often imported/exported/distributed as "jamfiles"), "newt" is used for all our IPC. The first two will most likely never change, the third is much more contingent (shared-memory IPC is probably the future for mars/urth).

The --jam option is useful if you need a lightweight way to generate a jammed noun, or if you're implementing +jam, +cue, or a new interpreter, or if you're moving nouns between nock interpreters, or if you just want to poke around with implementation details. I don't have an immediate operational use-case for it -- it's just obvious and low-cost.

We'll want to have a +cue command as well, maybe taking a hoon mold as text to control pretty-printing. And a version that can also cope with "newt" wire-framing, for handling responses from conn.

The naming of %khan/conn remains a sore spot and source of confusion -- the relationship between them is quite minimal. The most technically correct names for these arguments would be --jam/-j and --jam-newt (or --jam --newt/-jn). Which isn't to say that they're good. I'm not sure what would be ...

Copy link
Collaborator

@joemfb joemfb left a comment

Choose a reason for hiding this comment

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

this will do

further refactoring, argument tweaks/renames, or additional behaviors (jam into a file vs print the bytes) can come in as needed.

@jalehman jalehman merged commit 0194650 into urbit:develop Feb 8, 2023
ashelkovnykov added a commit that referenced this pull request Mar 9, 2023
Partially Resolves #197

Adds the `--cue` option to the `eval` utility. This allows jammed nouns
to be passed over `stdin` and pretty-printed to `stdout`.

Also includes a sub-option which will expect the incoming jammed noun to
be Khan output. If the thread resulted in a `goof`, it's pretty-printed
to `stderr` as a stack trace and the output is simply the `conn.c`
header info (unique ID, `%avow` mark signalling Khan output, `%.n`
loobean signalling thread failure).

Also includes the "todo"s from the comments for #155.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants