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

Reset crowdloan rewards storage in Moonbase runtime only. #710

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions moonbeam-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ export const moonbeamDefinitions = {
RewardInfo: {
total_reward: "Balance",
claimed_reward: "Balance",
contributed_relay_addresses: "Vec<RelayChainAccountId>",
},
RegistrationInfo: {
account: "AccountId",
Expand Down
33 changes: 32 additions & 1 deletion runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,38 @@ impl pallet_author_slot_filter::Config for Runtime {
type PotentialAuthors = ParachainStaking;
}

/// Migration that destroys all of pallet crowdloan rewards' stored data.
///
/// This is included in moonbase only so that we can re-test rewards intialization with the new
/// version of the pallet. This migration makes no attempt to recouperate already-claimed tokens
/// and it also mints tokens for the new pot.
///
/// NOT FOR USE IN VALUE-BEARING NETWORKS!
pub struct NukeRewardsStorage;

impl frame_support::traits::OnRuntimeUpgrade for NukeRewardsStorage {
fn on_runtime_upgrade() -> Weight {
// Delete all crowdlaon rewards storage
// Supply only the pallet name, no storage item name or map key
// This will cause the entire pallet's storage to be deleted
frame_support::storage::migration::remove_storage_prefix(b"CrowdloanRewards", &[], &[]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea what the ramifications of this are on storage proof size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to know what was stored there in order to delete it. So I think the storage proof will just need to contain sibling nodes down to the root of this pallet so they can calculate the correct post-state root.

I'm not that confident that I'm right, but that makes sense to me.

This comment was marked as duplicate.


// Reset the pot's funds
<Balances as frame_support::traits::Currency<AccountId>>::make_free_balance_be(
&CrowdloanRewards::account_id(),
//TODO is this the right amount to initialize to?
3_000_000 * currency::UNIT,
JoshOrndorff marked this conversation as resolved.
Show resolved Hide resolved
);

// Return weight of three DB writes (I'm not really that confident this is right)
// * One for the prefix removal
// * One for setting the balance
// * One for updating the total issuance
3 * <Runtime as frame_system::Config>::DbWeight::get().write
}
}

parameter_types! {
// TODO to be revisited
pub const VestingPeriod: BlockNumber = 4 * WEEKS;
pub const MinimumReward: Balance = 0;
pub const Initialized: bool = false;
Expand Down Expand Up @@ -828,6 +858,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
NukeRewardsStorage,
>;

// All of our runtimes share most of their Runtime API implementations.
Expand Down
2 changes: 0 additions & 2 deletions runtime/moonriver/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ fn initialize_crowdloan_addresses_with_batch_and_pay() {
});
}

#[ignore]
#[test]
fn claim_via_precompile() {
ExtBuilder::default()
Expand Down Expand Up @@ -831,7 +830,6 @@ fn reward_info_via_precompile() {
})
}

#[ignore]
#[test]
fn update_reward_address_via_precompile() {
ExtBuilder::default()
Expand Down