3

My team can run unit tests on our parachain crowdloan pallet.

Now how can I get a list of relay accounts, native accounts and reward amounts used in my unit tests from a real life Crowdloan campaign on the Relay Chain?

Here is doc from Polkadot Crowdloan: quote "Each fund has a child-trie which stores all contributors account IDs together with the amount they contributed; the root of this can then be used by the parachain to allow contributors to prove that they made some particular contribution to the project (e.g. to be rewarded through some token or badge)."

I am not sure when it says "the root of this". the root of what? what is the root? How can my the parachain use "the root of this" to find out who(relay account) has made contribution? and how much is the contribution?

Here is an unit test code from PureStake & Moonbeam's pallet unit tests

assert_ok!(Crowdloan::initialize_reward_vec(
    Origin::root(),
    vec![
        ([1u8; 32].into(), Some(1), 500u32.into()),
        ([2u8; 32].into(), Some(2), 500u32.into()),
        (pairs[0].public().into(), None, 500u32.into()),
        (pairs[1].public().into(), None, 500u32.into()),
        (pairs[2].public().into(), None, 500u32.into())
    ]
));

For relay accounts, I see pairs[0], pairs[3], pairs[2] are made from get_ed25519_pairs() located at the mock.rs, and [1u8; 32] & [2u8; 32] are made with random u8 integers I suppose.

For native accounts, I see Some(1) and Some(2), random integers I suppose.

Is this the way to make relay accounts and native accounts in real life or I can use PolkadotJS to achieve the same?

I see 500u32.into() is a reward amount in each of the vector items above.

How can I find out the reward amount for each contributor?

In real life, this contributor vector above can be very large. How can I easily deal with this problem?

Thank you

4
  • 1
    child-tries are mentioned a bit in Shawn's talk on storage: youtube.com/watch?v=kKKOL20FdII
    – Squirrel
    Commented Apr 15, 2022 at 15:54
  • 2
    Please parse your questions here into separate distinct ones. You ask quite a few, and its hard to parse what you are looking for specifically
    – Nuke
    Commented Apr 17, 2022 at 18:40
  • 1
    substrate.stackexchange.com/help/how-to-ask
    – Nuke
    Commented Apr 17, 2022 at 18:40
  • I am not familiar with that code, but from the context it seems that "The root of this" refers to the child-trie. Since child-trie is a trie it has a merkle root. The root of a merkle trie can be used as an authorization of some data being in that trie.
    – pepyakin
    Commented May 6, 2022 at 13:32

0

Browse other questions tagged or ask your own question.