Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The [`WithdrawalConfig`](../contracts/withdrawal/withdrawal-config.md) describes
- `log2MaxNumOfAccounts` sets how many accounts fit (the tree depth);
- `log2LeavesPerAccount` sets each record's size, which is `2^(5 + log2LeavesPerAccount)` bytes.

For the single-token case (see [`UsdWithdrawalOutputBuilder`](../contracts/withdrawal/usd-withdrawal-output-builder.md)), each record is 32 bytes: an 8-byte little-endian balance, followed by the 20-byte owner address, followed by padding.
For the single-token case (see [`UsdWithdrawalOutputBuilder`](../contracts/withdrawal/usd-withdrawal-output-builder.md)), each record is exactly 32 bytes: a 12-byte little-endian `uint96` balance, followed by the 20-byte owner address (no tail padding).

## Creating the accounts drive

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: exception
title: Exception
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

The `/exception` endpoint is used to register an exception when the dApp cannot proceed with request processing. This should be the last method called by the dApp backend while processing a request.

When an exception occurs during request processing, the dApp backend should:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: finish
title: Finish
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

The `/finish` endpoint is used to indicate 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.

The dApp backend should call the `/finish` endpoint to start processing rollup requests. The Rollup HTTP Server returns the next rollup request in the response body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: introduction
title: Introduction
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

The backend of a Cartesi dApp processes requests in the following manner:

- **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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: notices
title: Notices
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

A notice is a verifiable data declaration that attests to off-chain events or conditions and is accompanied by proof.

Notices provide a mechanism to communicate essential off-chain events from the execution layer to the base layer in a verifiable manner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: reports
title: Reports
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

Reports are stateless logs, offering a means to record read-only information without changing the state. Primarily used for logging and diagnostic purposes, reports provide valuable insights into the operation and performance of a dApp.

Unlike notices, reports lack any association with proof and are therefore unsuitable for facilitating trustless interactions, such as on-chain processing or convincing independent third parties of dApp outcomes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ resources:
title: DELEGATECALL Opcode
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

Vouchers serve as a mechanism for facilitating on-chain actions initiated in the execution layer.

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.
Expand Down Expand Up @@ -309,7 +311,7 @@ const abi = [
"function safeTransfer(address,address,uint256)"
];

async function emitSafeERC20Transfer(token, to, amount) {
async function emitSafeErc20Transfer(token, to, amount) {
const call = encodeFunctionData({
abi,
functionName: "safeTransfer",
Expand Down Expand Up @@ -422,7 +424,7 @@ import (
"github.com/ethereum/go-ethereum/common"
)

func emitSafeERC20Transfer(token, to common.Address, amount *big.Int) error {
func emitSafeErc20Transfer(token, to common.Address, amount *big.Int) error {
abiJSON := `[{
"type":"function",
"name":"safeTransfer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,42 @@
id: application-factory
title: ApplicationFactory
resources:
- url: https://github.com/cartesi/rollups-contracts/tree/v3.0.0-alpha.6/src/dapp/ApplicationFactory.sol
- url: https://github.com/cartesi/rollups-contracts/tree/v3.0.0-alpha.9/src/dapp/ApplicationFactory.sol
title: Application Factory contract
- url: https://github.com/cartesi/rollups-contracts/tree/v3.0.0-alpha.9/src/dapp/IApplicationFactory.sol
title: IApplicationFactory interface
---

<!-- Reviewed for Cartesi Rollups v2.0 documentation. -->

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.
Additionally, it provides a function to calculate the address of a potential new `Application` contract based on input parameters.

This contract ensures efficient and secure deployment of `Application` contracts within the Cartesi Rollups framework.
The factory takes an [`IRefundOutputBuilder`](https://github.com/cartesi/rollups-contracts/tree/v3.0.0-alpha.9/src/refund/IRefundOutputBuilder.sol) in its constructor. That refund builder is a factory-wide immutable: every application deployed by this factory shares it, and it is not part of `WithdrawalConfig` or of `newApplication` parameters.

## Functions

### `constructor()`

```solidity
constructor(IRefundOutputBuilder refundOutputBuilder)
```

**Parameters**

| Name | Type | Description |
|------|------|-------------|
| `refundOutputBuilder` | `IRefundOutputBuilder` | Factory-wide builder used for deposit refunds after foreclosure |

### `newApplication()`

```solidity
function newApplication(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
address appOwner,
bytes32 templateHash,
bytes calldata dataAvailability,
IInputBox inputBox,
WithdrawalConfig calldata withdrawalConfig
) external override returns (IApplication)
```
Expand All @@ -35,7 +51,7 @@ Deploys a new Application contract without a salt value for address derivation.
| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
| `appOwner` | `address` | Address of the owner of the application |
| `templateHash` | `bytes32` | Hash of the template for the application |
| `dataAvailability` | `bytes` | The data availability solution |
| `inputBox` | `IInputBox` | The input box contract |
| `withdrawalConfig` | `WithdrawalConfig` | The withdrawal configuration (see [WithdrawalConfig](./withdrawal/withdrawal-config.md)). Pass a zero-valued config to deploy without emergency withdrawal |

**Return Values**
Expand All @@ -51,7 +67,7 @@ function newApplication(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
address appOwner,
bytes32 templateHash,
bytes calldata dataAvailability,
IInputBox inputBox,
WithdrawalConfig calldata withdrawalConfig,
bytes32 salt
) external override returns (IApplication)
Expand All @@ -66,7 +82,7 @@ Deploys a new `Application` contract with a specified salt value for address der
| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
| `appOwner` | `address` | Address of the owner of the application |
| `templateHash` | `bytes32` | Hash of the template for the application |
| `dataAvailability` | `bytes` | The data availability solution |
| `inputBox` | `IInputBox` | The input box contract |
| `withdrawalConfig` | `WithdrawalConfig` | The withdrawal configuration (see [WithdrawalConfig](./withdrawal/withdrawal-config.md)). Pass a zero-valued config to deploy without emergency withdrawal |
| `salt` | `bytes32` | Salt value for address derivation |

Expand All @@ -83,7 +99,7 @@ function calculateApplicationAddress(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
address appOwner,
bytes32 templateHash,
bytes calldata dataAvailability,
IInputBox inputBox,
WithdrawalConfig calldata withdrawalConfig,
bytes32 salt
) external view override returns (address)
Expand All @@ -98,7 +114,7 @@ Calculates the address of a potential new Application contract based on input pa
| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The initial outputs Merkle root validator contract |
| `appOwner` | `address` | Address of the owner of the application |
| `templateHash` | `bytes32` | Hash of the template for the application |
| `dataAvailability` | `bytes` | The data availability solution |
| `inputBox` | `IInputBox` | The input box contract |
| `withdrawalConfig` | `WithdrawalConfig` | The withdrawal configuration (see [WithdrawalConfig](./withdrawal/withdrawal-config.md)). Pass a zero-valued config to deploy without emergency withdrawal |
| `salt` | `bytes32` | Salt value for address derivation |

Expand All @@ -108,16 +124,24 @@ Calculates the address of a potential new Application contract based on input pa
|------|------|-------------|
| `[0]` | `address` | Address of the potential new Application contract |

### `version()`

```solidity
function version() external view returns (string memory)
```

Return the rollups-contracts package version string.

## Events

### `ApplicationCreated()`

```solidity
event ApplicationCreated(
IOutputsMerkleRootValidator outputsMerkleRootValidator,
IOutputsMerkleRootValidator indexed outputsMerkleRootValidator,
address appOwner,
bytes32 templateHash,
bytes dataAvailability,
IInputBox inputBox,
WithdrawalConfig withdrawalConfig,
IApplication appContract
)
Expand All @@ -132,8 +156,8 @@ A new Application contract was deployed.
| `outputsMerkleRootValidator` | `IOutputsMerkleRootValidator` | The outputs Merkle root validator contract |
| `appOwner` | `address` | The owner of the application |
| `templateHash` | `bytes32` | The template hash |
| `dataAvailability` | `bytes` | The data availability solution |
| `withdrawalConfig` | `WithdrawalConfig` | The withdrawal configuration (see [WithdrawalConfig](./withdrawal/withdrawal-config.md)). Pass a zero-valued config to deploy without emergency withdrawal |
| `inputBox` | `IInputBox` | The input box contract |
| `withdrawalConfig` | `WithdrawalConfig` | The withdrawal configuration |
| `appContract` | `IApplication` | The deployed Application contract |

## Errors
Expand All @@ -146,8 +170,20 @@ error InvalidWithdrawalConfig(WithdrawalConfig withdrawalConfig)

Raised at deployment when the provided [`WithdrawalConfig`](./withdrawal/withdrawal-config.md) is invalid, meaning its accounts-drive layout does not fit inside the machine memory (see [`LibWithdrawalConfig.isValid`](./withdrawal/withdrawal-config.md#validation)). Checking the config in the factory means users and the node do not have to check it themselves.

**Parameters**
## Self-hosted factory

| Name | Type | Description |
|------|------|-------------|
| `withdrawalConfig` | `WithdrawalConfig` | The invalid withdrawal configuration |
[`ISelfHostedApplicationFactory`](https://github.com/cartesi/rollups-contracts/tree/v3.0.0-alpha.9/src/dapp/ISelfHostedApplicationFactory.sol) deploys an Authority + Application pair in one transaction.

```solidity
function deployContracts(
address authorityOwner,
uint256 epochLength,
uint256 claimStagingPeriod,
bytes32 templateHash,
IInputBox inputBox,
WithdrawalConfig calldata withdrawalConfig,
bytes32 salt
) external returns (IApplication, IAuthority);
```

There is no `appOwner` parameter: the factory deploys the application under its own ownership and immediately renounces it, so self-hosted applications are ownerless and cannot migrate to another outputs Merkle root validator after deployment. `calculateAddresses` takes the same arguments (without returning ownership control).
Loading
Loading