diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md index 817cffb7..a09ef8a5 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md @@ -3,18 +3,16 @@ id: introduction title: Introduction --- -The backend of a Cartesi dApp retrieves a new request as follows: +The backend of a Cartesi dApp processes requests in the following manner: -- Finish — Communicates that any previous processing has been completed and that the backend is ready to handle the subsequent request. This following request is returned as the call's response and can be of the following types: + - **Finish** — Called via [`/finish`](./finish.md), indicates that any previous processing has been completed and the backend is ready to handle the next request. The subsequent request is returned as the call's response and can be of the following types: - - **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an `Advance` request, the backend can call the methods `/voucher`, `/notice`, and `/report`. For such requests, the input data contains the payload and metadata, such as the account address that submitted the input. + - **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an Advance request, the backend can call the [`/voucher`](./vouchers.md), and [`/report`](./reports.md) endpoints. For such requests, the input data contains both the payload and metadata, including the account address that submitted the input. - - **Inspect** — This function submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged since the machine is reverted to its exact previous condition after processing. For Inspect requests, the input data has only a payload. - - :::caution Inspect requests - Inspect requests are best suited for non-production use, such as debugging and testing. They may not function reliably in production environments, potentially leading to errors or disruptions. - ::: + - **Inspect** — Submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged, as the machine reverts to its exact previous condition after processing. For Inspect requests, the input data contains only a payload, and the backend can only call the [`/report`](./reports.md) endpoint. + - **Exception** — Called by the backend when it encounters an unrecoverable error during request processing. This signals to the Rollup HTTP Server that the current request processing failed and should be terminated. See [`/exception`](./exception.md) for more details. + ## Advance and Inspect Here is a simple boilerplate application that handles Advance and Inspect requests: @@ -120,33 +118,111 @@ while True: + +

+
+```rust
+use json::{object, JsonValue};
+use std::env;
+
+pub async fn handle_advance(
+    _client: &hyper::Client,
+    _server_addr: &str,
+    request: JsonValue,
+) -> Result<&'static str, Box> {
+    println!("Received advance request data {}", &request);
+    let _payload = request["data"]["payload"]
+        .as_str()
+        .ok_or("Missing payload")?;
+    // TODO: add application logic here
+    Ok("accept")
+}
+
+pub async fn handle_inspect(
+    _client: &hyper::Client,
+    _server_addr: &str,
+    request: JsonValue,
+) -> Result<&'static str, Box> {
+    println!("Received inspect request data {}", &request);
+    let _payload = request["data"]["payload"]
+        .as_str()
+        .ok_or("Missing payload")?;
+    // TODO: add application logic here
+    Ok("accept")
+}
+
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+    let client = hyper::Client::new();
+    let server_addr = env::var("ROLLUP_HTTP_SERVER_URL")?;
+
+    let mut status = "accept";
+    loop {
+        println!("Sending finish");
+        let response = object! {"status" => status.clone()};
+        let request = hyper::Request::builder()
+            .method(hyper::Method::POST)
+            .header(hyper::header::CONTENT_TYPE, "application/json")
+            .uri(format!("{}/finish", &server_addr))
+            .body(hyper::Body::from(response.dump()))?;
+        let response = client.request(request).await?;
+        println!("Received finish status {}", response.status());
+
+        if response.status() == hyper::StatusCode::ACCEPTED {
+            println!("No pending rollup request, trying again");
+        } else {
+            let body = hyper::body::to_bytes(response).await?;
+            let utf = std::str::from_utf8(&body)?;
+            let req = json::parse(utf)?;
+
+            let request_type = req["request_type"]
+                .as_str()
+                .ok_or("request_type is not a string")?;
+            status = match request_type {
+                "advance_state" => handle_advance(&client, &server_addr[..], req).await?,
+                "inspect_state" => handle_inspect(&client, &server_addr[..], req).await?,
+                &_ => {
+                    eprintln!("Unknown request type");
+                    "reject"
+                }
+            };
+        }
+    }
+}
+```
+
+
+
-An **Advance** request involves sending input data to the base layer via JSON-RPC so they can reach the dApp backend to change the application's state. +An **Advance** request involves sending input data to the base layer via JSON-RPC, allowing it to reach the dApp backend to change the application's state. ![img](../../../../static/img/v1.3/advance.jpg) -In the dApp architecture, here is how an advance request plays out. +Here is how an advance request works in the dApp architecture: -- Step 1: Send an input to the [`addInput(address, bytes)`](../json-rpc/input-box.md) function of the InputBox smart contract. +- Step 1: Send an input to the [`addInput(address, bytes)`](../contracts/input-box.md#addinput) function of the InputBox smart contract. -- Step 2: The HTTP Rollups Server reads the data and gives it to the Cartesi machine for processing. +- Step 2: The HTTP Rollups Server reads the data and sends it to the Cartesi Machine for processing. -- Step 3: After the computation, the machine state is updated, and the results are returned to the rollup server. +- Step 3: After computation, the machine state is updated, and the results are returned to the rollup server. -An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without changing it. +An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without modifying it. ![img](../../../../static/img/v1.3/inspect.jpg) You can make a simple inspect call from your frontend client to retrieve reports. -To perform an Inspect call, use an HTTP GET request to `
/inspect/`. For example: +To perform an Inspect call, send an HTTP POST request to `
/inspect/` with a payload in the request body. For example: ```shell -curl http://localhost:8080/inspect/mypath +curl -X POST http://localhost:8080/inspect/ \ + -H "Content-Type: application/json" \ + -d '{"payload": "0xdeadbeef"}' ``` -Once the call's response is received, the payload is extracted from the response data, allowing the backend code to examine it and produce outputs as **reports**. +The payload should be a hex-encoded string starting with '0x' followed by pairs of hexadecimal numbers. +After receiving the call's response, the payload is extracted from the response data, allowing the backend code to examine it and produce outputs as **reports**. The direct output types for **Advance** requests are [vouchers](./vouchers.md), [notices](./notices.md), and [reports](./reports.md), while **Inspect** requests generate only [reports](./reports.md). diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/notices.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/notices.md index 3ff59a4c..2a6b8ae6 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/notices.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/notices.md @@ -56,16 +56,22 @@ async function handle_advance(data) {

 
 ```python
-# Notice creation Process from a message string
-def emit_notice(message):
-    notice_payload = {"payload": "0x" + message.encode("utf-8").hex()}
-    response = requests.post(rollup_server + "/notice", json=notice_payload)
-    if response.status_code == 200 or response.status_code == 201:
-        logger.info(f"Notice emitted successfully with data: {notice_payload}")
-    else:
-        logger.error(f"Failed to emit Notice with data: {notice_payload}. Status code: {response.status_code}")
-
-emit_notice("hello world")
+def handle_advance(data):
+   logger.info(f"Received advance request data {data}")
+
+   status = "accept"
+   try:
+       inputPayload = data["payload"]
+       # Send the input payload as a notice
+       response = requests.post(
+           rollup_server + "/notice", json={"payload": inputPayload}
+       )
+       logger.info(
+           f"Received notice status {response.status_code} body {response.content}"
+       )
+   except Exception as e:
+       # Emit report with error message here
+   return status
 ```
 
 
@@ -74,5 +80,5 @@ emit_notice("hello world") :::note querying notices -Frontend clients can query notices using a GraphQL API exposed by the Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server. +Frontend clients can query notices using a GraphQL API exposed by Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server. ::: diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md index 114048c2..04336dbc 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md @@ -1,32 +1,290 @@ --- id: vouchers title: Vouchers - +resources: + - url: https://www.evm.codes/?fork=cancun#f4 + title: DELEGATECALL Opcode --- Vouchers serve as a mechanism for facilitating on-chain actions initiated in the execution layer. -Imagine vouchers as digital authorization tickets, granting dApps the authority to execute specific actions directly on the base layer. This voucher encapsulates the details of the desired on-chain action, such as a token swap request or asset transfer. +Imagine vouchers as digital authorization tickets that grant dApps the authority to execute specific actions directly on the base layer. These vouchers encapsulate the details of the desired on-chain action, such as a token swap request or asset transfer. -The voucher explicitly specifies the action that the dApp intends to execute on the base layer. +A voucher explicitly specifies the action that the dApp intends to execute on the base layer. For instance, in a DeFi application built on Cartesi, users may want to swap one token for another. The dApp generates a voucher that authorizes the on-chain smart contract to execute the swap on the user's behalf. -The [`CartesiDApp`](../json-rpc/application.md) contract is crucial in validating and executing the received voucher on the blockchain. This execution process occurs through the [`executeVoucher()`](../json-rpc/application.md/#executevoucher) function, ensuring that the action specified in the voucher is legitimate and authorized. +The [`Application`](../contracts/application.md) contract is crucial in validating and executing the received voucher on the blockchain. This execution process occurs through the [`executeOutput()`](../../contracts/application/#executeoutput) function, which handles different types of outputs including vouchers and DELEGATECALL vouchers. The result of the voucher execution is recorded on the base layer. This recording typically involves submitting claims by a consensus contract, ensuring the integrity and transparency of the executed on-chain action. +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + +

+
+```javascript
+import { stringToHex, encodeFunctionData, erc20Abi, zeroHash } from "viem";
+
+async function handle_advance(data) {
+  console.log("Received advance request data " + JSON.stringify(data));
+  const sender = data["metadata"]["msg_sender"];
+  const erc20Token = "0x784f0c076CC55EAD0a585a9A13e57c467c91Dc3a"; // Sample ERC20 token address
+
+    const call = encodeFunctionData({
+    abi: erc20Abi,
+    functionName: "transfer",
+    args: [sender, BigInt(10)],
+  });
+
+  let voucher = {
+    destination: erc20Token,
+    payload: call,
+    value: zeroHash,
+  };
+
+  await emitVoucher(voucher);
+  return "accept";
+}
+
+
+const emitVoucher = async (voucher) => {
+  try {
+    await fetch(rollup_server + "/voucher", {
+      method: "POST",
+      headers: {
+        "Content-Type": "application/json",
+      },
+      body: JSON.stringify(voucher),
+    });
+  } catch (error) {
+    //Do something when there is an error
+  }
+};
+
+```
+
+
+
+ + +

+
+```python
+# Voucher creation process
+import requests
+import json
+from os import environ
+from eth_utils import function_signature_to_4byte_selector
+from eth_abi import decode, encode
+
+rollup_server = environ["ROLLUP_HTTP_SERVER_URL"]
+
+def emit_voucher(function_signature, destination, types, values):
+    selector = function_signature_to_4byte_selector(function_signature)    
+    encoded_params = encode(types, values)
+    payload = "0x" + (selector + encoded_params).hex()
+    response = requests.post(rollup_server + "/voucher", json={"payload": payload, "destination": destination, "value": '0x' + encode(["uint256"], [0]).hex()})
+    if response.status_code == 200 or response.status_code == 201:
+        logger.info(f"Voucher emitted successfully with data: {payload}")
+    else:
+        logger.error(f"Failed to emit Voucher with data: {payload}. Status code: {response.status_code}")
+
+
+emit_voucher("mint(address)", "0x784f0c076CC55EAD0a585a9A13e57c467c91Dc3a", ["address"], [data["metadata"]["msg_sender"]])
+```
+
+
+
+
+ :::note create a voucher [Refer to the documentation here](../../development/asset-handling.md) for asset handling and creating vouchers in your dApp. ::: -## Epoch configuration +## DELEGATECALL Vouchers + +:::danger Security Considerations +DELEGATECALL Vouchers are a powerful feature that should be used with extreme caution. Incorrect implementation can lead to serious security vulnerabilities as the target contract's code has full access to the Application contract's storage and funds. +::: + +DELEGATECALL Vouchers are an extension of vouchers that enables advanced smart contract interactions through the [`DELEGATECALL`](https://www.evm.codes/?fork=cancun#f4) opcode. + +Unlike regular vouchers, DELEGATECALL vouchers allow dApps to separate their execution logic from their storage context. When using DELEGATECALL voucher, the Application contract always maintains the storage, context, and funds (both ETH and tokens), while the target contract provides only the execution logic. This separation enables more flexible and reusable smart contract patterns while keeping all state changes and assets within the Application contract. + +When a DELEGATECALL voucher is executed through the Application contract, the code at the target address is executed with the following characteristics: + +- All storage operations occur in the Application contract's storage space +- All funds (ETH and tokens) remain in and are managed by the Application contract +- The msg.sender and msg.value from the original transaction are preserved +- The execution logic comes from the target contract, but operates on the Application contract's state and funds + +This mechanism, where the Application contract maintains the state and funds while borrowing logic from other contracts, enables powerful patterns such as: + +- **Paid Vouchers**: Vouchers that provide payment to the user who executes them. + +- **Future Vouchers**: Vouchers that are time-locked and can only be executed after a specific timestamp. + +- **Expirable Vouchers**: Vouchers that have an expiration timestamp, after which they can no longer be executed. + +- **Targeted Vouchers**: Vouchers that are restricted to execution by specific addresses or a list of authorized addresses. + +- **Atomic Vouchers**: A sequence of message calls that must be executed in order, ensuring atomicity of the operations. + +- **Re-executable Vouchers**: Vouchers that can be executed multiple times, unlike standard vouchers which can only be executed once. + +- **Ordered Vouchers**: Vouchers that must be executed in a specific sequence. For example, voucher A can only be executed after voucher B has been executed. + + + +

+
+```javascript
+import { encodeFunctionData } from "viem";
+
+const abi = [
+  "function safeTransfer(address,address,uint256)"
+];
+
+async function emitSafeERC20Transfer(token, to, amount) {
+  const call = encodeFunctionData({
+    abi,
+    functionName: "safeTransfer",
+    args: [token, to, amount],
+  });
+
+  const voucher = {
+    destination: "0xfafafafafafafafafafafafafafafafafafafafa", // address of the contract containing the logic
+    payload: call,
+  };
+
+  await fetch(rollup_server + "/delegate-call-voucher", {
+    method: "POST",
+    headers: { "Content-Type": "application/json" },
+    body: JSON.stringify(voucher),
+  });
+}
+```
+
+
+
+ + +

+
+```python
+from eth_utils import function_signature_to_4byte_selector, to_checksum_address
+from eth_abi import encode
+import requests
+
+def emit_safe_erc20_transfer(token, to, amount):
+    selector = function_signature_to_4byte_selector("safeTransfer(address,address,uint256)")
+    encoded_params = encode(["address", "address", "uint256"], [to_checksum_address(token), to_checksum_address(to), amount])
+    payload = "0x" + (selector + encoded_params).hex()
+    voucher = {
+        "destination": "0xfafafafafafafafafafafafafafafafafafafafa",  # endereço do contrato
+        "payload": payload,
+    }
+    response = requests.post(rollup_server + "/delegate-call-voucher", json=voucher)
+    return response
+```
+
+
+
+ + +

+
+```go
+package main
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"strings"
+
+	"github.com/ethereum/go-ethereum/accounts/abi"
+	"github.com/ethereum/go-ethereum/common"
+)
+
+func emitSafeERC20Transfer(token, to common.Address, amount *big.Int) error {
+	abiJSON := `[{
+		"type":"function",
+		"name":"safeTransfer",
+		"inputs":[
+			{"type":"address"},
+			{"type":"address"},
+			{"type":"uint256"}
+		]
+	}]`
+	
+	abiInterface, err := abi.JSON(strings.NewReader(abiJSON))
+	if err != nil {
+		return fmt.Errorf("failed to parse ABI: %w", err)
+	}
+	
+	payload, err := abiInterface.Pack("safeTransfer", token, to, amount)
+	if err != nil {
+		return fmt.Errorf("failed to pack ABI: %w", err)
+	}
+	
+	voucher := map[string]interface{}{
+		"destination": "0xfafafafafafafafafafafafafafafafafafafafa",
+		"payload":     common.Bytes2Hex(payload),
+	}
+	
+	voucherJSON, err := json.Marshal(voucher)
+	if err != nil {
+		return fmt.Errorf("failed to marshal voucher: %w", err)
+	}
+	
+	_, err = http.Post(rollupServer+"/delegate-call-voucher", "application/json", bytes.NewBuffer(voucherJSON))
+	if err != nil {
+		return fmt.Errorf("failed to send voucher: %w", err)
+	}
+	
+	return nil
+}
+```
+
+
+
+
+ +### Implementation Considerations + +When implementing DELEGATECALL vouchers, consider the following: + +1. **Storage Layout**: Since all storage operations happen in the Application contract, the storage layout of the target contract must be compatible with the Application contract's layout to prevent unintended storage collisions. + +2. **Security**: Since DELEGATECALL operations execute code in the context of the Application contract, careful validation of the target contract and its code is essential to prevent malicious modifications to the Application's state. + +3. **State Management**: All state changes occur in the Application contract's storage, making it the single source of truth for the application's state. + +### Execution Context + +In a DELEGATECALL voucher execution: + +- The Application contract provides the execution context and storage +- The target contract provides only the logic to be executed +- All storage operations affect the Application contract's state +- msg.sender and msg.value from the original transaction are preserved + +This architecture, where the Application contract maintains all state while being able to execute logic from other contracts, makes DELEGATECALL vouchers particularly useful for customizable logics while keeping all application state centralized in the Application contract. + +## Epoch Configuration An epoch refers to a specific period during which a batch of updates is processed off-chain, and upon agreement by validators, the finalized state is recorded on-chain. Epoch Length is the number of blocks that make up an epoch. It determines how long each epoch lasts in terms of block counts. For instance, if an epoch length is set to 7200 blocks, the epoch will end once 7200 blocks have been processed. This length directly influences how frequently updates are finalized and recorded on the blockchain. -One everyday use of vouchers in Cartesi dApps is to withdraw assets. Users initiate asset withdrawals by generating vouchers, which are then executed on the blockchain upon the closure of the corresponding epoch. +Vouchers and DELEGATECALL vouchers are executed on the blockchain upon the closure of the corresponding epoch. This ensures that all state changes and logic executions are properly validated and recorded in the blockchain. + +One common use of vouchers in Cartesi dApps is to withdraw assets. Users initiate asset withdrawals by generating vouchers, which are then executed on the blockchain upon the closure of the corresponding epoch. You can manually set the epoch length to facilitate quicker asset deposits and withdrawals. diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md index b91520c5..e9ca2fef 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/contracts/application-factory.md @@ -6,7 +6,11 @@ resources: title: Application Factory contract --- -The **ApplicationFactory** contract allows anyone to reliably deploy a new [`IApplication`](https://github.com/cartesi/rollups-contracts/blob/v2.0.0/src/dapp/IApplication.sol) contract. +The **ApplicationFactory** contract is a tool for reliably deploying new instances of the [`Application`](../contracts/application.md) contract with or without a specified salt value for address derivation. + +Additionally, it provides a function to calculate the address of a potential new `CartesiDApp` contract based on input parameters. + +This contract ensures efficient and secure deployment of `Application` contracts within the Cartesi Rollups framework. ## Functions diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml deleted file mode 100644 index 9faf3ac0..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/_category_.yml +++ /dev/null @@ -1,2 +0,0 @@ -label: Inputs -link: null diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md deleted file mode 100644 index 8193e1c0..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/inputs/input-filter.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -id: input-filter -title: InputFilter -hide_table_of_contents: false ---- - - -Filter object to restrict results depending on input properties - -```graphql -input InputFilter { - indexLowerThan: Int - indexGreaterThan: Int -} -``` - - -## Fields - -| Name | Type | Description | -| ---- |------| ------| -| `indexLowerThan` | [`Int`](../../scalars/int) | Filter only inputs with index lower than a given value | -| `indexGreaterThan` | [`Int`](../../scalars/int) | Filter only inputs with index greater than a given value | - - diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md index f0920851..cabf1f83 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-connection.md @@ -4,12 +4,15 @@ title: InputConnection hide_table_of_contents: false --- - -Represents a paginated connection of Inputs. +Represents a paginated list of inputs. ```graphql type InputConnection { + "Total number of entries that match the query" + totalCount: Int! + "List of edges in the connection" edges: [InputEdge!]! + "Information about the current page" pageInfo: PageInfo! } ``` @@ -17,10 +20,33 @@ type InputConnection { ## Fields | Name | Type | Description | -| ---- |------| ------| -| `edges`| [`InputEdge`](../../objects/input-edge) | A list of `InputEdge` objects. Each edge contains an `Input` object and a cursor for pagination. | -| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. | - - +| ---- |------| ----------- | +| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. | +| `edges` | [`[InputEdge!]!`](../../objects/input-edge) | List of edges in the connection. | +| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. | +## Example Query +```graphql +query { + inputs(first: 10) { + totalCount + edges { + node { + id + index + status + msgSender + payload + } + cursor + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md index c757528a..2f500b71 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input-edge.md @@ -4,24 +4,39 @@ title: InputEdge hide_table_of_contents: false --- - -Pagination entry. +Represents a single input in a paginated list. ```graphql type InputEdge { + "The input at this edge" node: Input! + "A cursor for use in pagination" cursor: String! } ``` - ## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `node` | [`Input!`](../../objects/input) | The Input object. | -| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. | - - +| ---- |------| ----------- | +| `node` | [`Input!`](../../objects/input) | The input at this edge. | +| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. | +## Example Query +```graphql +query { + inputs(first: 10) { + edges { + node { + id + index + status + msgSender + payload + } + cursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md index 49e0ac9b..a04ba1cf 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/input.md @@ -4,36 +4,119 @@ title: Input hide_table_of_contents: false --- - -Request submitted to the application to advance its state +Request submitted to the application to advance its state. ```graphql type Input { + "id of the input" + id: String! + "Input index starting from genesis" index: Int! + "Status of the input" status: CompletionStatus! - timestamp: DateTime! + "Address responsible for submitting the input" msgSender: String! - blockNumber: Int! + "Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded" + timestamp: BigInt! @deprecated(reason: "Use `blockTimestamp` instead") + "Number of the base layer block in which the input was recorded" + blockNumber: BigInt! + "Input payload in Ethereum hex binary format, starting with '0x'" payload: String! - notices: NoticeConnection! - vouchers: VoucherConnection! - reports: ReportConnection! + "Get vouchers from this particular input with support for pagination" + vouchers(first: Int, last: Int, after: String, before: String): VoucherConnection! + "Get DELEGATECALL vouchers from this particular input with support for pagination" + delegateCallVouchers(first: Int, last: Int, after: String, before: String): DelegateCallVoucherConnection! + "Get notices from this particular input with support for pagination" + notices(first: Int, last: Int, after: String, before: String): NoticeConnection! + "Get reports from this particular input with support for pagination" + reports(first: Int, last: Int, after: String, before: String): ReportConnection! + "Timestamp associated with the Espresso input submission" + espressoTimestamp: String @deprecated(reason: "Will be removed") + "Number of the Espresso block in which the input was recorded" + espressoBlockNumber: String @deprecated(reason: "Will be removed") + "Input index in the Input Box" + inputBoxIndex: String + "Block timestamp" + blockTimestamp: BigInt + "Previous RANDAO value" + prevRandao: String + "The application that produced the input" + application: Application! } ``` -### Fields +## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `index` | [`Int!`](../../scalars/int) | Unique identifier for the input. | -| `status` | [`CompletionStatus!`](../../objects/completion-status) | Current status of the input processing. | -| `timestamp` | [`DateTime!`](../../scalars/date-time) | Timestamp associated with the input submission. | -| `msgSender` | [`String!`](../../scalars/string) | Address of the account that submitted the input. | -| `blockNumber` | [`Int!`](../../scalars/int) | Number of the base layer block in which the input was recorded. | -| `payload` | [`String!`](../../scalars/string) | The actual data/content of the input. | -| `notices` | [`NoticeConnection!`](../../objects/notice-connection) | List of notices associated with this input. | -| `vouchers` | [`VoucherConnection!`](../../objects/voucher-connection) | List of vouchers associated with this input. | -| `reports` | [`ReportConnection!`](../../objects/report-connection) | List of reports associated with this input. | - +| ---- |------| ----------- | +| `id` | [`String!`](../../scalars/string) | ID of the input. | +| `index` | [`Int!`](../../scalars/int) | Input index starting from genesis. | +| `status` | [`CompletionStatus!`](../../enums/completion-status) | Status of the input. | +| `msgSender` | [`String!`](../../scalars/string) | Address responsible for submitting the input. | +| `timestamp` | [`BigInt!`](../../scalars/bigint) | Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded. | +| `blockNumber` | [`BigInt!`](../../scalars/bigint) | Number of the base layer block in which the input was recorded. | +| `payload` | [`String!`](../../scalars/string) | Input payload in Ethereum hex binary format, starting with '0x'. | +| `vouchers` | [`VoucherConnection!`](../../objects/voucher-connection) | Get vouchers from this particular input with support for pagination. | +| `delegateCallVouchers` | [`DelegateCallVoucherConnection!`](../../objects/delegate-call-voucher-connection) | Get DELEGATECALL vouchers from this particular input with support for pagination. | +| `notices` | [`NoticeConnection!`](../../objects/notice-connection) | Get notices from this particular input with support for pagination. | +| `reports` | [`ReportConnection!`](../../objects/report-connection) | Get reports from this particular input with support for pagination. | +| `espressoTimestamp` | [`String`](../../scalars/string) | Timestamp associated with the Espresso input submission. | +| `espressoBlockNumber` | [`String`](../../scalars/string) | Number of the Espresso block in which the input was recorded. | +| `inputBoxIndex` | [`String`](../../scalars/string) | Input index in the Input Box. | +| `blockTimestamp` | [`BigInt`](../../scalars/bigint) | Block timestamp. | +| `prevRandao` | [`String`](../../scalars/string) | Previous RANDAO value. | +| `application` | [`Application!`](../../objects/application) | The application that produced the input. | +## Example Query +```graphql +query { + input(outputIndex: 1) { + id + index + status + msgSender + timestamp + blockNumber + payload + vouchers(first: 10) { + edges { + node { + index + destination + payload + } + } + } + delegateCallVouchers(first: 10) { + edges { + node { + index + destination + payload + } + } + } + notices(first: 10) { + edges { + node { + index + payload + } + } + } + reports(first: 10) { + edges { + node { + index + payload + } + } + } + application { + address + name + } + } +} +``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md index 7bdf6b88..4e6117cd 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-connection.md @@ -4,12 +4,15 @@ title: NoticeConnection hide_table_of_contents: false --- - -Represents a paginated connection of Notices. +Represents a paginated list of notices. ```graphql type NoticeConnection { + "Total number of entries that match the query" + totalCount: Int! + "List of edges in the connection" edges: [NoticeEdge!]! + "Information about the current page" pageInfo: PageInfo! } ``` @@ -17,11 +20,34 @@ type NoticeConnection { ## Fields | Name | Type | Description | -| ---- |------| ------| -| `edges`| [`NoticeEdge`](../../objects/notice-edge) | A list of `Notice` objects. Each edge contains a `Notice` object and a cursor for pagination. | -| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. | - - - +| ---- |------| ----------- | +| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. | +| `edges` | [`[NoticeEdge!]!`](../../objects/notice-edge) | List of edges in the connection. | +| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. | +## Example Query +```graphql +query { + notices(first: 10) { + totalCount + edges { + node { + index + payload + proof { + outputIndex + outputHashesSiblings + } + } + cursor + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md index 09af6d6a..63188fb6 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice-edge.md @@ -4,12 +4,13 @@ title: NoticeEdge hide_table_of_contents: false --- - -Pagination entry +Represents a single notice in a paginated list. ```graphql type NoticeEdge { + "The notice at this edge" node: Notice! + "A cursor for use in pagination" cursor: String! } ``` @@ -17,11 +18,26 @@ type NoticeEdge { ## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `node` | [`Notice!`](../../objects/notice) | The Notice object. | -| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. | - - - +| ---- |------| ----------- | +| `node` | [`Notice!`](../../objects/notice) | The notice at this edge. | +| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. | +## Example Query +```graphql +query { + notices(first: 10) { + edges { + node { + index + payload + proof { + outputIndex + outputHashesSiblings + } + } + cursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md index 1bc7bf07..165b9566 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/notice.md @@ -4,30 +4,51 @@ title: Notice hide_table_of_contents: false --- - Informational statement that can be validated in the base layer blockchain. ```graphql type Notice { + "Notice index within the context of the input that produced it" index: Int! + "Input whose processing produced the notice" input: Input! + "Notice data as a payload in Ethereum hex binary format, starting with '0x'" payload: String! + "Proof object that allows this notice to be validated by the base layer blockchain" proof: Proof + "The application that produced the notice" + application: Application! } ``` - ## Fields | Name | Type | Description | | ---- |------| ----------- | -| `index`| [`Int!`](../../scalars/int) | Unique identifier for the notice. | -| `input`| [`Input!`](../../objects/input) | The input associated with this notice. | -| `payload`| [`String!`](../../scalars/string) |The actual data/content of the notice. | -| `proof`| [`Proof`](../../objects/proof) | Proof of the notice's validity (if available). | - - - - +| `index` | [`Int!`](../../scalars/int) | Notice index within the context of the input that produced it. | +| `input` | [`Input!`](../../objects/input) | Input whose processing produced the notice. | +| `payload` | [`String!`](../../scalars/string) | Notice data as a payload in Ethereum hex binary format, starting with '0x'. | +| `proof` | [`Proof`](../../objects/proof) | Proof object that allows this notice to be validated by the base layer blockchain. | +| `application` | [`Application!`](../../objects/application) | The application that produced the notice. | +## Example Query +```graphql +query { + notice(outputIndex: 1) { + index + input { + index + } + payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } + } +} +``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md index 2f96f7dd..57f3f671 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/proof.md @@ -4,24 +4,33 @@ title: Proof hide_table_of_contents: false --- -Represents the proof of validity for a notice or voucher. +Data that can be used as proof to validate notices and execute vouchers on the base layer blockchain. ```graphql type Proof { - validity: OutputValidityProof! - context: String! + "Index of the output in the output box" + outputIndex: BigInt! + "Array of sibling hashes in the output box merkle tree" + outputHashesSiblings: [String]! } ``` - ## Fields | Name | Type | Description | | ---- |------| ----------- | -| `validity`| [`OutputValidityProof!`](../../objects/output-validity-proof) | Validity proof for an output. | -| `context`| [`String!`](../../scalars/string) | Data that allows the validity proof to be contextualized within submitted claims, given as a payload in Ethereum hex binary format, starting with '0x'. | - - - +| `outputIndex` | [`BigInt!`](../../scalars/bigint) | Index of the output in the output box. | +| `outputHashesSiblings` | [`[String]!`](../../scalars/string) | Array of sibling hashes in the output box merkle tree. | +## Example Query +```graphql +query { + voucher(outputIndex: 1) { + proof { + outputIndex + outputHashesSiblings + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md index a79b44fc..c7c90c0c 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-connection.md @@ -4,26 +4,46 @@ title: ReportConnection hide_table_of_contents: false --- - -Represents a paginated connection of Reports. +Represents a paginated list of reports. ```graphql type ReportConnection { + "Total number of entries that match the query" + totalCount: Int! + "List of edges in the connection" edges: [ReportEdge!]! + "Information about the current page" pageInfo: PageInfo! } ``` - ## Fields | Name | Type | Description | -| ---- |------| ------| -| `edges`| [`ReportEdge`](../../objects/report-edge) | A list of `ReportEdge` objects. Each edge contains an `Input` object and a cursor for pagination. | -| `pageInfo`| [`PageInfo`](../../objects/page-info) | Metadata about the pagination. | - - - - +| ---- |------| ----------- | +| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. | +| `edges` | [`[ReportEdge!]!`](../../objects/report-edge) | List of edges in the connection. | +| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. | +## Example Query +```graphql +query { + reports(first: 10) { + totalCount + edges { + node { + index + payload + } + cursor + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md index a6fba549..91959d2f 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report-edge.md @@ -4,26 +4,36 @@ title: ReportEdge hide_table_of_contents: false --- - -Pagination entry +Represents a single report in a paginated list. ```graphql type ReportEdge { + "The report at this edge" node: Report! + "A cursor for use in pagination" cursor: String! } ``` - -### Fields - +## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `node` | [`Report!`](../../objects/report) | The Report object. | -| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. | - - - +| ---- |------| ----------- | +| `node` | [`Report!`](../../objects/report) | The report at this edge. | +| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. | +## Example Query +```graphql +query { + reports(first: 10) { + edges { + node { + index + payload + } + cursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md index ba904c27..8d8fd8f5 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/report.md @@ -4,28 +4,44 @@ title: Report hide_table_of_contents: false --- - -Represents application log or diagnostic information. +Application log or diagnostic information. ```graphql type Report { + "Report index within the context of the input that produced it" index: Int! + "Input whose processing produced the report" input: Input! + "Report data as a payload in Ethereum hex binary format, starting with '0x'" payload: String! + "The application that produced the report" + application: Application! } ``` - ## Fields | Name | Type | Description | | ---- |------| ----------- | -| `index`| [`Int!`](../../scalars/int) | Unique identifier for the report. | -| `input`| [`Input!`](../../objects/input) | The input associated with this report. | -| `payload`| [`String!`](../../scalars/string) | The actual data/content of the report. | - - - - +| `index` | [`Int!`](../../scalars/int) | Report index within the context of the input that produced it. | +| `input` | [`Input!`](../../objects/input) | Input whose processing produced the report. | +| `payload` | [`String!`](../../scalars/string) | Report data as a payload in Ethereum hex binary format, starting with '0x'. | +| `application` | [`Application!`](../../objects/application) | The application that produced the report. | +## Example Query +```graphql +query { + report(reportIndex: 1) { + index + input { + index + } + payload + application { + address + name + } + } +} +``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md index 02c05225..1f7eaec2 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-connection.md @@ -4,26 +4,50 @@ title: VoucherConnection hide_table_of_contents: false --- - -Represents a paginated connection of Vouchers. +Represents a paginated list of vouchers. ```graphql type VoucherConnection { + "Total number of entries that match the query" + totalCount: Int! + "List of edges in the connection" edges: [VoucherEdge!]! + "Information about the current page" pageInfo: PageInfo! } ``` - ## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `edges` | [`[VoucherEdge!]!`](../../objects/voucher-edge) | A list of `VoucherEdge` objects. Each edge contains a `Voucher` object and a cursor for pagination. | -| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Pagination metadata. | - - - - +| ---- |------| ----------- | +| `totalCount` | [`Int!`](../../scalars/int) | Total number of entries that match the query. | +| `edges` | [`[VoucherEdge!]!`](../../objects/voucher-edge) | List of edges in the connection. | +| `pageInfo` | [`PageInfo!`](../../objects/page-info) | Information about the current page. | +## Example Query +```graphql +query { + vouchers(first: 10) { + totalCount + edges { + node { + index + destination + payload + value + executed + transactionHash + } + cursor + } + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md index 99d42d30..0e5a8e8a 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher-edge.md @@ -4,26 +4,40 @@ title: VoucherEdge hide_table_of_contents: false --- - -Pagination entry. +Represents a single voucher in a paginated list. ```graphql type VoucherEdge { + "The voucher at this edge" node: Voucher! + "A cursor for use in pagination" cursor: String! } ``` - ## Fields | Name | Type | Description | -| ---- | ---- | ----------- | -| `node` | [`Voucher!`](../../objects/voucher) | The `Voucher` object. | -| `cursor` | [`String!`](../../scalars/string) | A string that serves as a pagination cursor for this particular edge. | - - - - +| ---- |------| ----------- | +| `node` | [`Voucher!`](../../objects/voucher) | The voucher at this edge. | +| `cursor` | [`String!`](../../scalars/string) | A cursor for use in pagination. | +## Example Query +```graphql +query { + vouchers(first: 10) { + edges { + node { + index + destination + payload + value + executed + transactionHash + } + cursor + } + } +} +``` diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md index 6713e671..b2959d38 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/objects/voucher.md @@ -4,30 +4,67 @@ title: Voucher hide_table_of_contents: false --- - Representation of a transaction that can be carried out on the base layer blockchain, such as a transfer of assets. ```graphql type Voucher { + "Voucher index within the context of the input that produced it" index: Int! + "Input whose processing produced the voucher" input: Input! + "Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x'" destination: String! + "Transaction payload in Ethereum hex binary format, starting with '0x'" payload: String! + "Proof object that allows this voucher to be validated and executed on the base layer blockchain" proof: Proof + "Value to be sent with the transaction" + value: BigInt + "Indicates whether the voucher has been executed on the base layer blockchain" + executed: Boolean + "The hash of executed transaction" + transactionHash: String + "The application that produced the voucher" + application: Application! } ``` - ## Fields | Name | Type | Description | | ---- |------| ----------- | -| `index`| [`Int!`](../../scalars/int) | Unique identifier for the voucher. | -| `input`| [`Input!`](../../objects/input) | The input associated with this voucher. | -| `destination`| [`String!`](../../scalars/string) | The address or identifier of the voucher's destination. | -| `payload`| [`String!`](../../scalars/string) | The actual data/content of the voucher. | -| `proof`| [`Proof`](../../objects/proof) | Proof object that allows this voucher to be validated and executed on the base layer blockchain(if available). | - - +| `index` | [`Int!`](../../scalars/int) | Voucher index within the context of the input that produced it. | +| `input` | [`Input!`](../../objects/input) | Input whose processing produced the voucher. | +| `destination` | [`String!`](../../scalars/string) | Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x'. | +| `payload` | [`String!`](../../scalars/string) | Transaction payload in Ethereum hex binary format, starting with '0x'. | +| `proof` | [`Proof`](../../objects/proof) | Proof object that allows this voucher to be validated and executed on the base layer blockchain. | +| `value` | [`BigInt`](../../scalars/bigint) | Value to be sent with the transaction. | +| `executed` | [`Boolean`](../../scalars/boolean) | Indicates whether the voucher has been executed on the base layer blockchain. | +| `transactionHash` | [`String`](../../scalars/string) | The hash of executed transaction. | +| `application` | [`Application!`](../../objects/application) | The application that produced the voucher. | +## Example Query +```graphql +query { + voucher(address: "0x123...") { + index + input { + index + } + destination + payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } + } +} +``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md index 92c5749a..abc5c2c8 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/notices.md @@ -11,28 +11,32 @@ Notices are informational statements that can be validated in the base layer blo Retrieve a specific notice based on its index and associated input index. ```graphql -query notice($noticeIndex: Int!, $inputIndex: Int!) { - notice(noticeIndex: $noticeIndex, inputIndex: $inputIndex) { +query notice($outputIndex: Int!) { + notice(outputIndex: $outputIndex) { index input { + id index - timestamp + status msgSender + blockTimestamp blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } payload proof { - validity { - inputIndexWithinEpoch - outputIndexWithinInput - outputHashesRootHash - vouchersEpochRootHash - noticesEpochRootHash - machineStateHash - outputHashInOutputHashesSiblings - outputHashesInEpochSiblings - } - context + outputIndex + outputHashesSiblings + } + application { + address + name } } } @@ -42,10 +46,9 @@ For notices, the API provides access to proof data that can be used for validati ### Arguments -| Name | Type | Description | -| ------------- | --------------------------- | ---------------------------------------------- | -| `noticeIndex` | [`Int!`](../../scalars/int) | Index of the notice to retrieve. | -| `inputIndex` | [`Int!`](../../scalars/int) | Index of the input associated with the notice. | +| Name | Type | Description | +| ------------ | --------------------------- | ---------------------------------------------- | +| `outputIndex` | [`Int!`](../../scalars/int) | Index of the notice to retrieve. | ### Response Type @@ -62,13 +65,35 @@ query notices { node { index input { + id index - timestamp + status msgSender + blockTimestamp blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } } + cursor + } + pageInfo { + hasNextPage + endCursor } } } @@ -93,14 +118,21 @@ query noticesByInput($inputIndex: Int!) { edges { node { index - input { - index - timestamp - msgSender - blockNumber - } payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } } + cursor + } + pageInfo { + hasNextPage + endCursor } } } @@ -124,15 +156,31 @@ query noticesByInput($inputIndex: Int!) { ```graphql query { - notice(noticeIndex: 3, inputIndex: 2) { + notice(outputIndex: 1) { index + input { + id + index + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } + } payload proof { - validity { - inputIndexWithinEpoch - outputIndexWithinInput - } - context + outputIndex + outputHashesSiblings + } + application { + address + name } } } @@ -147,10 +195,29 @@ query { node { index input { + id index - timestamp + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } } cursor } @@ -172,6 +239,14 @@ query { node { index payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } } cursor } @@ -183,3 +258,80 @@ query { } } ``` + +4. Listing notices with proof data and application information: + +```graphql +query { + notices(first: 10) { + edges { + node { + index + input { + id + index + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } + } + payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } + } + cursor + } + pageInfo { + hasNextPage + endCursor + } + } +} +``` + +5. Fetching a specific notice by output index: + +```graphql +query { + notice(outputIndex: 1) { + index + input { + id + index + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } + } + payload + proof { + outputIndex + outputHashesSiblings + } + application { + address + name + } + } +} +``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md index 9e4e2560..c5bbf344 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/graphql/queries/vouchers.md @@ -12,29 +12,36 @@ Vouchers represent transactions that can be carried out on the base layer blockc Retrieve a specific voucher based on its index and associated input index. ```graphql -query voucher($voucherIndex: Int!, $inputIndex: Int!) { - voucher(voucherIndex: $voucherIndex, inputIndex: $inputIndex) { +query voucher($outputIndex: Int!) { + voucher(outputIndex: $outputIndex) { index input { + id index - timestamp + status msgSender + blockTimestamp blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } destination payload proof { - validity { - inputIndexWithinEpoch - outputIndexWithinInput - outputHashesRootHash - vouchersEpochRootHash - noticesEpochRootHash - machineStateHash - outputHashInOutputHashesSiblings - outputHashesInEpochSiblings - } - context + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name } } } @@ -45,8 +52,7 @@ For vouchers, the API provides access to proof data that can be used for validat | Name | Type | Description | | ---- | ---- | ----------- | -| `voucherIndex` | [`Int!`](../../scalars/int) | The index of the voucher to retrieve. | -| `inputIndex` | [`Int!`](../../scalars/int) | The index of the associated input. | +| `outputIndex` | [`Int!`](../../scalars/int) | The index of the voucher to retrieve. | @@ -66,13 +72,33 @@ query vouchers($first: Int, $after: String) { node { index input { + id index - timestamp + status msgSender + blockTimestamp blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } destination payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } } cursor } @@ -110,6 +136,17 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) { index destination payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } } cursor } @@ -141,20 +178,39 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) { 1. Fetching a specific voucher: ```graphql - query { - voucher(voucherIndex: 3, inputIndex: 2) { + query { + voucher(outputIndex: 1) { + index + input { + id index - destination + status + msgSender + blockTimestamp + blockNumber payload - proof { - validity { - inputIndexWithinEpoch - outputIndexWithinInput - } - context + inputBoxIndex + prevRandao + application { + address + name } } + destination + payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } } + } ``` 2. Listing earlier(first 5) vouchers: @@ -166,11 +222,33 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) { node { index input { + id index - timestamp + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } } destination payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } } cursor } @@ -193,6 +271,17 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) { index destination payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } } cursor } @@ -203,4 +292,88 @@ query vouchersByInput($inputIndex: Int!, $first: Int, $after: String) { } } } + ``` + +4. Listing all vouchers with proof data: + + ```graphql + query { + vouchers(first: 10) { + edges { + node { + index + input { + id + index + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } + } + destination + payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } + } + } + pageInfo { + hasNextPage + endCursor + } + } + } + ``` + +5. Fetching a specific voucher by output index: + + ```graphql + query { + voucher(outputIndex: 1) { + index + input { + id + index + status + msgSender + blockTimestamp + blockNumber + payload + inputBoxIndex + prevRandao + application { + address + name + } + } + destination + payload + proof { + outputIndex + outputHashesSiblings + } + value + executed + transactionHash + application { + address + name + } + } + } ``` \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md index f4f4a67d..21839187 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/index.md @@ -12,7 +12,7 @@ resources: In a Cartesi dApp, the frontend and backend components communicate through the Rollups framework using HTTP and GraphQL APIs. -When designing the APIs for this communication with the framework, we wanted to ensure developers could create their applications without worrying too much about the low-level components of Cartesi Rollups. +When designing the APIs for this communication framework, we aimed to ensure that developers could create their applications without excessive concern about the low-level components of Cartesi Rollups. ## Backend APIs @@ -20,30 +20,29 @@ In a typical Cartesi dApp, the backend contains the application's state and veri The dApp's backend interacts with the Cartesi Rollups framework by retrieving processing requests and submitting corresponding outputs. -This is accomplished by calling a set of HTTP endpoints, as illustrated by the figure below: +This interaction occurs through a set of HTTP endpoints, as illustrated in the figure below: ![img](../../../static/img/v1.3/backend.jpg) -You can send two requests to an application depending on whether you want to change or read the state. +You can send two types of requests to an application depending on whether you want to change or read the state: -- **Advance**: In this request, any input data changes the state of the dApp. - -- **Inspect**: This involves making an external HTTP API call to the Cartesi Node to read the dApp state without changing it. +- **Advance**: With this request, input data changes the state of the dApp. +- **Inspect**: This involves making an external HTTP API call to the Cartesi Node to read the dApp state without modifying it. ## Base Layer Contracts The frontend component of the dApp needs to access the Cartesi Rollups framework to submit user requests and retrieve the corresponding outputs produced by the backend. -The figure below details some of the main use cases for these interactions: +The figure below illustrates the main use cases for these interactions: ![img](../../../static/img/v1.3/frontend.jpg) -- [`addInput()`](./json-rpc/input-box.md/#addinput) — This function submits input data to the InputBox smart contract on the base layer as a regular JSON-RPC blockchain transaction. When that transaction is mined and executed, an event containing the submitted input’s index is emitted, which the frontend can later use to query associated outputs. +- [`addInput()`](./contracts/input-box/#addinput) — This function submits input data to the InputBox smart contract on the base layer as a regular JSON-RPC blockchain transaction. When the transaction is mined and executed, it emits an event containing the submitted input's index, which the frontend can later use to query associated outputs. -- [`executeVoucher()`](./json-rpc/application.md/#executevoucher) — Submits a JSON-RPC blockchain transaction to request that a given voucher or notice be executed by the [`CartesiDApp`](./json-rpc/application.md) smart contract on the base layer. Vouchers can only be executed when an epoch is closed. +- [`executeOutput()`](./contracts/application/#executeoutput) — Submits a JSON-RPC blockchain transaction to request the execution of a given voucher or notice by the [`Application`](./contracts/application.md) smart contract on the base layer. Vouchers can only be executed when an epoch is closed. -- Query outputs — You can submit a query to a Cartesi node to retrieve vouchers, notices, and reports, as specified by the Cartesi Rollups GraphQL schema. +- Query outputs — You can submit a query to a Cartesi node to retrieve vouchers, notices, and reports as specified by the Cartesi Rollups GraphQL schema. - Inspect state — You can make an HTTP call to the Cartesi node to retrieve arbitrary dApp-specific application state. diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect-state-http-api-for-cartesi-rollups.info.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect-state-http-api-for-cartesi-rollups.info.mdx index 74658efc..f8b37435 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect-state-http-api-for-cartesi-rollups.info.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect-state-http-api-for-cartesi-rollups.info.mdx @@ -9,18 +9,40 @@ custom_edit_url: null --- import ApiLogo from "@theme/ApiLogo"; +import Heading from "@theme/Heading"; import SchemaTabs from "@theme/SchemaTabs"; import TabItem from "@theme/TabItem"; -import Export from "@theme/ApiDemoPanel/Export"; +import Export from "@theme/ApiExplorer/Export"; -Version: 0.5.1 + + -

Inspect-state HTTP API for Cartesi Rollups

+ + API that allows the dApp frontend to make inspect-state requests to the dApp backend. -

License

Apache-2.0
+
+

+ License +

+ Apache-2.0 + +
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect.api.mdx index ff6c3bff..2782999c 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/inspect/inspect.api.mdx @@ -5,25 +5,34 @@ description: "This method sends an inspect-state request to the dApp backend pas sidebar_label: "Inspect dApp state REST API" hide_title: true hide_table_of_contents: true -api: {"operationId":"inspect","description":"This method sends an inspect-state request to the dApp backend passing the payload string in the URL.\nThe payload string should be URL-encoded; the inspect server will decode the string to UTF-8.\nIf the dApp frontend needs to pass a binary string to the backend then it is advised to use the base64 encoding.\n\nThe response contains a status string and the reports generated by the dApp backend.\nThe status string can be either 'accept', 'reject', or 'exception'.\nIn case of exception, the field exception_payload will contain the exception payload;\nOtherwise, this field will be null.\n\nWhen running on machine mode, the whole Cartesi Machine is rolled back after processing the inspect-state request.\nOn host mode, it is advised against changing the dApp backend state when processing an inspect-state request.\nNotice that this method is synchronous, so it is not advised to perform resource-intensive operations.\n","parameters":[{"in":"path","name":"payload","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Inspect state response.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","description":"Whether inspection completed or not (and why not)","enum":["Accepted","Rejected","Exception","MachineHalted","CycleLimitExceeded","TimeLimitExceeded"],"example":"Accepted","title":"CompletionStatus"},"exception_payload":{"type":"string","description":"Payload in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"},"reports":{"type":"array","items":{"type":"object","properties":{"payload":{"type":"string","description":"Payload in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Report"}},"processed_input_count":{"type":"integer","description":"Number of processed inputs since genesis","example":0}},"title":"InspectResponse"}}}},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"get","path":"/{payload}","servers":[{"url":"https://"},{"url":"http://localhost:5005/inspect"}],"info":{"title":"Inspect-state HTTP API for Cartesi Rollups","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that allows the dApp frontend to make inspect-state requests to the dApp backend.\n"},"postman":{"name":"Inspect dApp state REST API","description":{"content":"This method sends an inspect-state request to the dApp backend passing the payload string in the URL.\nThe payload string should be URL-encoded; the inspect server will decode the string to UTF-8.\nIf the dApp frontend needs to pass a binary string to the backend then it is advised to use the base64 encoding.\n\nThe response contains a status string and the reports generated by the dApp backend.\nThe status string can be either 'accept', 'reject', or 'exception'.\nIn case of exception, the field exception_payload will contain the exception payload;\nOtherwise, this field will be null.\n\nWhen running on machine mode, the whole Cartesi Machine is rolled back after processing the inspect-state request.\nOn host mode, it is advised against changing the dApp backend state when processing an inspect-state request.\nNotice that this method is synchronous, so it is not advised to perform resource-intensive operations.\n","type":"text/plain"},"url":{"path":[":payload"],"host":["{{baseUrl}}"],"query":[],"variable":[{"disabled":false,"description":{"content":"(Required) ","type":"text/plain"},"type":"any","value":"","key":"payload"}]},"header":[{"key":"Accept","value":"application/json"}],"method":"GET"}} +api: eJztV01vGzcQ/SvEXpQAtqS4cT+UooDhKq2BNAkUBT0kgUHtjrRMdsktybUsCPrvfUNypbVlI8f24ItNDYczw5k3b7jbzDRkpVdGXxXZJFPaNZT77CQryOVWNbwD+bxUTtTkS1MIR7pwQmqRlE+dl56EpX9acl54I3xJorhoGrGQ+Tdoi0Y6p/QqbDRyUxkJM96ySOkg/Th7M/ys58f7rjRtVYhFUDklnZuCilfhTPKPgOwNWbFWVSUKYoWwnQwgno/z16c/w/zV8hDa0hrtOTZNhOtAi4MUUiyUlnbTO81HuotgjXt7gWzI4kY5KlijdZS0HP34UoQgcRge45UsucZoKOXwKRE23HDSWte5kdE2NBtjvRMr0lwWmF9sjtKZEnXXQo6CIEmkoG3FQOY5NX5wIgaWviJJWBmI6ZbFqOmA06FxClGZpdjLT4K3pSLkfC+87moSUpwuERT3Kl3ZXn3W7ziCNXLDtpCoaCwcRYC6raqQmL85lbbVmqOHgVrmpdIkatQvRrEuTUXiUlpPTom/0j4sWlNVnBqkQ8ilx30ba3I6YOxBZMLrOy1KA4xGH3frKFdcGS/yUupVZ+gOiqO1Ncfd8/dYI8DdW+NVztCQPqYidRBWbqPzEhA0rTsRzqRYtPF9XKE1l8bWjB/T2pxOFUPWqRvUrGtbBz9o10ZaCetkXTb5tEUfo2kb6UtsaWyEX6FAEHCAyhL63duWTjKXl1TLbLLN/KZh1QipbLf7wsoRu473z8Zj/neXG666Nky3j/pDOMpDi3k+IpumUnmIePTV8bntsV+z+BrJB+nF/byKXiPQj+O7T1JAVAB/KgejMjd1UxH3EdDP2X3GnbYuN/zjOSyQbmtkLLsI/UKcnllomLCcdvDGOuHvT1nFvctNXtEbVSvPWlQE4VzV92RIId1KjgIR9rx45YPoMkYIHx/iNXd84F7jff/u71OHpr6cciKorUVJtx2jMZSkT+SxVJa5em0Y71bmjBwhLYnB+HYA1aoy68g+jYQqcwRMSdCrqmWFLq4XfCJAOzc2Vj2A1qBHFxtPcPTahGJ4qXO0GywXJIsF0XLQOxO4V4oDxfhSVKRX+Pcy8CIbc+Ls7OxEvPjpB/z5Zcyrczi40ILqxm/2p5kcqIFlwO5Anoki+WqxWw4VOcTUq0lKJpciEXKvANJauYGy8lS774P3qYL/aQV3B9kslDKIEn1Tca100/rr3LSRplKJmGdXZI9q9DYkjVO5tyCCBRC6QorC3HbK9QMc92NIXDlLJIlgeLegpWwrf0ytU2tRgEco1dOtHzWVVA+T6SMw+50wvHl6UrBd4xJyFUwfUhrfLPE5l4fnF1MnhnerC2DGG3MoTHx7FS0xCAAsxiisY755edurSLhKuC8uHOcgpCsKHcODapKNtgkEO8ii4TjNWlthu/S+cZPR6NcCw+Q6kfw19n5Do/aVoFOZXFY86ifn4/H5qHvW8kBTemlCmu6WJA3vP+fz9+Li/RX32v7pMUMztQ1XlUOKeRwPz4cvIMFUI64kLKZBe9FgUtDp2XCM7buhr9froQzbQ2NXo3TWjd5cXU7ffpjymWHp6yrb3S8bhxRaVXJfuwfesSH93x55+7iHnuXcSdwMSFMtde8G3UQPytHObPphznm5j6ftAZFPHwlPHwlPHwn/54+ENBl6g2OXGGqbOPhTNukeLKBKTgPLtlsG7Udb7XYsRuR2AzmWN9IquWAeBU0XyvEavL6UFSr7OFM8m6VPkOfisbC615bmt9aNrFr+heU32vQ+ZnZfoFpi/mNYcwhxNz6ze+eOvj54EOyH0B/TOQbTv1f6Bz0= sidebar_class_name: "get api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/inspect/inspect-state-http-api-for-cartesi-rollups +info_path: cartesi-rollups/_versioned_docs/version-2.0/rollups-apis/inspect/inspect-state-http-api-for-cartesi-rollups custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Inspect dApp state REST API

+ + - + + + @@ -41,17 +50,34 @@ On host mode, it is advised against changing the dApp backend state when process Notice that this method is synchronous, so it is not advised to perform resource-intensive operations. -
Path Parameters
+ + + + + + + + + + + + + + -Inspect state response. -
Schema
    reports object[]
  • Array [
  • ]
- -Error response. - -
Schema
  • string
    - -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application-factory.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application-factory.md deleted file mode 100644 index 63bd1a53..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application-factory.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -id: application-factory -title: ApplicationFactory -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/prerelease/2.0.0/contracts/dapp/ApplicationFactory.sol - title: Application Factory contract ---- - -The **ApplicationFactory** contract is a tool for reliably deploying new instances of the [`CartesiDApp`](../json-rpc/application.md) contract with or without a specified salt value for address derivation. - -Additionally, it provides a function to calculate the address of a potential new `CartesiDApp` contract based on input parameters. - -This contract ensures efficient and secure deployment of `CartesiDApp` contracts within the Cartesi Rollups framework. - -## `newApplication()` - -```solidity -function newApplication( IConsensus consensus, address appOwner, bytes32 templateHash) external override returns (IApplication) -``` - -Deploys a new Application contract without specifying a salt value for address derivation. - -Emits an `ApplicationCreated` event upon successful deployment. - -#### Parameters - -| Name | Type | Description | -| ------------ | ---------- | ---------------------------------------- | -| consensus | IConsensus | Instance of the consensus interface | -| appOwner | address | Address of the owner of the application | -| templateHash | bytes32 | Hash of the template for the application | - -## `newApplication()`(with salt) - -```solidity -function newApplication( IConsensus consensus, address appOwner, bytes32 templateHash, bytes32 salt ) external override returns (IApplication) -``` - -Deploys a new `Application` contract with a specified salt value for address derivation. - -Emits an `ApplicationCreated` event upon successful deployment. - -#### Parameters - -| Name | Type | Description | -| ------------ | ---------- | ---------------------------------------- | -| consensus | IConsensus | Instance of the consensus interface | -| appOwner | address | Address of the owner of the application | -| templateHash | bytes32 | Hash of the template for the application | -| salt | bytes32 | Salt value for address derivation | - -### `calculateApplicationAddress()` - -```solidity -function calculateApplicationAddress( IConsensus consensus, address appOwner, bytes32 templateHash, bytes32 salt ) external view override returns (address) -``` - -Calculates the address of a potential new Application contract based on input parameters. - -#### Parameters - -| Name | Type | Description | -| ------------ | ---------- | ---------------------------------------- | -| consensus | IConsensus | Instance of the consensus interface | -| appOwner | address | Address of the owner of the application | -| templateHash | bytes32 | Hash of the template for the application | -| salt | bytes32 | Salt value for address derivation | - -#### Returns - -| Type | Description | -| ------- | ------------------------------------------------- | -| address | Address of the potential new Application contract | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application.md deleted file mode 100644 index 5efa4570..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/application.md +++ /dev/null @@ -1,250 +0,0 @@ ---- -id: application -title: CartesiDApp -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/dapp/CartesiDApp.sol - title: CartesiDApp contract - - url: https://docs.openzeppelin.com/contracts/5.x/ - title: OpenZeppelin Contracts ---- - -The **CartesiDApp** contract acts as the base layer incarnation of a dApp running on the execution layer. The dApp can interact with other smart contracts through the execution of [vouchers](../backend/vouchers.md) and the validation of [notices](../backend/notices.md). The dApp frontend on the execution layer generates these outputs, which can be proven in the base layer thanks to claims submitted by a consensus contract. - -Every dApp is subscribed to a consensus contract and governed by a single address, the owner. The consensus has the power to submit claims, which, in turn, are used to validate vouchers and notices. The owner has complete power over the dApp, as it can replace the consensus anytime. Therefore, the users of a dApp must trust both the consensus and the dApp owner. - -The dApp developer can choose whichever ownership and consensus models it wants. - -Examples of dApp ownership models include: - -- no owner (address zero) -- individual signer (externally-owned account) -- multiple signers (multi-sig) -- DAO (decentralized autonomous organization) -- self-owned dApp (off-chain governance logic) - -See `IConsensus` for examples of consensus models. - -This contract inherits the following OpenZeppelin contracts. - -- `Ownable` -- `ERC721Holder` -- `ERC1155Holder` -- `ReentrancyGuard` - -For more information, please consult [OpenZeppelin's official documentation](https://docs.openzeppelin.com/contracts/4.x/). - -## `executeVoucher()` - -```solidity -function executeVoucher(address _destination, bytes _payload, struct Proof _proof) external returns (bool) -``` - -Try to execute a voucher. - -Reverts if voucher was already successfully executed. - -_On a successful execution, emits a `VoucherExecuted` event._ - -### Parameters - -| Name | Type | Description | -| ------------- | ------------ | -------------------------------------------------------------------------------------------------- | -| \_destination | address | The address that will receive the payload through a message call | -| \_payload | bytes | The payload, which—in the case of Solidity contracts—encodes a function call | -| \_proof | struct Proof | The proof used to validate the voucher against a claim submitted by the current consensus contract | - -### Return Values - -| Name | Type | Description | -| ---- | ---- | ------------------------------------------- | -| [0] | bool | Whether the execution was successful or not | - -## `wasVoucherExecuted()` - -```solidity -function wasVoucherExecuted(uint256 _inboxInputIndex, uint256 _outputIndex) external view returns (bool) -``` - -Check whether a voucher has been executed. - -### Parameters - -| Name | Type | Description | -| ----------------- | ------- | ---------------------------------------- | -| \_inboxInputIndex | uint256 | The index of the input in the input box | -| \_outputIndex | uint256 | The index of output emitted by the input | - -### Return Values - -| Name | Type | Description | -| ---- | ---- | -------------------------------------------- | -| [0] | bool | Whether the voucher has been executed before | - -## `validateNotice()` - -```solidity -function validateNotice(bytes _notice, struct Proof _proof) external view returns (bool) -``` - -Validate a notice. - -### Parameters - -| Name | Type | Description | -| -------- | ---------------------- | --------------------------- | -| \_notice | bytes | The notice | -| \_proof | struct [Proof](#proof) | Data for validating outputs | - -### Return Values - -| Name | Type | Description | -| ---- | ---- | ---------------------------------- | -| [0] | bool | Whether the notice is valid or not | - -## `migrateToConsensus()` - -```solidity -function migrateToConsensus(contract IConsensus _newConsensus) external -``` - -Migrate the dApp to a new consensus. - -_Can only be called by the dApp owner._ - -### Parameters - -| Name | Type | Description | -| -------------- | ------------------- | ----------------- | -| \_newConsensus | contract IConsensus | The new consensus | - -## `getTemplateHash()` - -```solidity -function getTemplateHash() external view returns (bytes32) -``` - -Get the dApp's template hash. - -### Return Values - -| Name | Type | Description | -| ---- | ------- | ------------------------ | -| [0] | bytes32 | The dApp's template hash | - -## `getConsensus()` - -```solidity -function getConsensus() external view returns (contract IConsensus) -``` - -Get the current consensus. - -### Return Values - -| Name | Type | Description | -| ---- | ------------------- | --------------------- | -| [0] | contract IConsensus | The current consensus | - -### `receive()` - -```solidity -receive() external payable -``` - -Accept Ether transfers. - -_If you wish to transfer Ether to a dApp while informing -the dApp backend of it, then please do so through the Ether portal contract._ - -## `withdrawEther()` - -```solidity -function withdrawEther(address _receiver, uint256 _value) external -``` - -Transfer some amount of Ether to some recipient. - -_This function can only be called by the dApp itself through vouchers._ - -### Parameters - -| Name | Type | Description | -| ---------- | ------- | -------------------------------------------------- | -| \_receiver | address | The address which will receive the amount of Ether | -| \_value | uint256 | The amount of Ether to be transferred in Wei | - -### `NewConsensus()` - -```solidity -event NewConsensus(IConsensus newConsensus); -``` - -A new consensus is used, this event is emitted when a new consensus is set. This event must be triggered on a successful call to [migrateToConsensus](#migratetoconsensus). - -### Parameters - -| Name | Type | Description | -| ------------ | ---------- | -------------------------- | -| newConsensus | IConsensus | The new consensus contract | - -## `VoucherExecuted()` - -```solidity -event VoucherExecuted(uint256 voucherId); -``` - -A voucher was executed from the dApp, this event is emitted when a voucher is executed so it must be triggered on a successful call to [executeVoucher](#executevoucher). - -### Parameters - -| Name | Type | Description | -| --------- | ------- | --------------------------------------------------------------------------------------- | -| voucherId | uint256 | A number that uniquely identifies the voucher amongst all vouchers emitted by this dApp | - -## `Proof` - -Data for validating outputs - -```solidity -struct Proof { - OutputValidityProof validity; - bytes context; -} -``` - -### Members - -| Name | Type | Description | -| -------- | ------------------------------------------- | ------------------------------------------------ | -| validity | [OutputValidityProof](#outputvalidityproof) | A validity proof for the output | -| context | bytes | Data for querying the right claim from consensus | - -## `OutputValidityProof` - -Data used to prove the validity of an output (notices and vouchers) - -```solidity -struct OutputValidityProof { - uint256 inputIndexWithinEpoch; - uint256 outputIndexWithinInput; - bytes32 outputHashesRootHash; - bytes32 vouchersEpochRootHash; - bytes32 noticesEpochRootHash; - bytes32 machineStateHash; - bytes32[] outputHashInOutputHashesSiblings; - bytes32[] outputHashesInEpochSiblings; -} -``` - -### Members - -| Name | Type | Description | -| -------------------------------- | --------- | ----------------------------------------------------------------- | -| inputIndexWithinEpoch | uint256 | Which input, inside the epoch, the output belongs to | -| outputIndexWithinInput | uint256 | Index of output emitted by the input | -| outputHashesRootHash | bytes32 | Merkle root of hashes of outputs emitted by the input | -| vouchersEpochRootHash | bytes32 | Merkle root of all epoch's voucher metadata hashes | -| noticesEpochRootHash | bytes32 | Merkle root of all epoch's notice metadata hashes | -| machineStateHash | bytes32 | Hash of the machine state claimed this epoch | -| outputHashInOutputHashesSiblings | bytes32[] | Proof that this output metadata is in metadata memory range | -| outputHashesInEpochSiblings | bytes32[] | Proof that this output metadata is in epoch's output memory range | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/input-box.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/input-box.md deleted file mode 100644 index dde658cb..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/input-box.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -id: input-box -title: InputBox -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/inputs/InputBox.sol - title: InputBox contract ---- - -The **InputBox** is a trustless and permissionless contract that receives arbitrary blobs (called "inputs") from anyone and adds a compound hash to an append-only list (called "input box"). Each dApp has its input box. - -The hash stored on-chain comprises the hash of the input blob, the block number and timestamp, the input sender address, and the input index. - -Data availability is guaranteed by the emission of `InputAdded` events on every successful call to addInput. This ensures that inputs can be retrieved by anyone at any time without relying on centralized data providers. - -From the perspective of this contract, inputs are encoding-agnostic byte arrays. It is up to the dApp to interpret, validate, and act upon inputs. - - -## `InputAdded()` - -```solidity -event InputAdded(address dapp, uint256 inboxInputIndex, address sender, bytes input) -``` - -Emitted when an input is added to a dApp's input box. - -#### Parameters - -| Name | Type | Description | -| --------------- | ------- | --------------------------------------- | -| dapp | address | The address of the dApp | -| inboxInputIndex | uint256 | The index of the input in the input box | -| sender | address | The address that sent the input | -| input | bytes | The contents of the input | - -## `addInput()` - -```solidity -function addInput(address _dapp, bytes _input) external returns (bytes32) -``` - -Add an input to a dApp's input box. - -_MUST fire an `InputAdded` event accordingly._ - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------- | -| \_dapp | address | The address of the dApp | -| \_input | bytes | The contents of the input | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ---------------------------------------------- | -| [0] | bytes32 | The hash of the input plus some extra metadata | - -## `getNumberOfInputs()` - -```solidity -function getNumberOfInputs(address _dapp) external view returns (uint256) -``` - -Get the number of inputs in a dApp's input box. - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ----------------------- | -| \_dapp | address | The address of the dApp | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ---------------------------------------- | -| [0] | uint256 | Number of inputs in the dApp's input box | - -## `getInputHash()` - -```solidity -function getInputHash(address _dapp, uint256 _index) external view returns (bytes32) -``` - -Get the hash of an input in a dApp's input box. - -_`_index` MUST be in the interval `[0,n)` where `n` is the number of -inputs in the dApp's input box. See the `getNumberOfInputs` function._ - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ---------------------------------------------- | -| \_dapp | address | The address of the dApp | -| \_index | uint256 | The index of the input in the dApp's input box | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ------------------------------------------------------------------- | -| [0] | bytes32 | The hash of the input at the provided index in the dApp's input box | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/overview.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/overview.md deleted file mode 100644 index 3a41fd00..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/overview.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -id: overview -title: Overview -resources: - - url: https://github.com/cartesi/rollups-contracts/tree/v1.4.0/onchain/rollups/contracts - title: Smart Contracts for Cartesi Rollups ---- - -The Cartesi Rollups framework consists of components on the base layer (the foundational blockchain where a dApp contract is deployed, such as Ethereum) and the execution layer (the Cartesi off-chain layer where the dApp runs its backend logic). - -The frontend interacts with base layer smart contracts to send inputs to the backend, deposit assets, and process outputs. - -To interact with an Ethereum-compatible blockchain, the dApp frontend must connect to a blockchain node using Ethereum's JSON-RPC API. - -There are two ways in which clients can interact with Ethereum-compatible nodes using the JSON-RPC API: - -- **Querying state (read operations)** — The state can be queried by calling functions that do not alter the blockchain state or incur gas fees. - -- **Changing state (write operations)** — The state is changed by submitting a transaction, which incurs gas fees. The transaction must be cryptographically signed by an Ethereum account with funds in its wallet. - -## Cartesi Rollups Smart Contracts - -- [`InputBox`](../json-rpc/input-box.md): This contract receives inputs from users who want to interact with the off-chain layer. All inputs to your dApp go through this contract. - -- [`CartesiDApp`](../json-rpc/application.md): This `CartesiDApp` contract is instantiated for each dApp (i.e., each dApp has its application address). With this address, an application can hold ownership over digital assets on the base layer, like Ether, ERC-20 tokens, and NFTs. - -- [`CartesiDAppFactory`](../json-rpc/application-factory.md): The `CartesiDAppFactory` contract allows anyone to deploy [`CartesiDApp`](../json-rpc//application.md) contracts with a simple function call. It provides greater convenience to the deployer and security to users and validators, as they know the bytecode could not have been altered maliciously. - -- Portals: These are a set of contracts used to safely teleport assets from the base layer to the execution environment of your dApp. Currently, there are Portal contracts for the following types of assets: [Ether (ETH)](../json-rpc/portals/EtherPortal.md), [ERC-20 (Fungible tokens)](../json-rpc//portals/ERC20Portal.md), [ERC-721 (Non-fungible tokens)](../json-rpc//portals/ERC721Portal.md), [ERC-1155 single transfer](../json-rpc/portals/ERC1155SinglePortal.md) and [ERC-1155 batch token transfers](../json-rpc/portals/ERC1155BatchPortal.md). - - diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155BatchPortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155BatchPortal.md deleted file mode 100644 index e91d657d..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155BatchPortal.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC1155BatchPortal.sol - title: ERC1155BatchPortal contract ---- - -The **ERC1155BatchPortal** allows anyone to perform batch transfers of -ERC-1155 tokens to a dApp while informing the off-chain machine. - -## `depositBatchERC1155Token()` - -```solidity -function depositBatchERC1155Token( IERC1155 token, address appContract, uint256[] calldata tokenIds, uint256[] calldata values, bytes calldata baseLayerData, bytes calldata execLayerData) external; -``` - -Transfer a batch of ERC-1155 tokens to a dApp and add an input to -the dApp's input box to signal such operation. - -The caller must enable approval for the portal to manage all of their tokens -beforehand, by calling the `setApprovalForAll` function in the token contract. - -_Please make sure `tokenIds` and `values` have the same length._ - -#### Parameters - -| Name | Type | Description | -| ------------- | --------- | -------------------------------------------------------- | -| token | IERC1155 | The ERC-1155 token contract | -| appContract | address | The address of the dApp | -| tokenIds | uint256[] | The identifiers of the tokens being transferred | -| values | uint256[] | Transfer amounts per token type | -| baseLayerData | bytes | Additional data to be interpreted by the base layer | -| execLayerData | bytes | Additional data to be interpreted by the execution layer | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155SinglePortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155SinglePortal.md deleted file mode 100644 index ad41581a..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC1155SinglePortal.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC1155SinglePortal.sol - title: ERC1155SinglePortal contract ---- - -The **ERC1155SinglePortal** allows anyone to perform single transfers of ERC-1155 tokens to a dApp while informing the off-chain machine. - -### `depositSingleERC1155Token()` - -```solidity -function depositSingleERC1155Token( IERC1155 token, address appContract, uint256 tokenId, uint256 value, bytes calldata baseLayerData, bytes calldata execLayerData) external; - -``` - -Transfer an ERC-1155 token to a dApp and add an input to -the dApp's input box to signal such operation. - -The caller must enable approval for the portal to manage all of their tokens -beforehand, by calling the `setApprovalForAll` function in the token contract. - -#### Parameters - -| Name | Type | Description | -| ------------- | -------- | -------------------------------------------------------- | -| token | IERC1155 | The ERC-1155 token contract | -| appContract | address | The address of the dApp | -| tokenId | uint256 | The identifier of the token being transferred | -| value | uint256 | Transfer amount | -| baseLayerData | bytes | Additional data to be interpreted by the base layer | -| execLayerData | bytes | Additional data to be interpreted by the execution layer | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC20Portal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC20Portal.md deleted file mode 100644 index ded704b1..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC20Portal.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC20Portal.sol - title: ERC20Portal contract ---- - -The **ERC20Portal** allows anyone to perform transfers of -ERC-20 tokens to a dApp while informing the off-chain machine. - -## `depositERC20Tokens()` - -```solidity -function depositERC20Tokens(IERC20 token, address appContract, uint256 value, bytes calldata execLayerData) external; -``` - -Transfer ERC-20 tokens to a dApp and add an input to -the dApp's input box to signal such operation. - -The caller must allow the portal to withdraw at least `_amount` tokens -from their account beforehand, by calling the `approve` function in the -token contract. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------- | -| token | IERC20 | The ERC-20 token contract address | -| appContract | address | The address of the dApp | -| value | uint256 | The amount of tokens to be transferred | -| execLayerData | bytes | Additional data to be interpreted by the execution layer | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC721Portal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC721Portal.md deleted file mode 100644 index 443f7cd5..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/ERC721Portal.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/portals/ERC721Portal.sol - title: ERC721Portal contract ---- - -The **ERC721Portal** allows anyone to perform transfers of -ERC-721 tokens to a dApp while informing the off-chain machine. - -## `depositERC721Token()` - -```solidity -function depositERC721Token( IERC721 token, address appContract, uint256 tokenId, bytes baseLayerData, bytes execLayerData) external -``` - -Transfer an ERC-721 token to a dApp and add an input to -the dApp's input box to signal such operation. - -The caller must change the approved address for the ERC-721 token -to the portal address beforehand, by calling the `approve` function in the -token contract. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------- | -| token | IERC721 | The ERC-721 token contract address | -| appContract | address | The address of the dApp | -| tokenId | uint256 | The identifier of the token being transferred | -| baseLayerData | bytes | Additional data to be interpreted by the base layer | -| execLayerData | bytes | Additional data to be interpreted by the execution layer | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/EtherPortal.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/EtherPortal.md deleted file mode 100644 index a39cb8c4..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/portals/EtherPortal.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.2.0/onchain/rollups/contracts/portals/EtherPortal.sol - title: EtherPortal contract ---- - -The **EtherPortal** allows anyone to perform transfers of -Ether to a dApp while informing the off-chain machine. - -## `depositEther()` - -```solidity -function depositEther(address appContract, bytes execLayerData) external payable -``` - -Transfer Ether to a dApp and add an input to -the dApp's input box to signal such operation. - -All the value sent through this function is forwarded to the dApp. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------- | -| appContract | address | The address of the dApp | -| execLayerData | bytes | Additional data to be interpreted by the execution layer | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/relays/relays.md b/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/relays/relays.md deleted file mode 100644 index 56548533..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/json-rpc/relays/relays.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -id: relays -title: DAppAddressRelay -resources: - - url: https://github.com/cartesi/rollups-contracts/blob/v1.4.0/onchain/rollups/contracts/relays/DAppAddressRelay.sol - title: DAppAddressRelay contract ---- - -The **DAppAddressRelay** contract allows anyone to inform the off-chain machine -of the address of the dApp contract in a trustless and permissionless way. - -## `relayDAppAddress()` - -```solidity -function relayDAppAddress(address _dapp) external -``` - -Add an input to a dApp's input box with its address. - -### Parameters - -| Name | Type | Description | -| ------ | ------- | ----------------------- | -| \_dapp | address | The address of the dApp | diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-notice.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-notice.api.mdx index 900aaf95..f9b08d8a 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-notice.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-notice.api.mdx @@ -5,25 +5,34 @@ description: "The dApp backend can call this method to add a new notice when pro sidebar_label: "Add a new notice" hide_title: true hide_table_of_contents: true -api: {"operationId":"addNotice","description":"The dApp backend can call this method to add a new notice when processing the advance-state request.\nA notice describes any changes to the internal state of the dApp that may be relevant to the blockchain.\nBetween calls to the finish method, the notice method can be called up to 32k times.\n\nThe returned value is the index of the notice for the current advance request.\nIn other words, the index counting restarts at every request.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"payload":{"type":"string","description":"The payload is in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Notice"}}}},"responses":{"200":{"description":"Created the notice.","content":{"application/json":{"schema":{"type":"object","properties":{"index":{"type":"integer","format":"uint64","description":"Position in the Merkle tree.","example":123}},"title":"IndexResponse"}}}},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"post","path":"/notice","servers":[{"url":"https://"},{"url":"http://localhost:5005/rollup"}],"jsonRequestBodyExample":{"payload":"0xdeadbeef"},"info":{"title":"Cartesi Rollup HTTP API","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that the Cartesi Rollup HTTP Server implements.\n\nIn the box below, there is an example of a dApp backend that uses the Rollup HTTP API.\n\n```\nimport requests\nimport sys\n\nrollup = sys.argv[1]\n\ndef check_status_code(response):\n if response.status_code not in range(200, 300):\n print(f'Error: invalid status code {response.status_code}')\n sys.exit(1)\n return response\n\nfinish = {'status': 'accept'}\nwhile True:\n print('Sending finish')\n r = check_status_code(requests.post(rollup + '/finish', json=finish))\n if r.status_code == 202:\n print('No pending rollup request, trying again')\n continue\n\n rollup_request = r.json()\n if rollup_request['request_type'] == 'advance_state':\n print('Sending voucher')\n voucher = {\n 'destination': rollup_request['data']['metadata']['msg_sender'],\n 'payload': rollup_request['data']['payload']\n }\n check_status_code(requests.post(rollup + '/voucher', json=voucher))\n\n print('Sending notice')\n notice = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/notice', json=notice))\n\n print('Sending report')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n finish['status'] = 'accept'\n\n elif rollup_request['request_type'] == 'inspect_state':\n print('Sending report per inspect request')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n else:\n print('Throwing rollup exception')\n exception = {'payload': rollup_request['data']['payload']}\n requests.post(rollup + '/exception', json=exception)\n break\n```\n\nIn production mode, if the dApp exits the Rollups initialization script will register a Rollup Exception.\nSee [/exception](#api-Default-registerException).\n\nIn host mode, the Cartesi Rollups infrastructure is not able to detect that the dApp exited.\nIt is up to the dApp developer to re-launch the dApp.\n"},"postman":{"name":"Add a new notice","description":{"content":"The dApp backend can call this method to add a new notice when processing the advance-state request.\nA notice describes any changes to the internal state of the dApp that may be relevant to the blockchain.\nBetween calls to the finish method, the notice method can be called up to 32k times.\n\nThe returned value is the index of the notice for the current advance request.\nIn other words, the index counting restarts at every request.\n","type":"text/plain"},"url":{"path":["notice"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}}}} +api: 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 sidebar_class_name: "post api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api +info_path: cartesi-rollups/_versioned_docs/version-2.0/api-reference/rollup/cartesi-rollup-http-api custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Add a new notice

+ + - + + + @@ -35,17 +44,34 @@ The returned value is the index of the notice for the current advance request. In other words, the index counting restarts at every request. -
Request Body
+ + -Created the notice. + + + -
Schema
+ + + -Error response. + + + -
Schema
  • string
    -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-report.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-report.api.mdx index b25f0444..c26919d1 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-report.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-report.api.mdx @@ -5,25 +5,34 @@ description: "The dApp can call this method to add a new report for the given ro sidebar_label: "Add a new report" hide_title: true hide_table_of_contents: true -api: {"operationId":"addReport","description":"The dApp can call this method to add a new report for the given rollup request.\nA report can be a diagnostic or a log; reports are not discarded when a request is rejected.\nBetween calls to the finish method, the report method can be called any number of times.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"payload":{"type":"string","description":"The payload is in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Report"}}}},"responses":{"200":{"description":"Created the report."},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"post","path":"/report","servers":[{"url":"https://"},{"url":"http://localhost:5005/rollup"}],"jsonRequestBodyExample":{"payload":"0xdeadbeef"},"info":{"title":"Cartesi Rollup HTTP API","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that the Cartesi Rollup HTTP Server implements.\n\nIn the box below, there is an example of a dApp backend that uses the Rollup HTTP API.\n\n```\nimport requests\nimport sys\n\nrollup = sys.argv[1]\n\ndef check_status_code(response):\n if response.status_code not in range(200, 300):\n print(f'Error: invalid status code {response.status_code}')\n sys.exit(1)\n return response\n\nfinish = {'status': 'accept'}\nwhile True:\n print('Sending finish')\n r = check_status_code(requests.post(rollup + '/finish', json=finish))\n if r.status_code == 202:\n print('No pending rollup request, trying again')\n continue\n\n rollup_request = r.json()\n if rollup_request['request_type'] == 'advance_state':\n print('Sending voucher')\n voucher = {\n 'destination': rollup_request['data']['metadata']['msg_sender'],\n 'payload': rollup_request['data']['payload']\n }\n check_status_code(requests.post(rollup + '/voucher', json=voucher))\n\n print('Sending notice')\n notice = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/notice', json=notice))\n\n print('Sending report')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n finish['status'] = 'accept'\n\n elif rollup_request['request_type'] == 'inspect_state':\n print('Sending report per inspect request')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n else:\n print('Throwing rollup exception')\n exception = {'payload': rollup_request['data']['payload']}\n requests.post(rollup + '/exception', json=exception)\n break\n```\n\nIn production mode, if the dApp exits the Rollups initialization script will register a Rollup Exception.\nSee [/exception](#api-Default-registerException).\n\nIn host mode, the Cartesi Rollups infrastructure is not able to detect that the dApp exited.\nIt is up to the dApp developer to re-launch the dApp.\n"},"postman":{"name":"Add a new report","description":{"content":"The dApp can call this method to add a new report for the given rollup request.\nA report can be a diagnostic or a log; reports are not discarded when a request is rejected.\nBetween calls to the finish method, the report method can be called any number of times.\n","type":"text/plain"},"url":{"path":["report"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"text/plain"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}}}} +api: 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 sidebar_class_name: "post api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api +info_path: cartesi-rollups/_versioned_docs/version-2.0/api-reference/rollup/cartesi-rollup-http-api custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Add a new report

+ + - + + + @@ -32,17 +41,34 @@ A report can be a diagnostic or a log; reports are not discarded when a request Between calls to the finish method, the report method can be called any number of times. -
Request Body
+ + -Created the report. + + + -
+ + + -Error response. + + + -
Schema
  • string
    -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-voucher.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-voucher.api.mdx index f13fa2bd..30ee9878 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-voucher.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/add-voucher.api.mdx @@ -5,25 +5,34 @@ description: "The dApp backend can call this method to add a new voucher when pr sidebar_label: "Add a new voucher" hide_title: true hide_table_of_contents: true -api: {"operationId":"addVoucher","description":"The dApp backend can call this method to add a new voucher when processing an advance-state request.\nVouchers are collateral effects actionable in the blockchain.\nBetween calls to the finish method, the voucher method can be called up to 32k times.\n\nThe returned value is the index of the voucher for the current advance-state request.\nIn other words, the index counting restarts at every request.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"destination":{"type":"string","description":"20-byte address of the destination contract for which the payload will be sent.","example":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"},"payload":{"type":"string","description":"String in Ethereum hex binary format describing a method call to be executed by the destination contract.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xcdcd77c0' corresponds to a payload with length 4 and bytes 205, 205, 119, 192.\nTo describe the method call, the payload should consist of a function selector (method identifier) followed\nby its ABI-encoded arguments.\nref: https://docs.soliditylang.org/en/v0.8.19/abi-spec.html\n","example":"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001"}},"title":"Voucher"}}}},"responses":{"200":{"description":"Created the voucher.","content":{"application/json":{"schema":{"type":"object","properties":{"index":{"type":"integer","format":"uint64","description":"Position in the Merkle tree.","example":123}},"title":"IndexResponse"}}}},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"post","path":"/voucher","servers":[{"url":"https://"},{"url":"http://localhost:5005/rollup"}],"jsonRequestBodyExample":{"destination":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","payload":"0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001"},"info":{"title":"Cartesi Rollup HTTP API","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that the Cartesi Rollup HTTP Server implements.\n\nIn the box below, there is an example of a dApp backend that uses the Rollup HTTP API.\n\n```\nimport requests\nimport sys\n\nrollup = sys.argv[1]\n\ndef check_status_code(response):\n if response.status_code not in range(200, 300):\n print(f'Error: invalid status code {response.status_code}')\n sys.exit(1)\n return response\n\nfinish = {'status': 'accept'}\nwhile True:\n print('Sending finish')\n r = check_status_code(requests.post(rollup + '/finish', json=finish))\n if r.status_code == 202:\n print('No pending rollup request, trying again')\n continue\n\n rollup_request = r.json()\n if rollup_request['request_type'] == 'advance_state':\n print('Sending voucher')\n voucher = {\n 'destination': rollup_request['data']['metadata']['msg_sender'],\n 'payload': rollup_request['data']['payload']\n }\n check_status_code(requests.post(rollup + '/voucher', json=voucher))\n\n print('Sending notice')\n notice = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/notice', json=notice))\n\n print('Sending report')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n finish['status'] = 'accept'\n\n elif rollup_request['request_type'] == 'inspect_state':\n print('Sending report per inspect request')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n else:\n print('Throwing rollup exception')\n exception = {'payload': rollup_request['data']['payload']}\n requests.post(rollup + '/exception', json=exception)\n break\n```\n\nIn production mode, if the dApp exits the Rollups initialization script will register a Rollup Exception.\nSee [/exception](#api-Default-registerException).\n\nIn host mode, the Cartesi Rollups infrastructure is not able to detect that the dApp exited.\nIt is up to the dApp developer to re-launch the dApp.\n"},"postman":{"name":"Add a new voucher","description":{"content":"The dApp backend can call this method to add a new voucher when processing an advance-state request.\nVouchers are collateral effects actionable in the blockchain.\nBetween calls to the finish method, the voucher method can be called up to 32k times.\n\nThe returned value is the index of the voucher for the current advance-state request.\nIn other words, the index counting restarts at every request.\n","type":"text/plain"},"url":{"path":["voucher"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}}}} +api: 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 sidebar_class_name: "post api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api +info_path: cartesi-rollups/_versioned_docs/version-2.0/api-reference/rollup/cartesi-rollup-http-api custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Add a new voucher

+ + - + + + @@ -35,17 +44,34 @@ The returned value is the index of the voucher for the current advance-state req In other words, the index counting restarts at every request. -
Request Body
+ + -Created the voucher. + + + -
Schema
+ + + -Error response. + + + -
Schema
  • string
    -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/finish.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/finish.api.mdx index a2544071..008eaf19 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/finish.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/finish.api.mdx @@ -5,25 +5,34 @@ description: "The dApp backend should call this method to start processing rollu sidebar_label: "Finish and get next request" hide_title: true hide_table_of_contents: true -api: {"operationId":"finish","description":"The dApp backend should call this method to start processing rollup requests.\nThe Rollup HTTP Server returns the next rollup request in the response body.\n\nThe possible values for the request_type field are 'advance_state' and 'inspect_state'.\nThe data field contains the rollup request input data.\nFor advance-state requests, the input data contains the advance-state metadata and the payload.\nFor inspect-state requests, the input data contains only the payload.\n\nAfter processing a rollup request, the dApp back-end should call again the finish method.\nFor advance-state requests, depending on the result of the request processing, it should fill the status field of the request body with 'accept' or 'reject'.\nThe Rollup HTTP Server ignores the content of the status field for the first finish request and after an inspect-state request.\n\nIf the advance-state request is rejected, the vouchers and notices are discarded.\nIn contrast, reports are not discarded in case of rejection.\nWhen running inside a Cartesi Machine, the Cartesi Server Manager reverts the entire state of the machine to what it was before receiving the request.\n\nDuring a finish call, the next rollup request might not be immediately available.\nWhen the dApp backend and the Rollup HTTP Server are running inside a Cartesi Machine, the Cartesi Server Manager pauses the whole machine execution until the next request is ready.\nWhen running in host mode, the Rollup HTTP Server returns the status code 202 after 10 seconds to avoid the connection timing out.\nWhen the Rollup HTTP Server returns 202, the dApp backend should retry the call to finish passing the same arguments as before.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["accept","reject"],"example":"accept"}},"title":"Finish"}}}},"responses":{"200":{"description":"Finish accepted and next rollup request returned.","content":{"application/json":{"schema":{"type":"object","properties":{"request_type":{"type":"string","enum":["advance_state","inspect_state"],"example":"advance_state"},"data":{"type":"object","oneOf":[{"type":"object","properties":{"metadata":{"type":"object","properties":{"msg_sender":{"type":"string","description":"20-byte address of the account that submitted the input.","example":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"},"epoch_index":{"type":"integer","format":"uint64","description":"Deprecated. Always receives 0.","example":0},"input_index":{"type":"integer","format":"uint64","description":"Input index starting from genesis.","example":123},"block_number":{"type":"integer","format":"uint64","description":"Block number when input was posted.","example":10000000},"timestamp":{"type":"integer","format":"uint64","description":"Unix timestamp of block in milliseconds.","example":1588598533000}},"title":"Metadata"},"payload":{"type":"string","description":"The payload is in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Advance"},{"type":"object","properties":{"payload":{"type":"string","description":"The payload is in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Inspect"}]}},"title":"RollupRequest"}}}},"202":{"description":"Finish accepted but try again to obtain the next request."},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"post","path":"/finish","servers":[{"url":"https://"},{"url":"http://localhost:5005/rollup"}],"jsonRequestBodyExample":{"status":"accept"},"info":{"title":"Cartesi Rollup HTTP API","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that the Cartesi Rollup HTTP Server implements.\n\nIn the box below, there is an example of a dApp backend that uses the Rollup HTTP API.\n\n```\nimport requests\nimport sys\n\nrollup = sys.argv[1]\n\ndef check_status_code(response):\n if response.status_code not in range(200, 300):\n print(f'Error: invalid status code {response.status_code}')\n sys.exit(1)\n return response\n\nfinish = {'status': 'accept'}\nwhile True:\n print('Sending finish')\n r = check_status_code(requests.post(rollup + '/finish', json=finish))\n if r.status_code == 202:\n print('No pending rollup request, trying again')\n continue\n\n rollup_request = r.json()\n if rollup_request['request_type'] == 'advance_state':\n print('Sending voucher')\n voucher = {\n 'destination': rollup_request['data']['metadata']['msg_sender'],\n 'payload': rollup_request['data']['payload']\n }\n check_status_code(requests.post(rollup + '/voucher', json=voucher))\n\n print('Sending notice')\n notice = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/notice', json=notice))\n\n print('Sending report')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n finish['status'] = 'accept'\n\n elif rollup_request['request_type'] == 'inspect_state':\n print('Sending report per inspect request')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n else:\n print('Throwing rollup exception')\n exception = {'payload': rollup_request['data']['payload']}\n requests.post(rollup + '/exception', json=exception)\n break\n```\n\nIn production mode, if the dApp exits the Rollups initialization script will register a Rollup Exception.\nSee [/exception](#api-Default-registerException).\n\nIn host mode, the Cartesi Rollups infrastructure is not able to detect that the dApp exited.\nIt is up to the dApp developer to re-launch the dApp.\n"},"postman":{"name":"Finish and get next request","description":{"content":"The dApp backend should call this method to start processing rollup requests.\nThe Rollup HTTP Server returns the next rollup request in the response body.\n\nThe possible values for the request_type field are 'advance_state' and 'inspect_state'.\nThe data field contains the rollup request input data.\nFor advance-state requests, the input data contains the advance-state metadata and the payload.\nFor inspect-state requests, the input data contains only the payload.\n\nAfter processing a rollup request, the dApp back-end should call again the finish method.\nFor advance-state requests, depending on the result of the request processing, it should fill the status field of the request body with 'accept' or 'reject'.\nThe Rollup HTTP Server ignores the content of the status field for the first finish request and after an inspect-state request.\n\nIf the advance-state request is rejected, the vouchers and notices are discarded.\nIn contrast, reports are not discarded in case of rejection.\nWhen running inside a Cartesi Machine, the Cartesi Server Manager reverts the entire state of the machine to what it was before receiving the request.\n\nDuring a finish call, the next rollup request might not be immediately available.\nWhen the dApp backend and the Rollup HTTP Server are running inside a Cartesi Machine, the Cartesi Server Manager pauses the whole machine execution until the next request is ready.\nWhen running in host mode, the Rollup HTTP Server returns the status code 202 after 10 seconds to avoid the connection timing out.\nWhen the Rollup HTTP Server returns 202, the dApp backend should retry the call to finish passing the same arguments as before.\n","type":"text/plain"},"url":{"path":["finish"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}}}} +api: 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 sidebar_class_name: "post api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api +info_path: cartesi-rollups/_versioned_docs/version-2.0/api-reference/rollup/cartesi-rollup-http-api custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Finish and get next request

+ + - + + + @@ -49,21 +58,34 @@ When running in host mode, the Rollup HTTP Server returns the status code 202 af When the Rollup HTTP Server returns 202, the dApp backend should retry the call to finish passing the same arguments as before. -
Request Body
+ + + + + + + + + + + + + + -Finish accepted and next rollup request returned. -
Schema
    data object
  • oneOf
    metadata object
- -Finish accepted but try again to obtain the next request. - -
- -Error response. - -
Schema
  • string
    - -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/register-exception.api.mdx b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/register-exception.api.mdx index 395a0421..088e2437 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/register-exception.api.mdx +++ b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/register-exception.api.mdx @@ -5,25 +5,34 @@ description: "The dApp should call this method when it cannot proceed with the r sidebar_label: "Register an exception" hide_title: true hide_table_of_contents: true -api: {"operationId":"registerException","description":"The dApp should call this method when it cannot proceed with the request processing after an exception happens.\nThis method should be the last method ever called by the dApp backend while processing a request.\n\nWhen running in production mode, the Cartesi Server Manager pauses the Cartesi Machine and reverts the entire state of the machine to what it was before receiving the request.\nNo HTTP status code will be sent or received.\n\nWhen running in host mode, the Rollup HTTP Server returns the status code 200.\nIn both cases, the input will be skipped with the reason EXCEPTION and the exception message will be forwarded.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"payload":{"type":"string","description":"The payload is in the Ethereum hex binary format.\nThe first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.\nFor instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.\nAn empty payload is represented by the string '0x'.\n","example":"0xdeadbeef","title":"Payload"}},"title":"Exception"}}}},"responses":{"200":{"description":"Accepted the exception throw."},"default":{"description":"Error response.","content":{"text/plain":{"schema":{"type":"string","description":"Detailed error message.","example":"The request could not be understood by the server due to malformed syntax","title":"Error"}}}}},"method":"post","path":"/exception","servers":[{"url":"https://"},{"url":"http://localhost:5005/rollup"}],"jsonRequestBodyExample":{"payload":"0xdeadbeef"},"info":{"title":"Cartesi Rollup HTTP API","version":"0.5.1","license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"description":"API that the Cartesi Rollup HTTP Server implements.\n\nIn the box below, there is an example of a dApp backend that uses the Rollup HTTP API.\n\n```\nimport requests\nimport sys\n\nrollup = sys.argv[1]\n\ndef check_status_code(response):\n if response.status_code not in range(200, 300):\n print(f'Error: invalid status code {response.status_code}')\n sys.exit(1)\n return response\n\nfinish = {'status': 'accept'}\nwhile True:\n print('Sending finish')\n r = check_status_code(requests.post(rollup + '/finish', json=finish))\n if r.status_code == 202:\n print('No pending rollup request, trying again')\n continue\n\n rollup_request = r.json()\n if rollup_request['request_type'] == 'advance_state':\n print('Sending voucher')\n voucher = {\n 'destination': rollup_request['data']['metadata']['msg_sender'],\n 'payload': rollup_request['data']['payload']\n }\n check_status_code(requests.post(rollup + '/voucher', json=voucher))\n\n print('Sending notice')\n notice = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/notice', json=notice))\n\n print('Sending report')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n finish['status'] = 'accept'\n\n elif rollup_request['request_type'] == 'inspect_state':\n print('Sending report per inspect request')\n report = {'payload': rollup_request['data']['payload']}\n check_status_code(requests.post(rollup + '/report', json=report))\n\n else:\n print('Throwing rollup exception')\n exception = {'payload': rollup_request['data']['payload']}\n requests.post(rollup + '/exception', json=exception)\n break\n```\n\nIn production mode, if the dApp exits the Rollups initialization script will register a Rollup Exception.\nSee [/exception](#api-Default-registerException).\n\nIn host mode, the Cartesi Rollups infrastructure is not able to detect that the dApp exited.\nIt is up to the dApp developer to re-launch the dApp.\n"},"postman":{"name":"Register an exception","description":{"content":"The dApp should call this method when it cannot proceed with the request processing after an exception happens.\nThis method should be the last method ever called by the dApp backend while processing a request.\n\nWhen running in production mode, the Cartesi Server Manager pauses the Cartesi Machine and reverts the entire state of the machine to what it was before receiving the request.\nNo HTTP status code will be sent or received.\n\nWhen running in host mode, the Rollup HTTP Server returns the status code 200.\nIn both cases, the input will be skipped with the reason EXCEPTION and the exception message will be forwarded.\n","type":"text/plain"},"url":{"path":["exception"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"text/plain"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}}}} +api: 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 sidebar_class_name: "post api-method" -info_path: cartesi-rollups/_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api +info_path: cartesi-rollups/_versioned_docs/version-2.0/api-reference/rollup/cartesi-rollup-http-api custom_edit_url: null --- -import ApiTabs from "@theme/ApiTabs"; -import DiscriminatorTabs from "@theme/DiscriminatorTabs"; -import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint"; -import MimeTabs from "@theme/MimeTabs"; -import ParamsItem from "@theme/ParamsItem"; -import ResponseSamples from "@theme/ResponseSamples"; -import SchemaItem from "@theme/SchemaItem"; -import SchemaTabs from "@theme/SchemaTabs"; +import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; +import ParamsDetails from "@theme/ParamsDetails"; +import RequestSchema from "@theme/RequestSchema"; +import StatusCodes from "@theme/StatusCodes"; +import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; +import Heading from "@theme/Heading"; -

Register an exception

+ + - + + + @@ -37,17 +46,34 @@ When running in host mode, the Rollup HTTP Server returns the status code 200. In both cases, the input will be skipped with the reason EXCEPTION and the exception message will be forwarded. -
Request Body
+ + + + + + + + + + + + + + -Accepted the exception throw. -
- -Error response. - -
Schema
  • string
    - -Detailed error message. - -
\ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/sidebar.js b/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/sidebar.js deleted file mode 100644 index e40358fe..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/api-reference/rollup/sidebar.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = [{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/cartesi-rollup-http-api"},{"type":"category","label":"UNTAGGED","items":[{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/finish","label":"Finish and get next request","className":"api-method post"},{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/add-voucher","label":"Add a new voucher","className":"api-method post"},{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/add-notice","label":"Add a new notice","className":"api-method post"},{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/add-report","label":"Add a new report","className":"api-method post"},{"type":"doc","id":"_versioned_docs/version-1.5/rollups-apis/rollup/register-exception","label":"Register an exception","className":"api-method post"}]}]; \ No newline at end of file diff --git a/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md b/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md index fd9d8550..ac584e03 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md +++ b/cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md @@ -27,8 +27,6 @@ The `cartesi build` command produces the Cartesi genesis machine, which contains After deployment, any changes to the application code will generate a different hash and, hence, require another deployment. -The smart contract that represents the application on the base layer can be deployed using the [`CartesiDAppFactory`](../api-reference/json-rpc/application-factory.md) smart contract. - There are two methods to deploy an application: 1. [Self-hosted deployment](./self-hosted.md): Deploy the application node using your infrastructure diff --git a/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md b/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md index e4f85dc3..4affc444 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md +++ b/cartesi-rollups_versioned_docs/version-2.0/deployment/self-hosted.md @@ -10,96 +10,9 @@ This guide explains how to run a Cartesi Rollups node locally on your machine fo While this setup works with testnet environments, it's designed exclusively for development purposes. It lacks critical production requirements such as: -## Initiating deployment - -1. Compile your application into RISC-V architecture and consequently build a Cartesi machine by running: - - ```shell - cartesi build - ``` - -2. Run the command below to start the deployment process. - - ```shell - cartesi deploy --hosting self-hosted --webapp https://sunodo.io/deploy - ``` - - The command generates a Docker image containing the rollups node and machine. You will be redirected to a web application to deploy the necessary smart contracts. - - ![img](../../../static/img/v1.3/deploy.png) - -## Deploying the contracts - -On the deploy web interface, the hash of the Cartesi machine will be automatically configured. - -1. Connect your wallet to set the application chain’s base layer and deployer account. - -2. Create a wallet specifically for Cartesi rollups node transactions. The Cartesi rollups node will use this wallet to submit transactions to the base layer. Paste the public address of this wallet. - - :::note create a wallet - You can use [Cast](https://book.getfoundry.sh/reference/cast/cast-wallet-new-mnemonic) to create a new wallet by running `cast wallet new-mnemonic --words 24`. For increased security, you can use a wallet managed by [AWS KMS](https://aws.amazon.com/blogs/database/part1-use-aws-kms-to-securely-manage-ethereum-accounts/). - ::: - -3. After successful deployment, the node’s configuration is presented in a `.env` file and a `.toml` format. This config file includes the addresses of the deployed smart contracts and information on the base layer chain. - - You will need the `.env` when [hosting the node on the cloud provider](./self-hosted.md/#hosting-on-a-cloud-provider) and the `.toml` file when [hosting on Fly.io](./self-hosted.md/#hosting-on-flyio). - - - - -## Hosting the node - -You’ll need a server to host the application node and keep it operational 24/7. This server will expose a single port for client access to the rollups node APIs through GraphQL or Inspect requests. - - -The server requirements depend on your application's expected usage and the specifications of the Cartesi machine you're using, such as its RAM size and total capacity. Consider a minimum of 8GB of RAM, and adjust as needed. - - -The Cartesi rollups node is distributed as a Docker image. Any popular cloud provider, like AWS, GCP, Azure, Digital Ocean, or Linode, can run docker containers and hence can be used to host the rollups node. - -Alternatively, you can use a service like [Fly.io](https://fly.io/) to deploy your application node. - -### Hosting on a cloud provider - -1. Download the `.env` configuration file into the root directory of your application. - -1. Obtain HTTP and WebSocket URLs from a web3 provider for the `CARTESI_BLOCKCHAIN_HTTP_ENDPOINT` and `CARTESI_BLOCKCHAIN_WS_ENDPOINT` variables. - - Here is an example from [Alchemy](https://dashboard.alchemy.com/): - - ![img](../../../static/img/v1.3/alchemy.png) - - :::caution important - The web3 provider URLs and wallet mnemonic are sensitive information that can compromise your application and funds. You should keep it **secure** and **private** at all times. - ::: - -1. Create a PostgreSQL database and configure the connection string in the `.env` file. - - The connection string for a PostgreSQL database must be configured at the `CARTESI_POSTGRES_ENDPOINT` variable. - - You can use any PostgreSQL database, whether managed by a cloud provider or set up on your local infrastructure. The key configuration required is the connection string, encompassing the database URL, username, password, and name. The node necessitates a PostgreSQL database to store the application state, which is accessible via the [GraphQL API](../api-reference/graphql/basics.md). - -1. With all the config variables set, here is how you can run the node on your local machine: - - ``` - docker run --env-file -p 10000:10000 - ``` - - Replace `` and `` with the `.env` file name and `sha256` hash of your Cartesi machine. - - The image can be tagged using [docker tag](https://docs.docker.com/reference/cli/docker/image/tag/). - - You can deploy your node with a cloud provider or use any managed container solution, like Kubernetes. - -### Hosting on fly.io - -Fly.io is a platform where you can conveniently deploy applications packaged as Docker containers. - -:::caution important -If deploying to Fly.io from macOS with Apple Silicon, create a Docker image for `linux/amd64` with: `cartesi deploy build --platform linux/amd64` +- Public snapshot verification +- Proper security hardening +- Production-grade infrastructure ::: ## Prerequisites diff --git a/cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md b/cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md index 4c2845ff..106a2771 100644 --- a/cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md +++ b/cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md @@ -12,11 +12,11 @@ As with any execution layer solution, a Cartesi Application that wants to manipu Currently, Cartesi Rollups support the following types of assets: -- [Ether (ETH)](../api-reference/json-rpc/portals/EtherPortal.md) -- [ERC-20](../api-reference/json-rpc/portals/ERC20Portal.md) -- [ERC-721](../api-reference/json-rpc/portals/ERC721Portal.md) -- [ERC-1155 Single](../api-reference/json-rpc/portals/ERC1155SinglePortal.md) -- [ERC-1155 Batch](../api-reference/json-rpc/portals/ERC1155BatchPortal.md) +- [Ether (ETH)](../api-reference/contracts/portals/EtherPortal.md) +- [ERC-20](../api-reference/contracts/portals/ERC20Portal.md) +- [ERC-721](../api-reference/contracts/portals/ERC721Portal.md) +- [ERC-1155 Single](../api-reference/contracts/portals/ERC1155SinglePortal.md) +- [ERC-1155 Batch](../api-reference/contracts/portals/ERC1155BatchPortal.md) ![img](../../..//static/img/v2.0/onchain-contracts.jpg) @@ -48,8 +48,100 @@ Users can deposit assets to a Cartesi Application, but only the Application can Vouchers are crucial in allowing applications in the execution layer to interact with contracts in the base layer through message calls. They are emitted by the off-chain machine and executed by any participant in the base layer. Each voucher includes a destination address and a payload, typically encoding a function call for Solidity contracts. +The application’s off-chain layer often requires knowledge of its address to facilitate on-chain interactions for withdrawals, for example: `transferFrom(sender, recipient, amount)`. In this case, the sender is the application itself. + By calling [`relayDAppAddress()`](../api-reference/json-rpc/relays/relays.md), function of the `DAppAddressRelay` contract, it adds the dApp’s address as a new input for the Cartesi dApp to process. Next, the off-chain machine uses this address to generate a voucher for execution at the [`executeVoucher()`](../api-reference/json-rpc/application.md/#executevoucher) function of the `CartesiDApp` contract. +Below is a sample JavaScript code with the implementations to transfer tokens to whoever calls the application, notice that the `const call` variable is an encoded function data containing the token contract ABI, function name and also arguments like recipient and amount, while the actual `voucher` structure itself contains a destination (erc20 token contract where the transfer execution should occur), the payload (encoded function data in `call`) and finally a value field which is initialized to `0` meaning no Ether is intended to be sent alongside this transfer request. + +```javascript +import { stringToHex, encodeFunctionData, erc20Abi, hexToString, zeroHash } from "viem"; + +const rollup_server = process.env.ROLLUP_HTTP_SERVER_URL; +console.log("HTTP rollup_server url is " + rollup_server); + +async function handle_advance(data) { + console.log("Received advance request data " + JSON.stringify(data)); + + const sender = data["metadata"]["msg_sender"]; + const payload = hexToString(data.payload); + const erc20Token = "0x784f0c076CC55EAD0a585a9A13e57c467c91Dc3a"; // Sample ERC20 token address + + const call = encodeFunctionData({ + abi: erc20Abi, + functionName: "transfer", + args: [sender, BigInt(10)], + }); + + let voucher = { + destination: erc20Token, + payload: call, + value: zeroHash, + }; + + await emitVoucher(voucher); + return "accept"; +} + +const emitVoucher = async (voucher) => { + try { + await fetch(rollup_server + "/voucher", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(voucher), + }); + } catch (error) { + //Do something when there is an error + } +}; +``` + +### Withdrawing Ether + +To execute Ether withdrawal it is important to emit a voucher with the necessary details as regarding whom you intend to send the Ether to and also the amount to send, nevertheless since the Application contract Executes vouchers by making a [safeCall](https://github.com/cartesi/rollups-contracts/blob/cb52d00ededd2da9f8bf7757710301dccb7d536d/src/library/LibAddress.sol#L18C14-L18C22) to the destination, passing a value (Ether amount to send along with the call) and a payload (function signature to call), it's acceptable to leave the payload section empty if you do not intend to call any functions in the destination address while sending just the specified value of Ether to the destination address. If you intend to call a payable function and also send Ether along, you can add a function signature matching the payable function you intend to call to the payload field. + +Below is another sample JavaScript code, this time the voucher structure has been modified to send ether to an address instead of calling a function in a smart contract, notice there is no `encodedFunctionData`, so the payload section is initialized to zeroHash. + +```javascript +import { stringToHex, encodeFunctionData, erc20Abi, hexToString, zeroHash, parseEther } from "viem"; + +const rollup_server = process.env.ROLLUP_HTTP_SERVER_URL; +console.log("HTTP rollup_server url is " + rollup_server); + +async function handle_advance(data) { + console.log("Received advance request data " + JSON.stringify(data)); + + const sender = data["metadata"]["msg_sender"]; + const payload = hexToString(data.payload); + + + let voucher = { + destination: sender, + payload: zeroHash, + value: numberToHex(BigInt(parseEther("1"))).slice(2), + }; + + await emitVoucher(voucher); + return "accept"; +} + +const emitVoucher = async (voucher) => { + try { + await fetch(rollup_server + "/voucher", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(voucher), + }); + } catch (error) { + //Do something when there is an error + } +}; +``` + :::note epoch length By default, Cartesi nodes close one epoch every 7200 blocks. You can [manually set the epoch length](./cli-commands.md/#run) to facilitate quicker asset-handling methods. ::: diff --git a/cartesi-rollups_versioned_docs/version-2.0/development/building-a-dapp.md b/cartesi-rollups_versioned_docs/version-2.0/development/building-a-dapp.md deleted file mode 100644 index 226f1523..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/development/building-a-dapp.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -id: building-a-dapp -title: Building a dApp -resources: - - url: https://github.com/Calindra/nonodo - title: NoNodo - - url: https://cartesiscan.io/ - title: CartesiScan ---- - - -## Creating the application -Cartesi CLI simplifies creating dApps on Cartesi. To create a new application, run: - -```shell -cartesi create --template -``` - -For example, create a Python project. - -```shell -cartesi create new-dapp --template python -``` - -This command creates a `new-dapp` directory with essential files for your dApp development. - -- `Dockerfile`: Contains configurations to build a complete Cartesi machine with your app's dependencies. Your backend code will run in this environment. - -- `README.md`: A markdown file with basic information and instructions about your dApp. - -- `dapp.py`: A Python file with template backend code that serves as your application's entry point. - -- `requirements.txt`: Lists the Python dependencies required for your application. - -Cartesi CLI has templates for the following languages – `cpp`, `cpp-low-level`, `go`, `javascript`, `lua`, `python`, `ruby`, `rust`, and `typescript`. - -After creating your application, you can start building your dApp by adding your logic to the `dapp.py` file. - - -:::note Building with Go? -For Go applications on Cartesi, we recommend using [Rollmelette](https://github.com/rollmelette/rollmelette). It’s a high-level Go framework and an alternative template that simplifies development and enhances input management, providing a smoother and more efficient experience. -::: - - -## Building the application - -“Building” in this context compiles your application into RISC-V architecture and consequently builds a Cartesi machine containing your application. This architecture enables computation done by your application to be reproducible and verifiable. - -With the Docker engine running, change the directory to your application and build by running: - -```shell -cartesi build -``` - -The successful execution of this step will log this in your terminal: - -```shell - . - / \ - / \ -\---/---\ /----\ - \ X \ - \----/ \---/---\ - \ / CARTESI - \ / MACHINE - ' - -[INFO rollup_http_server] starting http dispatcher service... -[INFO rollup_http_server::http_service] starting http dispatcher http service! -[INFO actix_server::builder] starting 1 workers -[INFO actix_server::server] Actix runtime found; starting in Actix runtime -[INFO rollup_http_server::dapp_process] starting dapp -INFO:__main__:HTTP rollup_server url is http://127.0.0.1:5004 -INFO:__main__:Sending finish - -Manual yield rx-accepted (0x100000000 data) -Cycles: 2767791744 -2767791744: b740d27cf75b6cb10b1ab18ebd96be445ca8011143d94d8573221342108822f5 -Storing machine: please wait -Successfully copied 288MB to /Users/michaelasiedu/Code/calculator/python/.cartesi/image -``` -### Memory - -To change the default memory size for the Cartesi Machine, you can personalize it by adding a specific label in your Dockerfile. - -The line below lets you define the memory size in megabytes (MB): - -```dockerfile -LABEL io.cartesi.rollups.ram_size=128Mi -``` - -:::note environment variables -You can create a `.cartesi.env` in the project's root and override any variable controlling the rollups-node. -::: - - -## Running the Application - -Running your application starts your backend on port `8080` and local Anvil node on port `8545`. - -In essence, the node also logs all outputs received by your backend. - -Here are the prerequisites to run the node: - -- Docker Engine must be active. -- Cartesi machine snapshot successfully built with `cartesi build`. - -To start the node, run: - -```shell -cartesi run -``` - -This command runs your backend compiled to RISC-V and packages it as a Cartesi machine. - -:::troubleshoot troubleshooting common errors - -#### Error: Depth Too High - -```shell -Attaching to 2bd74695-prompt-1, 2bd74695-validator-1 -2bd74695-validator-1 | Error: DepthTooHigh { depth: 2, latest: 1 } -2bd74695-validator-1 | Error: DepthTooHigh { depth: 2, latest: 1 } -``` - -This indicates that the node is reading blocks too far behind the current blockchain state. - -#### Solution - -Create or modify a `.cartesi.env` file in your project directory and set: - -```shell -TX_DEFAULT_CONFIRMATIONS=1 -``` - -This adjustment should align the node's block reading with the blockchain's current state. - -::: - -### Overview of Node Services - -The `cartesi run` command activates several services essential for node operation: - -- **Anvil Chain**: Runs a local blockchain available at `http://localhost:8545`. - -- **GraphQL Playground**: An interactive IDE at `http://localhost:8080/graphql` for exploring the GraphQL server. - -- **Blockchain Explorer**: Monitors node activity and manages transactions via `http://localhost:8080/explorer/`. - -- **Inspect**: A diagnostic tool accessible at `http://localhost:8080/inspect/` to inspect the node’s state. - - -### CartesiScan - -[CartesiScan](https://cartesiscan.io/) is a valuable tool for developers and users alike, offering a comprehensive overview of Cartesi Rollups applications and their interactions with the blockchain. - -Additionally, it provides expandable data regarding outputs, encompassing notices, vouchers, and reports. - -When you run your application with `cartesi run` , there is a local instance of CartesiScan on `http://localhost:8080/explorer`. - -:::note Testing tools -[NoNodo](https://github.com/Calindra/nonodo) is a Cartesi Rollups testing tool that works with host machine applications, eliminating the need for Docker or RISC-V compilation. -::: diff --git a/cartesi-rollups_versioned_docs/version-2.0/development/building-an-application.md b/cartesi-rollups_versioned_docs/version-2.0/development/building-an-application.md new file mode 100644 index 00000000..6f04bf24 --- /dev/null +++ b/cartesi-rollups_versioned_docs/version-2.0/development/building-an-application.md @@ -0,0 +1,53 @@ +--- +id: building-an-application +title: Building an application +--- + +“Building” in this context compiles your application into RISC-V architecture and consequently builds a Cartesi machine containing your application. This architecture enables computation done by your application to be reproducible and verifiable. + +Ensure you have Docker engine running, then navigate the directory to your application and build by running: + +```shell +cartesi build +``` + +The successful execution of this step will log this in your terminal: + +```shell + + . + / \ + / \ +\---/---\ /----\ + \ X \ + \----/ \---/---\ + \ / CARTESI + \ / MACHINE + ' + +[INFO rollup_http_server] starting http dispatcher service... +[INFO rollup_http_server::http_service] starting http dispatcher http service! +[INFO actix_server::builder] starting 1 workers +[INFO actix_server::server] Actix runtime found; starting in Actix runtime +[INFO rollup_http_server::dapp_process] starting dapp: dapp +Sending finish + +Manual yield rx-accepted (1) (0x000020 data) +Cycles: 69709199 +69709199: 9e0420c0fda1a5dc9256b3f9783b09f207e5222a88429e91629cc2e495282b35 +Storing machine: please wait +``` + +## Memory + +To change the default memory size for the Cartesi Machine, you can personalize it by adding a specific label in your Dockerfile. + +The line below lets you define the memory size in megabytes (MB): + +```dockerfile +LABEL io.cartesi.rollups.ram_size=128Mi +``` + +:::note environment variables +You can create a `.cartesi.env` in the project's root and override any variable controlling the rollups-node. +::: diff --git a/cartesi-rollups_versioned_docs/version-2.0/development/cli-commands.md b/cartesi-rollups_versioned_docs/version-2.0/development/cli-commands.md deleted file mode 100644 index 6d92fdaa..00000000 --- a/cartesi-rollups_versioned_docs/version-2.0/development/cli-commands.md +++ /dev/null @@ -1,155 +0,0 @@ ---- -id: cli-commands -title: CLI commands ---- - - -The Cartesi CLI provides essential tools for developing, deploying, and interacting with Cartesi applications. This page offers a quick reference to available commands and usage. - -## Basic Usage -To use any command, run: - -```bash -cartesi [COMMAND] -``` - -For detailed help on a specific command, use: - -```bash -cartesi help [COMMAND] -``` - -## Core Commands - -| Command | Description | -|---------|-------------| -| `create` | Create a new application | -| `build` | Build the application | -| `run` | Run the application node | -| `send` | Send input to the application | -| `deploy` | Deploy application to a live network | -| `address-book` | Prints addresses of deployed smart contracts | -| `clean` | Clean build artifacts of the application | -| `doctor` | Verify the minimal system requirements | -| `hash` | Print the image hash generated by the build command | -| `shell` | Start a shell in the Cartesi machine of the application | - - ---- -### `create` - -Create a new Cartesi application from a template. - -#### Usage: -```bash -cartesi create NAME --template [--branch ] -``` - -#### Flags: - -- `--template=