Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testnet setup for development + registrar registration #1

Open
hitchhooker opened this issue Jul 1, 2024 · 0 comments
Open

testnet setup for development + registrar registration #1

hitchhooker opened this issue Jul 1, 2024 · 0 comments

Comments

@hitchhooker
Copy link

hitchhooker commented Jul 1, 2024

TESTNET setup

Prerequisites

Setup mainnet like testnet with ROOT

  1. Clone the Repository

    git clone https://github.com/rotkonetworks/pop-cli
    cd pop-cli
  2. Build the Project

    cargo build
  3. Run the Testnet

    cargo run up parachain -f ./tests/networks/rococo+people.toml

Setup mainnet like testnet with governance

  1. Clone the Repository

    git clone https://github.com/rotkonetworks/pop-cli
    cd pop-cli
  2. Build the Project

    cargo build
  3. Run the Testnet

    cargo run up parachain -f ./tests/networks/polkadot+people.toml

Steps to Create a Registrar with Governance

  1. Set Up and Run the Local Testnet

    Follow the steps in the provided README to set up and run the local testnet.

  2. Access Polkadot.js Apps

    Open Polkadot.js Apps and connect to your local testnet.

  3. Prepare the Extrinsic

    Prepare the extrinsic to make Alice a registrar on the People parachain. You can use the following call to prepare the extrinsic:

    extrinsic: 0x320000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  4. Create a Governance Proposal

    Since you need to act as ROOT and you don't have direct root access, you need to create a governance proposal on the relay chain to send an XCM message to the People parachain. Here’s how to do it:

    • Go to the "Governance" section on Polkadot.js Apps and navigate to "Submit a proposal".

    • Use the following XCM message format to submit the proposal:

    {
      "send": {
        "dest": {
          "V3": {
            "parents": 0,
            "interior": {
              "X1": {
                "Parachain": 1000
              }
            }
          }
        },
        "message": {
          "V3": {
            "transact": {
              "originType": "SovereignAccount",
              "requireWeightAtMost": 1000000000,
              "call": {
                "encoded": "0x320000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
              }
            }
          }
        }
      }
    }
    • Our testnet is set with parachain ID 1000. Change for mainnet accordingly.
  5. Submit and Approve the Proposal

    • After submitting the proposal, it will go through the governance process on the relay chain. Depending on your governance settings, it might require voting or some other form of approval.

    • Once the proposal is approved, the XCM message will be sent to the People parachain.

  6. Verify the Registrar Creation

    • After the XCM message is executed, verify that Alice is now a registrar on the People parachain by checking the appropriate module (likely the identity module) on the People parachain.

Example Polkadot.js Script

If you want to automate some of these steps using a script, you can use the Polkadot.js API. Here’s an example script to submit the governance proposal:

const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');
const { blake2AsHex } = require('@polkadot/util-crypto');

async function main() {
  const HOST = 'ws://127.0.0.1';
  const PORT = 42803;
  const PARACHAIN_ID = 1000;
  const WEIGHT_LIMIT = 1000000000;
  const ENCODED_CALL = '0x320000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
  const ENACTMENT_BLOCKS_AFTER = 10;

  const wsProvider = new WsProvider(`${HOST}:${PORT}`);
  const api = await ApiPromise.create({ provider: wsProvider });

  const keyring = new Keyring({ type: 'sr25519' });
  const alice = keyring.addFromUri('//Alice');

  const xcmMessage = {
    V3: {
      parents: 0,
      interior: { X1: { Parachain: PARACHAIN_ID } }
    }
  };

  const xcmCall = {
    V3: {
      transact: {
        originType: 'SovereignAccount',
        requireWeightAtMost: WEIGHT_LIMIT,
        call: {
          encoded: ENCODED_CALL
        }
      }
    }
  };

  const proposal = api.tx.polkadotXcm.send(xcmMessage, xcmCall);
  const encodedProposal = proposal.method.toHex();
  const proposalHash = blake2AsHex(encodedProposal);

  const proposalLen = encodedProposal.length / 2;
  const enactmentMoment = api.createType('FrameSupportScheduleDispatchTime', { After: ENACTMENT_BLOCKS_AFTER });

  const boundedCall = api.createType('FrameSupportPreimagesBounded', {
    hash_: proposalHash,
    len: proposalLen
  });

  const proposalOrigin = api.createType('PolkadotRuntimeOriginCaller', {
    system: api.createType('FrameSupportDispatchRawOrigin', 'Root')
  });

  const referendaSubmission = api.tx.referenda.submit(proposalOrigin, boundedCall, enactmentMoment);

  const unsub = await referendaSubmission
    .signAndSend(alice, (result) => {
      if (result.status.isInBlock) {
        console.log('Proposal included at block hash', result.status.asInBlock.toHex());
      } else if (result.status.isFinalized) {
        console.log('Proposal finalized at block hash', result.status.asFinalized.toHex());
        unsub();
      }
    });

  console.log('Proposal submitted');
}

main().catch(console.error);```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant