Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add a new ReleaseSchedule trait #49

Merged
merged 81 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
f3eabc8
wip: Add initial trait
lrazovic Jul 17, 2023
69a52f2
feat: start to draft the ReleaseSchedule trait
lrazovic Jul 17, 2023
f3fc15e
wip: start linear-release pallet
lrazovic Jul 18, 2023
15d326a
Delete Cargo.toml
lrazovic Jul 18, 2023
3b10eb1
revert: Delete Cargo.toml
lrazovic Jul 18, 2023
9f0250e
revert pallet-funding changes
lrazovic Jul 18, 2023
51e6758
feat; hardcode the LockType to focus on the main logic
lrazovic Jul 18, 2023
17a8e57
wip: add release schedule
lrazovic Jul 18, 2023
afcd124
feat: add linear release to the funding pallet
lrazovic Jul 18, 2023
2a394d6
feat: relax the genesis config type
lrazovic Jul 19, 2023
a898aba
feat: the lock should now implement Ser and Des
lrazovic Jul 19, 2023
4f31ef3
fix: few tests
lrazovic Jul 19, 2023
280713a
feat: add the Ser and Des trait to LockType
lrazovic Jul 19, 2023
f0f063f
feat: the vesting_balance now uses the latest Inspect API
lrazovic Jul 19, 2023
b5830d8
tests: git gud
lrazovic Jul 19, 2023
38857e6
wip: save
JuaniRios Jul 14, 2023
8d3f835
feat(214): ProjectDetails changed. Evaluation total bond now stored i…
JuaniRios Jul 18, 2023
065dbe1
feat(214): bid refunds on failure due to candle end and ct soldout im…
JuaniRios Jul 19, 2023
926cb93
fix(funding): re-add serde into the Cargo.toml
lrazovic Jul 19, 2023
c513dd6
feat(214): tried to add final price check on new_with for CommunityFu…
JuaniRios Jul 19, 2023
f3d113b
fix(214): reflecting BidInfoFilter changes on tests
JuaniRios Jul 19, 2023
f3d83aa
feat: homogeneous parameters
lrazovic Jul 20, 2023
90d126c
feat: use multiple reasons
lrazovic Jul 20, 2023
0f503c6
doc: add TODO about different reasons
lrazovic Jul 20, 2023
e726198
test: add a new account
lrazovic Jul 21, 2023
2facc32
test: check what happens when merging different locks
lrazovic Jul 21, 2023
b32ff48
chore: move the imports to the main lib.rs
lrazovic Jul 21, 2023
7ca9262
feat: remove unused constraint
lrazovic Jul 21, 2023
0bd5d85
feat: add VestingTransferred event
lrazovic Jul 21, 2023
927fd91
chore: remove unused file
lrazovic Jul 12, 2023
485cc43
wip
lrazovic Jul 12, 2023
ebc45af
feat: the big cleanup
lrazovic Jul 13, 2023
edb84f6
make integration tests compile
lrazovic Jul 13, 2023
cc1cb23
feat: update to 0.9.42
lrazovic Jul 14, 2023
272b760
feat: add parachain staking
lrazovic Jul 14, 2023
4489e8c
fix: building using workspace inheritance
lrazovic Jul 14, 2023
79a616c
chore: fmt
JuaniRios Jul 14, 2023
5cd3a9f
chore(214): fix warnings
JuaniRios Jul 21, 2023
dee16ba
fix(214): broken auction unbond test fixed
JuaniRios Jul 21, 2023
6affad0
chore(214): cargo fmt
JuaniRios Jul 21, 2023
cca032c
chore(214): unsafe math fix
JuaniRios Jul 21, 2023
0b3beb8
chore(220): reorder imports
JuaniRios Jul 21, 2023
69ff08e
feat(220): do_evaluation_end uses the config type as threshold. Confi…
JuaniRios Jul 21, 2023
d5b4430
feat: add linear release to the funding pallet
lrazovic Jul 18, 2023
1020a30
tests: fix the used reason
lrazovic Jul 21, 2023
640ce58
Revert "tests: fix the used reason"
lrazovic Jul 21, 2023
749be27
Revert "feat: add linear release to the funding pallet"
lrazovic Jul 21, 2023
ef0f2e9
Revert "feat(220): do_evaluation_end uses the config type as threshol…
lrazovic Jul 21, 2023
daac339
Revert "chore(220): reorder imports"
lrazovic Jul 21, 2023
2b0a9ac
Revert "chore(214): unsafe math fix"
lrazovic Jul 21, 2023
fc4c5b9
Revert "chore(214): cargo fmt"
lrazovic Jul 21, 2023
528e6f0
Revert "fix(214): broken auction unbond test fixed"
lrazovic Jul 21, 2023
a8baa84
Revert "chore(214): fix warnings"
lrazovic Jul 21, 2023
f57bd6a
Revert "chore: fmt"
lrazovic Jul 21, 2023
fb2fb80
Revert "fix: building using workspace inheritance"
lrazovic Jul 21, 2023
4617300
Revert "feat: add parachain staking"
lrazovic Jul 21, 2023
384b203
Revert "feat: update to 0.9.42"
lrazovic Jul 21, 2023
15371ac
Revert "make integration tests compile"
lrazovic Jul 21, 2023
b6ee734
Revert "feat: the big cleanup"
lrazovic Jul 21, 2023
295c3da
Revert "wip"
lrazovic Jul 21, 2023
0f1d2e6
Revert "chore: remove unused file"
lrazovic Jul 21, 2023
3d4b136
Merge branch 'main' into feature/add-pallet-vesting
lrazovic Jul 21, 2023
499e2b3
feat: add vesting to funding
lrazovic Jul 21, 2023
326977a
chore: add missing headers
lrazovic Jul 21, 2023
78506e6
chore: cargo fmt
lrazovic Jul 21, 2023
0706439
rename total_{locked->held}_now & typos
Lederstrumpf Jul 22, 2023
e8916c9
feat: use Exact preceision
lrazovic Jul 23, 2023
61663e3
chore: rename for clarity
lrazovic Jul 23, 2023
9274cbd
feat: accrue, not add
lrazovic Jul 23, 2023
434e29e
feat: new extrinsics to "release" all the reasons
lrazovic Jul 23, 2023
e7f9b1f
feat: modify what the "vesting_balance" is
lrazovic Jul 23, 2023
87b89b8
test: add tests for the new vest_all extrinsics
lrazovic Jul 23, 2023
5db9099
chore: clippy warnings
lrazovic Jul 24, 2023
c68e994
feat: add pallet-linear-release to the runtime
lrazovic Jul 24, 2023
0817995
feat: add default genesis config to the node
lrazovic Jul 24, 2023
3d14489
chore: fmt
lrazovic Jul 24, 2023
c9f89c9
feat: move the ReleaseSchedule trait outside of the pallet
lrazovic Jul 24, 2023
ff1432f
doc: remove "\"
lrazovic Jul 24, 2023
a53332a
doc: add a TODO to a possible future improvement
lrazovic Jul 24, 2023
729f6e2
doc: README revamp
lrazovic Jul 24, 2023
435210a
docs: fix markdown
lrazovic Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,695 changes: 917 additions & 778 deletions polimec-skeleton/Cargo.lock

Large diffs are not rendered by default.

33 changes: 10 additions & 23 deletions polimec-skeleton/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
TPublic::Pair::from_string(&format!("//{}", seed), None).expect("static values are valid; qed").public()
}

/// The extensions for the [`ChainSpec`].
Expand Down Expand Up @@ -77,14 +75,8 @@ pub fn development_config() -> ChainSpec {
testnet_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
(get_account_id_from_seed::<sr25519::Public>("Alice"), get_collator_keys_from_seed("Alice")),
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_collator_keys_from_seed("Bob")),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down Expand Up @@ -132,14 +124,8 @@ pub fn local_testnet_config() -> ChainSpec {
testnet_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
(get_account_id_from_seed::<sr25519::Public>("Alice"), get_collator_keys_from_seed("Alice")),
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_collator_keys_from_seed("Bob")),
],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down Expand Up @@ -177,7 +163,9 @@ pub fn local_testnet_config() -> ChainSpec {
}

fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>, endowed_accounts: Vec<AccountId>, id: ParaId,
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> parachain_template_runtime::GenesisConfig {
parachain_template_runtime::GenesisConfig {
system: parachain_template_runtime::SystemConfig {
Expand Down Expand Up @@ -211,10 +199,9 @@ fn testnet_genesis(
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: parachain_template_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
polkadot_xcm: parachain_template_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
transaction_payment: Default::default(),
credentials: Default::default(),
vesting: Default::default(),
}
}
15 changes: 4 additions & 11 deletions polimec-skeleton/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ const AFTER_HELP_EXAMPLE: &str = color_print::cstr!(
"#
);
#[derive(Debug, clap::Parser)]
#[command(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
)]
#[command(propagate_version = true, args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]
#[clap(after_help = AFTER_HELP_EXAMPLE)]
pub struct Cli {
#[command(subcommand)]
Expand Down Expand Up @@ -100,15 +96,12 @@ pub struct RelayChainCli {
impl RelayChainCli {
/// Parse the relay chain CLI parameters using the para chain `Configuration`.
pub fn new<'a>(
para_config: &sc_service::Configuration, relay_chain_args: impl Iterator<Item = &'a String>,
para_config: &sc_service::Configuration,
relay_chain_args: impl Iterator<Item = &'a String>,
) -> Self {
let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
Self {
base_path,
chain_id,
base: clap::Parser::parse_from(relay_chain_args),
}
Self { base_path, chain_id, base: clap::Parser::parse_from(relay_chain_args) }
}
}
69 changes: 30 additions & 39 deletions polimec-skeleton/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,37 +128,35 @@ pub fn run() -> Result<()> {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
}
},
Some(Subcommand::CheckBlock(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| Ok(cmd.run(components.client, config.database)))
}
},
Some(Subcommand::ExportState(cmd)) => {
construct_async_run!(|components, cli, cmd, config| Ok(cmd.run(components.client, config.chain_spec)))
}
},
Some(Subcommand::ImportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue))
})
}
},
Some(Subcommand::Revert(cmd)) => {
construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.backend, None))
})
}
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| {
let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()]
.iter()
.chain(cli.relay_chain_args.iter()),
[RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()),
);

let polkadot_config =
Expand All @@ -167,64 +165,61 @@ pub fn run() -> Result<()> {

cmd.run(config, polkadot_config)
})
}
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, state_version)
})
}
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run(&*spec)
})
}
},
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;
// Switch on the concrete benchmark sub-command-
match cmd {
BenchmarkCmd::Pallet(cmd) => {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ParachainNativeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
}
}
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config)?;
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => {
BenchmarkCmd::Storage(_) =>
return Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into())
}
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
}),
BenchmarkCmd::Machine(cmd) => {
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))
}
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
// NOTE: this allows the Client to leniently implement
// new benchmark commands without requiring a companion MR.
#[allow(unreachable_patterns)]
_ => Err("Benchmarking sub-command unsupported".into()),
}
}
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use parachain_template_runtime::MILLISECS_PER_BLOCK;
Expand All @@ -246,12 +241,9 @@ pub fn run() -> Result<()> {
let info_provider = timestamp_with_aura_info(MILLISECS_PER_BLOCK);

runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>, _>(Some(info_provider)),
task_manager,
))
Ok((cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>, _>(Some(info_provider)), task_manager))
})
}
},
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \
You can enable it with `--features try-runtime`."
Expand Down Expand Up @@ -311,7 +303,7 @@ pub fn run() -> Result<()> {
.map(|r| r.0)
.map_err(Into::into)
})
}
},
}
}

Expand Down Expand Up @@ -351,10 +343,7 @@ impl CliConfiguration<Self> for RelayChainCli {
}

fn base_path(&self) -> Result<Option<BasePath>> {
Ok(self
.shared_params()
.base_path()?
.or_else(|| self.base_path.clone().map(Into::into)))
Ok(self.shared_params().base_path()?.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
Expand All @@ -370,13 +359,19 @@ impl CliConfiguration<Self> for RelayChainCli {
}

fn prometheus_config(
&self, default_listen_port: u16, chain_spec: &Box<dyn ChainSpec>,
&self,
default_listen_port: u16,
chain_spec: &Box<dyn ChainSpec>,
) -> Result<Option<PrometheusConfig>> {
self.base.base.prometheus_config(default_listen_port, chain_spec)
}

fn init<F>(
&self, _support_url: &String, _impl_version: &String, _logger_hook: F, _config: &sc_service::Configuration,
&self,
_support_url: &String,
_impl_version: &String,
_logger_hook: F,
_config: &sc_service::Configuration,
) -> Result<()>
where
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
Expand All @@ -387,11 +382,7 @@ impl CliConfiguration<Self> for RelayChainCli {
fn chain_id(&self, is_dev: bool) -> Result<String> {
let chain_id = self.base.base.chain_id(is_dev)?;

Ok(if chain_id.is_empty() {
self.chain_id.clone().unwrap_or_default()
} else {
chain_id
})
Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id })
}

fn role(&self, is_dev: bool) -> Result<sc_service::Role> {
Expand Down
6 changes: 1 addition & 5 deletions polimec-skeleton/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ where
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcExtension::new(());
let FullDeps {
client,
pool,
deny_unsafe,
} = deps;
let FullDeps { client, pool, deny_unsafe } = deps;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
Expand Down
Loading