Skip to content

Commit 4a3a8a0

Browse files
resolved conflicts for merge
2 parents 0074c51 + e4614e0 commit 4a3a8a0

15 files changed

Lines changed: 611 additions & 168 deletions

File tree

cartesi-rollups_versioned_docs/version-1.5/development/asset-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The dApp’s off-chain layer often requires knowledge of its address to facilita
5353
By calling [`relayDAppAddress()`](../rollups-apis/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()`](../rollups-apis/json-rpc/application.md/#executevoucher) function of the `CartesiDApp` contract.
5454

5555
:::note epoch length
56-
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.
56+
By default, Cartesi nodes close one epoch every 7200 blocks. You can [manually set the epoch length](/get-started/cli-commands/#run) to facilitate quicker asset-handling methods.
5757
:::
5858

5959
Here are the function signatures used by vouchers to withdraw the different types of assets:

cartesi-rollups_versioned_docs/version-1.5/rollups-apis/backend/vouchers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ One everyday use of vouchers in Cartesi dApps is to withdraw assets. Users initi
3131
You can manually set the epoch length to facilitate quicker asset deposits and withdrawals.
3232

3333
:::note epoch duration
34-
[Refer to the documentation here](../../development/cli-commands.md/#run) to manually configure epoch length during development.
34+
[Refer to the documentation here](/get-started/cli-commands/#run) to manually configure epoch length during development.
3535
:::

cartesi-rollups_versioned_docs/version-1.5/tutorials/marketplace.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ cargo add [email protected]
156156
</TabItem>
157157
</Tabs>
158158

159-
**NOTE::** For python developers, add the below snippet to `line 26` of your Dockerfile. It should come immediately after the line `COPY ./requirements.txt .`.
160-
161-
This command would help install essential compilers to help compile some dependencies we'll be using.
159+
:::caution Note for Python Developers
160+
Add the below snippet to `line 26` of your Dockerfile. It should come immediately after the line `COPY ./requirements.txt .`
161+
This command would install essential meta-packages to help compile some dependencies we'll be using.
162+
:::
162163

163164
```Dockerfile
164165
# Install build dependencies for compiling native extensions

cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,5 @@ One common use of vouchers in Cartesi dApps is to withdraw assets. Users initiat
380380
You can manually set the epoch length to facilitate quicker asset deposits and withdrawals.
381381

382382
:::note epoch duration
383-
[Refer to the documentation here](../../development/cli-commands.md/#run) to manually configure epoch length during development.
383+
[Refer to the documentation here](/get-started/cli-commands/#run) to manually configure epoch length during development.
384384
:::

cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const emitVoucher = async (voucher) => {
143143
```
144144

145145
:::note epoch length
146-
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.
146+
By default, Cartesi nodes close one epoch every 7200 blocks. You can manually set the epoch length to facilitate quicker asset-handling methods.
147147
:::
148148

149149
Here are the function signatures used by vouchers to withdraw the different types of assets:
Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
# Bonds
22

3-
:::warning Work in progress
4-
Bonds mechanism is not yet implemented in the Cartesi's fraud proof system. To get the latest updates, get in touch with the core contributors on Cartesi [Discord](https://discord.gg/cartesi).
5-
:::
3+
## What is a bond mechanism?
64

5+
A bond mechanism in the fraud-proof system is an economic security system that requires any participant to post a collateral when submitting a claim in the dispute-resolution process.
6+
7+
The goal is to introduce a modest economic cost to submitting claims, thereby mitigating the impact of Sybil attacks. Bonds provide a means to reimburse dispute-related expenses, ensuring that honest participants are not financially penalized for engaging in validation.
8+
9+
The mechanism is not intended to create participation incentives, rather, its design objective is to keep honest, altruistic validation as close to costless as possible, irrespective of the number or behavior of Sybil identities.
10+
11+
## Why do we need bonds? A Case without Bonds
12+
In a dispute process, each transaction made on Ethereum would incur gas costs for the proposer and the challenger. This cost does not include the bond amount. In this setup, a malicious proposer who can spend a relatively large amount of gas fees has an advantage to repeatedly post claims until the honest challenger exhausts their funds or computational resources.
13+
14+
This is infamously known as the resource-exhaustion attack or [proof-of-whale attack](https://ethresear.ch/t/fraud-proofs-are-broken/19234). It is a type of Sybil attack. To deter such an attack, we introduce a bond system in the fraud-proof system.
15+
16+
Naively introducing a high bond amount will impact decentralisation. Liveness and security may depend on preventing the adversary from creating too many Sybils. Increasing bonds in such a scenario harms decentralization by restricting the number of players that can afford to participate.
17+
18+
## Implementation in PRT v2
19+
Cartesi’s _Permissionless Refereed Tournament (PRT) v2_ features a bond system. Each tournament level requires a bond to be posted in order for a commitment to be submitted.
20+
21+
A defender gets the gas fees as a refund with an optional incentive to be an active defender of the system. In a single dispute process (a tournament system), the fraud-proof design asks participants to stake a bond at each level of the game.
22+
23+
In the worst-case scenario, an honest validator will have one bond for each tournament level. Currently, PRT v2 features three levels: top, middle, and bottom, which correspond to three bonds. Bond values differ at each level.
24+
25+
When joining a tournament, participants must send the bond value in Ether. The contract enforces this requirement and reverts with an `InsufficientBond` error if the payment is insufficient.
26+
27+
The **refund calculation** is capped by three values: the contract balance, a weighted fraction of the bond value, and the actual gas used plus a profit margin. The profit margin incentivizes honest participants to perform necessary operations.
28+
29+
The submitter of the winning commitment receives any remaining bonds after tournament completion, recovering their costs plus rewards from eliminated participants.
30+
31+
However, in practice, issuing refunds introduces an additional challenge. During dispute actions such as bisections and steps, multiple honest validators may attempt the same operation simultaneously. Only the first transaction succeeds, while any following ones revert, creating a race condition that leads to unnecessary gas losses and complicates proper refunds.
32+
33+
To address this, PRT can leverage a targeted technique based on **MEV-Share’s** `mev_sendBundle` RPC. Although MEV-Share is a general MEV redistribution protocol, we rely on it only for its ability to relay transactions predictably through searcher relays. By submitting dispute actions via `mev_sendBundle`, validators avoid public mempool races and ensure that the intended action is included without incurring failed-transaction costs.
34+
35+
This approach preserves the goal of making honest validation effectively costless, even when many validators attempt the same operation.

fraud-proofs/honeypot/introduction.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Introduction
22

3-
:::caution
4-
Honeypot app is being updated. We recently found a bug in the application that has led to a fail-stop state. This means the current deployment is permanently frozen, and the bounty funds within it are no longer recoverable. Get in touch with us on [Discord](https://discord.gg/cWGbyFkQ2W) for more details.
5-
:::
6-
73
This section focuses on the Cartesi application - the Honeypot - its introduction, application logic and how it demonstrates the PRT fraud-proof system's capabilities in a real-world scenario.
84

95
## What is the Honeypot App?

fraud-proofs/references/daveconsensus.md

Lines changed: 73 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
## DaveConsensus Contract
44
---
55

6+
DaveConsensus (also referred to as PRT-Rollups Consensus) is the consensus contract for applications that use Dave-style tournaments (such as PRT) for verification.
7+
This contract is responsible for validating a single application, whose inputs must originate from a pre-configured InputBox contract.
8+
9+
DaveConsensus manages epochs, which are defined as half-open block-number intervals of the form [a, b).
10+
Epochs are numbered sequentially starting from 0.
11+
12+
Off-chain nodes can track progress by subscribing to the _EpochSealed_ event. This event indicates which epochs have been sealed, which ones are fully settled, and which epoch is currently open for challenges.
13+
Anyone may settle an epoch by calling _settle()_, and an epoch’s eligibility for settlement can be checked via _canSettle()_. Learn more about epochs [here](../../../fraud-proofs/fraud-proof-basics/epochs).
14+
15+
This contract links input ingestion, epoch progression, and Dave tournament-based verification under a single consensus interface.
16+
617
### `canSettle()`
718

819
```solidity
@@ -15,25 +26,25 @@ Check if the current epoch can be settled by querying the tournament's arbitrati
1526

1627
| Name | Type | Description |
1728
|------|------|-------------|
18-
| `isFinished` | `bool` | Whether tournament is finished |
19-
| `epochNumber` | `uint256` | Current epoch number |
20-
| `winnerCommitment` | `Tree.Node` | Winner's commitment from tournament |
29+
| `isFinished` | `bool` | Whether the current sealed epoch tournament has finished |
30+
| `epochNumber` | `uint256` | Current sealed epoch number |
31+
| `winnerCommitment` | `Tree.Node` | Winner's commitment in case the tournament has finished |
2132

2233
### `settle()`
2334

2435
```solidity
2536
function settle(uint256 epochNumber, bytes32 outputsMerkleRoot, bytes32[] calldata proof) external
2637
```
2738

28-
Settle an epoch using tournament results and create a new tournament for the next epoch.
39+
Settle the current sealed epoch. On success, it emits an [`EpochSealed`](#epochsealed) event.
2940

3041
**Parameters:**
3142

3243
| Name | Type | Description |
3344
|------|------|-------------|
34-
| `epochNumber` | `uint256` | The epoch number to settle |
35-
| `outputsMerkleRoot` | `bytes32` | Root hash of the outputs Merkle tree |
36-
| `proof` | `bytes32[]` | Merkle proof array for validation |
45+
| `epochNumber` | `uint256` | The current sealed epoch number (used to avoid race conditions) |
46+
| `outputsMerkleRoot` | `bytes32` | The post-epoch outputs Merkle root (used to validate outputs) |
47+
| `proof` | `bytes32[]` | The bottom-up Merkle proof of the outputs Merkle root in the final machine state |
3748

3849
### `getCurrentSealedEpoch()`
3950

@@ -50,7 +61,7 @@ Get information about the current sealed epoch including bounds and tournament.
5061
| `epochNumber` | `uint256` | Current epoch number |
5162
| `inputIndexLowerBound` | `uint256` | Lower bound of input indices (inclusive) |
5263
| `inputIndexUpperBound` | `uint256` | Upper bound of input indices (exclusive) |
53-
| `tournament` | `ITournament` | Current tournament contract |
64+
| `tournament` | `ITournament` | The tournament that will decide the post-epoch state |
5465

5566
### `isOutputsMerkleRootValid()`
5667

@@ -69,9 +80,9 @@ Validate whether a given outputs Merkle root is valid for the specified applicat
6980

7081
**Returns:**
7182

72-
| Name | Type | Description |
83+
| Index | Type | Description |
7384
|------|------|-------------|
74-
| `valid` | `bool` | Whether the outputs Merkle root is valid |
85+
| [0] | `bool` | Whether the outputs Merkle root is valid |
7586

7687
### `provideMerkleRootOfInput()`
7788

@@ -90,63 +101,76 @@ Get the Merkle root for input data at a specific index within the current epoch.
90101

91102
**Returns:**
92103

93-
| Name | Type | Description |
104+
| Index | Type | Description |
94105
|------|------|-------------|
95-
| `merkleRoot` | `bytes32` | Merkle root of the input data |
96-
97-
## DaveConsensusFactory Contract
98-
---
99-
100-
### `newDaveConsensus()`
106+
| [0] | `bytes32` | Merkle root of the input data |
101107

108+
### `ConsensusCreation`
102109
```solidity
103-
function newDaveConsensus(address appContract, Machine.Hash initialMachineStateHash) external returns (DaveConsensus)
110+
event ConsensusCreation(IInputBox inputBox, address appContract, ITournamentFactory tournamentFactory)
104111
```
105112

106-
Deploy a new DaveConsensus contract instance for an application.
113+
An event emitted when a new DaveConsensus contract is deployed.
107114

108115
**Parameters:**
109-
110116
| Name | Type | Description |
111117
|------|------|-------------|
112-
| `appContract` | `address` | Application contract address |
113-
| `initialMachineStateHash` | `Machine.Hash` | Initial state hash of the Cartesi machine |
118+
| `inputBox` | `IInputBox` | The input box contract |
119+
| `appContract` | `address` | The application contract |
120+
| `tournamentFactory` | `ITournamentFactory` | The tournament factory contract |
114121

115-
**Returns:**
122+
### `EpochSealed`
123+
```solidity
124+
event EpochSealed(uint256 epochNumber, uint256 inputIndexLowerBound, uint256 inputIndexUpperBound, Machine.Hash initialMachineStateHash, bytes32 outputsMerkleRoot, ITournament tournament)
125+
```
116126

127+
An event emitted when a new epoch is sealed.
128+
129+
**Parameters:**
117130
| Name | Type | Description |
118131
|------|------|-------------|
119-
| `daveConsensus` | `DaveConsensus` | Deployed DaveConsensus contract instance |
132+
| `epochNumber` | `uint256` | The epoch number |
133+
| `inputIndexLowerBound` | `uint256` | The lower bound of the input index (inclusive) |
134+
| `inputIndexUpperBound` | `uint256` | The upper bound of the input index (exclusive) |
135+
| `initialMachineStateHash` | `Machine.Hash` | The initial machine state hash |
136+
| `outputsMerkleRoot` | `bytes32` | The Merkle root hash of the outputs tree |
137+
| `tournament` | `ITournament` | The sealed epoch tournament contract|
138+
139+
## DaveAppFactory Contract
140+
---
141+
142+
Dave-Application Factory contract allows anyone to reliably deploy an application validated with its corresponding Consensus contract.
120143

121-
### `newDaveConsensus()` (with salt)
144+
### `newDaveApp()`
122145

123146
```solidity
124-
function newDaveConsensus(address appContract, Machine.Hash initialMachineStateHash, bytes32 salt) external returns (DaveConsensus)
147+
function newDaveApp(bytes32 templateHash, bytes32 salt) external returns (IApplication appContract, IDaveConsensus daveConsensus)
125148
```
126149

127-
Deploy a new DaveConsensus contract with deterministic address using CREATE2.
150+
Deploy a new Dave-Application pair deterministically.
128151

129152
**Parameters:**
130153

131154
| Name | Type | Description |
132155
|------|------|-------------|
133-
| `appContract` | `address` | Application contract address |
134-
| `initialMachineStateHash` | `Machine.Hash` | Initial state hash of the Cartesi machine |
135-
| `salt` | `bytes32` | Salt for CREATE2 deterministic deployment |
156+
| `templateHash` | `bytes32` | Template hash of the application |
157+
| `salt` | `bytes32` | A 32-byte value used to add entropy to the addresses |
136158

137159
**Returns:**
138160

139161
| Name | Type | Description |
140162
|------|------|-------------|
141-
| `daveConsensus` | `DaveConsensus` | Deployed DaveConsensus contract instance |
163+
| `appContract` | `IApplication` | Deployed application contract |
164+
| `daveConsensus` | `IDaveConsensus` | Deployed DaveConsensus contract |
142165

143-
### `calculateDaveConsensusAddress()`
166+
167+
### `calculateDaveAppAddress()`
144168

145169
```solidity
146-
function calculateDaveConsensusAddress(address appContract, Machine.Hash initialMachineStateHash, bytes32 salt) external view returns (address)
170+
function calculateDaveAppAddress(bytes32 templateHash, bytes32 salt) external view returns (address appContractAddress, address daveConsensusAddress)
147171
```
148172

149-
Calculate the deployment address for a DaveConsensus contract before deployment.
173+
Calculate the deployment address for a Dave-App pair before deployment.
150174

151175
**Parameters:**
152176

@@ -160,4 +184,18 @@ Calculate the deployment address for a DaveConsensus contract before deployment.
160184

161185
| Name | Type | Description |
162186
|------|------|-------------|
163-
| `address` | `address` | Calculated deployment address |
187+
| `appContractAddress` | `address` | Calculated deployment address for the application contract |
188+
| `daveConsensusAddress` | `address` | Calculated deployment address for the DaveConsensus contract |
189+
190+
### `DaveAppCreated`
191+
```solidity
192+
event DaveAppCreated(IApplication appContract, IDaveConsensus daveConsensus)
193+
```
194+
195+
An event emitted when a new Dave-App pair is deployed.
196+
197+
**Parameters:**
198+
| Name | Type | Description |
199+
|------|------|-------------|
200+
| `appContract` | `IApplication` | The deployed application contract |
201+
| `daveConsensus` | `IDaveConsensus` | The deployed DaveConsensus contract |

0 commit comments

Comments
 (0)