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

Migrate the node project. #1126

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 0 additions & 18 deletions Cargo.lock

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

9 changes: 3 additions & 6 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ use node_runtime::{
versioned_store::InputValidationLengthConstraint as VsInputValidation,
AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
ContractsConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
MembersConfig, MigrationConfig, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature,
StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig,
VersionedStoreConfig, DAYS, WASM_BINARY,
DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig,
ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
};

type AccountPublic = <Signature as Verify>::Signer;
Expand Down Expand Up @@ -244,7 +243,6 @@ pub fn testnet_genesis(
pallet_grandpa: Some(GrandpaConfig {
authorities: vec![],
}),
pallet_indices: Some(IndicesConfig { indices: vec![] }),
pallet_session: Some(SessionConfig {
keys: initial_authorities
.iter()
Expand Down Expand Up @@ -334,7 +332,6 @@ pub fn testnet_genesis(
channel_banner_constraint: InputValidationLengthConstraint::new(5, 1024),
channel_title_constraint: InputValidationLengthConstraint::new(5, 1024),
}),
migration: Some(MigrationConfig {}),
proposals_codex: Some(ProposalsCodexConfig {
set_validator_count_proposal_voting_period: cpcp
.set_validator_count_proposal_voting_period,
Expand Down
8 changes: 4 additions & 4 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ mod tests {
use codec::{Decode, Encode};
use node_runtime::RuntimeApi;
use node_runtime::{currency::CENTS, SLOT_DURATION};
use node_runtime::{opaque::Block, DigestItem, Signature};
use node_runtime::{Address, BalancesCall, Call, UncheckedExtrinsic};
use node_runtime::{opaque::Block, AccountId, DigestItem, Signature};
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic};
use sc_consensus_babe::{BabeIntermediate, CompatibleDigestItem, INTERMEDIATE_KEY};
use sc_consensus_epochs::descendent_query;
use sc_finality_grandpa::{self as grandpa};
Expand Down Expand Up @@ -590,8 +590,8 @@ mod tests {
},
|service, _| {
let amount = 5 * CENTS;
let to: Address = AccountPublic::from(bob.public()).into_account().into();
let from: Address = AccountPublic::from(charlie.public()).into_account().into();
let to: AccountId = AccountPublic::from(bob.public()).into_account().into();
let from: AccountId = AccountPublic::from(charlie.public()).into_account().into();
let genesis_hash = service.client().block_hash(0).unwrap().unwrap();
let best_block_id = BlockId::number(service.client().chain_info().best_number);
let (spec_version, transaction_version) = {
Expand Down
23 changes: 0 additions & 23 deletions runtime-modules/proposals/codex/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,6 @@ where

pub type Extrinsic = TestXt<Call, ()>;

/*
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVoteHandler;
type RewardRemainder = RewardRemainderMock;
type Event = MetaEvent;
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
type BondingDuration = BondingDuration;
type SessionInterface = Self;
type RewardCurve = RewardCurve;
type NextNewSession = Session;
type ElectionLookahead = ElectionLookahead;
type Call = Call;
type MaxIterations = MaxIterations;
type MinSolutionScoreBump = MinSolutionScoreBump;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = UnsignedPriority;
*/

impl staking::SessionInterface<u64> for Test {
fn disable_validator(_: &u64) -> Result<bool, ()> {
unimplemented!()
Expand Down
3 changes: 2 additions & 1 deletion runtime-modules/working-group/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
Ok(())
}

fn initialize_working_group(
// Initialize working group constraints and mint.
pub(crate) fn initialize_working_group(
opening_human_readable_text_constraint: InputValidationLengthConstraint,
worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
worker_exit_rationale_text_constraint: InputValidationLengthConstraint,
Expand Down
3 changes: 0 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi
pallet-grandpa = { package = 'pallet-grandpa', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-babe = { package = 'pallet-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-indices = { package = 'pallet-indices', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-transaction-payment = { package = 'pallet-transaction-payment', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-transaction-payment-rpc-runtime-api = { package = 'pallet-transaction-payment-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
pallet-authorship = { package = 'pallet-authorship', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
Expand Down Expand Up @@ -133,7 +132,6 @@ std = [
'pallet-staking/std',
# 'pallet-staking-reward-curve/std', // don't have 'std' features
'pallet-sudo/std',
'pallet-indices/std',
'pallet-im-online/std',
'pallet-collective/std',
'pallet-offences/std',
Expand Down Expand Up @@ -168,7 +166,6 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-indices/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"frame-benchmarking",
Expand Down
6 changes: 2 additions & 4 deletions runtime/src/integration/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use frame_support::debug;
use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial};
use sp_runtime::generic;
use sp_runtime::generic::SignedPayload;
use sp_runtime::traits::StaticLookup;
use sp_runtime::SaturatedConversion;

use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic};
use crate::{Call, Indices, Runtime, System};
use crate::{Call, Runtime, System};

/// Stub for zero transaction weights.
pub struct NoWeights;
Expand Down Expand Up @@ -65,7 +64,6 @@ pub(crate) fn create_transaction<
})
.ok()?;
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
let address = Indices::unlookup(account);
let (call, extra, _) = raw_payload.deconstruct();
Some((call, (address, signature, extra)))
Some((call, (account, signature, extra)))
}
29 changes: 3 additions & 26 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

mod constants;
mod integration;
mod migration;
mod primitives;
mod runtime_api;
#[cfg(test)]
Expand All @@ -30,14 +29,11 @@ use frame_support::{construct_runtime, parameter_types};
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as pallet_session_historical;
use pallet_transaction_payment::Multiplier;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_core::crypto::KeyTypeId;
use sp_runtime::curve::PiecewiseLinear;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, OpaqueKeys, Saturating};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, FixedPointNumber, Perbill, Perquintill,
};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, Perbill};
use sp_std::boxed::Box;
use sp_std::vec::Vec;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -110,7 +106,7 @@ impl system::Trait for Runtime {
type Hash = Hash;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = Indices;
type Lookup = IdentityLookup<AccountId>;
Copy link
Member

@mnaamani mnaamani Aug 12, 2020

Choose a reason for hiding this comment

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

With this change, as identified by @shamil-gadelshin we were required to add "Address": "AccountId","LookupSource": "AccountId" to the types registration in polkadot-js api, which isn't done automatically by the api library unless it detects the node-template specName in the runtime version.

type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Event = Event;
type BlockHashCount = BlockHashCount;
Expand Down Expand Up @@ -190,17 +186,6 @@ where
type OverarchingCall = Call;
}

parameter_types! {
pub const IndexDeposit: Balance = 0; // no minimum deposit
}

impl pallet_indices::Trait for Runtime {
type AccountIndex = AccountIndex;
type Currency = Balances;
type Deposit = IndexDeposit;
type Event = Event;
}

parameter_types! {
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
}
Expand Down Expand Up @@ -228,9 +213,6 @@ impl pallet_balances::Trait for Runtime {

parameter_types! {
pub const TransactionByteFee: Balance = 0; // TODO: adjust fee
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
}

impl pallet_transaction_payment::Trait for Runtime {
Expand Down Expand Up @@ -487,9 +469,6 @@ impl forum::Trait for Runtime {
type PostId = PostId;
}

impl migration::Trait for Runtime {
type Event = Event;
}
// The storage working group instance alias.
pub type StorageWorkingGroupInstance = working_group::Instance2;

Expand Down Expand Up @@ -618,7 +597,6 @@ construct_runtime!(
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Expand All @@ -633,7 +611,6 @@ construct_runtime!(
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
Copy link
Member

Choose a reason for hiding this comment

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

Unless we are able to control who can deploy contracts, we should we keep the Contracts module out for now until we decide we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I'll remove all traces of the contracts pallet.

// Joystream
Migration: migration::{Module, Call, Storage, Event<T>, Config},
CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
Council: council::{Module, Call, Storage, Event<T>, Config<T>},
Memo: memo::{Module, Call, Storage, Event<T>},
Expand Down
75 changes: 0 additions & 75 deletions runtime/src/migration.rs

This file was deleted.

10 changes: 4 additions & 6 deletions runtime/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use sp_api::impl_runtime_apis;
use sp_core::crypto::KeyTypeId;
use sp_core::OpaqueMetadata;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor, StaticLookup};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor};
use sp_runtime::{generic, ApplyExtrinsicResult};
use sp_std::vec::Vec;

Expand All @@ -17,12 +17,10 @@ use crate::{
GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION,
};
use crate::{
AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, Indices,
InherentDataExt, RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, InherentDataExt,
RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
};

/// The address format for describing accounts.
pub type Address = <Indices as StaticLookup>::Source;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
Copy link
Member

Choose a reason for hiding this comment

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

If the contracts module is in the runtime, I think there needs to be a signed extension, something about checks on Gas?

Copy link
Contributor Author

@shamil-gadelshin shamil-gadelshin Aug 10, 2020

Choose a reason for hiding this comment

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

I'll remove all traces of the contracts pallet.

system::CheckSpecVersion<Runtime>,
Expand Down Expand Up @@ -51,7 +49,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signature, SignedExtra>;

/// Executive: handles dispatch to the various modules.
pub type Executive =
Expand Down