Skip to content

Commit fc2999a

Browse files
authored
Polkadot v1.0.0 upgrade (#245)
* upgrade to polkadot-v1.0.0 * cargo fix * fmt * fix typo * zepter, taplo and sort features * fix claims * fix std? * bump serde * serde feature fix * fix serde for claims * clippy * fix
1 parent 094b1e9 commit fc2999a

File tree

35 files changed

+587
-623
lines changed

35 files changed

+587
-623
lines changed

Cargo.lock

Lines changed: 212 additions & 219 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
2+
resolver = "2"
23
members = [
34
"claims",
45
"enclave-bridge",

claims/Cargo.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,53 @@ edition = "2021"
77

88
[dependencies]
99
libsecp256k1 = { version = "0.7.0", default-features = false, optional = true }
10-
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
10+
parity-scale-codec = { version = "3.6.1", default-features = false, features = ["derive"] }
1111
rustc-hex = { version = "2.1.0", default-features = false }
12-
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
13-
serde = { version = "1.0.13", default-features = false }
14-
serde_derive = { version = "1.0.13", optional = true }
12+
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
13+
serde = { version = "1.0.171", default-features = false }
14+
serde_derive = { version = "1.0.171", optional = true }
1515

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

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

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

3535
[features]
3636
default = ["std"]
3737
no_std = []
3838
std = [
39+
"claims-primitives/std",
40+
"frame-support/std",
41+
"frame-system/std",
3942
"parity-scale-codec/std",
4043
"rustc-hex/std",
4144
"scale-info/std",
42-
"serde_derive",
4345
"serde/std",
44-
"sp-std/std",
46+
"serde_derive",
4547
"sp-io/std",
46-
"frame-support/std",
4748
"sp-runtime/std",
48-
"frame-system/std",
49-
"claims-primitives/std",
49+
"sp-std/std",
5050
]
5151
runtime-benchmarks = [
52-
"libsecp256k1/hmac",
53-
"libsecp256k1/static-context",
5452
"frame-benchmarking",
5553
"frame-support/runtime-benchmarks",
5654
"frame-system/runtime-benchmarks",
55+
"libsecp256k1/hmac",
56+
"libsecp256k1/static-context",
5757
]
5858

5959
try-runtime = ["frame-support/try-runtime"]

claims/src/lib.rs

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ pub use pallet::*;
2828
use parity_scale_codec::{Decode, Encode};
2929
use scale_info::TypeInfo;
3030
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
31-
#[cfg(feature = "std")]
32-
use sp_runtime::traits::Zero;
3331
use sp_runtime::{
34-
traits::{CheckedSub, DispatchInfoOf, SignedExtension},
32+
traits::{CheckedSub, DispatchInfoOf, SignedExtension, Zero},
3533
transaction_validity::{
3634
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
3735
},
3836
};
39-
use sp_std::{fmt::Debug, prelude::*, vec};
37+
use sp_std::{fmt::Debug, prelude::*, vec, vec::Vec};
4038

4139
type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
4240
<T as frame_system::Config>::AccountId,
@@ -85,7 +83,7 @@ pub mod pallet {
8583
pub trait Config: frame_system::Config {
8684
/// The overarching event type.
8785
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
88-
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>;
86+
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
8987
#[pallet::constant]
9088
type Prefix: Get<&'static [u8]>;
9189
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
@@ -131,7 +129,7 @@ pub mod pallet {
131129
#[pallet::storage]
132130
#[pallet::getter(fn vesting)]
133131
pub(super) type Vesting<T: Config> =
134-
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>;
132+
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;
135133

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

144142
#[allow(clippy::type_complexity)]
143+
#[derive(frame_support::DefaultNoBound)]
145144
#[pallet::genesis_config]
146145
pub struct GenesisConfig<T: Config> {
147146
pub claims:
148147
Vec<(EthereumAddress, BalanceOf<T>, Option<T::AccountId>, Option<StatementKind>)>,
149-
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber))>,
150-
}
151-
152-
#[cfg(feature = "std")]
153-
impl<T: Config> Default for GenesisConfig<T> {
154-
fn default() -> Self {
155-
GenesisConfig { claims: Default::default(), vesting: Default::default() }
156-
}
148+
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>))>,
157149
}
158150

159151
#[pallet::genesis_build]
160-
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
152+
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
161153
fn build(&self) {
162154
// build `Claims`
163155
self.claims.iter().map(|(a, b, _, _)| (a, b)).for_each(|(a, b)| {
@@ -257,7 +249,7 @@ pub mod pallet {
257249
origin: OriginFor<T>,
258250
who: EthereumAddress,
259251
value: BalanceOf<T>,
260-
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>,
252+
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>,
261253
statement: Option<StatementKind>,
262254
) -> DispatchResult {
263255
ensure_root(origin)?;
@@ -639,33 +631,30 @@ mod tests {
639631

640632
use parity_scale_codec::Encode;
641633
use sp_core::H256;
642-
use sp_runtime::{DispatchError::Token, TokenError::Frozen};
634+
use sp_runtime::{generic, DispatchError::Token, TokenError::Frozen};
643635
// The testing primitives are very useful for avoiding having to work with signatures
644636
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
645637
use super::Call as ClaimsCall;
646638
use frame_support::{
647639
assert_err, assert_noop, assert_ok,
648640
dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays},
649641
ord_parameter_types, parameter_types,
650-
traits::{ExistenceRequirement, GenesisBuild, WithdrawReasons},
642+
traits::{ExistenceRequirement, WithdrawReasons},
651643
};
652644

653645
use sp_runtime::{
654646
testing::Header,
655647
traits::{BlakeTwo256, Identity, IdentityLookup},
656648
transaction_validity::TransactionLongevity,
649+
BuildStorage,
657650
};
658651

659652
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
660-
type Block = frame_system::mocking::MockBlock<Test>;
661653

662654
frame_support::construct_runtime!(
663-
pub enum Test where
664-
Block = Block,
665-
NodeBlock = Block,
666-
UncheckedExtrinsic = UncheckedExtrinsic,
655+
pub enum Test
667656
{
668-
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
657+
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
669658
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
670659
Vesting: pallet_vesting::{Pallet, Call, Storage, Config<T>, Event<T>},
671660
Claims: super::pallet::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
@@ -679,16 +668,15 @@ mod tests {
679668
type BaseCallFilter = frame_support::traits::Everything;
680669
type BlockWeights = ();
681670
type BlockLength = ();
671+
type Block = generic::Block<Header, UncheckedExtrinsic>;
682672
type DbWeight = ();
683673
type RuntimeOrigin = RuntimeOrigin;
684674
type RuntimeCall = RuntimeCall;
685-
type Index = u64;
686-
type BlockNumber = u64;
675+
type Nonce = u64;
687676
type Hash = H256;
688677
type Hashing = BlakeTwo256;
689678
type AccountId = u64;
690679
type Lookup = IdentityLookup<u64>;
691-
type Header = Header;
692680
type RuntimeEvent = RuntimeEvent;
693681
type BlockHashCount = BlockHashCount;
694682
type Version = ();
@@ -716,8 +704,8 @@ mod tests {
716704
type MaxReserves = ();
717705
type ReserveIdentifier = [u8; 8];
718706
type WeightInfo = ();
719-
type HoldIdentifier = ();
720707
type FreezeIdentifier = ();
708+
type RuntimeHoldReason = ();
721709
type MaxHolds = ();
722710
type MaxFreezes = ();
723711
}
@@ -772,7 +760,7 @@ mod tests {
772760
// This function basically just builds a genesis storage key/value store according to
773761
// our desired mockup.
774762
pub fn new_test_ext() -> sp_io::TestExternalities {
775-
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
763+
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
776764
// We use default for brevity, but you can configure as desired if needed.
777765
pallet_balances::GenesisConfig::<Test>::default()
778766
.assimilate_storage(&mut t)

enclave-bridge/Cargo.toml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,56 @@ license = "MS-RSL"
99
edition = "2021"
1010

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

1717
# local
1818
enclave-bridge-primitives = { path = "../primitives/enclave-bridge", default-features = false }
1919
pallet-teerex = { path = "../teerex", default-features = false }
2020
teerex-primitives = { path = "../primitives/teerex", default-features = false }
2121

2222
# substrate dependencies
23-
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
24-
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
25-
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
26-
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
27-
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
28-
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
29-
timestamp = { package = "pallet-timestamp", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
23+
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
24+
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
25+
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
26+
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
27+
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
28+
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
29+
timestamp = { package = "pallet-timestamp", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
3030

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

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

4646
[features]
4747
default = ["std"]
4848
std = [
4949
"codec/std",
50-
"log/std",
51-
"scale-info/std",
52-
"serde",
53-
# local
54-
"pallet-teerex/std",
5550
"enclave-bridge-primitives/std",
56-
# substrate
5751
"frame-support/std",
5852
"frame-system/std",
53+
"log/std",
54+
"pallet-teerex/std",
55+
"scale-info/std",
56+
"serde",
5957
"sp-core/std",
6058
"sp-io/std",
6159
"sp-runtime/std",
6260
"sp-std/std",
61+
"teerex-primitives/std",
6362
"timestamp/std",
6463
]
6564
runtime-benchmarks = [

0 commit comments

Comments
 (0)