Skip to content
New issue

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

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

Already on GitHub? # to your account

Polkadot v1.0.0 upgrade #245

Merged
merged 12 commits into from
Jan 25, 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
431 changes: 212 additions & 219 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"claims",
"enclave-bridge",
Expand Down
42 changes: 21 additions & 21 deletions claims/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,53 @@ edition = "2021"

[dependencies]
libsecp256k1 = { version = "0.7.0", default-features = false, optional = true }
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "3.6.1", default-features = false, features = ["derive"] }
rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.13", default-features = false }
serde_derive = { version = "1.0.13", optional = true }
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
serde = { version = "1.0.171", default-features = false }
serde_derive = { version = "1.0.171", optional = true }

# substrate dependencies
frame-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-std = { package = "sp-std", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
frame-benchmarking = { optional = true, default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", features = ["serde"] }
sp-std = { package = "sp-std", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }

# local
claims-primitives = { package = "claims-primitives", path = "../primitives/claims", default-features = false }
claims-primitives = { package = "claims-primitives", path = "../primitives/claims", default-features = false, features = ["serde_derive"] }

[dev-dependencies]
hex-literal = "0.3.3"
libsecp256k1 = "0.7.0"
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
pallet-vesting = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-vesting = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
serde_json = { version = "1.0" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }

[features]
default = ["std"]
no_std = []
std = [
"claims-primitives/std",
"frame-support/std",
"frame-system/std",
"parity-scale-codec/std",
"rustc-hex/std",
"scale-info/std",
"serde_derive",
"serde/std",
"sp-std/std",
"serde_derive",
"sp-io/std",
"frame-support/std",
"sp-runtime/std",
"frame-system/std",
"claims-primitives/std",
"sp-std/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
"libsecp256k1/static-context",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"libsecp256k1/hmac",
"libsecp256k1/static-context",
]

try-runtime = ["frame-support/try-runtime"]
46 changes: 17 additions & 29 deletions claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ pub use pallet::*;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
#[cfg(feature = "std")]
use sp_runtime::traits::Zero;
use sp_runtime::{
traits::{CheckedSub, DispatchInfoOf, SignedExtension},
traits::{CheckedSub, DispatchInfoOf, SignedExtension, Zero},
transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
},
};
use sp_std::{fmt::Debug, prelude::*, vec};
use sp_std::{fmt::Debug, prelude::*, vec, vec::Vec};

type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
<T as frame_system::Config>::AccountId,
Expand Down Expand Up @@ -85,7 +83,7 @@ pub mod pallet {
pub trait Config: frame_system::Config {
/// The overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
#[pallet::constant]
type Prefix: Get<&'static [u8]>;
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
Expand Down Expand Up @@ -131,7 +129,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn vesting)]
pub(super) type Vesting<T: Config> =
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>;
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;

/// The statement kind that must be signed, if any.
#[pallet::storage]
Expand All @@ -142,22 +140,16 @@ pub mod pallet {
pub(super) type Preclaims<T: Config> = StorageMap<_, Identity, T::AccountId, EthereumAddress>;

#[allow(clippy::type_complexity)]
#[derive(frame_support::DefaultNoBound)]
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub claims:
Vec<(EthereumAddress, BalanceOf<T>, Option<T::AccountId>, Option<StatementKind>)>,
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber))>,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig { claims: Default::default(), vesting: Default::default() }
}
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>))>,
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
// build `Claims`
self.claims.iter().map(|(a, b, _, _)| (a, b)).for_each(|(a, b)| {
Expand Down Expand Up @@ -257,7 +249,7 @@ pub mod pallet {
origin: OriginFor<T>,
who: EthereumAddress,
value: BalanceOf<T>,
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>,
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>,
statement: Option<StatementKind>,
) -> DispatchResult {
ensure_root(origin)?;
Expand Down Expand Up @@ -639,33 +631,30 @@ mod tests {

use parity_scale_codec::Encode;
use sp_core::H256;
use sp_runtime::{DispatchError::Token, TokenError::Frozen};
use sp_runtime::{generic, DispatchError::Token, TokenError::Frozen};
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use super::Call as ClaimsCall;
use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ExistenceRequirement, GenesisBuild, WithdrawReasons},
traits::{ExistenceRequirement, WithdrawReasons},
};

use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Identity, IdentityLookup},
transaction_validity::TransactionLongevity,
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum Test
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Vesting: pallet_vesting::{Pallet, Call, Storage, Config<T>, Event<T>},
Claims: super::pallet::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
Expand All @@ -679,16 +668,15 @@ mod tests {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type Block = generic::Block<Header, UncheckedExtrinsic>;
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<u64>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
Expand Down Expand Up @@ -716,8 +704,8 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type MaxFreezes = ();
}
Expand Down Expand Up @@ -772,7 +760,7 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
Expand Down
43 changes: 21 additions & 22 deletions enclave-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,56 @@ license = "MS-RSL"
edition = "2021"

[dependencies]
codec = { version = "3.0.0", default-features = false, features = ["derive"], package = "parity-scale-codec" }
codec = { version = "3.6.1", default-features = false, features = ["derive"], package = "parity-scale-codec" }
log = { version = "0.4.14", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", features = ["derive"], optional = true }
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
serde = { version = "1.0.171", features = ["derive"], optional = true }

# local
enclave-bridge-primitives = { path = "../primitives/enclave-bridge", default-features = false }
pallet-teerex = { path = "../teerex", default-features = false }
teerex-primitives = { path = "../primitives/teerex", default-features = false }

# substrate dependencies
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
timestamp = { package = "pallet-timestamp", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
timestamp = { package = "pallet-timestamp", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }

# benchmarking
frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
hex-literal = { version = "0.3.2", optional = true }
pallet-balances = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-balances = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
test-utils = { path = "../test-utils", default-features = false, optional = true }

[dev-dependencies]
env_logger = "0.9.0"
externalities = { package = "sp-externalities", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
externalities = { package = "sp-externalities", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
hex-literal = "0.3.2"
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
test-utils = { path = "../test-utils" }

[features]
default = ["std"]
std = [
"codec/std",
"log/std",
"scale-info/std",
"serde",
# local
"pallet-teerex/std",
"enclave-bridge-primitives/std",
# substrate
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-teerex/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"teerex-primitives/std",
"timestamp/std",
]
runtime-benchmarks = [
Expand Down
Loading
Loading