Skip to content

Commit

Permalink
Merge pull request #2 from mangata-finance/feature/code-cleaning
Browse files Browse the repository at this point in the history
Feature/code cleaning
  • Loading branch information
gleb-urvanov authored Dec 2, 2020
2 parents 04ccae9 + 78173fa commit 9e3d87e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 28 deletions.
3 changes: 0 additions & 3 deletions client/block-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ where
let mut rng: StdRng = SeedableRng::from_seed(extrinsics_hash.to_fixed_bytes());
previous_block_extrinsics.shuffle(&mut rng);

// self.backend.revert(1.into(), false);
info!("transaction execution after reversion");
previous_block_extrinsics.into_iter().for_each(|xt| {
self.api.execute_in_transaction(|api| {
match api.apply_extrinsic_with_context(
Expand All @@ -261,7 +259,6 @@ where
},
}

info!("Finalizing block");
let header = self.api.finalize_block_with_context(
&self.block_id, ExecutionContext::BlockConstruction
)?;
Expand Down
6 changes: 0 additions & 6 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,7 @@ impl<B, C, E, I, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for BabeSlot
))?;
let digest_item = <DigestItemFor<B> as CompatibleDigestItem>::babe_seal(signature.into());

info!("Block import params using Babe");
let mut import_block = BlockImportParams::new(BlockOrigin::Own, header);
info!("Pushing digest to block");
import_block.post_digests.push(digest_item);
import_block.body = Some(body);
import_block.storage_changes = Some(storage_changes);
Expand Down Expand Up @@ -1127,7 +1125,6 @@ impl<Block, Client, Inner> BlockImport<Block> for BabeBlockImport<Block, Client,
mut block: BlockImportParams<Block, Self::Transaction>,
new_cache: HashMap<CacheKeyId, Vec<u8>>,
) -> Result<ImportResult, Self::Error> {
info!("Importing block using Babe");
let hash = block.post_hash();
let number = *block.header.number();

Expand All @@ -1152,8 +1149,6 @@ impl<Block, Client, Inner> BlockImport<Block> for BabeBlockImport<Block, Client,
Error::<Block>::ParentUnavailable(parent_hash, hash)
).into()))?;


info!("Parent slot pre digest");
let parent_slot = find_pre_digest::<Block>(&parent_header)
.map(|d| d.slot_number())
.expect("parent is non-genesis; valid BABE headers contain a pre-digest; \
Expand Down Expand Up @@ -1413,7 +1408,6 @@ pub fn block_import<Client, Block: BlockT, I>(
Client: AuxStore + HeaderBackend<Block> + HeaderMetadata<Block, Error = sp_blockchain::Error>,
{

info!("Block import using Babe");
let epoch_changes = aux_schema::load_epoch_changes::<Block, _>(&*client, &config)?;
let link = BabeLink {
epoch_changes: epoch_changes.clone(),
Expand Down
1 change: 0 additions & 1 deletion pallets/erc20-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ impl<T: Trait> Module<T> {
return Err(Error::<T>::InvalidAssetId.into())
}

// <asset::Module<T>>::do_mint(payload.token_addr, &payload.recipient_addr, payload.amount)?;
//FIXME overflow unsafe!
if !<asset::Module<T>>::exists(payload.token_addr) {
let id = <assets::Module<T>>::assets_issue(&payload.recipient_addr,
Expand Down
11 changes: 1 addition & 10 deletions pallets/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,14 @@
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
use sp_runtime::print;
use sp_std::{prelude::*, marker::PhantomData};
use frame_support::{
storage::StorageValue, weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
traits::{OnInitialize, OnFinalize, OnRuntimeUpgrade, OffchainWorker},
dispatch::PostDispatchInfo,
};
use sp_runtime::{
generic::Digest, ApplyExtrinsicResult,
print, generic::Digest, ApplyExtrinsicResult,
traits::{
self, Header, Zero, One, Checkable, Applyable, CheckEqual, ValidateUnsigned, NumberFor,
Block as BlockT, Dispatchable, Saturating,
Expand Down Expand Up @@ -275,7 +274,6 @@ where

fn initial_checks(block: &Block) {

print("Initial checks");
sp_tracing::enter_span!(sp_tracing::Level::TRACE, "initial_checks");
let header = block.header();

Expand All @@ -296,13 +294,11 @@ where

/// Actually execute all transitions for `block`.
pub fn execute_block(block: Block) {
print("Block is being executed");
sp_io::init_tracing();
sp_tracing::within_span! {
sp_tracing::info_span!( "execute_block", ?block);
{

print("inside block execution");
Self::initialize_block(block.header());

// any initial checks
Expand All @@ -328,7 +324,6 @@ where

/// Execute given extrinsics and take care of post-extrinsics book-keeping.
fn execute_extrinsics_with_book_keeping(extrinsics: Vec<Block::Extrinsic>, block_number: NumberFor<Block>) {
print("extrinsic are executed with book keeping (dont expect to see this message)");
extrinsics.into_iter().for_each(Self::apply_extrinsic_no_note);

// post-extrinsics book-keeping
Expand All @@ -340,7 +335,6 @@ where
/// Finalize the block - it is up the caller to ensure that all header fields are valid
/// except state-root.
pub fn finalize_block() -> System::Header {
print("block is being finalized");
sp_io::init_tracing();
sp_tracing::enter_span!( sp_tracing::Level::TRACE, "finalize_block" );
<frame_system::Module<System>>::note_finished_extrinsics();
Expand All @@ -358,7 +352,6 @@ where
/// This doesn't attempt to validate anything regarding the block, but it builds a list of uxt
/// hashes.
pub fn apply_extrinsic(uxt: Block::Extrinsic) -> ApplyExtrinsicResult {
print("extrinsic applied outside block execution");
sp_io::init_tracing();
let encoded = uxt.encode();
let encoded_len = encoded.len();
Expand All @@ -371,7 +364,6 @@ where

/// Apply an extrinsic inside the block execution function.
fn apply_extrinsic_no_note(uxt: Block::Extrinsic) {
print("extrinsic applied inside block execution");
let l = uxt.encode().len();
match Self::apply_extrinsic_with_len(uxt, l, None) {
Ok(_) => (),
Expand All @@ -385,7 +377,6 @@ where
encoded_len: usize,
to_note: Option<Vec<u8>>,
) -> ApplyExtrinsicResult {
print("extrinsic application from unknown origin");
sp_tracing::enter_span!(
sp_tracing::info_span!("apply_extrinsic",
ext=?sp_core::hexdisplay::HexDisplay::from(&uxt.encode()))
Expand Down
4 changes: 2 additions & 2 deletions primitives/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl fmt::Display for StringError {
const DEFAULT_APP_ID: [u8; 20] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = env::var("OUT_DIR").unwrap();
/*let out_dir = env::var("OUT_DIR").unwrap();
let appid_envs: Vec<&str> = vec!["ETH_APP_ID", "ERC20_APP_ID"];
for appid_env in appid_envs.into_iter() {
Expand All @@ -61,6 +61,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-env-changed=ETH_APP_ID");
println!("cargo:rerun-if-env-changed=ERC20_APP_ID");
println!("cargo:rerun-if-changed=build.rs");

*/
Ok(())
}
6 changes: 4 additions & 2 deletions primitives/core/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

use crate::types::AppId;
use sp_std::convert::TryInto;

/// Short identifer for an application.
#[derive(Copy, Clone)]
Expand All @@ -14,14 +15,15 @@ struct Entry {
pub id: AppId,
}

// FIXME add app ids as constants in readable format
static APP_REGISTRY: &[Entry] = &[
Entry {
app: App::ETH,
id: include!(concat!(env!("OUT_DIR"), "/eth_app_id.rs")),
id: [0xdd, 0x51, 0x4b, 0xaa, 0x31, 0x7b, 0xf0, 0x95, 0xdd, 0xba, 0x2c, 0x0a, 0x84, 0x77, 0x65, 0xfe, 0xb3, 0x89, 0xc6, 0xa0],
},
Entry {
app: App::ERC20,
id: include!(concat!(env!("OUT_DIR"), "/erc20_app_id.rs")),
id: [0x00, 0xe3, 0x92, 0xc0, 0x47, 0x43, 0x35, 0x9e, 0x39, 0xf0, 0x0c, 0xd2, 0x68, 0xa5, 0x39, 0x0d, 0x27, 0xef, 0x6b, 0x44],
}
];

Expand Down
2 changes: 0 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));


use sp_runtime::print;
use sp_std::prelude::*;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
Expand Down Expand Up @@ -567,7 +566,6 @@ impl_runtime_apis! {

impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
print("extrinsic application called using rpc");
Executive::apply_extrinsic(extrinsic)
}

Expand Down
2 changes: 0 additions & 2 deletions utils/frame/rpc/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use std::sync::Arc;

use sp_runtime::print;
use codec::{self, Codec, Decode, Encode};
use sc_client_api::light::{future_header, RemoteBlockchain, Fetcher, RemoteCallRequest};
use jsonrpc_core::{
Expand Down Expand Up @@ -149,7 +148,6 @@ where
data: Some(format!("{:?}", e).into()),
})?;

print("dry running transactions");
let result = "test";
// let result = api.apply_extrinsic(&at, uxt)
// .map_err(|e| RpcError {
Expand Down

0 comments on commit 9e3d87e

Please sign in to comment.