This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: FRAME
umbrella crate.
#14137
Open
kianenigma
wants to merge
41
commits into
master
Choose a base branch
from
kiz-frame-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: FRAME
umbrella crate.
#14137
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
188a57b
new doc/api package:
kianenigma 1b203a2
adding stuff for runtime
kianenigma da3c1d6
new features
kianenigma c5ad834
a lot of changes
kianenigma 6d5286b
Master.into()
kianenigma 5543456
everything works again
kianenigma 54c4901
remove expanded file
kianenigma 02908ab
Merge branch 'master' of github.com:paritytech/substrate into kiz-fra…
kianenigma 901a8d0
checkpoint
kianenigma 433fbf1
some updates
kianenigma 837c78a
Merge branch 'master' of github.com:paritytech/substrate into kiz-fra…
kianenigma 4a3ce15
some chanes
kianenigma fcfdee6
merge master again
kianenigma b278a05
update
kianenigma 43824f8
Merge branch 'master' of github.com:paritytech/substrate into kiz-fra…
kianenigma ebb6c5e
update with master
kianenigma 658d84f
compiles without support and system
kianenigma 6cd251f
minimal-node and runtime, with frame, with sudo and timestamp
kianenigma be42459
works with tx-fee payment
kianenigma 010d906
works without timestamp for now
kianenigma 289f18e
Merge branch 'master' of github.com:paritytech/substrate into kiz-fra…
kianenigma 5934bcc
add dual consensus modes
kianenigma 6b7e50a
remove unused deps and all
kianenigma 679bcea
Update frame/src/lib.rs
kianenigma aee26b9
Update frame/src/lib.rs
kianenigma bfda7d8
Update frame/src/lib.rs
kianenigma 7d912d0
make impl_runtime_api work without sp-api
kianenigma 07128f5
Merge branch 'kiz-frame-api' of github.com:paritytech/substrate into …
kianenigma c96624b
use docify for example
kianenigma dac888e
clone for identity
kianenigma 81202d1
single tuple is also a signed extension
kianenigma 247582e
update to master
kianenigma 554bd2e
cleanup
kianenigma 7c9ed07
fix how we handel return macro in tt stuff
kianenigma 787eff7
bring back example pallet
kianenigma dfaa2af
fix warning
kianenigma 37ff8a8
Update bin/minimal/node/src/service.rs
kianenigma 377f148
Update bin/minimal/node/src/service.rs
kianenigma 7284b50
make the node WASM-only
kianenigma c04418c
Master.into()
kianenigma 1cf4cec
Empty-Commit
kianenigma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[package] | ||
name = "minimal-node" | ||
version = "4.0.0-dev" | ||
description = "A fresh FRAME-based Substrate node, ready for hacking." | ||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"] | ||
homepage = "https://substrate.io/" | ||
edition = "2021" | ||
license = "MIT-0" | ||
publish = false | ||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/" | ||
build = "build.rs" | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[[bin]] | ||
name = "minimal-node" | ||
|
||
[dependencies] | ||
clap = { version = "4.0.9", features = ["derive"] } | ||
futures = { version = "0.3.21", features = ["thread-pool"] } | ||
futures-timer = "3.0.1" | ||
jsonrpsee = { version = "0.16.2", features = ["server"] } | ||
|
||
sc-cli = { path = "../../../client/cli" } | ||
sc-executor = { path = "../../../client/executor" } | ||
sc-network = { path = "../../../client/network" } | ||
sc-service = { path = "../../../client/service" } | ||
sc-telemetry = { path = "../../../client/telemetry" } | ||
sc-transaction-pool = { path = "../../../client/transaction-pool" } | ||
sc-transaction-pool-api = { path = "../../../client/transaction-pool/api" } | ||
sc-consensus = { path = "../../../client/consensus/common" } | ||
sc-consensus-manual-seal = { path = "../../../client/consensus/manual-seal" } | ||
sc-rpc-api = { path = "../../../client/rpc-api" } | ||
sc-basic-authorship = { path = "../../../client/basic-authorship" } | ||
sc-offchain = { path = "../../../client/offchain" } | ||
sc-client-api = { path = "../../../client/api" } | ||
|
||
sp-timestamp = { path = "../../../primitives/timestamp" } | ||
sp-keyring = { path = "../../../primitives/keyring" } | ||
sp-api = { path = "../../../primitives/api" } | ||
sp-blockchain = { path = "../../../primitives/blockchain" } | ||
sp-block-builder = { path = "../../../primitives/block-builder" } | ||
sp-io = { path = "../../../primitives/io" } | ||
|
||
|
||
substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } | ||
|
||
frame = { path = "../../../frame" } | ||
runtime = { package = "minimal-runtime", path = "../runtime" } | ||
|
||
[build-dependencies] | ||
substrate-build-script-utils = { version = "3.0.0", path = "../../../utils/build-script-utils" } | ||
|
||
[features] | ||
default = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; | ||
|
||
fn main() { | ||
generate_cargo_keys(); | ||
rerun_if_git_head_changed(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use runtime::{BalancesConfig, RuntimeGenesisConfig, SudoConfig, SystemConfig, WASM_BINARY}; | ||
use sc_service::{ChainType, Properties}; | ||
use sp_keyring::AccountKeyring; | ||
|
||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. | ||
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>; | ||
|
||
fn props() -> Properties { | ||
let mut properties = Properties::new(); | ||
properties.insert("tokenDecimals".to_string(), 0.into()); | ||
properties.insert("tokenSymbol".to_string(), "TEST".into()); | ||
properties | ||
} | ||
|
||
pub fn development_config() -> Result<ChainSpec, String> { | ||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; | ||
Ok(ChainSpec::from_genesis( | ||
"Development", | ||
"dev", | ||
ChainType::Development, | ||
move || testnet_genesis(wasm_binary), | ||
vec![], | ||
None, | ||
None, | ||
None, | ||
Some(props()), | ||
None, | ||
)) | ||
} | ||
|
||
pub fn local_testnet_config() -> Result<ChainSpec, String> { | ||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; | ||
|
||
Ok(ChainSpec::from_genesis( | ||
"Local Testnet", | ||
"local_testnet", | ||
ChainType::Local, | ||
move || testnet_genesis(wasm_binary), | ||
vec![], | ||
None, | ||
None, | ||
None, | ||
Some(props()), | ||
None, | ||
)) | ||
} | ||
|
||
/// Configure initial storage state for FRAME modules. | ||
fn testnet_genesis(wasm_binary: &[u8]) -> RuntimeGenesisConfig { | ||
use frame::traits::Get; | ||
use runtime::interface::{Balance, MinimumBalance}; | ||
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000; | ||
let balances = AccountKeyring::iter() | ||
.map(|a| (a.to_account_id(), endowment)) | ||
.collect::<Vec<_>>(); | ||
RuntimeGenesisConfig { | ||
system: SystemConfig { | ||
// Add Wasm runtime to storage. | ||
code: wasm_binary.to_vec(), | ||
_config: Default::default(), | ||
}, | ||
balances: BalancesConfig { balances }, | ||
sudo: SudoConfig { key: Some(AccountKeyring::Alice.to_account_id()) }, | ||
..Default::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use sc_cli::RunCmd; | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Consensus { | ||
ManualSeal(u64), | ||
InstantSeal, | ||
} | ||
|
||
impl std::str::FromStr for Consensus { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(if s == "instant-seal" { | ||
Consensus::InstantSeal | ||
} else if let Some(block_time) = s.strip_prefix("manual-seal-") { | ||
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?) | ||
} else { | ||
return Err("incorrect consensus identifier".into()) | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, clap::Parser)] | ||
pub struct Cli { | ||
#[command(subcommand)] | ||
pub subcommand: Option<Subcommand>, | ||
|
||
#[clap(long, default_value = "manual-seal-3000")] | ||
pub consensus: Consensus, | ||
|
||
#[clap(flatten)] | ||
pub run: RunCmd, | ||
} | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum Subcommand { | ||
/// Key management cli utilities | ||
#[command(subcommand)] | ||
Key(sc_cli::KeySubcommand), | ||
|
||
/// Build a chain specification. | ||
BuildSpec(sc_cli::BuildSpecCmd), | ||
|
||
/// Validate blocks. | ||
CheckBlock(sc_cli::CheckBlockCmd), | ||
|
||
/// Export blocks. | ||
ExportBlocks(sc_cli::ExportBlocksCmd), | ||
|
||
/// Export the state of a given block into a chain spec. | ||
ExportState(sc_cli::ExportStateCmd), | ||
|
||
/// Import blocks. | ||
ImportBlocks(sc_cli::ImportBlocksCmd), | ||
|
||
/// Remove the whole chain. | ||
PurgeChain(sc_cli::PurgeChainCmd), | ||
|
||
/// Revert the chain to a previous state. | ||
Revert(sc_cli::RevertCmd), | ||
|
||
/// Db meta columns information. | ||
ChainInfo(sc_cli::ChainInfoCmd), | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking if there should be actual
substrate::client
and/orsubstrate::primitives
namespaces?Re-exporting everything from the
substrate
crate could work, but not sure if its a good or horrible idea 😆