Skip to content

Commit 435d3b1

Browse files
0xAleksaOpacicvitsalisSebastianElvis
authored
docs: rollup contract managment&interaction (#95)
## Description This PR introduces one big doc for rollup bsn contract managment Resolves #79 --------- Co-authored-by: Vitalis Salis <[email protected]> Co-authored-by: Runchao Han <[email protected]>
1 parent 4b2839c commit 435d3b1

File tree

6 files changed

+613
-187
lines changed

6 files changed

+613
-187
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
8080

8181
### Improvements
8282

83+
* [#95](https://github.com/babylonlabs-io/rollup-bsn-contracts/pull/95) docs: rollup contract managment
8384
* [#83](https://github.com/babylonlabs-io/rollup-bsn-contracts/pull/83) docs: rollup bsn contract guide
8485
* [#84](https://github.com/babylonlabs-io/rollup-bsn-contracts/pull/84) chore: consolidate tests for InstantiateMsg
8586
* [#81](https://github.com/babylonlabs-io/rollup-bsn-contracts/issues/81) Add

docs/assets/interaction.png

87.2 KB
Loading

docs/assets/lifecycle.png

80.6 KB
Loading

docs/contract-interaction.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Rollup BSN Contract Interaction
2+
3+
## Table of Contents
4+
5+
1. [Introduction](#introduction)
6+
2. [Committing Public Randomness](#1-committing-public-randomness)
7+
3. [Submitting Finality Signatures](#2-submitting-finality-signatures)
8+
9+
## Introduction
10+
11+
<img width="3100" height="772" alt="governance" src="./assets/interaction.png" />
12+
13+
The Rollup BSN contract is a CosmWasm smart contract deployed on the Babylon
14+
Genesis chain that tracks finality signatures for rollup blocks. Interaction with
15+
the contract is performed by submitting messages to commit public randomness and
16+
to submit finality signatures for rollup blocks. All interactions require the
17+
submitter's BTC public key to be added to the contract's `allow-list`.
18+
19+
Each operation is executed with:
20+
21+
```shell
22+
babylond tx wasm execute <CONTRACT_ADDRESS> '$JSON_MSG'
23+
```
24+
**Note**: `<CONTRACT_ADDRESS>` refers to the address of the deployed Rollup BSN
25+
contract on Babylon. `$JSON_MSG` is the execute message in JSON format,
26+
described below.
27+
28+
## 1. Handling Public Randomness Commitments
29+
30+
To commit a batch of public randomness values, submit a Merkle root to the
31+
contract. This prevents adaptive randomness generation based on block contents.
32+
33+
**Message Format:**
34+
```shell
35+
JSON_MSG={
36+
"commit_public_randomness": {
37+
"commitment": "$MERKLE_ROOT",
38+
"fp_pubkey_hex": "$FP_BTC_PUBKEY",
39+
"num_pub_rand": $COUNT,
40+
"signature": "$SIGNATURE",
41+
"start_height": $START_BLOCK
42+
}
43+
}
44+
```
45+
46+
> **Variables:**
47+
> `$MERKLE_ROOT`: Hex-encoded Merkle root of the randomness batch (string)
48+
> `$FP_BTC_PUBKEY`: Hex-encoded compressed BTC public key of the submitter
49+
> (string)
50+
> `$COUNT`: Number of randomness values committed (integer)
51+
> `$SIGNATURE`: Signature over the commitment (string)
52+
> `$START_BLOCK`: Rollup block height for the first randomness value (integer)
53+
54+
## 2. Submitting Finality Signatures
55+
56+
To submit a finality signature for a rollup block, send a message that proves
57+
the use of previously committed randomness via a Merkle proof.
58+
59+
**Message Format:**
60+
```shell
61+
JSON_MSG={
62+
"submit_finality_signature": {
63+
"block_hash": "$BLOCK_HASH",
64+
"fp_pubkey_hex": "$FP_BTC_PUBKEY",
65+
"height": $BLOCK_HEIGHT,
66+
"proof": "$MERKLE_PROOF",
67+
"pub_rand": "$PUBLIC_RANDOMNESS",
68+
"signature": "$SIGNATURE",
69+
"l1_block_hash_hex": "$L1_HASH",
70+
"l1_block_number": $L1_NUMBER
71+
}
72+
}
73+
```
74+
75+
> **Variables:**
76+
> `$BLOCK_HASH`: Hex-encoded rollup block hash (string)
77+
> `$FP_BTC_PUBKEY`: Hex-encoded compressed BTC public key of the submitter
78+
> (string)
79+
> `$BLOCK_HEIGHT`: Rollup block height (integer)
80+
> `$MERKLE_PROOF`: Merkle proof that `pub_rand` is in the committed Merkle root
81+
> (string)
82+
> `$PUBLIC_RANDOMNESS`: Revealed randomness value (string)
83+
> `$SIGNATURE`: Signature over the message (string)
84+
> `$L1_HASH`: (Optional) L1 block hash (string)
85+
> `$L1_NUMBER`: (Optional) L1 block number (integer)

0 commit comments

Comments
 (0)