Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuanyshbaev committed Feb 19, 2025
1 parent faf8635 commit f3a4bed
Show file tree
Hide file tree
Showing 12 changed files with 1,493 additions and 1,144 deletions.
2,407 changes: 1,382 additions & 1,025 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ color-print = "0.3.4"
futures = { version = "0.3.21", features = ["thread-pool"] }
hex-literal = "0.3.4"
serde = { version = "1.0.171", features = ["derive"] }
serde_json = "1.0.138"
jsonrpsee = { version = "0.24.7", features = ["server"] }
thiserror = "1.0.43"
async-trait = "0.1.71"
Expand Down
2 changes: 1 addition & 1 deletion frame/datalog/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl WeightInfo for () {
Default::default()
}

fn erase(win: u64) -> Weight {
fn erase(_win: u64) -> Weight {
Default::default()
}
}
2 changes: 2 additions & 0 deletions frame/digital-twin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
//! Digital twin runtime module. This can be compiled with `#[no_std]`, ready for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;

#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;
Expand Down
13 changes: 7 additions & 6 deletions frame/rws/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 2018-2024 Robonomics Network <[email protected]>
// Copyright 2018-2025 Robonomics Network <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,8 @@ use parity_scale_codec::{Decode, Encode, HasCompact, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;

pub use pallet::*;

//#[cfg(test)]
//mod tests;

Expand Down Expand Up @@ -433,7 +435,7 @@ pub mod pallet {
<Auction<T>>::insert(&index, AuctionLedger::new(kind.clone()));

// insert auction into queue
<AuctionQueue<T>>::mutate(|queue| queue.try_push(index.clone()));
let _ = <AuctionQueue<T>>::mutate(|queue| queue.try_push(index.clone()));

// deposit descriptive event
Self::deposit_event(Event::NewAuction(kind, index));
Expand All @@ -453,19 +455,18 @@ pub mod pallet {
.partition(|(_, auction)| auction.winner.is_some());

// store auction indexes without bids to queue
//<AuctionQueue<T>>::put(next.iter().map(|(i, _)| i).collect::<Vec<_>>());
let mut indexes_without_bids = BoundedVec::new();
next.iter()
let _ = next
.iter()
.map(|(i, _)| indexes_without_bids.try_push(i.clone()));
<AuctionQueue<T>>::put(indexes_without_bids);
//------------------------------------------------

for (_, auction) in finished.iter() {
if let Some(subscription_id) = &auction.winner {
// transfer reserve to reward pool
let (slash, _) =
T::AuctionCurrency::slash_reserved(&subscription_id, auction.best_price);
T::AuctionCurrency::burn(slash.peek());
let _ = T::AuctionCurrency::burn(slash.peek());
// register subscription
<Ledger<T>>::insert(
subscription_id,
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ clap = { workspace = true }
color-print = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }

robonomics-primitives = { path = "../primitives" }
robonomics-service = { path = "./service" }
Expand Down
4 changes: 0 additions & 4 deletions node/rpc/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use std::sync::Arc;
use robonomics_primitives::{AccountId, Balance, Block, Nonce};

use sc_client_api::AuxStore;
pub use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand All @@ -37,8 +36,6 @@ pub struct CoreDeps<C, P> {
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
// /// Whether to deny unsafe calls.
// pub deny_unsafe: DenyUnsafe,
/// RPC extensions
pub ext_rpc: RpcExtension,
}
Expand Down Expand Up @@ -67,7 +64,6 @@ where
let CoreDeps {
client,
pool,
// deny_unsafe,
ext_rpc,
} = deps;

Expand Down
21 changes: 8 additions & 13 deletions node/service/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ use sc_consensus_grandpa::{
GrandpaBlockImport, GrandpaParams, LinkHalf, SharedVoterState, VotingRulesBuilder,
};
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::{service::traits::NetworkBackend, NetworkService};
use sc_network::service::traits::NetworkBackend;
use sc_service::{config::Configuration, error::Error as ServiceError, TaskManager};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::{CallApiAt, ConstructRuntimeApi};
use sp_api::ConstructRuntimeApi;
use sp_consensus_aura::sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair};
use sp_runtime::{
traits::{BlakeTwo256, Block as BlockT},
OpaqueExtrinsic,
};
use sp_runtime::traits::BlakeTwo256;

use futures::FutureExt;
use std::sync::Arc;
Expand Down Expand Up @@ -199,12 +196,10 @@ where
let client = client.clone();
let pool = transaction_pool.clone();

// move |deny_unsafe, _| {
move |_| {
let deps = robonomics_rpc_core::CoreDeps {
client: client.clone(),
pool: pool.clone(),
// deny_unsafe,
// TODO: enable RPC extensions for dev node
ext_rpc: jsonrpsee::RpcModule::new(()),
};
Expand Down Expand Up @@ -290,11 +285,11 @@ where
);
net_config.add_notification_protocol(grandpa_protocol_config);

let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Vec::default(),
));
// let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
// backend.clone(),
// grandpa_link.shared_authority_set().clone(),
// Vec::default(),
// ));

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand Down
6 changes: 2 additions & 4 deletions node/service/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use cumulus_client_consensus_common::{
use cumulus_client_consensus_relay_chain::{
build_relay_chain_consensus, BuildRelayChainConsensusParams,
};
use cumulus_client_parachain_inherent::{ParachainInherentData, ParachainInherentDataProvider};
use cumulus_client_parachain_inherent::ParachainInherentDataProvider;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_collator,
start_full_node, BuildNetworkParams, CollatorSybilResistance, StartCollatorParams,
Expand All @@ -38,7 +38,7 @@ use robonomics_primitives::{AccountId, Balance, Block, Hash, Nonce};
use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::{config::FullNetworkConfiguration, NetworkBlock};
use sc_network_sync::{service::network::Network, SyncingService};
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::{ApiExt, ConstructRuntimeApi, Metadata};
Expand Down Expand Up @@ -385,13 +385,11 @@ where
let client = client.clone();
let transaction_pool = transaction_pool.clone();

// Box::new(move |deny_unsafe, _| {
Box::new(move |_| {
let deps = robonomics_rpc_core::CoreDeps {
client: client.clone(),
pool: transaction_pool.clone(),
ext_rpc: rpc_ext_builder(client.clone())?,
// deny_unsafe,
};

robonomics_rpc_core::create_core_rpc(deps).map_err(Into::into)
Expand Down
100 changes: 60 additions & 40 deletions node/src/chain_spec/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ use dev_runtime::{
use robonomics_primitives::{AccountId, Balance, CommunityAccount};

use sc_chain_spec::ChainType;
use serde_json::json;
use sp_core::sr25519;
use sp_runtime::traits::IdentifyAccount;

// /// DevNet Chain Specification.
// pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig, Extensions>;
/// DevNet Chain Specification.
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
// pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

fn get_authority_keys_from_seed(seed: &str) -> (AuraId, GrandpaId) {
(
Expand All @@ -44,7 +43,7 @@ fn devnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
balances: Vec<(AccountId, Balance)>,
sudo_key: AccountId,
code: Vec<u8>,
_code: Vec<u8>,
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
Expand Down Expand Up @@ -123,50 +122,71 @@ pub fn genesis(
// get_account_id_from_seed::<sr25519::Public>("Alice"),
// )
// };
//
// let mut properties = sc_chain_spec::Properties::new();
// properties.insert("tokenSymbol".into(), "XRT".into());
// properties.insert("tokenDecimals".into(), 9.into());
//
// // ChainSpec::from_genesis(
// // "Development",
// // "dev",
// // ChainType::Development,
// // mk_genesis,
// // vec![],
// // None,
// // None,
// // None,
// // Some(properties),
// // Default::default(),
// // )
//
// ChainSpec::from_genesis(
// "Development",
// "dev",
// ChainType::Development,
// mk_genesis,
// vec![],
// None,
// None,
// None,
// Some(properties),
// Default::default(),
// )
// }

pub fn config() -> ChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "XRT".into());
properties.insert("tokenDecimals".into(), 9.into());

ChainSpec::builder(
wasm_binary_unwrap(),
// genesis(
// vec![get_authority_keys_from_seed("Alice")],
// None,
// get_account_id_from_seed::<sr25519::Public>("Alice"),
// ),
Extensions {
// ???
relay_chain: "kusama".into(),
// You MUST set this to the correct network!
// ???
para_id: 1000,
},
)
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
// .with_extensions()
.build()
ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.with_genesis_config_patch(json!({
"aura": {
"authorities": [
get_account_id_from_seed::<sr25519::Public>("Alice"),
],
},
"grandpa": {
"authorities": [
get_account_id_from_seed::<sr25519::Public>("Alice"),
],
},
"sudo": {
"key": vec![get_authority_keys_from_seed("Alice")],
}
}))
.with_properties(properties)
.build()
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_spec() {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "XRT".into());
properties.insert("tokenDecimals".into(), 9.into());

let spec = ChainSpec::builder(wasm_binary_unwrap(), Default::default())
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.with_properties(properties)
.build();

let raw_chain_spec = spec.as_json(true);
assert!(raw_chain_spec.is_ok());
}
}
10 changes: 4 additions & 6 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use robonomics_service as service;
use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::{info, warn};
use log::info;
use sc_chain_spec::ChainSpec;
use sc_cli::{
CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams,
Expand Down Expand Up @@ -277,10 +277,9 @@ pub fn run() -> sc_cli::Result<()> {
})
}
Some(Subcommand::ExportGenesisState(cmd)) => {
// construct_async_run!(|components, cli, cmd, config| {
// Ok(async move { cmd.run(&*config.chain_spec, &*components.client) })
// })
Ok(())
construct_async_run!(|components, cli, cmd, config| {
Ok(async move { cmd.run(components.client) })
})
}
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand All @@ -295,7 +294,6 @@ pub fn run() -> sc_cli::Result<()> {
match cmd {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
// runner.sync_run(|config| cmd.run::<Block, ()>(config))
runner.sync_run(|config| cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ReclaimHostFunctions>(Some(config.chain_spec)))
} else {
Err("Benchmarking wasn't enabled when building the node. \
Expand Down
Loading

0 comments on commit f3a4bed

Please sign in to comment.