rchain / rchip-proposals

Where RChain improvement proposals can be submitted
Apache License 2.0
8 stars 5 forks source link

rholang 1.1 -> 1.0 dev tool a la babel #48

Open dckc opened 3 years ago

dckc commented 3 years ago

We have a rholang 1.1 implementation in the form of a source-to-source translation to rholang 1.0. Getting this integrated into validator nodes on mainnet involves lots of coordination that will understandably take time, but meanwhile, much like JavaScript developers use babel to translate new features to syntax understood by deployed browsers, we should expose the rholang 1.1 to 1.0 translator as tool so that developers can write rholang 1.1 and translate it rholang 1.0 automatically for deployment.

We could, for example, integrate that with the Rholang Playground - RChain.

ref:

tgrospic commented 2 years ago

We could publish special pre-release with Rholang 1.1 which can be used in evaluated mode to get translation to desugared syntax.

For example this code evaluated with Rholang 1.1

let x <- 1 ; y <- 2 ; z <- 3 in {
  (*x, *y, *z)
}

produces this output

match [1] {
  [x0] => {
    match [2] {
      [x1] => {
        match [3] {
          [x2] => {
            (x0, x1, x2)
          }
        }
      }
    }
  }
}
dckc commented 2 years ago

Exactly.

I was thinking of a standalone jar a la https://github.com/rchain/rchain/tree/dev/rholang#command-line-usage

But anything that can be used from a batch dev tool (npm script, makefile, ...) is fine.

Bill-Kunj commented 2 years ago

I'm glad someone finally brought this to the foreground. Rholang 1.0 is hard for newbies. Rholang 1.1 would be invaluable for new practitioners. @tgrospic How hard will it be to publish a batch tool similar to what @dckc suggests? What can I do to help?

tgrospic commented 2 years ago

@Bill-Kunj I'm suggesting to publish a pre-release with all the artifacts (Docker image, deb package, ...) so it can be used in VSCode extension or with eval command like any other release.

Bill-Kunj commented 2 years ago

This sounds like a great start.

Bill-Kunj commented 2 years ago

@Bill-Kunj I'm suggesting to publish a pre-release with all the artifacts (Docker image, deb package, ...) so it can be used in VSCode extension or with eval command like any other release.

Not being pushy, but I really, really want to try this out. When can I start using it?

tgrospic commented 2 years ago

Rholang 1.1 pre-release (special build) is published: v0.12.4+rholang-1.1-rc1.

Docker image has tag name with __ instead of + and it's published here: v0.12.4__rholang-1.1-rc1.

It's based on v0.12.4 version with some small updates not related to Rholang.

These test can help to understand how the new syntax is desugared to Rholang 1.0.

Enjoy! :partying_face:

dckc commented 2 years ago

Rholang 1.1 pre-release (special build) is published

Thanks!

Enjoy!

I'm struggling to figure out how. Help, please?

I put the example above in r1.rho:

let x <- 1 ; y <- 2 ; z <- 3 in {
  (*x, *y, *z)
}

Now what? How do I convert it to rholang 1.0 using v0.12.4+rholang-1.1-rc1?

I tried:

$ docker run -v/tmp:/tmp -ti --rm rchain/rnode:v0.12.4__rholang-1.1-rc1 eval /tmp/r1.rho
Evaluating from /tmp/r1.rho

Result for /tmp/r1.rho:
Error: Connection refused: localhost/127.0.0.1:40401

then I tried:

$ docker run -d --net host -v/tmp:/tmp --rm rchain/rnode:v0.12.4__rholang-1.1-rc1
0233e39840af1cc97957c1f16e17054d6b3228245d1bbed5bf48d3f2628217f1
$ docker run --net host -v/tmp:/tmp -ti --rm rchain/rnode:v0.12.4__rholang-1.1-rc1 eval /tmp/r1.rho
Evaluating from /tmp/r1.rho

Result for /tmp/r1.rho:
Error: Connection refused: localhost/0:0:0:0:0:0:0:1:40401
tgrospic commented 2 years ago

@dckc You need to run an instance of RNode and call gRPC method eval. This is what CLI eval method is doing.

So first start standalone instance.

$ docker run --name rho -v $PWD/tmp:/tmp -ti --rm rchain/rnode:v0.12.4__rholang-1.1-rc1 run -s

When it's up (unfortunately after the blockchain part is ready) you can call eval to that instance with the same container, so escape all of networking setup. Eval is on private port, so port 40402.

docker exec rho bin/rnode --grpc-port 40402 eval /tmp/r1.rho