Using DAC in your Smart Rollups

By Gauthier Sebille

Previously, we have posted two blog posts about DAC. First one to announce that we, Marigold and TriliTech, have successfully deployed the Community DAC on Tezos Ghostnet.

The second one is a tutorial to give you all the details to configure and deploy your own DAC for your Smart Rollups!

In this blog post, we are going to integrate the DAC inside Tzwitter. Without the DAC, Tzwitter was limited to text tzweets. With the DAC, we can now post large text tzweet (>4KB) and images!

Please note that this is not a Smart Rollup tutorial, or a front web app tutorial. Hence, we are going to focus only on the useful functions to push data to Ghostnet Community DAC and reveal them on Smart Rollup side.

Prerequisites

  1. Introducing DAC,
  2. Ghostnet Community DAC is alive,
  3. Originating a Smart Rollup,
  4. Deploy your own DAC to run your DAC Observer.

Improving Tzwitter

As explained in the introduction, we are going to enable Tzwitter user to post images.

  1. Post an image (> 4KB) to Ghostnet Community DAC using Tzwitter front web-app,
  2. Send received DAC Certificate from front to Smart Rollup,
  3. Process received DAC Certificate on Smart Rollup and reveal corresponding data.

DAC Certificate

As you have read in our previous blog posts, a DAC message is composed of three fields, this is a DAC Certificate from the Kernel-SDK point of view:

pub enum Certificate {
    V0(V0Certificate),
}

/// A Dac V0 certificate.
#[derive(Debug, HasEncoding, NomReader, BinWriter)]
pub struct V0Certificate {
    /// The preimage hash of the root [`V0HashPage`].
    ///
    /// [`V0HashPage`]: crate::dac::pages::V0HashPage
    pub root_hash: PreimageHash,
    /// Aggregated signature of the DAC committee.
    pub aggregated_signature: BlsSignature,
    /// Data_encoding.Bit_set.t is actually a Z.t
    pub witnesses: Zarith,
}

If you have followed our previous blog posts, you know there is a fourth field version. This one is not present in the previous struct which is sent to Smart Rollups because it is captured by the Certificate enum. This previous struct is defined inside the Kernel-SDK

fn get_dac_committee() -> Result> {
    // Assume that we have 3 DAC committee Members PK stored as raw bytes of CompressedPK.
    // In the future, we probably want to have a bigger DAC committee.

    // Current PK of member-1 of Community DAC. Public key hash is "tz4EXupF2QRtHyrHW7Cy7y1jtW48NhgcZvXP"
    let pk_0 = PublicKeyBls::from_base58_check(
        "BLpk1nEyxfm3tzJ6Xx6S2UVgMonQ3KFBjKWEZ2TgJg89S7Mykb5dPsT8w7zeg1iUAVXgUqZqybX7",
    )
    .map_err(|_err| Error::FromBase58CheckError)?;

    //Current PK of member-2 of Community DAC. Public key hash is "tz4RnqbpM3PiFGWgAAr2xZGAQKeRM5nqYppq"
    let pk_1 = PublicKeyBls::from_base58_check(
        "BLpk1nHoWTSPMiG1W8qpimTSqrosAxc1L33Hyb9xHgXeVSZkzg26BxMunwajX2zekW8KuuT8Y4LP",
    )
    .map_err(|_err| Error::FromBase58CheckError)?;

    //Current PK of TT member of Community DAC. Public key hash is "tz4CdFt1ktHZz3mfLtmt8e1YwbSvioL7aQEs"
    let pk_2 = PublicKeyBls::from_base58_check(
        "BLpk1rNLTcT3Z6Y8ndq3Dw5XBiJSHuVsMSkn6nczbdt29WG3ksHRw14vy4KqwfMiedmmVYEYC2Nw",
    )
    .map_err(|_err| Error::FromBase58CheckError)?;

    Ok(vec![pk_0, pk_1, pk_2])
}

Order of this list is important, it must be the same that the configuration of DAC Coordinator for the Community DAC.

I provided them in the correct order.

If you want to know more about DAC and Smart Rolups, please read our blog post on Marigold website :point_right: Using DAC in your Smart Rollups