From 52da7f23285f6e6673bc5bbe1b21d19a542e7551 Mon Sep 17 00:00:00 2001 From: Gleb Urvanov Date: Mon, 30 Nov 2020 12:56:31 +0100 Subject: [PATCH 1/4] code cleaning from debug comments --- client/consensus/babe/src/lib.rs | 6 ------ pallets/executive/src/lib.rs | 11 +---------- runtime/src/lib.rs | 2 -- utils/frame/rpc/system/src/lib.rs | 2 -- 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 59c43c7d3e6f9..1ec04b9ca3639 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -612,9 +612,7 @@ impl sc_consensus_slots::SimpleSlotWorker for BabeSlot ))?; let digest_item = 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); @@ -1127,7 +1125,6 @@ impl BlockImport for BabeBlockImport, new_cache: HashMap>, ) -> Result { - info!("Importing block using Babe"); let hash = block.post_hash(); let number = *block.header.number(); @@ -1152,8 +1149,6 @@ impl BlockImport for BabeBlockImport::ParentUnavailable(parent_hash, hash) ).into()))?; - - info!("Parent slot pre digest"); let parent_slot = find_pre_digest::(&parent_header) .map(|d| d.slot_number()) .expect("parent is non-genesis; valid BABE headers contain a pre-digest; \ @@ -1413,7 +1408,6 @@ pub fn block_import( Client: AuxStore + HeaderBackend + HeaderMetadata, { - info!("Block import using Babe"); let epoch_changes = aux_schema::load_epoch_changes::(&*client, &config)?; let link = BabeLink { epoch_changes: epoch_changes.clone(), diff --git a/pallets/executive/src/lib.rs b/pallets/executive/src/lib.rs index 79ce3d0c26fa3..6bdb55cf69e62 100644 --- a/pallets/executive/src/lib.rs +++ b/pallets/executive/src/lib.rs @@ -114,7 +114,6 @@ //! ``` #![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}, @@ -122,7 +121,7 @@ use frame_support::{ 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, @@ -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(); @@ -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 @@ -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_number: NumberFor) { - 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 @@ -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" ); >::note_finished_extrinsics(); @@ -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(); @@ -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(_) => (), @@ -385,7 +377,6 @@ where encoded_len: usize, to_note: Option>, ) -> 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())) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index b013df32587c0..01ef664175a2b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -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::{ @@ -567,7 +566,6 @@ impl_runtime_apis! { impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - print("extrinsic application called using rpc"); Executive::apply_extrinsic(extrinsic) } diff --git a/utils/frame/rpc/system/src/lib.rs b/utils/frame/rpc/system/src/lib.rs index e0642aa6ae809..f41b5dff0157c 100644 --- a/utils/frame/rpc/system/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -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::{ @@ -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 { From d46a81822c3445bdc652873b1d88cfc13c282879 Mon Sep 17 00:00:00 2001 From: Gleb Urvanov Date: Mon, 30 Nov 2020 12:59:55 +0100 Subject: [PATCH 2/4] code cleaning --- client/block-builder/src/lib.rs | 3 --- pallets/erc20-app/src/lib.rs | 1 - 2 files changed, 4 deletions(-) diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index d0c994f103032..ac4b199d4c4f6 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -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( @@ -261,7 +259,6 @@ where }, } - info!("Finalizing block"); let header = self.api.finalize_block_with_context( &self.block_id, ExecutionContext::BlockConstruction )?; diff --git a/pallets/erc20-app/src/lib.rs b/pallets/erc20-app/src/lib.rs index 4f037b335f2d6..b2171752053df 100644 --- a/pallets/erc20-app/src/lib.rs +++ b/pallets/erc20-app/src/lib.rs @@ -105,7 +105,6 @@ impl Module { return Err(Error::::InvalidAssetId.into()) } - // >::do_mint(payload.token_addr, &payload.recipient_addr, payload.amount)?; //FIXME overflow unsafe! if !>::exists(payload.token_addr) { let id = >::assets_issue(&payload.recipient_addr, From 07327cad5ae1f5a9a763bac2f3f06354777941dd Mon Sep 17 00:00:00 2001 From: Gleb Urvanov Date: Wed, 2 Dec 2020 19:42:49 +0100 Subject: [PATCH 3/4] hardcoded test contracts addresses --- primitives/core/src/registry.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/primitives/core/src/registry.rs b/primitives/core/src/registry.rs index a540b22e18896..4cc86115b5b6a 100644 --- a/primitives/core/src/registry.rs +++ b/primitives/core/src/registry.rs @@ -1,5 +1,6 @@ use crate::types::AppId; +use sp_std::convert::TryInto; /// Short identifer for an application. #[derive(Copy, Clone)] @@ -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], } ]; From 78173fa0c6e24b0237adccbd4220ba0e794881db Mon Sep 17 00:00:00 2001 From: Gleb Urvanov Date: Wed, 2 Dec 2020 19:58:08 +0100 Subject: [PATCH 4/4] removed custom artemis build code --- primitives/core/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primitives/core/build.rs b/primitives/core/build.rs index e48793ccfe8a0..6e7da8cb5c682 100644 --- a/primitives/core/build.rs +++ b/primitives/core/build.rs @@ -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> { - 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() { @@ -61,6 +61,6 @@ fn main() -> Result<(), Box> { 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(()) }