nonodo

command module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

NoNodo

CI Go Report Card

NoNodo is a development node for Cartesi Rollups that was designed to work with applications running in the host machine instead of the Cartesi machine. So, the application developer doesn't need to be concerned with compiling their application to RISC-V. The application back-end should run in the developer's machine and call the Rollup HTTP API to process advance and inspect inputs. NoNodo is a valuable development workflow help, but there are some caveats the developer must be aware of.

Installation

Pre-requisites

NoNodo uses the Anvil as the underlying Ethereum node. To install Anvil, read the instructions on the Foundry book.

Installing from npm
npm i -g nonodo
Binaries

Download the binaries from the relase page.

Installing from source

Installing NoNodo using the go install command is possible. To use this command, install Go following the instructions on the Go website. Then, run the command below to install NoNodo.

go install github.com/calindra/nonodo@latest

The command above installs NoNodo into the bin directory inside the directory defined by the GOPATH environment variable. If you don't set the GOPATH variable, the default install location is $HOME/go/bin. So, to call the nonodo command directly, you should add it to the PATH variable. The command below exemplifies that.

export PATH="$HOME/go/bin:$PATH"

Usage

To start NoNodo with the default configuration, run the command below.

nonodo

With the default configuration, NoNodo starts an Anvil node with the Cartesi Rollups contracts deployed. NoNodo uses the same deployment used by sunodo, so the contract addresses are the same. NoNodo offers some flags to configure Anvil, starting with --anvil-*.

NoNodo exposes the Cartesi Rollups GraphQL (/graphql) and Inspect (/inspect) APIs for the application front-end, and the Rollup (http://127.0.0.1:5004/finish) API for the application back-end. NoNodo uses the HTTP address and port set by the --http-address and --http-port flags. By default, NoNodo binds to the http://127.0.0.1:8080/ address.

Address Book

To display the contract addresses, run:

nonodo address-book

Architecture

NoNodo Architecture

The image above illustrates the interaction between NoNodo, Anvil, and the application front-end and back-end.

Running the Application

NoNodo can run the application back-end as a sub-process. If this process exits, NoNodo will also stop its execution. This option is helpful to keep the whole development context in a single terminal. To use this option, pass the command to run the application after --.

nonodo -- ./my-app
Built-in Echo Application

NoNodo has a built-in echo application that generates a voucher, a notice, and a report for each advance input. The echo also generates a report for each inspect input. This option is useful when testing the application front-end without a working back-end. To start NoNodo with the built-in echo application, use the --enable-echo flag.

nonodo --enable-echo
Flags and Commands

This is useful for searching for more behavior as described in this README. You can see any additional flags or commands with --help like:

nonodo --help
Timeout

You can increase the default timeout by passing a flag. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

nonodo --sm-deadline-advance-state 30s --sm-deadline-inspect-state 30s
Sending inputs

To send an input to the Cartesi application, you may use cast, a command-line tool from the foundry package. For instance, the invocation below sends an input with contents 0xdeadbeef to the running application.

INPUT=0xdeadbeef; \
INPUT_BOX_ADDRESS=0x58Df21fE097d4bE5dCf61e01d9ea3f6B81c2E1dB; \
APPLICATION_ADDRESS=0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e; \
cast send \
    --mnemonic "test test test test test test test test test test test junk" \
    --rpc-url "http://localhost:8545" \
    $INPUT_BOX_ADDRESS "addInput(address,bytes)(bytes32)" $APPLICATION_ADDRESS $INPUT
GraphQL API

NoNodo exposes the GraphQL reader API in the endpoint http://127.0.0.1:8080/graphql. You may access this address to use the GraphQL interactive playground in your web browser. You can also make POST requests directly to the GraphQL API. For instance, the command below gets the number of inputs.

QUERY='query { inputs { totalCount } }'; \
curl \
    -X POST \
    -H 'Content-Type: application/json' \
    -d "{\"query\": \"$QUERY\"}" \
    http://127.0.0.1:8080/graphql
Inspect API

NoNodo exposes the Inspect API in the endpoint http://127.0.0.1:8080/inspect. Like the Rollups Node, you may send inspect requests with GET or POST methods. For instance, the command below sends an inspect input with payload hi to NoNodo.

curl -X POST -d "hi" http://127.0.0.1:8080/inspect
Connecting to Test Net

NoNodo can connect to an external Ethereum node instead of setting up a local Anvil node. To do so, pass the RPC URL to the --rpc-url command-line parameter. When connecting to an external node, you must pass the input-box deployment block number to the parameter --contracts-input-box-block. As an example, the command below reads all the inputs sent to the echo application on the Sepolia test net.

nonodo \
    --enable-echo \
    --contracts-application-address 0x9f12D4365806FC000D6555ACB85c5371b464E506 \
    --contracts-input-box-address 0x59b22D57D4f067708AB0c00552767405926dc768 \
    --contracts-input-box-block 3963384 \
    --rpc-url wss://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY
Connecting to PostGresDB and Graphile locally

Start a PostGres instance locally, "cd" to db folder and use docker-compose.yml example. Set PostGres connection details using environment variables

export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DB=mydatabase
export POSTGRES_USER=myuser
export POSTGRES_PASSWORD=mypassword

When running nonodo, set flag db-implementation with the value postgres

Graphile can be called using http://localhost:5001/graphql and you can test queries using http://localhost:5001/graphiql

You can change Graphile address and port using the flags graphile-url.

nonodo --graphile-url http://mygraphileaddress:5034

Salsa/Lambada Support

You can start a Lambda server using Salsa

nonodo --salsa 

Optionally, you can ser server's host and port

nonodo --salsa --salsa-url 127.0.0.1:8080

Compatibility

NoNodo is compatible with the following version of the Cartesi Rollups.

Component Version
Cartesi Rollups Contracts v1.1.0
Cartesi Rollups Node v1.2.0

Caveats

  • The application will eventually need to be compiled to RISC-V or use a RISC-V runtime in case of interpreted languages;
  • With NoNodo, the application will not be running inside the sandbox of the Cartesi machine and will not block operations that won't be allowed when running inside a Cartesi machine, like accessing remote resources;
  • Inspects, rejects, and exceptions revert the whole machine when running the application in the Cartesi machine; NoNodo cannot simulate this behavior in the host;
  • NoNodo only works for applications that use the Cartesi Rollups HTTP API and doesn't work with applications using the low-level API;
  • Performance inside a Cartesi machine will be much lower than running on the host;
  • Inputs take much longer to arrive when running in testnet and mainnet than the local NoNodo devnet.

Contributors

Made with contributors-img.

Documentation

Overview

This package contains the main function that executes the nonodo command.

Directories

Path Synopsis
api
internal
contracts
This package contains the contract bindings for Cartesi Rollups.
This package contains the contract bindings for Cartesi Rollups.
contracts/generate
This binary generates the Go bindings for the Cartesi Rollups contracts.
This binary generates the Go bindings for the Cartesi Rollups contracts.
devnet/gen-devnet-state
This program gets the devnet state from the devnet Docker image.
This program gets the devnet state from the devnet Docker image.
echoapp
This pkg is a echo application that uses the Cartesi rollup HTTP API.
This pkg is a echo application that uses the Cartesi rollup HTTP API.
echoapp/echoapp
This pkg is a binary for the echo application.
This pkg is a binary for the echo application.
inspect
Package inspect provides primitives to interact with the openapi HTTP API.
Package inspect provides primitives to interact with the openapi HTTP API.
model
The nonodo model uses a shared-memory paradigm to synchronize between threads.
The nonodo model uses a shared-memory paradigm to synchronize between threads.
nonodo
This package contains the nonodo run function.
This package contains the nonodo run function.
reader
This package is responsible for serving the GraphQL reader API.
This package is responsible for serving the GraphQL reader API.
reader/model
This module is a wrapper for the nonodo model that converts the internal types to GraphQL-compatible types.
This module is a wrapper for the nonodo model that converts the internal types to GraphQL-compatible types.
readerclient
This package contains a client for the GraphQL reader API for testing purposes.
This package contains a client for the GraphQL reader API for testing purposes.
rollup
Package rollup provides primitives to interact with the openapi HTTP API.
Package rollup provides primitives to interact with the openapi HTTP API.
supervisor
This package contains a simple supervisor for goroutine workers.
This package contains a simple supervisor for goroutine workers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL