Skip to content

Commit f759e08

Browse files
committed
docs: small write-up.
1 parent 5d68dfe commit f759e08

File tree

2 files changed

+20
-57
lines changed

2 files changed

+20
-57
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,29 @@
1-
## Foundry
1+
# MRC
2+
- **RFC**: [RFC MCR](https://github.com/movementlabsxyz/rfcs/pulls)
23

3-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
4+
This directory contains the implementation of the MRC settlement smart contract. To test the contract, run:
45

5-
Foundry consists of:
6-
7-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
11-
12-
## Documentation
13-
14-
https://book.getfoundry.sh/
15-
16-
## Usage
17-
18-
### Build
19-
20-
```shell
21-
$ forge build
22-
```
23-
24-
### Test
25-
26-
```shell
27-
$ forge test
28-
```
29-
30-
### Format
31-
32-
```shell
33-
$ forge fmt
34-
```
35-
36-
### Gas Snapshots
37-
38-
```shell
39-
$ forge snapshot
6+
```bash
7+
forge test
408
```
419

42-
### Anvil
10+
There is a long-running test cover over 50 epochs. It will take about a minute and a half to complete on most machines.
4311

44-
```shell
45-
$ anvil
46-
```
12+
# Implementation
13+
## Description
14+
For a given block height, MCR selects the earliest block commitment that matches the supermajority of stake for a given epoch by:
15+
1. Fixing the stake parameters for the epoch; all stake changes apply to the next epoch.
16+
2. Tracking commitments for each block height until one exceeds the supermajority of stake.
4717

48-
### Deploy
18+
## Proof of Correctness
19+
The stake is fixed for an epoch, so only commitments for a specific block height are considered, allowing for a straightforward proof.
4920

50-
```shell
51-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52-
```
21+
Let $C$ represent all possible commitments, and $C'$ be an ordered subset of $C$. MCR returns $c_i \in C'$, the earliest commitment matching the supermajority of stake, defined as:
5322

54-
### Cast
23+
$$
24+
\delta(C') = \frac{2}{3} \times \sum_{c \in C'} s(v(c)),
25+
$$
5526

56-
```shell
57-
$ cast <subcommand>
58-
```
27+
where $v: C \to V$ maps a commitment to its validator and $s: V \to \mathbb{N}$ maps a validator to their stake. Define $\sigma'(C', i) = \sum_{j = 0}^{i} s(v(c_j))$, the cumulative stake up to the $i$-th commitment. $\sigma'$ is non-decreasing as $\sigma(C', i) = \sigma(C', i - 1) + s(v(c_i))$.
5928

60-
### Help
61-
62-
```shell
63-
$ forge --help
64-
$ anvil --help
65-
$ cast --help
66-
```
29+
If $\sigma(C', i) \geq \delta(C')$, then $c_i$ is the earliest commitment where the supermajority is met, since any earlier commitment $c_j$ for $j < i$ would violate the non-decreasing nature of $\sigma'$.

protocol-units/settlement/mcr/contracts/test/MCR.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ contract MCRTest is Test {
257257
// dishonest signers
258258
dishonestSigners.push(signer3);
259259

260-
for (uint i = 0; i < 10; i++) {
260+
for (uint i = 0; i < 50; i++) {
261261

262262
for(uint j = 0; j < 10; j++) {
263263

0 commit comments

Comments
 (0)