|
| 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