Skip to content

Commit

Permalink
test migration with zombienet
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Jun 24, 2024
1 parent 7874fdf commit d49b0fe
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 77 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

13 changes: 13 additions & 0 deletions pallets/funding/src/functions/7_ct_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Handle the channel open request from the relay on behalf of a parachain.
/// If the para id belongs to a funded project with that id, then send an acceptance message and a request for a
/// channel in the opposite direction to the relay.
pub fn do_handle_channel_open_request(message: Instruction) -> XcmResult {
// TODO: set these constants with a proper value
const EXECUTION_DOT: MultiAsset = MultiAsset {
Expand Down Expand Up @@ -115,6 +118,8 @@ impl<T: Config> Pallet<T> {
}
}

/// Handle the channel accepted message of project->polimec from the relay on behalf of the project parachain.
/// Start the migration readiness check for the project.
pub fn do_handle_channel_accepted(message: Instruction) -> XcmResult {
match message {
Instruction::HrmpChannelAccepted { recipient } => {
Expand Down Expand Up @@ -146,6 +151,8 @@ impl<T: Config> Pallet<T> {
}
}

/// After the bidirectional HRMP channels are established, check that the project chain has the receiver pallet,
/// and has minted the amount of CTs sold to the polimec sovereign account.
#[transactional]
pub fn do_start_migration_readiness_check(caller: &AccountIdOf<T>, project_id: ProjectId) -> DispatchResult {
// * Get variables *
Expand Down Expand Up @@ -237,6 +244,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Handle the migration readiness check response from the project chain.
#[transactional]
pub fn do_migration_check_response(
location: MultiLocation,
Expand Down Expand Up @@ -326,6 +334,9 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Migrate all the CTs of a project for a single participant
/// This entails transferring the funds from the polimec sovereign account to the participant account, and applying
/// a vesting schedule if necessary.
#[transactional]
pub fn do_migrate_one_participant(project_id: ProjectId, participant: AccountIdOf<T>) -> DispatchResult {
// * Get variables *
Expand Down Expand Up @@ -370,6 +381,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Mark the migration item that corresponds to a single participation as confirmed or failed.
#[transactional]
pub fn do_confirm_migrations(location: MultiLocation, query_id: QueryId, response: Response) -> DispatchResult {
use xcm::v3::prelude::*;
Expand All @@ -382,6 +394,7 @@ impl<T: Config> Pallet<T> {
Error::<T>::WrongParaId
);


let status = match response {
Response::DispatchResult(MaybeErrorCode::Success) => {
Self::change_migration_status(project_id, participant.clone(), MigrationStatus::Confirmed)?;
Expand Down
4 changes: 3 additions & 1 deletion runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ polimec-common.workspace = true
pallet-parachain-staking.workspace = true

# Substrate
pallet-sudo = {workspace = true, optional = true}
frame-benchmarking = { workspace = true, optional = true }
frame-executive.workspace = true
frame-support.workspace = true
Expand Down Expand Up @@ -279,5 +280,6 @@ try-runtime = [
on-chain-release-build = [ "sp-api/disable-logging" ]

development-settings = [
"shared-configuration/development-settings"
"shared-configuration/development-settings",
"pallet-sudo"
]
76 changes: 0 additions & 76 deletions scripts/chopsticks/assethub-transfers/polkadot-polimec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,3 @@ import-storage:
{ providers: 1, data: { free: "10000000000000000" } },
],
]
# This will be deleted once Polimec has all funding assets registered in ForeignAssets pallet
ForeignAssets:
Asset:
[
[
[1984],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
[
[10],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
[
[1337],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
]

Metadata:
[
[[1984], { symbol: "USDT", name: USDT, decimals: 6, isFrozen: false }],
[[10], { symbol: "DOT", name: DOT, decimals: 10, isFrozen: false }],
[[1337], { symbol: "USDC", name: USDC, decimals: 6, isFrozen: false }],
]

Account:
[
[
[1984, 15CyvMWHKwbAPQ3ekqRFWLyq3kcjU8ypMuuGfsMnxanW85WZ],
{ balance: 1000000000 },
],
[
[10, 15CyvMWHKwbAPQ3ekqRFWLyq3kcjU8ypMuuGfsMnxanW85WZ],
{ balance: 1000000000 },
],
]

79 changes: 79 additions & 0 deletions scripts/chopsticks/ct-migration/penpal-3000.raw.json

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions scripts/chopsticks/ct-migration/penpal-3369.raw.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions scripts/chopsticks/ct-migration/polkadot-penpal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
db: ./db.sqlite
mock-signature-host: true
genesis: scripts/chopsticks/ct-migration/penpal-3369.raw.json
wasm-override: target/release/wbuild/penpal-runtime/penpal_runtime.compact.compressed.wasm
97 changes: 97 additions & 0 deletions scripts/chopsticks/ct-migration/polkadot-polimec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
db: ./db.sqlite
mock-signature-host: true
endpoint: wss://rpc.polimec.org
wasm-override: target/production/wbuild/polimec-runtime/polimec_runtime.compact.compressed.wasm
import-storage:
System:
Account:
# account0 - 50k PLMC
- - - "5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z"
- providers: 1
data:
free: "500000000000000"

# account1 - 50k PLMC
- - - "5EoHniZVuKRKNXNtVZzw8Jbc8Qtgy8GN5QKDKSA78HEok7YW"
- providers: 1
data:
free: "500000000000000"

# account2 - 50k PLMC
- - - "5GeXY2mKL4ADz7mDtsuHvNrRky48NqdWb4u8c5Sg9N8s3T1y"
- providers: 1
data:
free: "500000000000000"

# account3 - 50k PLMC
- - - "5EfE8r9uWWMazvyh8tkcuuKSy6PbAZQSqq42CXYwGdvwjpb8"
- providers: 1
data:
free: "500000000000000"

# account4 - 50k PLMC
- - - "5C8ULBGhfaP2nmDcuFbiShQ1hMwWsB7ghbChDKAwdszSWnA5"
- providers: 1
data:
free: "500000000000000"

# account5 - 50k PLMC
- - - "5HGqvcE29nHekDEYND3ZZtobbP4UeCcALFgwEm5YUvroZJr6"
- providers: 1
data:
free: "500000000000000"

# account6 - 50k PLMC
- - - "5CGEmsGTJcYSBCdXvsjDUBxW2dtvte5M8By95gwMwToih37s"
- providers: 1
data:
free: "500000000000000"

# account7 - 50k PLMC
- - - "5GsWm46kXRF7p6ifSQjrdc8HgPbzY4uWgJdQSUcGGDczkDGa"
- providers: 1
data:
free: "500000000000000"

# account8 - 50k PLMC
- - - "5H4AWTrkHN6aaQCv2jn48HVZjGhiCqswt6sPBksFPrrf2FPY"
- providers: 1
data:
free: "500000000000000"

# account9 - 50k PLMC
- - - "5CabLepLT8e6NvJCtzrEZLEBRd1FxKXU72F2NvbYTVf3bNej"
- providers: 1
data:
free: "500000000000000"


ForeignAssets:
Account:
# account0 - 500k DOT, 500k USDT, 500k USDC
[
[
[1984, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z],
{ balance: 500000000 },
],
[
[1337, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z],
{ balance: 500000000 },
],
[
[ 10, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z ],
{ balance: 5000000000000 },
],
]

Council:
Members:
[
"5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z",
]

TechnicalCommittee:
Members:
[
"5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z",
]

0 comments on commit d49b0fe

Please sign in to comment.