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

Data Preservers Assignments #563

Merged
merged 37 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
60e8f95
add assignments
nanocryk May 29, 2024
91851ef
rust tests
nanocryk May 29, 2024
c895b68
update runtimes and tests
nanocryk Jun 3, 2024
08d07cb
migration
nanocryk Jun 5, 2024
2b6bcdb
Merge remote-tracking branch 'origin/master' into jeremy-data-preserv…
nanocryk Jun 5, 2024
d191a8a
allow owner to stop assignment + prevent deletion of assigned profile
nanocryk Jun 6, 2024
1b4bef4
switch to btreesets + remove BootNodes storage
nanocryk Jun 6, 2024
d80650f
Merge remote-tracking branch 'origin/master' into jeremy-data-preserv…
nanocryk Jun 6, 2024
f716dbc
benchmarks
nanocryk Jun 7, 2024
d92994c
force start/stop assignment, refactor normal/forced operations
nanocryk Jun 7, 2024
77cd09a
local benchmark run
nanocryk Jun 7, 2024
c8ab111
real benchmarks
nanocryk Jun 7, 2024
33f026d
Merge remote-tracking branch 'origin/master' into jeremy-data-preserv…
nanocryk Jun 7, 2024
ed557f6
fix clippy errors
nanocryk Jun 7, 2024
3db3c2e
typescript api
nanocryk Jun 7, 2024
442e31c
clippy
nanocryk Jun 7, 2024
f4298ac
fmt
nanocryk Jun 7, 2024
76040bb
update some ts tests
nanocryk Jun 10, 2024
a960897
Merge remote-tracking branch 'origin/master' into HEAD
girazoki Jun 10, 2024
a70a2cc
fix a couple of things
girazoki Jun 10, 2024
c86f3a4
just in case, bring api-augment
girazoki Jun 10, 2024
4e20e7f
fix test
girazoki Jun 10, 2024
b0e4204
fix zombienet
girazoki Jun 10, 2024
de96ce4
ts lint and fmt
nanocryk Jun 10, 2024
705b153
put bag genesis config with bootnodes
nanocryk Jun 10, 2024
8bb69c4
cargo clippy
nanocryk Jun 10, 2024
acafc1f
Fix zombie parathread tests
tmpolaczyk Jun 10, 2024
50406c5
migration no longer rely on para managers
nanocryk Jun 10, 2024
e6b971b
Merge remote-tracking branch 'origin/master' into jeremy-data-preserv…
nanocryk Jun 11, 2024
5294bfc
fix merge
nanocryk Jun 11, 2024
d9fcdb8
properly record migration weight
nanocryk Jun 11, 2024
39d5ad1
move types in distinct file
nanocryk Jun 11, 2024
266aba7
move trait in primitives
nanocryk Jun 11, 2024
fdf2e0f
add ts tests for start/stop assignment
nanocryk Jun 11, 2024
8de8503
Fix zombienet tests that do not run in CI
tmpolaczyk Jun 11, 2024
f2c82c9
remove unused config type + update ts api
nanocryk Jun 11, 2024
7944442
remove type in mock
nanocryk Jun 11, 2024
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
3 changes: 1 addition & 2 deletions client/consensus/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ where
&mut params.overseer_handle,
&mut params.relay_client,
)
.await
.get(0)
.await.first()
{
*core_index
} else {
Expand Down
4 changes: 2 additions & 2 deletions client/services-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where
.client
.runtime_api()
.block_cost(self.client.usage_info().chain.best_hash, para_id)
.map_err(|e| internal_err(e))?;
.map_err(internal_err)?;
Ok(cost)
}

Expand All @@ -77,7 +77,7 @@ where
.client
.runtime_api()
.collator_assignment_cost(self.client.usage_info().chain.best_hash, para_id)
.map_err(|e| internal_err(e))?;
.map_err(internal_err)?;
Ok(cost)
}
}
Expand Down
2 changes: 1 addition & 1 deletion container-chains/nodes/frontier/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};

use fc_storage::StorageOverride;
use {
container_chain_template_frontier_runtime::{opaque::Block, AccountId, Hash, Index},
cumulus_client_parachain_inherent::ParachainInherentData,
cumulus_primitives_core::{ParaId, PersistedValidationData},
cumulus_test_relay_sproof_builder::RelayStateSproofBuilder,
fc_rpc::{EthTask, TxPool},
fc_rpc_core::TxPoolApiServer,
fc_storage::StorageOverride,
fp_rpc::EthereumRuntimeRPCApi,
futures::StreamExt,
jsonrpsee::RpcModule,
Expand Down
13 changes: 7 additions & 6 deletions container-chains/runtime-templates/frontier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,13 @@ where
let deploy_filter: DeployFilter = AddressList::get();

match deploy_filter {
DeployFilter::All => return Ok(()),
DeployFilter::All => Ok(()),
DeployFilter::Whitelisted(addresses_vec) => {
if !addresses_vec.contains(address) {
return Err(pallet_evm::Error::<Runtime>::CreateOriginNotAllowed);
Err(pallet_evm::Error::<Runtime>::CreateOriginNotAllowed)
} else {
Ok(())
}
return Ok(());
}
}
}
Expand Down Expand Up @@ -1366,7 +1367,7 @@ impl_runtime_apis! {
);

// verify initial balance
assert_eq!(Balances::free_balance(&who), balance);
assert_eq!(Balances::free_balance(who), balance);

// set up local asset
let asset_amount = 10u128;
Expand All @@ -1386,10 +1387,10 @@ impl_runtime_apis! {
let verify = Box::new(move || {
// verify native balance after transfer, decreased by transferred fee amount
// (plus transport fees)
assert!(Balances::free_balance(&who) <= balance - fee_amount);
assert!(Balances::free_balance(who) <= balance - fee_amount);
// verify asset balance decreased by exactly transferred amount
assert_eq!(
ForeignAssets::balance(asset_id, &who),
ForeignAssets::balance(asset_id, who),
initial_asset_amount - asset_amount,
);
});
Expand Down
24 changes: 17 additions & 7 deletions node/src/chain_spec/dancebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,26 @@ fn testnet_genesis(
.iter()
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000, 100).into())
.collect();
let para_id_boot_nodes: Vec<_> = para_ids
let data_preservers_bootnodes: Vec<_> = para_ids
.iter()
.map(|(para_id, _genesis_data, boot_nodes)| (*para_id, boot_nodes.clone()))
.flat_map(|(para_id, _genesis_data, bootnodes)| {
bootnodes.clone().into_iter().map(|bootnode| {
(
*para_id,
AccountId::from([0u8; 32]),
bootnode,
dancebox_runtime::PreserversAssignementPaymentRequest::Free,
dancebox_runtime::PreserversAssignementPaymentWitness::Free,
)
})
})
.collect();
let para_ids: Vec<_> = para_ids
.into_iter()
.map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data))
.collect();

let accounts_with_ed = vec![
let accounts_with_ed = [
dancebox_runtime::StakingAccount::get(),
dancebox_runtime::ParachainBondAccount::get(),
dancebox_runtime::PendingRewardsAccount::get(),
Expand Down Expand Up @@ -250,10 +260,6 @@ fn testnet_genesis(
},
parachain_system: Default::default(),
configuration,
data_preservers: DataPreserversConfig {
para_id_boot_nodes,
..Default::default()
},
tmpolaczyk marked this conversation as resolved.
Show resolved Hide resolved
registrar: RegistrarConfig { para_ids },
services_payment: ServicesPaymentConfig { para_id_credits },
sudo: SudoConfig {
Expand All @@ -271,6 +277,10 @@ fn testnet_genesis(
transaction_payment: Default::default(),
tx_pause: Default::default(),
treasury: Default::default(),
data_preservers: DataPreserversConfig {
bootnodes: data_preservers_bootnodes,
..Default::default()
},
};

serde_json::to_value(g).unwrap()
Expand Down
25 changes: 18 additions & 7 deletions node/src/chain_spec/flashbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,27 @@ fn testnet_genesis(
.iter()
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000, 100).into())
.collect();
let para_id_boot_nodes: Vec<_> = para_ids
let data_preservers_bootnodes: Vec<_> = para_ids
.iter()
.map(|(para_id, _genesis_data, boot_nodes)| (*para_id, boot_nodes.clone()))
.flat_map(|(para_id, _genesis_data, bootnodes)| {
bootnodes.clone().into_iter().map(|bootnode| {
(
*para_id,
AccountId::from([0u8; 32]),
bootnode,
flashbox_runtime::PreserversAssignementPaymentRequest::Free,
flashbox_runtime::PreserversAssignementPaymentWitness::Free,
)
})
})
.collect();

let para_ids: Vec<_> = para_ids
.into_iter()
.map(|(para_id, genesis_data, _boot_nodes)| (para_id, genesis_data))
.collect();

let accounts_with_ed = vec![
let accounts_with_ed = [
flashbox_runtime::StakingAccount::get(),
flashbox_runtime::ParachainBondAccount::get(),
flashbox_runtime::PendingRewardsAccount::get(),
Expand Down Expand Up @@ -250,10 +261,6 @@ fn testnet_genesis(
},
parachain_system: Default::default(),
configuration,
data_preservers: DataPreserversConfig {
para_id_boot_nodes,
..Default::default()
},
registrar: RegistrarConfig { para_ids },
services_payment: ServicesPaymentConfig { para_id_credits },
sudo: SudoConfig {
Expand All @@ -269,6 +276,10 @@ fn testnet_genesis(
transaction_payment: Default::default(),
tx_pause: Default::default(),
treasury: Default::default(),
data_preservers: DataPreserversConfig {
bootnodes: data_preservers_bootnodes,
..Default::default()
},
};

serde_json::to_value(g).unwrap()
Expand Down
7 changes: 3 additions & 4 deletions node/src/container_chain_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ fn delete_container_chain_db(db_path: &Path) {
let _ = std::fs::remove_dir_all(db_path);
// Remove all the empty folders inside `simple_container_2002`, including self
if let Some(parent) = db_path.ancestors().nth(2) {
let _ = delete_empty_folders_recursive(parent);
delete_empty_folders_recursive(parent);
}
}

Expand All @@ -821,7 +821,7 @@ fn delete_empty_folders_recursive(path: &Path) {

let path = entry.path();
if path.is_dir() {
let _ = delete_empty_folders_recursive(&path);
delete_empty_folders_recursive(&path);
}
}

Expand Down Expand Up @@ -903,8 +903,7 @@ fn check_paritydb_lock_held(db_path: &Path) -> Result<bool, std::io::Error> {

#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
use {super::*, std::path::PathBuf};

// Copy of ContainerChainSpawner with extra assertions for tests, and mocked spawn function.
struct MockContainerChainSpawner {
Expand Down
3 changes: 2 additions & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ async fn start_node_impl(
.base
.base
.import_params
.wasmtime_precompiled = parachain_config.wasmtime_precompiled.clone();
.wasmtime_precompiled
.clone_from(&parachain_config.wasmtime_precompiled);
}
}

Expand Down
3 changes: 1 addition & 2 deletions node/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ mod panics;
fn create_runner() -> Runner<Cli> {
// tanssi-node args should go here, `--dev` is probably enough
let cli = Cli::from_iter(["--dev"]);
let runner = cli.create_runner(&cli.run.normalize()).unwrap();

runner
cli.create_runner(&cli.run.normalize()).unwrap()
}

// Nice hack from polkadot-sdk to run a unit test in a separate process.
Expand Down
4 changes: 2 additions & 2 deletions pallets/author-noting/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ benchmarks! {
let para_id = 1000.into();
let block_number = 1;
let author: T::AccountId = account("account id", 0u32, 0u32);
}: _(RawOrigin::Root, para_id, block_number, author, (block_number as u64).into())
}: _(RawOrigin::Root, para_id, block_number, author, u64::from(block_number).into())

kill_author_data {
let para_id = 1000.into();
let block_number = 1;
let author: T::AccountId = account("account id", 0u32, 0u32);
assert_ok!(Pallet::<T>::set_author(RawOrigin::Root.into(), para_id, block_number, author, (block_number as u64).into()));
assert_ok!(Pallet::<T>::set_author(RawOrigin::Root.into(), para_id, block_number, author, u64::from(block_number).into()));
}: _(RawOrigin::Root, para_id)

impl_benchmark_test_suite!(
Expand Down
5 changes: 2 additions & 3 deletions pallets/data-preservers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true

dp-core = { workspace = true }
log = { workspace = true }
serde = { workspace = true, optional = true }
serde = { workspace = true, default-features = false, features = [ "derive" ] }
tp-traits = { workspace = true }

# Substrate
Expand Down Expand Up @@ -52,8 +52,7 @@ std = [
"pallet-balances/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"serde?/std",
"serde/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
Expand Down
Loading
Loading