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

📒 Add Ledger support #398

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
54 changes: 54 additions & 0 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ frame-system = { version = "35.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "33.0.0", default-features = false }
frame-system-benchmarking = { version = "35.0.0", default-features = false }
frame-try-runtime = { version = "0.41.0", default-features = false }
frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
sp-api = { version = "33.0.0", default-features = false }
sp-debug-derive = { version = "14.0.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
Expand Down
28 changes: 15 additions & 13 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ itertools.workspace = true
pallet-democracy.workspace = true
pallet-scheduler.workspace = true
pallet-treasury.workspace = true
frame-metadata-hash-extension.workspace = true

# Runtimes
polkadot-runtime.workspace = true
Expand All @@ -88,6 +89,7 @@ std = [
"asset-hub-polkadot-runtime/std",
"cumulus-pallet-xcm/std",
"cumulus-primitives-core/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system/std",
"itertools/use_std",
Expand Down Expand Up @@ -142,40 +144,40 @@ std = [
development-settings = [ "polimec-runtime/development-settings" ]
runtime-benchmarks = [
"asset-hub-polkadot-runtime/runtime-benchmarks",
"polkadot-runtime/runtime-benchmarks",
"penpal-runtime/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-dispenser/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-funding/runtime-benchmarks",
"pallet-linear-release/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"polimec-receiver/runtime-benchmarks",
"polimec-common/runtime-benchmarks",
"polimec-common-test-utils/runtime-benchmarks",
"polimec-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-dispenser/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-funding/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-linear-release/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"penpal-runtime/runtime-benchmarks",
"polimec-common-test-utils/runtime-benchmarks",
"polimec-common/runtime-benchmarks",
"polimec-receiver/runtime-benchmarks",
"polimec-runtime/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"polkadot-runtime/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks"
"xcm-executor/runtime-benchmarks",
]

1 change: 1 addition & 0 deletions integration-tests/src/tests/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn dispenser_signed_extensions_pass_for_new_account() {
pallet_dispenser::extensions::CheckNonce::<PolimecRuntime>::from(0u32),
frame_system::CheckWeight::<PolimecRuntime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<PolimecRuntime>::from(0u64.into()).into(),
frame_metadata_hash_extension::CheckMetadataHash::<PolimecRuntime>::new(true),
);
assert_err!(
extra.validate(&who, &paid_call, &paid_call.get_dispatch_info(), 0),
Expand Down
2 changes: 1 addition & 1 deletion pallets/funding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"itertools/use_alloc",
"on-slash-vesting/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-linear-release/runtime-benchmarks",
Expand All @@ -114,7 +115,6 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"on-slash-vesting/runtime-benchmarks"
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
14 changes: 7 additions & 7 deletions pallets/funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
//! There are 3 types of users in Polimec:
//! - **Issuers**: They create projects and are responsible for their success.
//! - **Evaluators**: They are incentivized to assess projects accurately by locking their PLMC. If at least 10% of its
//! target funding (in USD) is locked in PLMC, a project is given access to the funding round. Evaluators are either
//! rewarded in contribution tokens if the project gets funded, or have their PLMC slashed otherwise.
//! target funding (in USD) is locked in PLMC, a project is given access to the funding round. Evaluators are either
//! rewarded in contribution tokens if the project gets funded, or have their PLMC slashed otherwise.
//! - **Participants**: They contribute financially to projects by locking PLMC and paying out USDT/USDC/DOT, and are rewarded in contribution tokens.
//!
//! Users need to go through a KYC/AML by a third party in order to use the protocol. This process classifies them
Expand All @@ -52,15 +52,15 @@
//! 10) **Remainder Round Start**: After a defined [period](<T as Config>::CommunityRoundDuration), the remainder round starts.
//! 11) **Contribute**: Participants with winning bids can also contribute at the weighted average price with the [`contribute`](Pallet::contribute) extrinsic.
//! 12) **Funding End**: Anyone can end the project with the [`end_project`](Pallet::end_project) extrinsic after the defined end block.
//! The project will now be considered Failed if it reached <=33% of its target funding in USD, and Successful otherwise.
//! The project will now be considered Failed if it reached <=33% of its target funding in USD, and Successful otherwise.
//! 13) **Settlement Start**: Anyone can start the settlement process with the [`start_settlement`](Pallet::start_settlement) extrinsic after the defined end block.
//! 14) **Settle Evaluation**: Anyone can now settle an evaluation with the [`settle_evaluation`](Pallet::settle_evaluation) extrinsic.
//! This will unlock the PLMC bonded, and either apply a slash to the PLMC, or reward CTs to the evaluator.
//! This will unlock the PLMC bonded, and either apply a slash to the PLMC, or reward CTs to the evaluator.
//! 15) **Settle Bid**: Anyone can now settle a bid with the [`settle_bid`](Pallet::settle_bid) extrinsic.
//! This will set a vesting schedule on the PLMC bonded, and pay out the funding assets to the issuer. It will also issue refunds in case the bid failed,
//! or the price paid was higher than the weighted average price.
//! This will set a vesting schedule on the PLMC bonded, and pay out the funding assets to the issuer. It will also issue refunds in case the bid failed,
//! or the price paid was higher than the weighted average price.
//! 16) **Settle Contribution**: Anyone can now settle a contribution with the [`settle_contribution`](Pallet::settle_contribution) extrinsic.
//! This will set a vesting schedule on the PLMC bonded, and pay out the funding assets to the issuer.
//! This will set a vesting schedule on the PLMC bonded, and pay out the funding assets to the issuer.
//! 17) **Settlement End**: Anyone can now mark the project settlement as finished by calling the [`mark_project_as_settled`](Pallet::mark_project_as_settled) extrinsic.
//! 18) **Migration Start**: Once the issuer has tokens to distribute on mainnet, he can start the migration process with the [`start_offchain`](Pallet::start_offchain_migration) extrinsic.
//! 19) **Confirm Migration**: The issuer has to mark each participant's CTs as migrated with the [`confirm_offchain_migration`](Pallet::confirm_offchain_migration) extrinsic.
Expand Down
2 changes: 1 addition & 1 deletion pallets/on-slash-vesting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"sp-runtime/runtime-benchmarks"
"sp-runtime/runtime-benchmarks",
]
2 changes: 0 additions & 2 deletions pallets/on-slash-vesting/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ impl pallet_balances::Config for TestRuntime {
}

impl pallet_vesting::Config for TestRuntime {
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkReason = BenchmarkReason;
type BlockNumberProvider = System;
type BlockNumberToBalance = ConvertInto;
type Currency = Balances;
Expand Down
1 change: 0 additions & 1 deletion pallets/on-slash-vesting/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ fn multiple_schedules() {
assert_ok!(<PalletBalances as MutateHold<u64>>::hold(&MockRuntimeHoldReason::Reason, &1u64, 100u128));
assert_eq!(PalletBalances::usable_balance(1), 0);


PalletSystem::set_block_number(3);

// Unlock 10*2 + 65*2 + 5*2 + 20*2 = 200
Expand Down
11 changes: 9 additions & 2 deletions runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version.workspace = true
workspace = true

[build-dependencies]
substrate-wasm-builder.workspace = true
substrate-wasm-builder = { workspace = true, optional = true }

[dependencies]
parity-scale-codec = { workspace= true, default-features = false, features = [
Expand Down Expand Up @@ -81,6 +81,7 @@ sp-std.workspace = true
sp-transaction-pool.workspace = true
sp-version.workspace = true
sp-genesis-builder.workspace = true
frame-metadata-hash-extension.workspace = true

# Polkadot
pallet-xcm.workspace = true
Expand Down Expand Up @@ -124,6 +125,7 @@ std = [
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
Expand Down Expand Up @@ -181,6 +183,7 @@ std = [
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
Expand All @@ -197,6 +200,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"on-slash-vesting/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand Down Expand Up @@ -228,7 +232,6 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"on-slash-vesting/runtime-benchmarks"
]

try-runtime = [
Expand Down Expand Up @@ -279,8 +282,12 @@ try-runtime = [
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = [
"metadata-hash",
"pallet-funding/on-chain-release-build",
"sp-api/disable-logging",
]

development-settings = [ "shared-configuration/development-settings" ]

# Enable the metadata hash generation in the wasm-builder
metadata-hash = [ "substrate-wasm-builder?/metadata-hash" ]
13 changes: 11 additions & 2 deletions runtimes/polimec/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use substrate_wasm_builder::WasmBuilder;
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults().enable_metadata_hash("PLMC", 10).build();
}

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
WasmBuilder::new().with_current_project().export_heap_base().import_memory().build();
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
2 changes: 2 additions & 0 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub type SignedExtra = (
Runtime,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down Expand Up @@ -901,6 +902,7 @@ where
pallet_dispenser::extensions::SkipCheckIfFeeless::from(
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(true),
);
let raw_payload = generic::SignedPayload::new(call, extra)
.map_err(|e| {
Expand Down
4 changes: 2 additions & 2 deletions runtimes/polimec/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use super::{
AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Balance, Balances, EnsureRoot, ForeignAssets,
Funding, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
ToTreasury, TreasuryAccount, Vec, WeightToFee, XcmpQueue,
ToTreasury, TreasuryAccount, Vec, WeightToFee,
};
use core::marker::PhantomData;
use cumulus_primitives_core::ParaId;
Expand Down Expand Up @@ -320,7 +320,7 @@ pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains.
XcmpQueue,
super::XcmpQueue,
);
#[cfg(feature = "runtime-benchmarks")]
pub type XcmRouter = DummyXcmSender;
Expand Down
2 changes: 1 addition & 1 deletion scripts/zombienet/polimec-paseo-local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ chain_spec_path = "./scripts/zombienet/relay-chain-specs/paseo-local.plain.json"

[[parachains]]
id = 3344
chain = "polimec-paseo"
chain = "polimec-paseo-local"

[[parachains.collators]]
name = "collator1"
Expand Down