Browse Source

runtime: Migrate to Substrate v2.0.0

Shamil Gadelshin 4 years ago
parent
commit
74fe277be6

File diff suppressed because it is too large
+ 614 - 110
Cargo.lock


+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [workspace]
 members = [
-	#"runtime",
+	"runtime",
 	"runtime-modules/proposals/engine",
 	"runtime-modules/proposals/codex",
 	"runtime-modules/proposals/discussion",

+ 85 - 85
runtime/Cargo.toml

@@ -4,7 +4,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '7.11.0'
+version = '9.0.0'
 
 [dependencies]
 # Third-party dependencies
@@ -12,79 +12,79 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] }
 codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
 
 # Substrate primitives
-sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-offchain = { package = 'sp-offchain', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-authority-discovery = { package = 'sp-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-consensus-babe = { package = 'sp-consensus-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-transaction-pool = { package = 'sp-transaction-pool', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-session = { package = 'sp-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-block-builder = { package = 'sp-block-builder', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-api = { package = 'sp-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-version = { package = 'sp-version', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-sp-application-crypto = { package = 'sp-application-crypto', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-offchain = { package = 'sp-offchain', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-authority-discovery = { package = 'sp-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-consensus-babe = { package = 'sp-consensus-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-transaction-pool = { package = 'sp-transaction-pool', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-session = { package = 'sp-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-block-builder = { package = 'sp-block-builder', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-api = { package = 'sp-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-version = { package = 'sp-version', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+sp-application-crypto = { package = 'sp-application-crypto', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 # Frame
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-executive = { package = 'frame-executive', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-frame-system-rpc-runtime-api = { package = 'frame-system-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-executive = { package = 'frame-executive', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system-rpc-runtime-api = { package = 'frame-system-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 # Pallets
-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-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'}
-pallet-session = { package = 'pallet-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-offences = { package = 'pallet-offences', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-finality-tracker = { package = 'pallet-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-randomness-collective-flip = { package = 'pallet-randomness-collective-flip', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-authority-discovery = { package = 'pallet-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-sudo = { package = 'pallet-sudo', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-collective = { package = 'pallet-collective', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-utility = { package = 'pallet-utility', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+pallet-grandpa = { package = 'pallet-grandpa', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-babe = { package = 'pallet-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-transaction-payment = { package = 'pallet-transaction-payment', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-transaction-payment-rpc-runtime-api = { package = 'pallet-transaction-payment-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-authorship = { package = 'pallet-authorship', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-session = { package = 'pallet-session', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-offences = { package = 'pallet-offences', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-finality-tracker = { package = 'pallet-finality-tracker', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-randomness-collective-flip = { package = 'pallet-randomness-collective-flip', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-authority-discovery = { package = 'pallet-authority-discovery', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-sudo = { package = 'pallet-sudo', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-im-online = { package = 'pallet-im-online', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+pallet-collective = { package = 'pallet-collective', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+substrate-utility = { package = 'pallet-utility', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 
 # Benchmarking
-frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true }
-frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true }
-pallet-offences-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true }
-pallet-session-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4', default-features = false, optional = true }
+frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', default-features = false, optional = true }
+frame-system-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', default-features = false, optional = true }
+pallet-offences-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', default-features = false, optional = true }
+pallet-session-benchmarking = { git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', default-features = false, optional = true }
 
 # Joystream
-common = { package = 'pallet-common', default-features = false, path = '../runtime-modules/common'}
-memo = { package = 'pallet-memo', default-features = false, path = '../runtime-modules/memo'}
-forum = { package = 'pallet-forum', default-features = false, path = '../runtime-modules/forum'}
-membership = { package = 'pallet-membership', default-features = false, path = '../runtime-modules/membership'}
-stake = { package = 'pallet-stake', default-features = false, path = '../runtime-modules/stake'}
-governance = { package = 'pallet-governance', default-features = false, path = '../runtime-modules/governance'}
-hiring = { package = 'pallet-hiring', default-features = false, path = '../runtime-modules/hiring'}
-minting = { package = 'pallet-token-mint', default-features = false, path = '../runtime-modules/token-minting'}
-recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../runtime-modules/recurring-reward'}
-working-group = { package = 'pallet-working-group', default-features = false, path = '../runtime-modules/working-group'}
-content-working-group = { package = 'pallet-content-working-group', default-features = false, path = '../runtime-modules/content-working-group'}
-versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../runtime-modules/versioned-store'}
-versioned-store-permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../runtime-modules/versioned-store-permissions'}
-storage = { package = 'pallet-storage', default-features = false, path = '../runtime-modules/storage'}
-service-discovery = { package = 'pallet-service-discovery', default-features = false, path = '../runtime-modules/service-discovery'}
-proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../runtime-modules/proposals/engine'}
-proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'}
-proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'}
-content-directory = { package = 'pallet-content-directory', default-features = false, path = '../runtime-modules/content-directory' }
+#common = { package = 'pallet-common', default-features = false, path = '../runtime-modules/common'}
+#memo = { package = 'pallet-memo', default-features = false, path = '../runtime-modules/memo'}
+#forum = { package = 'pallet-forum', default-features = false, path = '../runtime-modules/forum'}
+#membership = { package = 'pallet-membership', default-features = false, path = '../runtime-modules/membership'}
+#stake = { package = 'pallet-stake', default-features = false, path = '../runtime-modules/stake'}
+#governance = { package = 'pallet-governance', default-features = false, path = '../runtime-modules/governance'}
+#hiring = { package = 'pallet-hiring', default-features = false, path = '../runtime-modules/hiring'}
+#minting = { package = 'pallet-token-mint', default-features = false, path = '../runtime-modules/token-minting'}
+#recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../runtime-modules/recurring-reward'}
+#working-group = { package = 'pallet-working-group', default-features = false, path = '../runtime-modules/working-group'}
+#content-working-group = { package = 'pallet-content-working-group', default-features = false, path = '../runtime-modules/content-working-group'}
+#versioned-store = { package = 'pallet-versioned-store', default-features = false, path = '../runtime-modules/versioned-store'}
+#versioned-store-permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../runtime-modules/versioned-store-permissions'}
+#storage = { package = 'pallet-storage', default-features = false, path = '../runtime-modules/storage'}
+#service-discovery = { package = 'pallet-service-discovery', default-features = false, path = '../runtime-modules/service-discovery'}
+#proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../runtime-modules/proposals/engine'}
+#proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'}
+#proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'}
+#content-directory = { package = 'pallet-content-directory', default-features = false, path = '../runtime-modules/content-directory' }
 
 [dev-dependencies]
-sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 strum = {version = "0.19", default-features = false}
 [build-dependencies]
-wasm-builder-runner = { package = "substrate-wasm-builder-runner", git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+wasm-builder-runner = { package = "substrate-wasm-builder-runner", git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca' }
 
 [features]
 default = ['std']
@@ -114,7 +114,7 @@ std = [
     'frame-support/std',
     'frame-executive/std',
     'frame-system-rpc-runtime-api/std',
-    'system/std',
+    'frame-system/std',
 
     # Pallets
     'pallet-timestamp/std',
@@ -134,31 +134,31 @@ std = [
     'pallet-im-online/std',
     'pallet-collective/std',
     'pallet-offences/std',
-    'pallet-utility/std',
+    'substrate-utility/std',
 
     # Joystream
-    'common/std',
-    'memo/std',
-    'forum/std',
-    'membership/std',
-    'stake/std',
-    'governance/std',
-    'hiring/std',
-    'minting/std',
-    'recurring-rewards/std',
-    'working-group/std',
-    'content-working-group/std',
-    'versioned-store/std',
-    'versioned-store-permissions/std',
-    'storage/std',
-    'service-discovery/std',
-    'proposals-engine/std',
-    'proposals-discussion/std',
-    'proposals-codex/std',
-    'content-directory/std',
+#    'common/std',
+#    'memo/std',
+#    'forum/std',
+#    'membership/std',
+#    'stake/std',
+#    'governance/std',
+#    'hiring/std',
+#    'minting/std',
+#    'recurring-rewards/std',
+#    'working-group/std',
+#    'content-working-group/std',
+#    'versioned-store/std',
+#    'versioned-store-permissions/std',
+#    'storage/std',
+#    'service-discovery/std',
+#    'proposals-engine/std',
+#    'proposals-discussion/std',
+#    'proposals-codex/std',
+#    'content-directory/std',
 ]
 runtime-benchmarks = [
-    "system/runtime-benchmarks",
+    "frame-system/runtime-benchmarks",
 	"frame-support/runtime-benchmarks",
 	"sp-runtime/runtime-benchmarks",
 	"pallet-balances/runtime-benchmarks",
@@ -170,7 +170,7 @@ runtime-benchmarks = [
     "frame-system-benchmarking",
     "pallet-offences-benchmarking",
 	"pallet-session-benchmarking",
-    "pallet-utility/runtime-benchmarks",
+    "substrate-utility/runtime-benchmarks",
 ]
 
 

+ 7 - 7
runtime/src/integration/mod.rs

@@ -1,8 +1,8 @@
-pub mod content_directory;
-pub mod content_working_group;
-pub mod forum;
-pub mod proposals;
-pub mod storage;
+// pub mod content_directory;
+// pub mod content_working_group;
+// pub mod forum;
+// pub mod proposals;
+// pub mod storage;
 pub mod transactions;
-pub mod versioned_store_permissions;
-pub mod working_group;
+// pub mod versioned_store_permissions;
+// pub mod working_group;

+ 12 - 28
runtime/src/integration/transactions.rs

@@ -1,36 +1,21 @@
 use codec::Encode;
 use frame_support::debug;
-use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial};
 use sp_runtime::generic;
 use sp_runtime::generic::SignedPayload;
 use sp_runtime::SaturatedConversion;
 
-use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic};
+use crate::{AccountId, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic};
 use crate::{Call, Runtime, System};
 
-/// Stub for zero transaction weights.
-pub struct NoWeights;
-impl WeightToFeePolynomial for NoWeights {
-    type Balance = Balance;
-
-    fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
-        Default::default()
-    }
-
-    fn calc(_weight: &u64) -> Self::Balance {
-        Default::default()
-    }
-}
-
 /// 'Create transaction' default implementation.
 pub(crate) fn create_transaction<
-    C: system::offchain::AppCrypto<
-        <Runtime as system::offchain::SigningTypes>::Public,
-        <Runtime as system::offchain::SigningTypes>::Signature,
+    C: frame_system::offchain::AppCrypto<
+        <Runtime as frame_system::offchain::SigningTypes>::Public,
+        <Runtime as frame_system::offchain::SigningTypes>::Signature,
     >,
 >(
     call: Call,
-    public: <<Runtime as system::offchain::SigningTypes>::Signature as sp_runtime::traits::Verify>::Signer,
+    public: <<Runtime as frame_system::offchain::SigningTypes>::Signature as sp_runtime::traits::Verify>::Signer,
     account: AccountId,
     nonce: Index,
 ) -> Option<(
@@ -44,19 +29,18 @@ pub(crate) fn create_transaction<
         .unwrap_or(2) as u64;
     let current_block = System::block_number()
         .saturated_into::<u64>()
-        // The `System::block_number` is initialized with `n+1`,
+        // The `frame_system::block_number` is initialized with `n+1`,
         // so the actual block number is `n`.
         .saturating_sub(1);
     let tip = 0;
     let extra: SignedExtra = (
-        system::CheckSpecVersion::<Runtime>::new(),
-        system::CheckTxVersion::<Runtime>::new(),
-        system::CheckGenesis::<Runtime>::new(),
-        system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
-        system::CheckNonce::<Runtime>::from(nonce),
-        system::CheckWeight::<Runtime>::new(),
+        frame_system::CheckSpecVersion::<Runtime>::new(),
+        frame_system::CheckTxVersion::<Runtime>::new(),
+        frame_system::CheckGenesis::<Runtime>::new(),
+        frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
+        frame_system::CheckNonce::<Runtime>::from(nonce),
+        frame_system::CheckWeight::<Runtime>::new(),
         pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
-        pallet_grandpa::ValidateEquivocationReport::<Runtime>::new(),
     );
     let raw_payload = SignedPayload::new(call, extra)
         .map_err(|e| {

+ 389 - 314
runtime/src/lib.rs

@@ -17,21 +17,25 @@ mod constants;
 mod integration;
 pub mod primitives;
 mod runtime_api;
-#[cfg(test)]
-mod tests; // Runtime integration tests
+mod weights;
+// #[cfg(test)]
+// mod tests; // Runtime integration tests
 
-use frame_support::traits::KeyOwnerProofSystem;
+use frame_support::traits::{Currency, KeyOwnerProofSystem, OnUnbalanced};
 use frame_support::weights::{
     constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
     Weight,
 };
+use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial};
 use frame_support::{construct_runtime, parameter_types};
+use frame_system::EnsureRoot;
 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 sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
 use sp_core::crypto::KeyTypeId;
 use sp_runtime::curve::PiecewiseLinear;
+use sp_runtime::traits::Convert;
 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;
@@ -39,43 +43,41 @@ use sp_std::vec::Vec;
 #[cfg(feature = "std")]
 use sp_version::NativeVersion;
 use sp_version::RuntimeVersion;
-use system::EnsureRoot;
 
 pub use constants::*;
 pub use primitives::*;
 pub use runtime_api::*;
 
-use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};
-
-use governance::{council, election};
-use storage::data_object_storage_registry;
-
-// Node dependencies
-pub use common;
-pub use content_working_group as content_wg;
-pub use forum;
-pub use governance::election_params::ElectionParameters;
-pub use membership;
-#[cfg(any(feature = "std", test))]
-pub use pallet_balances::Call as BalancesCall;
-pub use pallet_staking::StakerStatus;
-pub use proposals_codex::ProposalsConfigParameters;
-pub use storage::{data_directory, data_object_type_registry};
-pub use versioned_store;
-pub use versioned_store_permissions;
-pub use working_group;
-
-pub use content_directory;
-pub use content_directory::{
-    HashedTextMaxLength, InputValidationLengthConstraint, MaxNumber, TextMaxLength, VecMaxLength,
-};
+// use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder, MembershipOriginValidator};
+//
+// use governance::{council, election};
+// use storage::data_object_storage_registry;
+
+// // Node dependencies
+// pub use common;
+// pub use content_working_group as content_wg;
+// pub use forum;
+// pub use governance::election_params::ElectionParameters;
+// pub use membership;
+// #[cfg(any(feature = "std", test))]
+// pub use pallet_balances::Call as BalancesCall;
+// pub use pallet_staking::StakerStatus;
+// pub use proposals_codex::ProposalsConfigParameters;
+// pub use storage::{data_directory, data_object_type_registry};
+// pub use versioned_store;
+// pub use versioned_store_permissions;
+// pub use working_group;
+// pub use content_directory;
+// pub use content_directory::{
+//     HashedTextMaxLength, InputValidationLengthConstraint, MaxNumber, TextMaxLength, VecMaxLength,
+// };
 
 /// This runtime version.
 pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
-    authoring_version: 7,
-    spec_version: 11,
+    authoring_version: 9,
+    spec_version: 0,
     impl_version: 0,
     apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS,
     transaction_version: 1,
@@ -105,7 +107,7 @@ parameter_types! {
 const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
 
 // TODO: adjust weight
-impl system::Trait for Runtime {
+impl frame_system::Trait for Runtime {
     type BaseCallFilter = ();
     type Origin = Origin;
     type Call = Call;
@@ -126,15 +128,44 @@ impl system::Trait for Runtime {
     type MaximumBlockLength = MaximumBlockLength;
     type AvailableBlockRatio = AvailableBlockRatio;
     type Version = Version;
-    type ModuleToIndex = ModuleToIndex;
+    type PalletInfo = PalletInfo;
     type AccountData = pallet_balances::AccountData<Balance>;
     type OnNewAccount = ();
     type OnKilledAccount = ();
+    type SystemWeightInfo = weights::frame_system::WeightInfo;
+}
+
+//TODO: remove:
+/// A structure that converts the currency type into a lossy u64
+/// And back from u128
+pub struct CurrencyToVoteHandler;
+
+impl Convert<u128, u64> for CurrencyToVoteHandler {
+    fn convert(x: u128) -> u64 {
+        if x >> 96 == 0 {
+            x as u64
+        } else {
+            u64::max_value()
+        }
+    }
+}
+
+impl Convert<u128, u128> for CurrencyToVoteHandler {
+    fn convert(x: u128) -> u128 {
+        // if it practically fits in u64
+        if x >> 64 == 0 {
+            x
+        } else {
+            // 0000_0000_FFFF_FFFF_FFFF_FFFF_0000_0000
+            u64::max_value() as u128
+        }
+    }
 }
 
-impl pallet_utility::Trait for Runtime {
+impl substrate_utility::Trait for Runtime {
     type Event = Event;
     type Call = Call;
+    type WeightInfo = weights::substrate_utility::WeightInfo;
 }
 
 parameter_types! {
@@ -146,6 +177,22 @@ impl pallet_babe::Trait for Runtime {
     type EpochDuration = EpochDuration;
     type ExpectedBlockTime = ExpectedBlockTime;
     type EpochChangeTrigger = pallet_babe::ExternalTrigger;
+    type KeyOwnerProofSystem = Historical;
+
+    type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
+        KeyTypeId,
+        pallet_babe::AuthorityId,
+    )>>::Proof;
+
+    type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
+        KeyTypeId,
+        pallet_babe::AuthorityId,
+    )>>::IdentificationTuple;
+
+    type HandleEquivocation =
+        pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
+
+    type WeightInfo = ();
 }
 
 impl pallet_grandpa::Trait for Runtime {
@@ -161,19 +208,16 @@ impl pallet_grandpa::Trait for Runtime {
 
     type KeyOwnerProofSystem = Historical;
 
-    type HandleEquivocation = pallet_grandpa::EquivocationHandler<
-        Self::KeyOwnerIdentification,
-        primitives::report::ReporterAppCrypto,
-        Runtime,
-        Offences,
-    >;
+    type HandleEquivocation =
+        pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
+    type WeightInfo = ();
 }
 
-impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
+impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
 where
     Call: From<LocalCall>,
 {
-    fn create_transaction<C: system::offchain::AppCrypto<Self::Public, Self::Signature>>(
+    fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
         call: Call,
         public: <Signature as sp_runtime::traits::Verify>::Signer,
         account: AccountId,
@@ -186,12 +230,12 @@ where
     }
 }
 
-impl system::offchain::SigningTypes for Runtime {
+impl frame_system::offchain::SigningTypes for Runtime {
     type Public = <Signature as sp_runtime::traits::Verify>::Signer;
     type Signature = Signature;
 }
 
-impl<C> system::offchain::SendTransactionTypes<C> for Runtime
+impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
 where
     Call: From<C>,
 {
@@ -207,13 +251,14 @@ impl pallet_timestamp::Trait for Runtime {
     type Moment = Moment;
     type OnTimestampSet = Babe;
     type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = weights::pallet_timestamp::WeightInfo;
 }
 
 parameter_types! {
     pub const ExistentialDeposit: u128 = 0;
     pub const TransferFee: u128 = 0;
     pub const CreationFee: u128 = 0;
-    pub const InitialMembersBalance: u32 = 2000;
+    pub const MaxLocks: u32 = 50;
 }
 
 impl pallet_balances::Trait for Runtime {
@@ -222,18 +267,43 @@ impl pallet_balances::Trait for Runtime {
     type Event = Event;
     type ExistentialDeposit = ExistentialDeposit;
     type AccountStore = System;
+    type WeightInfo = weights::pallet_balances::WeightInfo;
+    type MaxLocks = MaxLocks;
 }
 
 parameter_types! {
-    pub const TransactionByteFee: Balance = 0; // TODO: adjust fee
+    pub const TransactionByteFee: Balance = 0;
+}
+
+type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
+
+pub struct Author;
+impl OnUnbalanced<NegativeImbalance> for Author {
+    fn on_nonzero_unbalanced(amount: NegativeImbalance) {
+        Balances::resolve_creating(&Authorship::author(), amount);
+    }
+}
+
+/// Stub for zero transaction weights.
+pub struct NoWeights;
+impl WeightToFeePolynomial for NoWeights {
+    type Balance = Balance;
+
+    fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
+        Default::default()
+    }
+
+    fn calc(_weight: &u64) -> Self::Balance {
+        Default::default()
+    }
 }
 
 impl pallet_transaction_payment::Trait for Runtime {
     type Currency = Balances;
     type OnTransactionPayment = ();
     type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = integration::transactions::NoWeights; // TODO: adjust weight
-    type FeeMultiplierUpdate = (); // TODO: adjust fee
+    type WeightToFee = NoWeights;
+    type FeeMultiplierUpdate = ();
 }
 
 impl pallet_sudo::Trait for Runtime {
@@ -279,6 +349,7 @@ impl pallet_session::Trait for Runtime {
     type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
     type Keys = SessionKeys;
     type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
+    type WeightInfo = weights::pallet_session::WeightInfo;
 }
 
 impl pallet_session::historical::Trait for Runtime {
@@ -319,7 +390,7 @@ parameter_types! {
 impl pallet_staking::Trait for Runtime {
     type Currency = Balances;
     type UnixTime = Timestamp;
-    type CurrencyToVote = common::currency::CurrencyToVoteHandler;
+    type CurrencyToVote = CurrencyToVoteHandler;
     type RewardRemainder = (); // Could be Treasury.
     type Event = Event;
     type Slash = (); // Where to send the slashed funds. Could be Treasury.
@@ -331,12 +402,13 @@ impl pallet_staking::Trait for Runtime {
     type SessionInterface = Self;
     type RewardCurve = RewardCurve;
     type NextNewSession = Session;
-    type ElectionLookahead = MaxIterations;
+    type ElectionLookahead = ElectionLookahead;
     type Call = Call;
     type MaxIterations = MaxIterations;
     type MinSolutionScoreBump = MinSolutionScoreBump;
     type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
     type UnsignedPriority = StakingUnsignedPriority;
+    type WeightInfo = weights::pallet_staking::WeightInfo;
 }
 
 impl pallet_im_online::Trait for Runtime {
@@ -344,6 +416,9 @@ impl pallet_im_online::Trait for Runtime {
     type Event = Event;
     type SessionDuration = SessionDuration;
     type ReportUnresponsiveness = Offences;
+    // Using the default weights until we check if we can run the benchmarks for this pallet in
+    // the reference machine in an acceptable time.
+    type WeightInfo = ();
     type UnsignedPriority = ImOnlineUnsignedPriority;
 }
 
@@ -366,245 +441,245 @@ parameter_types! {
 }
 
 impl pallet_finality_tracker::Trait for Runtime {
-    type OnFinalizationStalled = Grandpa;
+    type OnFinalizationStalled = ();
     type WindowSize = WindowSize;
     type ReportLatency = ReportLatency;
 }
 
-impl versioned_store::Trait for Runtime {
-    type Event = Event;
-}
-
-impl versioned_store_permissions::Trait for Runtime {
-    type Credential = Credential;
-    type CredentialChecker = (
-        integration::content_working_group::ContentWorkingGroupCredentials,
-        integration::versioned_store_permissions::SudoKeyHasAllCredentials,
-    );
-    type CreateClassPermissionsChecker =
-        integration::versioned_store_permissions::ContentLeadOrSudoKeyCanCreateClasses;
-}
-
-type EntityId = <Runtime as content_directory::Trait>::EntityId;
-
-parameter_types! {
-    pub const PropertyNameLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 49);
-    pub const PropertyDescriptionLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 500);
-    pub const ClassNameLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 49);
-    pub const ClassDescriptionLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 500);
-    pub const MaxNumberOfClasses: MaxNumber = 100;
-    pub const MaxNumberOfMaintainersPerClass: MaxNumber = 10;
-    pub const MaxNumberOfSchemasPerClass: MaxNumber = 20;
-    pub const MaxNumberOfPropertiesPerSchema: MaxNumber = 40;
-    pub const MaxNumberOfEntitiesPerClass: MaxNumber = 5000;
-    pub const MaxNumberOfCuratorsPerGroup: MaxNumber = 50;
-    pub const MaxNumberOfOperationsDuringAtomicBatching: MaxNumber = 500;
-    pub const VecMaxLengthConstraint: VecMaxLength = 200;
-    pub const TextMaxLengthConstraint: TextMaxLength = 5000;
-    pub const HashedTextMaxLengthConstraint: HashedTextMaxLength = Some(25000);
-    pub const IndividualEntitiesCreationLimit: EntityId = 500;
-}
-
-impl content_directory::Trait for Runtime {
-    type Event = Event;
-    type Nonce = u64;
-    type ClassId = u64;
-    type EntityId = u64;
-    type PropertyNameLengthConstraint = PropertyNameLengthConstraint;
-    type PropertyDescriptionLengthConstraint = PropertyDescriptionLengthConstraint;
-    type ClassNameLengthConstraint = ClassNameLengthConstraint;
-    type ClassDescriptionLengthConstraint = ClassDescriptionLengthConstraint;
-    type MaxNumberOfClasses = MaxNumberOfClasses;
-    type MaxNumberOfMaintainersPerClass = MaxNumberOfMaintainersPerClass;
-    type MaxNumberOfSchemasPerClass = MaxNumberOfSchemasPerClass;
-    type MaxNumberOfPropertiesPerSchema = MaxNumberOfPropertiesPerSchema;
-    type MaxNumberOfEntitiesPerClass = MaxNumberOfEntitiesPerClass;
-    type MaxNumberOfCuratorsPerGroup = MaxNumberOfCuratorsPerGroup;
-    type MaxNumberOfOperationsDuringAtomicBatching = MaxNumberOfOperationsDuringAtomicBatching;
-    type VecMaxLengthConstraint = VecMaxLengthConstraint;
-    type TextMaxLengthConstraint = TextMaxLengthConstraint;
-    type HashedTextMaxLengthConstraint = HashedTextMaxLengthConstraint;
-    type IndividualEntitiesCreationLimit = IndividualEntitiesCreationLimit;
-}
-
-impl hiring::Trait for Runtime {
-    type OpeningId = u64;
-    type ApplicationId = u64;
-    type ApplicationDeactivatedHandler = (); // TODO - what needs to happen?
-    type StakeHandlerProvider = hiring::Module<Self>;
-}
-
-impl minting::Trait for Runtime {
-    type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
-    type MintId = u64;
-}
-
-impl recurring_rewards::Trait for Runtime {
-    type PayoutStatusHandler = (); // TODO - deal with successful and failed payouts
-    type RecipientId = u64;
-    type RewardRelationshipId = u64;
-}
-
-parameter_types! {
-    pub const StakePoolId: [u8; 8] = *b"joystake";
-}
-
-impl stake::Trait for Runtime {
-    type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
-    type StakePoolId = StakePoolId;
-    type StakingEventsHandler = (
-        crate::integration::proposals::StakingEventsHandler<Self>,
-        (
-            crate::integration::working_group::ContentDirectoryWGStakingEventsHandler<Self>,
-            crate::integration::working_group::StorageWgStakingEventsHandler<Self>,
-        ),
-    );
-    type StakeId = u64;
-    type SlashId = u64;
-}
-
-impl content_wg::Trait for Runtime {
-    type Event = Event;
-}
-
-impl common::currency::GovernanceCurrency for Runtime {
-    type Currency = pallet_balances::Module<Self>;
-}
-
-impl governance::election::Trait for Runtime {
-    type Event = Event;
-    type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
-}
-
-impl governance::council::Trait for Runtime {
-    type Event = Event;
-    type CouncilTermEnded = (CouncilElection,);
-}
-
-impl memo::Trait for Runtime {
-    type Event = Event;
-}
-
-parameter_types! {
-    pub const MaxObjectsPerInjection: u32 = 100;
-}
-
-impl storage::data_object_type_registry::Trait for Runtime {
-    type Event = Event;
-    type DataObjectTypeId = u64;
-}
-
-impl storage::data_directory::Trait for Runtime {
-    type Event = Event;
-    type ContentId = ContentId;
-    type StorageProviderHelper = integration::storage::StorageProviderHelper;
-    type IsActiveDataObjectType = DataObjectTypeRegistry;
-    type MemberOriginValidator = MembershipOriginValidator<Self>;
-    type MaxObjectsPerInjection = MaxObjectsPerInjection;
-}
-
-impl storage::data_object_storage_registry::Trait for Runtime {
-    type Event = Event;
-    type DataObjectStorageRelationshipId = u64;
-    type ContentIdExists = DataDirectory;
-}
-
-impl membership::Trait for Runtime {
-    type Event = Event;
-    type MemberId = MemberId;
-    type PaidTermId = u64;
-    type SubscriptionId = u64;
-    type ActorId = ActorId;
-}
-
-impl forum::Trait for Runtime {
-    type Event = Event;
-    type MembershipRegistry = integration::forum::ShimMembershipRegistry;
-    type ThreadId = ThreadId;
-    type PostId = PostId;
-}
-
-// The storage working group instance alias.
-pub type StorageWorkingGroupInstance = working_group::Instance2;
-
-// The content directory working group instance alias.
-pub type ContentDirectoryWorkingGroupInstance = working_group::Instance3;
-
-parameter_types! {
-    pub const MaxWorkerNumberLimit: u32 = 100;
-}
-
-impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
-    type Event = Event;
-    type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
-}
-
-impl working_group::Trait<ContentDirectoryWorkingGroupInstance> for Runtime {
-    type Event = Event;
-    type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
-}
-
-impl service_discovery::Trait for Runtime {
-    type Event = Event;
-}
-
-parameter_types! {
-    pub const ProposalCancellationFee: u64 = 10000;
-    pub const ProposalRejectionFee: u64 = 5000;
-    pub const ProposalTitleMaxLength: u32 = 40;
-    pub const ProposalDescriptionMaxLength: u32 = 3000;
-    pub const ProposalMaxActiveProposalLimit: u32 = 20;
-}
-
-impl proposals_engine::Trait for Runtime {
-    type Event = Event;
-    type ProposerOriginValidator = MembershipOriginValidator<Self>;
-    type VoterOriginValidator = CouncilManager<Self>;
-    type TotalVotersCounter = CouncilManager<Self>;
-    type ProposalId = u32;
-    type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
-    type CancellationFee = ProposalCancellationFee;
-    type RejectionFee = ProposalRejectionFee;
-    type TitleMaxLength = ProposalTitleMaxLength;
-    type DescriptionMaxLength = ProposalDescriptionMaxLength;
-    type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
-    type DispatchableCallCode = Call;
-}
-impl Default for Call {
-    fn default() -> Self {
-        panic!("shouldn't call default for Call");
-    }
-}
-
-parameter_types! {
-    pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
-    pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
-    pub const ProposalThreadTitleLengthLimit: u32 = 40;
-    pub const ProposalPostLengthLimit: u32 = 1000;
-}
-
-impl proposals_discussion::Trait for Runtime {
-    type Event = Event;
-    type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
-    type ThreadId = ThreadId;
-    type PostId = PostId;
-    type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
-    type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
-    type PostLengthLimit = ProposalPostLengthLimit;
-    type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
-}
-
-parameter_types! {
-    pub const TextProposalMaxLength: u32 = 5_000;
-    pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 3_000_000;
-}
-
-impl proposals_codex::Trait for Runtime {
-    type MembershipOriginValidator = MembershipOriginValidator<Self>;
-    type TextProposalMaxLength = TextProposalMaxLength;
-    type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
-    type ProposalEncoder = ExtrinsicProposalEncoder;
-}
+// impl versioned_store::Trait for Runtime {
+//     type Event = Event;
+// }
+//
+// impl versioned_store_permissions::Trait for Runtime {
+//     type Credential = Credential;
+//     type CredentialChecker = (
+//         integration::content_working_group::ContentWorkingGroupCredentials,
+//         integration::versioned_store_permissions::SudoKeyHasAllCredentials,
+//     );
+//     type CreateClassPermissionsChecker =
+//         integration::versioned_store_permissions::ContentLeadOrSudoKeyCanCreateClasses;
+// }
+//
+// type EntityId = <Runtime as content_directory::Trait>::EntityId;
+//
+// parameter_types! {
+//     pub const PropertyNameLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 49);
+//     pub const PropertyDescriptionLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 500);
+//     pub const ClassNameLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 49);
+//     pub const ClassDescriptionLengthConstraint: InputValidationLengthConstraint = InputValidationLengthConstraint::new(1, 500);
+//     pub const MaxNumberOfClasses: MaxNumber = 100;
+//     pub const MaxNumberOfMaintainersPerClass: MaxNumber = 10;
+//     pub const MaxNumberOfSchemasPerClass: MaxNumber = 20;
+//     pub const MaxNumberOfPropertiesPerSchema: MaxNumber = 40;
+//     pub const MaxNumberOfEntitiesPerClass: MaxNumber = 5000;
+//     pub const MaxNumberOfCuratorsPerGroup: MaxNumber = 50;
+//     pub const MaxNumberOfOperationsDuringAtomicBatching: MaxNumber = 500;
+//     pub const VecMaxLengthConstraint: VecMaxLength = 200;
+//     pub const TextMaxLengthConstraint: TextMaxLength = 5000;
+//     pub const HashedTextMaxLengthConstraint: HashedTextMaxLength = Some(25000);
+//     pub const IndividualEntitiesCreationLimit: EntityId = 500;
+// }
+//
+// impl content_directory::Trait for Runtime {
+//     type Event = Event;
+//     type Nonce = u64;
+//     type ClassId = u64;
+//     type EntityId = u64;
+//     type PropertyNameLengthConstraint = PropertyNameLengthConstraint;
+//     type PropertyDescriptionLengthConstraint = PropertyDescriptionLengthConstraint;
+//     type ClassNameLengthConstraint = ClassNameLengthConstraint;
+//     type ClassDescriptionLengthConstraint = ClassDescriptionLengthConstraint;
+//     type MaxNumberOfClasses = MaxNumberOfClasses;
+//     type MaxNumberOfMaintainersPerClass = MaxNumberOfMaintainersPerClass;
+//     type MaxNumberOfSchemasPerClass = MaxNumberOfSchemasPerClass;
+//     type MaxNumberOfPropertiesPerSchema = MaxNumberOfPropertiesPerSchema;
+//     type MaxNumberOfEntitiesPerClass = MaxNumberOfEntitiesPerClass;
+//     type MaxNumberOfCuratorsPerGroup = MaxNumberOfCuratorsPerGroup;
+//     type MaxNumberOfOperationsDuringAtomicBatching = MaxNumberOfOperationsDuringAtomicBatching;
+//     type VecMaxLengthConstraint = VecMaxLengthConstraint;
+//     type TextMaxLengthConstraint = TextMaxLengthConstraint;
+//     type HashedTextMaxLengthConstraint = HashedTextMaxLengthConstraint;
+//     type IndividualEntitiesCreationLimit = IndividualEntitiesCreationLimit;
+// }
+//
+// impl hiring::Trait for Runtime {
+//     type OpeningId = u64;
+//     type ApplicationId = u64;
+//     type ApplicationDeactivatedHandler = (); // TODO - what needs to happen?
+//     type StakeHandlerProvider = hiring::Module<Self>;
+// }
+//
+// impl minting::Trait for Runtime {
+//     type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
+//     type MintId = u64;
+// }
+//
+// impl recurring_rewards::Trait for Runtime {
+//     type PayoutStatusHandler = (); // TODO - deal with successful and failed payouts
+//     type RecipientId = u64;
+//     type RewardRelationshipId = u64;
+// }
+//
+// parameter_types! {
+//     pub const StakePoolId: [u8; 8] = *b"joystake";
+// }
+//
+// impl stake::Trait for Runtime {
+//     type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
+//     type StakePoolId = StakePoolId;
+//     type StakingEventsHandler = (
+//         crate::integration::proposals::StakingEventsHandler<Self>,
+//         (
+//             crate::integration::working_group::ContentDirectoryWGStakingEventsHandler<Self>,
+//             crate::integration::working_group::StorageWgStakingEventsHandler<Self>,
+//         ),
+//     );
+//     type StakeId = u64;
+//     type SlashId = u64;
+// }
+//
+// impl content_wg::Trait for Runtime {
+//     type Event = Event;
+// }
+//
+// impl common::currency::GovernanceCurrency for Runtime {
+//     type Currency = pallet_balances::Module<Self>;
+// }
+//
+// impl governance::election::Trait for Runtime {
+//     type Event = Event;
+//     type CouncilElected = (Council, integration::proposals::CouncilElectedHandler);
+// }
+//
+// impl governance::council::Trait for Runtime {
+//     type Event = Event;
+//     type CouncilTermEnded = (CouncilElection,);
+// }
+//
+// impl memo::Trait for Runtime {
+//     type Event = Event;
+// }
+//
+// parameter_types! {
+//     pub const MaxObjectsPerInjection: u32 = 100;
+// }
+//
+// impl storage::data_object_type_registry::Trait for Runtime {
+//     type Event = Event;
+//     type DataObjectTypeId = u64;
+// }
+//
+// impl storage::data_directory::Trait for Runtime {
+//     type Event = Event;
+//     type ContentId = ContentId;
+//     type StorageProviderHelper = integration::storage::StorageProviderHelper;
+//     type IsActiveDataObjectType = DataObjectTypeRegistry;
+//     type MemberOriginValidator = MembershipOriginValidator<Self>;
+//     type MaxObjectsPerInjection = MaxObjectsPerInjection;
+// }
+//
+// impl storage::data_object_storage_registry::Trait for Runtime {
+//     type Event = Event;
+//     type DataObjectStorageRelationshipId = u64;
+//     type ContentIdExists = DataDirectory;
+// }
+//
+// impl membership::Trait for Runtime {
+//     type Event = Event;
+//     type MemberId = MemberId;
+//     type PaidTermId = u64;
+//     type SubscriptionId = u64;
+//     type ActorId = ActorId;
+// }
+//
+// impl forum::Trait for Runtime {
+//     type Event = Event;
+//     type MembershipRegistry = integration::forum::ShimMembershipRegistry;
+//     type ThreadId = ThreadId;
+//     type PostId = PostId;
+// }
+//
+// // The storage working group instance alias.
+// pub type StorageWorkingGroupInstance = working_group::Instance2;
+//
+// // The content directory working group instance alias.
+// pub type ContentDirectoryWorkingGroupInstance = working_group::Instance3;
+//
+// parameter_types! {
+//     pub const MaxWorkerNumberLimit: u32 = 100;
+// }
+//
+// impl working_group::Trait<StorageWorkingGroupInstance> for Runtime {
+//     type Event = Event;
+//     type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
+// }
+//
+// impl working_group::Trait<ContentDirectoryWorkingGroupInstance> for Runtime {
+//     type Event = Event;
+//     type MaxWorkerNumberLimit = MaxWorkerNumberLimit;
+// }
+//
+// impl service_discovery::Trait for Runtime {
+//     type Event = Event;
+// }
+//
+// parameter_types! {
+//     pub const ProposalCancellationFee: u64 = 10000;
+//     pub const ProposalRejectionFee: u64 = 5000;
+//     pub const ProposalTitleMaxLength: u32 = 40;
+//     pub const ProposalDescriptionMaxLength: u32 = 3000;
+//     pub const ProposalMaxActiveProposalLimit: u32 = 20;
+// }
+//
+// impl proposals_engine::Trait for Runtime {
+//     type Event = Event;
+//     type ProposerOriginValidator = MembershipOriginValidator<Self>;
+//     type VoterOriginValidator = CouncilManager<Self>;
+//     type TotalVotersCounter = CouncilManager<Self>;
+//     type ProposalId = u32;
+//     type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
+//     type CancellationFee = ProposalCancellationFee;
+//     type RejectionFee = ProposalRejectionFee;
+//     type TitleMaxLength = ProposalTitleMaxLength;
+//     type DescriptionMaxLength = ProposalDescriptionMaxLength;
+//     type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
+//     type DispatchableCallCode = Call;
+// }
+// impl Default for Call {
+//     fn default() -> Self {
+//         panic!("shouldn't call default for Call");
+//     }
+// }
+//
+// parameter_types! {
+//     pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
+//     pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
+//     pub const ProposalThreadTitleLengthLimit: u32 = 40;
+//     pub const ProposalPostLengthLimit: u32 = 1000;
+// }
+//
+// impl proposals_discussion::Trait for Runtime {
+//     type Event = Event;
+//     type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
+//     type ThreadId = ThreadId;
+//     type PostId = PostId;
+//     type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
+//     type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
+//     type PostLengthLimit = ProposalPostLengthLimit;
+//     type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
+// }
+//
+// parameter_types! {
+//     pub const TextProposalMaxLength: u32 = 5_000;
+//     pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 3_000_000;
+// }
+//
+// impl proposals_codex::Trait for Runtime {
+//     type MembershipOriginValidator = MembershipOriginValidator<Self>;
+//     type TextProposalMaxLength = TextProposalMaxLength;
+//     type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
+//     type ProposalEncoder = ExtrinsicProposalEncoder;
+// }
 
 parameter_types! {
     pub const TombstoneDeposit: Balance = 1; // TODO: adjust fee
@@ -637,9 +712,9 @@ construct_runtime!(
         UncheckedExtrinsic = UncheckedExtrinsic
     {
         // Substrate
-        System: system::{Module, Call, Storage, Config, Event<T>},
-        Utility: pallet_utility::{Module, Call, Event},
-        Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
+        System: frame_system::{Module, Call, Storage, Config, Event<T>},
+        Utility: substrate_utility::{Module, Call, Event},
+        Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned},
         Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
         Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
         Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
@@ -654,32 +729,32 @@ construct_runtime!(
         Offences: pallet_offences::{Module, Call, Storage, Event},
         RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
         Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
-        // Joystream
-        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>},
-        Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
-        Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
-        VersionedStore: versioned_store::{Module, Call, Storage, Event<T>, Config},
-        VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage, Config<T>},
-        Stake: stake::{Module, Call, Storage},
-        Minting: minting::{Module, Call, Storage},
-        RecurringRewards: recurring_rewards::{Module, Call, Storage},
-        Hiring: hiring::{Module, Call, Storage},
-        ContentWorkingGroup: content_wg::{Module, Call, Storage, Event<T>, Config<T>},
-        ContentDirectory: content_directory::{Module, Call, Storage, Event<T>, Config<T>},
-        // --- Storage
-        DataObjectTypeRegistry: data_object_type_registry::{Module, Call, Storage, Event<T>, Config<T>},
-        DataDirectory: data_directory::{Module, Call, Storage, Event<T>, Config<T>},
-        DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
-        Discovery: service_discovery::{Module, Call, Storage, Event<T>},
-        // --- Proposals
-        ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
-        ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
-        ProposalsCodex: proposals_codex::{Module, Call, Storage, Config<T>},
-        // --- Working groups
-        // reserved for the future use: ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
-        StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Event<T>},
-        ContentDirectoryWorkingGroup: working_group::<Instance3>::{Module, Call, Storage, Config<T>, Event<T>},
+        // // Joystream
+        // 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>},
+        // Members: membership::{Module, Call, Storage, Event<T>, Config<T>},
+        // Forum: forum::{Module, Call, Storage, Event<T>, Config<T>},
+        // VersionedStore: versioned_store::{Module, Call, Storage, Event<T>, Config},
+        // VersionedStorePermissions: versioned_store_permissions::{Module, Call, Storage, Config<T>},
+        // Stake: stake::{Module, Call, Storage},
+        // Minting: minting::{Module, Call, Storage},
+        // RecurringRewards: recurring_rewards::{Module, Call, Storage},
+        // Hiring: hiring::{Module, Call, Storage},
+        // ContentWorkingGroup: content_wg::{Module, Call, Storage, Event<T>, Config<T>},
+        // ContentDirectory: content_directory::{Module, Call, Storage, Event<T>, Config<T>},
+        // // --- Storage
+        // DataObjectTypeRegistry: data_object_type_registry::{Module, Call, Storage, Event<T>, Config<T>},
+        // DataDirectory: data_directory::{Module, Call, Storage, Event<T>, Config<T>},
+        // DataObjectStorageRegistry: data_object_storage_registry::{Module, Call, Storage, Event<T>, Config<T>},
+        // Discovery: service_discovery::{Module, Call, Storage, Event<T>},
+        // // --- Proposals
+        // ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
+        // ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
+        // ProposalsCodex: proposals_codex::{Module, Call, Storage, Config<T>},
+        // // --- Working groups
+        // // reserved for the future use: ForumWorkingGroup: working_group::<Instance1>::{Module, Call, Storage, Event<T>},
+        // StorageWorkingGroup: working_group::<Instance2>::{Module, Call, Storage, Config<T>, Event<T>},
+        // ContentDirectoryWorkingGroup: working_group::<Instance3>::{Module, Call, Storage, Config<T>, Event<T>},
     }
 );

+ 1 - 2
runtime/src/primitives.rs

@@ -1,7 +1,6 @@
 //! Low-level types used throughout the Substrate code.
 
 #![warn(missing_docs)]
-
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use sp_runtime::{
@@ -71,8 +70,8 @@ pub type MemberId = u64;
 /// account.
 pub mod report {
     use super::{Signature, Verify};
+    use frame_system::offchain::AppCrypto;
     use sp_core::crypto::{key_types, KeyTypeId};
-    use system::offchain::AppCrypto;
 
     /// Key type for the reporting module. Used for reporting BABE and GRANDPA
     /// equivocations.

+ 155 - 13
runtime/src/runtime_api.rs

@@ -23,14 +23,13 @@ use frame_support::weights::Weight;
 
 /// The SignedExtension to the basic transaction logic.
 pub type SignedExtra = (
-    system::CheckSpecVersion<Runtime>,
-    system::CheckTxVersion<Runtime>,
-    system::CheckGenesis<Runtime>,
-    system::CheckEra<Runtime>,
-    system::CheckNonce<Runtime>,
-    system::CheckWeight<Runtime>,
+    frame_system::CheckSpecVersion<Runtime>,
+    frame_system::CheckTxVersion<Runtime>,
+    frame_system::CheckGenesis<Runtime>,
+    frame_system::CheckEra<Runtime>,
+    frame_system::CheckNonce<Runtime>,
+    frame_system::CheckWeight<Runtime>,
     pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
-    pallet_grandpa::ValidateEquivocationReport<Runtime>,
 );
 
 /// Digest item type.
@@ -53,7 +52,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signa
 
 // Default Executive type without the RuntimeUpgrade
 // pub type Executive =
-//     frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
+//     frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllModules>;
 
 /// Custom runtime upgrade handler.
 pub struct CustomOnRuntimeUpgrade;
@@ -67,7 +66,7 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
 pub type Executive = frame_executive::Executive<
     Runtime,
     Block,
-    system::ChainContext<Runtime>,
+    frame_system::ChainContext<Runtime>,
     Runtime,
     AllModules,
     CustomOnRuntimeUpgrade,
@@ -139,7 +138,7 @@ impl_runtime_apis! {
             Grandpa::grandpa_authorities()
         }
 
-        fn submit_report_equivocation_extrinsic(
+        fn submit_report_equivocation_unsigned_extrinsic(
             equivocation_proof: fg_primitives::EquivocationProof<
                 <Block as BlockT>::Hash,
                 NumberFor<Block>,
@@ -148,7 +147,7 @@ impl_runtime_apis! {
         ) -> Option<()> {
             let key_owner_proof = key_owner_proof.decode()?;
 
-            Grandpa::submit_report_equivocation_extrinsic(
+            Grandpa::submit_unsigned_equivocation_report(
                 equivocation_proof,
                 key_owner_proof,
             )
@@ -183,6 +182,29 @@ impl_runtime_apis! {
             }
         }
 
+        fn generate_key_ownership_proof(
+            _slot_number: sp_consensus_babe::SlotNumber,
+            authority_id: sp_consensus_babe::AuthorityId,
+        ) -> Option<sp_consensus_babe::OpaqueKeyOwnershipProof> {
+            use codec::Encode;
+
+            Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id))
+                .map(|p| p.encode())
+                .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new)
+        }
+
+        fn submit_report_equivocation_unsigned_extrinsic(
+            equivocation_proof: sp_consensus_babe::EquivocationProof<<Block as BlockT>::Header>,
+            key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof,
+        ) -> Option<()> {
+            let key_owner_proof = key_owner_proof.decode()?;
+
+            Babe::submit_unsigned_equivocation_report(
+                equivocation_proof,
+                key_owner_proof,
+            )
+        }
+
         fn current_epoch_start() -> sp_consensus_babe::SlotNumber {
             Babe::current_epoch_start()
         }
@@ -203,9 +225,8 @@ impl_runtime_apis! {
     impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
         Block,
         Balance,
-        UncheckedExtrinsic,
     > for Runtime {
-        fn query_info(uxt: UncheckedExtrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
+        fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
             TransactionPayment::query_info(uxt, len)
         }
     }
@@ -220,4 +241,125 @@ impl_runtime_apis! {
             SessionKeys::decode_into_raw_public_keys(&encoded)
         }
     }
+
+    #[cfg(feature = "runtime-benchmarks")]
+    impl frame_benchmarking::Benchmark<Block> for Runtime {
+        fn dispatch_benchmark(
+            config: frame_benchmarking::BenchmarkConfig
+        ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
+            use sp_std::vec;
+            use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
+
+            use pallet_session_benchmarking::Module as SessionBench;
+            use frame_system_benchmarking::Module as SystemBench;
+            use frame_system::RawOrigin;
+            use crate::ProposalsDiscussion;
+            use crate::ProposalsEngine;
+            use crate::ProposalsCodex;
+            use crate::Constitution;
+            use crate::Forum;
+            use crate::Members;
+            use crate::ContentDirectoryWorkingGroup;
+            use crate::Utility;
+            use crate::Timestamp;
+            use crate::ImOnline;
+            use crate::Council;
+            use crate::Referendum;
+            use crate::Blog;
+            use crate::JoystreamUtility;
+
+
+            // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency issues.
+            // To get around that, we separated the Session benchmarks into its own crate, which is why
+            // we need these two lines below.
+            impl pallet_session_benchmarking::Trait for Runtime {}
+            impl frame_system_benchmarking::Trait for Runtime {}
+            impl referendum::OptionCreator<<Runtime as frame_system::Trait>::AccountId, <Runtime as common::Trait>::MemberId> for Runtime {
+                fn create_option(account_id: <Runtime as frame_system::Trait>::AccountId, member_id: <Runtime as common::Trait>::MemberId) {
+                    crate::council::Module::<Runtime>::announce_candidacy(
+                        RawOrigin::Signed(account_id.clone()).into(),
+                        member_id,
+                        account_id.clone(),
+                        account_id.clone(),
+                        <Runtime as council::Trait>::MinCandidateStake::get().into(),
+                    ).expect(
+                        "Should pass a valid member associated to the account and the account
+                        should've enough
+                        free balance to stake the minimum for a council candidate."
+                    );
+                }
+            }
+
+            impl membership::MembershipWorkingGroupHelper<
+                <Runtime as frame_system::Trait>::AccountId,
+                <Runtime as common::Trait>::MemberId,
+                <Runtime as common::Trait>::ActorId,
+                    > for Runtime
+            {
+                fn insert_a_lead(
+                    opening_id: u32,
+                    caller_id: &<Runtime as frame_system::Trait>::AccountId,
+                    member_id: <Runtime as common::Trait>::MemberId,
+                ) -> <Runtime as common::Trait>::ActorId {
+                    working_group::benchmarking::complete_opening::<Runtime, crate::MembershipWorkingGroupInstance>(
+                        working_group::OpeningType::Leader,
+                        opening_id,
+                        None,
+                        &caller_id,
+                        member_id,
+                    )
+                }
+            }
+
+            let whitelist: Vec<TrackedStorageKey> = vec![
+                // Block Number
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
+                // Total Issuance
+                hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
+                // Execution Phase
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
+                // Event Count
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
+                // System Events
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+                // Caller 0 Account
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(),
+                // Treasury Account
+                hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
+            ];
+
+            let mut batches = Vec::<BenchmarkBatch>::new();
+            let params = (&config, &whitelist);
+
+            // Note: For benchmarking Stake and Balances we need to change ExistentialDeposit to
+            // a non-zero value.
+            // For now, due to the complexity grandpa and babe aren't benchmarked automatically
+            // we should use the default manually created weights.
+            // Finally, pallet_offences have no `WeightInfo` so there's no need to benchmark it
+            // the benchmark is only for illustrative pourpuses.
+
+            // Frame benchmarks
+            add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
+            add_benchmark!(params, batches, substrate_utility, Utility);
+            add_benchmark!(params, batches, pallet_timestamp, Timestamp);
+            add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
+            add_benchmark!(params, batches, pallet_im_online, ImOnline);
+
+            // Joystream Benchmarks
+            add_benchmark!(params, batches, proposals_discussion, ProposalsDiscussion);
+            add_benchmark!(params, batches, proposals_codex, ProposalsCodex);
+            add_benchmark!(params, batches, proposals_engine, ProposalsEngine);
+            add_benchmark!(params, batches, membership, Members);
+            add_benchmark!(params, batches, forum, Forum);
+            add_benchmark!(params, batches, pallet_constitution, Constitution);
+            add_benchmark!(params, batches, working_group, ContentDirectoryWorkingGroup);
+            add_benchmark!(params, batches, referendum, Referendum);
+            add_benchmark!(params, batches, council, Council);
+            add_benchmark!(params, batches, blog, Blog);
+            add_benchmark!(params, batches, joystream_utility, JoystreamUtility);
+
+            if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
+            Ok(batches)
+        }
+    }
 }

+ 41 - 0
runtime/src/weights/frame_system.rs

@@ -0,0 +1,41 @@
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
+
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl frame_system::WeightInfo for WeightInfo {
+    // WARNING! Some components were not used: ["b"]
+    fn remark() -> Weight {
+        (9_342_000 as Weight)
+    }
+    fn set_heap_pages() -> Weight {
+        (11_274_000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    // WARNING! Some components were not used: ["d"]
+    fn set_changes_trie_config() -> Weight {
+        (32_325_000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+    fn set_storage(i: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((2_060_000 as Weight).saturating_mul(i as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
+    }
+    fn kill_storage(i: u32) -> Weight {
+        (27_686_000 as Weight)
+            .saturating_add((1_237_000 as Weight).saturating_mul(i as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
+    }
+    fn kill_prefix(p: u32) -> Weight {
+        (27_689_000 as Weight)
+            .saturating_add((1_205_000 as Weight).saturating_mul(p as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
+    }
+    fn suicide() -> Weight {
+        (145_274_000 as Weight)
+    }
+}

+ 24 - 0
runtime/src/weights/mod.rs

@@ -0,0 +1,24 @@
+// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// 	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! A list of the different weight modules for our runtime.
+
+// FRAME pallets
+pub mod frame_system;
+pub mod pallet_balances;
+pub mod pallet_session;
+pub mod pallet_staking;
+pub mod pallet_timestamp;
+pub mod substrate_utility;

+ 47 - 0
runtime/src/weights/pallet_balances.rs

@@ -0,0 +1,47 @@
+// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// 	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl pallet_balances::WeightInfo for WeightInfo {
+    fn transfer() -> Weight {
+        (65949000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn transfer_keep_alive() -> Weight {
+        (46665000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_balance_creating() -> Weight {
+        (27086000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_balance_killing() -> Weight {
+        (33424000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn force_transfer() -> Weight {
+        (65343000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+}

+ 20 - 0
runtime/src/weights/pallet_session.rs

@@ -0,0 +1,20 @@
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
+
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl pallet_session::WeightInfo for WeightInfo {
+    fn set_keys() -> Weight {
+        (433_479_000 as Weight)
+            .saturating_add(DbWeight::get().reads(6 as Weight))
+            .saturating_add(DbWeight::get().writes(5 as Weight))
+    }
+    fn purge_keys() -> Weight {
+        (299_139_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(5 as Weight))
+    }
+}

+ 166 - 0
runtime/src/weights/pallet_staking.rs

@@ -0,0 +1,166 @@
+// This file is part of Substrate.
+
+// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// 	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Default weights of pallet-staking.
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
+
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl pallet_staking::WeightInfo for WeightInfo {
+    fn bond() -> Weight {
+        (144278000 as Weight)
+            .saturating_add(DbWeight::get().reads(5 as Weight))
+            .saturating_add(DbWeight::get().writes(4 as Weight))
+    }
+    fn bond_extra() -> Weight {
+        (110715000 as Weight)
+            .saturating_add(DbWeight::get().reads(4 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+    fn unbond() -> Weight {
+        (99840000 as Weight)
+            .saturating_add(DbWeight::get().reads(5 as Weight))
+            .saturating_add(DbWeight::get().writes(3 as Weight))
+    }
+    fn withdraw_unbonded_update(s: u32) -> Weight {
+        (100728000 as Weight)
+            .saturating_add((63000 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(5 as Weight))
+            .saturating_add(DbWeight::get().writes(3 as Weight))
+    }
+    fn withdraw_unbonded_kill(s: u32) -> Weight {
+        (168879000 as Weight)
+            .saturating_add((6666000 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(7 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
+    }
+    fn validate() -> Weight {
+        (35539000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+    fn nominate(n: u32) -> Weight {
+        (48596000 as Weight)
+            .saturating_add((308000 as Weight).saturating_mul(n as Weight))
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+    fn chill() -> Weight {
+        (35144000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+    fn set_payee() -> Weight {
+        (24255000 as Weight)
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_controller() -> Weight {
+        (52294000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(3 as Weight))
+    }
+    fn set_validator_count() -> Weight {
+        (5185000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn force_no_eras() -> Weight {
+        (5907000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn force_new_era() -> Weight {
+        (5917000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn force_new_era_always() -> Weight {
+        (5952000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn set_invulnerables(v: u32) -> Weight {
+        (6324000 as Weight)
+            .saturating_add((9000 as Weight).saturating_mul(v as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn force_unstake(s: u32) -> Weight {
+        (119691000 as Weight)
+            .saturating_add((6681000 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(4 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
+    }
+    fn cancel_deferred_slash(s: u32) -> Weight {
+        (5820201000 as Weight)
+            .saturating_add((34672000 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(1 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    fn payout_stakers_dead_controller(n: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((92486000 as Weight).saturating_mul(n as Weight))
+            .saturating_add(DbWeight::get().reads(4 as Weight))
+            .saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight)))
+    }
+    fn payout_stakers_alive_staked(n: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((117324000 as Weight).saturating_mul(n as Weight))
+            .saturating_add(DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight)))
+            .saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight)))
+    }
+    fn rebond(l: u32) -> Weight {
+        (71316000 as Weight)
+            .saturating_add((142000 as Weight).saturating_mul(l as Weight))
+            .saturating_add(DbWeight::get().reads(4 as Weight))
+            .saturating_add(DbWeight::get().writes(3 as Weight))
+    }
+    fn set_history_depth(e: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((51901000 as Weight).saturating_mul(e as Weight))
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(4 as Weight))
+            .saturating_add(DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight)))
+    }
+    fn reap_stash(s: u32) -> Weight {
+        (147166000 as Weight)
+            .saturating_add((6661000 as Weight).saturating_mul(s as Weight))
+            .saturating_add(DbWeight::get().reads(4 as Weight))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+            .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
+    }
+    fn new_era(v: u32, n: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((1440459000 as Weight).saturating_mul(v as Weight))
+            .saturating_add((182580000 as Weight).saturating_mul(n as Weight))
+            .saturating_add(DbWeight::get().reads(10 as Weight))
+            .saturating_add(DbWeight::get().reads((4 as Weight).saturating_mul(v as Weight)))
+            .saturating_add(DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
+            .saturating_add(DbWeight::get().writes(8 as Weight))
+            .saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight)))
+    }
+    fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight {
+        (0 as Weight)
+            .saturating_add((964000 as Weight).saturating_mul(v as Weight))
+            .saturating_add((432000 as Weight).saturating_mul(n as Weight))
+            .saturating_add((204294000 as Weight).saturating_mul(a as Weight))
+            .saturating_add((9546000 as Weight).saturating_mul(w as Weight))
+            .saturating_add(DbWeight::get().reads(6 as Weight))
+            .saturating_add(DbWeight::get().reads((4 as Weight).saturating_mul(a as Weight)))
+            .saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight)))
+            .saturating_add(DbWeight::get().writes(2 as Weight))
+    }
+}

+ 34 - 0
runtime/src/weights/pallet_timestamp.rs

@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// 	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
+
+#![allow(unused_parens)]
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl pallet_timestamp::WeightInfo for WeightInfo {
+    // WARNING! Some components were not used: ["t"]
+    fn set() -> Weight {
+        (9133000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
+    // WARNING! Some components were not used: ["t"]
+    fn on_finalize() -> Weight {
+        (5915000 as Weight)
+    }
+}

+ 17 - 0
runtime/src/weights/substrate_utility.rs

@@ -0,0 +1,17 @@
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
+
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
+
+pub struct WeightInfo;
+impl substrate_utility::WeightInfo for WeightInfo {
+    fn batch(c: u32) -> Weight {
+        (0 as Weight).saturating_add((105_180_000 as Weight).saturating_mul(c as Weight))
+    }
+    // WARNING! Some components were not used: ["u"]
+    fn as_derivative() -> Weight {
+        (67_812_000 as Weight)
+    }
+}

Some files were not shown because too many files changed in this diff