Repository: paritytech/ink
Pull request #812 (2021-06-09 08:08:02)

Spellchecking for examples + Fix master CI
Some miscellaneous improvements and fixes for the nightly clippy errors which currently make the CI fail on `master`.


Patch:
diff --git a/.config/cargo_spellcheck.dic b/.config/cargo_spellcheck.dic
index ef83cb1de6..52037641ce 100644
--- a/.config/cargo_spellcheck.dic
+++ b/.config/cargo_spellcheck.dic
@@ -35,6 +35,7 @@ scalable
 adjunctive
 invariants
 deserializes
+DApp
 
 hasher/S
 hashmap/S
@@ -48,3 +49,4 @@ defragment/SD
 layout/JG
 endian/P
 accessor/S
+NFT/S
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 983d3c38c9..074fc4be73 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -157,6 +157,12 @@ spellcheck:
         when: never
     script:
         - cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1
+        - for example in examples/*/; do
+            cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 ${example};
+          done
+        - for contract in ${DELEGATOR_SUBCONTRACTS}; do
+            cargo spellcheck check --cfg=.config/cargo_spellcheck.toml --checkers hunspell --code 1 examples/delegator/${contract}/;
+          done
 
 codecov:
   stage:                           workspace
diff --git a/crates/engine/src/database.rs b/crates/engine/src/database.rs
index 388f311b8d..e9419f93d8 100644
--- a/crates/engine/src/database.rs
+++ b/crates/engine/src/database.rs
@@ -69,7 +69,7 @@ impl Database {
         account_id: &[u8],
         key: &[u8],
     ) -> Option<&Vec<u8>> {
-        let hashed_key = storage_of_contract_key(&account_id, key);
+        let hashed_key = storage_of_contract_key(account_id, key);
         self.hmap.get(&hashed_key.to_vec())
     }
 
@@ -80,7 +80,7 @@ impl Database {
         key: &[u8],
         value: Vec<u8>,
     ) -> Option<Vec<u8>> {
-        let hashed_key = storage_of_contract_key(&account_id, key);
+        let hashed_key = storage_of_contract_key(account_id, key);
         self.hmap.insert(hashed_key.to_vec(), value)
     }
 
@@ -90,7 +90,7 @@ impl Database {
         account_id: &[u8],
         key: &[u8],
     ) -> Option<Vec<u8>> {
-        let hashed_key = storage_of_contract_key(&account_id, key);
+        let hashed_key = storage_of_contract_key(account_id, key);
         self.hmap.remove(&hashed_key.to_vec())
     }
 
@@ -112,7 +112,7 @@ impl Database {
 
     /// Returns the balance of `account_id`, if available.
     pub fn get_balance(&self, account_id: &[u8]) -> Option<Balance> {
-        let hashed_key = balance_of_key(&account_id);
+        let hashed_key = balance_of_key(account_id);
         self.get(&hashed_key).map(|encoded_balance| {
             scale::Decode::decode(&mut &encoded_balance[..])
                 .expect("unable to decode balance from database")
@@ -121,7 +121,7 @@ impl Database {
 
     /// Sets the balance of `account_id` to `new_balance`.
     pub fn set_balance(&mut self, account_id: &[u8], new_balance: Balance) {
-        let hashed_key = balance_of_key(&account_id);
+        let hashed_key = balance_of_key(account_id);
         let encoded_balance = scale::Encode::encode(&new_balance);
         self.hmap
             .entry(hashed_key.to_vec())
diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs
index 8fa8f900f2..0ae04076f3 100644
--- a/crates/engine/src/ext.rs
+++ b/crates/engine/src/ext.rs
@@ -91,6 +91,9 @@ define_error_codes! {
     CodeNotFound = 7,
     /// The account that was called is either no contract (e.g. user account) or is a tombstone.
     NotCallable = 8,
+    /// The call to `seal_debug_message` had no effect because debug message
+    /// recording was disabled.
+    LoggingDisabled = 9,
 }
 
 /// The raw return code returned by the host side.
@@ -291,7 +294,7 @@ impl Engine {
             .as_ref()
             .expect("no callee has been set")
             .as_bytes();
-        set_output(output, &callee)
+        set_output(output, callee)
     }
 
     /// Restores a tombstone to the original smart contract.
@@ -317,10 +320,10 @@ impl Engine {
         unimplemented!("off-chain environment does not yet support `restore_to`");
     }
 
-    /// Prints the given contents to the console log.
-    pub fn println(&mut self, content: &str) {
-        self.debug_info.record_println(String::from(content));
-        println!("{}", content);
+    /// Records the given debug message and appends to stdout.
+    pub fn debug_message(&mut self, message: &str) {
+        self.debug_info.record_debug_message(String::from(message));
+        print!("{}", message);
     }
 
     /// Conduct the BLAKE-2 256-bit hash and place the result into `output`.
@@ -343,14 +346,14 @@ impl Engine {
         super::hashing::keccak_256(input, output);
     }
 
-    pub fn now(&self, _output: &mut &mut [u8]) {
-        unimplemented!("off-chain environment does not yet support `now`");
-    }
-
     pub fn block_number(&self, _output: &mut &mut [u8]) {
         unimplemented!("off-chain environment does not yet support `block_number`");
     }
 
+    pub fn block_timestamp(&self, _output: &mut &mut [u8]) {
+        unimplemented!("off-chain environment does not yet support `block_timestamp`");
+    }
+
     pub fn gas_left(&self, _output: &mut &mut [u8]) {
         unimplemented!("off-chain environment does not yet support `gas_left`");
     }
diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml
index 217c10e56e..a42f3086aa 100644
--- a/crates/env/Cargo.toml
+++ b/crates/env/Cargo.toml
@@ -62,4 +62,6 @@ std = [
     "sha3",
     "blake2",
 ]
+# Enable contract debug messages via `debug_print!` and `debug_println!`.
+ink-debug = []
 ink-experimental-engine = ["ink_engine"]
diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs
index 945ab8e5d4..ce8444a664 100644
--- a/crates/env/src/api.rs
+++ b/crates/env/src/api.rs
@@ -553,10 +553,10 @@ where
     })
 }
 
-/// Prints the given contents to the environmental log.
-pub fn debug_println(content: &str) {
+/// Appends the given message to the debug message buffer.
+pub fn debug_message(message: &str) {
     <EnvInstance as OnInstance>::on_instance(|instance| {
-        EnvBackend::println(instance, content)
+        EnvBackend::debug_message(instance, message)
     })
 }
 
diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs
index feaffca187..150b7a8504 100644
--- a/crates/env/src/backend.rs
+++ b/crates/env/src/backend.rs
@@ -119,8 +119,15 @@ pub trait EnvBackend {
     where
         R: scale::Encode;
 
-    /// Prints the given contents to the console log.
-    fn println(&mut self, content: &str);
+    /// Emit a custom debug message.
+    ///
+    /// The message is appended to the debug buffer which is then supplied to the calling RPC
+    /// client. This buffer is also printed as a debug message to the node console if the
+    /// `debug` log level is enabled for the `runtime::contracts` target.
+    ///
+    /// If debug message recording is disabled in the contracts pallet, which is always the case
+    /// when the code is executing on-chain, then this will have no effect.
+    fn debug_message(&mut self, content: &str);
 
     /// Conducts the crypto hash of the given input and stores the result in `output`.
     fn hash_bytes<H>(&mut self, input: &[u8], output: &mut <H as HashOutput>::Type)
diff --git a/crates/env/src/engine/experimental_off_chain/impls.rs b/crates/env/src/engine/experimental_off_chain/impls.rs
index 0781e0670f..3c627c7b04 100644
--- a/crates/env/src/engine/experimental_off_chain/impls.rs
+++ b/crates/env/src/engine/experimental_off_chain/impls.rs
@@ -111,6 +111,7 @@ impl From<ext::Error> for crate::Error {
             ext::Error::NewContractNotFunded => Self::NewContractNotFunded,
             ext::Error::CodeNotFound => Self::CodeNotFound,
             ext::Error::NotCallable => Self::NotCallable,
+            ext::Error::LoggingDisabled => Self::LoggingDisabled,
         }
     }
 }
@@ -227,8 +228,8 @@ impl EnvBackend for EnvInstance {
         )
     }
 
-    fn println(&mut self, content: &str) {
-        self.engine.println(content)
+    fn debug_message(&mut self, message: &str) {
+        self.engine.debug_message(message)
     }
 
     fn hash_bytes<H>(&mut self, input: &[u8], output: &mut <H as HashOutput>::Type)
@@ -288,7 +289,7 @@ impl TypedEnvBackend for EnvInstance {
     }
 
     fn block_timestamp<T: Environment>(&mut self) -> Result<T::Timestamp> {
-        self.get_property::<T::Timestamp>(Engine::now)
+        self.get_property::<T::Timestamp>(Engine::block_timestamp)
     }
 
     fn account_id<T: Environment>(&mut self) -> Result<T::AccountId> {
diff --git a/crates/env/src/engine/off_chain/db/accounts.rs b/crates/env/src/engine/off_chain/db/accounts.rs
index fe41b76384..e23f9ce474 100644
--- a/crates/env/src/engine/off_chain/db/accounts.rs
+++ b/crates/env/src/engine/off_chain/db/accounts.rs
@@ -92,7 +92,7 @@ impl AccountsDb {
         //       the borrow-checker somehow cannot make sense of it according
         //       to its lifetime analysis. Consider this to be a hack until
         //       the borrow-checker eventually let's us do this.
-        if self.get_account::<T>(&at).is_some() {
+        if self.get_account::<T>(at).is_some() {
             self.get_account_mut::<T>(at)
                 .expect("just checked that account exists")
         } else {
diff --git a/crates/env/src/engine/off_chain/db/console.rs b/crates/env/src/engine/off_chain/db/debug_buf.rs
similarity index 50%
rename from crates/env/src/engine/off_chain/db/console.rs
rename to crates/env/src/engine/off_chain/db/debug_buf.rs
index 67486b4e8f..959c4d7365 100644
--- a/crates/env/src/engine/off_chain/db/console.rs
+++ b/crates/env/src/engine/off_chain/db/debug_buf.rs
@@ -14,53 +14,53 @@
 
 use ink_prelude::string::String;
 
-/// A debug console used to print console contents and store them.
-pub struct Console {
-    /// The buffer to store the already pasted contents.
-    past_prints: Vec<String>,
+/// A debug buffer used to store debug messages and print them to stdout.
+pub struct DebugBuffer {
+    /// The buffer to store the emitted debug messages.
+    past_debug_messages: Vec<String>,
 }
 
-impl Console {
+impl DebugBuffer {
     /// Creates a new empty console.
     pub fn new() -> Self {
         Self {
-            past_prints: Vec::new(),
+            past_debug_messages: Vec::new(),
         }
     }
 
-    /// Resets the console to uninitialized state.
+    /// Resets the debug buffer to uninitialized state.
     pub fn reset(&mut self) {
-        self.past_prints.clear();
+        self.past_debug_messages.clear();
     }
 
-    /// Prints the contents to the actual console and stores them.
-    pub fn println(&mut self, contents: &str) {
-        self.past_prints.push(contents.to_string());
-        println!("{}", contents);
+    /// Prints the message to stdout and stores it.
+    pub fn debug_message(&mut self, message: &str) {
+        self.past_debug_messages.push(message.to_string());
+        print!("{}", message);
     }
 
-    /// Returns an iterator over the past console prints.
-    pub fn past_prints(&self) -> PastPrints {
-        PastPrints::new(self)
+    /// Returns an iterator over the past debug messages.
+    pub fn past_debug_messages(&self) -> DebugMessages {
+        DebugMessages::new(self)
     }
 }
 
-/// Iterator over the past prints to the console.
-pub struct PastPrints<'a> {
-    /// Iterator over the past printlns.
+/// Iterator over the past debug messages.
+pub struct DebugMessages<'a> {
+    /// Iterator over the past debug messages.
     iter: core::slice::Iter<'a, String>,
 }
 
-impl<'a> PastPrints<'a> {
-    /// Creates a new iterator over the past console prints.
-    fn new(console: &'a Console) -> Self {
+impl<'a> DebugMessages<'a> {
+    /// Creates a new iterator over the past debug messages.
+    fn new(console: &'a DebugBuffer) -> Self {
         Self {
-            iter: console.past_prints.iter(),
+            iter: console.past_debug_messages.iter(),
         }
     }
 }
 
-impl<'a> Iterator for PastPrints<'a> {
+impl<'a> Iterator for DebugMessages<'a> {
     type Item = &'a str;
 
     fn next(&mut self) -> Option<Self::Item> {
@@ -68,13 +68,13 @@ impl<'a> Iterator for PastPrints<'a> {
     }
 }
 
-impl<'a> ExactSizeIterator for PastPrints<'a> {
+impl<'a> ExactSizeIterator for DebugMessages<'a> {
     fn len(&self) -> usize {
         self.iter.len()
     }
 }
 
-impl<'a> DoubleEndedIterator for PastPrints<'a> {
+impl<'a> DoubleEndedIterator for DebugMessages<'a> {
     fn next_back(&mut self) -> Option<Self::Item> {
         self.iter.next_back().map(AsRef::as_ref)
     }
diff --git a/crates/env/src/engine/off_chain/db/mod.rs b/crates/env/src/engine/off_chain/db/mod.rs
index 100a652127..42ff658b6a 100644
--- a/crates/env/src/engine/off_chain/db/mod.rs
+++ b/crates/env/src/engine/off_chain/db/mod.rs
@@ -15,7 +15,7 @@
 mod accounts;
 mod block;
 mod chain_spec;
-mod console;
+mod debug_buf;
 mod events;
 mod exec_context;
 
@@ -30,9 +30,9 @@ pub use self::{
     },
     block::Block,
     chain_spec::ChainSpec,
-    console::{
-        Console,
-        PastPrints,
+    debug_buf::{
+        DebugBuffer,
+        DebugMessages,
     },
     events::{
         EmittedEvent,
diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs
index abf6790816..17909e7059 100644
--- a/crates/env/src/engine/off_chain/impls.rs
+++ b/crates/env/src/engine/off_chain/impls.rs
@@ -175,8 +175,8 @@ impl EnvBackend for EnvInstance {
         std::process::exit(flags.into_u32() as i32)
     }
 
-    fn println(&mut self, content: &str) {
-        self.console.println(content)
+    fn debug_message(&mut self, message: &str) {
+        self.debug_buf.debug_message(message)
     }
 
     fn hash_bytes<H>(&mut self, input: &[u8], output: &mut <H as HashOutput>::Type)
diff --git a/crates/env/src/engine/off_chain/mod.rs b/crates/env/src/engine/off_chain/mod.rs
index 5dc11e5a0d..bb3ce8d41b 100644
--- a/crates/env/src/engine/off_chain/mod.rs
+++ b/crates/env/src/engine/off_chain/mod.rs
@@ -28,8 +28,8 @@ pub use self::{
     call_data::CallData,
     db::{
         AccountError,
+        DebugMessages,
         EmittedEvent,
-        PastPrints,
     },
     typed_encoded::TypedEncodedError,
 };
@@ -40,7 +40,7 @@ use self::{
         AccountsDb,
         Block,
         ChainSpec,
-        Console,
+        DebugBuffer,
         EmittedEventsRecorder,
         ExecContext,
     },
@@ -84,8 +84,8 @@ pub struct EnvInstance {
     chain_spec: ChainSpec,
     /// The blocks of the chain.
     blocks: Vec<Block>,
-    /// The console to print debug contents.
-    console: Console,
+    /// The debug buffer to collect debug messages and print them to stdout.
+    debug_buf: DebugBuffer,
     /// Handler for registered chain extensions.
     chain_extension_handler: ChainExtensionHandler,
     /// Emitted events recorder.
@@ -102,7 +102,7 @@ impl EnvInstance {
             exec_context: Vec::new(),
             chain_spec: ChainSpec::uninitialized(),
             blocks: Vec::new(),
-            console: Console::new(),
+            debug_buf: DebugBuffer::new(),
             chain_extension_handler: ChainExtensionHandler::new(),
             emitted_events: EmittedEventsRecorder::new(),
             clear_storage_disabled: false,
@@ -133,7 +133,7 @@ impl EnvInstance {
         self.exec_context.clear();
         self.chain_spec.reset();
         self.blocks.clear();
-        self.console.reset();
+        self.debug_buf.reset();
         self.chain_extension_handler.reset();
         self.emitted_events.reset();
         self.clear_storage_disabled = false;
diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs
index dfbd3dd167..d621247bef 100644
--- a/crates/env/src/engine/on_chain/ext.rs
+++ b/crates/env/src/engine/on_chain/ext.rs
@@ -76,6 +76,9 @@ define_error_codes! {
     CodeNotFound = 7,
     /// The account that was called is either no contract (e.g. user account) or is a tombstone.
     NotCallable = 8,
+     /// The call to `seal_debug_message` had no effect because debug message
+    /// recording was disabled.
+    LoggingDisabled = 9,
 }
 
 /// Thin-wrapper around a `u32` representing a pointer for Wasm32.
@@ -308,8 +311,6 @@ mod sys {
 
         pub fn seal_set_rent_allowance(value_ptr: Ptr32<[u8]>, value_len: u32);
 
-        pub fn seal_println(str_ptr: Ptr32<[u8]>, str_len: u32);
-
         pub fn seal_hash_keccak_256(
             input_ptr: Ptr32<[u8]>,
             input_len: u32,
@@ -344,6 +345,9 @@ mod sys {
 
     #[link(wasm_import_module = "__unstable__")]
     extern "C" {
+        #[cfg(feature = "ink-debug")]
+        pub fn seal_debug_message(str_ptr: Ptr32<[u8]>, str_len: u32) -> ReturnCode;
+
         pub fn seal_rent_params(
             output_ptr: Ptr32Mut<[u8]>,
             output_len_ptr: Ptr32Mut<u32>,
@@ -645,11 +649,37 @@ pub fn random(subject: &[u8], output: &mut &mut [u8]) {
     extract_from_slice(output, output_len as usize);
 }
 
-pub fn println(content: &str) {
-    let bytes = content.as_bytes();
-    unsafe { sys::seal_println(Ptr32::from_slice(bytes), bytes.len() as u32) }
+#[cfg(feature = "ink-debug")]
+/// Call `seal_debug_message` with the supplied UTF-8 encoded message.
+///
+/// If debug message recording is disabled in the contracts pallet, the first call to will
+/// return LoggingDisabled error, and further calls will be a no-op to avoid the cost of calling
+/// into the supervisor.
+///
+/// # Note
+///
+/// This depends on the the `seal_debug_message` interface which requires the
+/// `"pallet-contracts/unstable-interface"` feature to be enabled in the target runtime.
+pub fn debug_message(message: &str) {
+    static mut DEBUG_ENABLED: bool = true;
+
+    // SAFETY: safe because executing in a single threaded context
+    if unsafe { DEBUG_ENABLED } {
+        let bytes = message.as_bytes();
+        let ret_code = unsafe {
+            sys::seal_debug_message(Ptr32::from_slice(bytes), bytes.len() as u32)
+        };
+        if let Err(Error::LoggingDisabled) = ret_code.into() {
+            // SAFETY: safe because executing in a single threaded context
+            unsafe { DEBUG_ENABLED = false }
+        }
+    }
 }
 
+#[cfg(not(feature = "ink-debug"))]
+/// A no-op. Enable the `ink-debug` feature for debug messages.
+pub fn debug_message(_message: &str) {}
+
 macro_rules! impl_hash_fn {
     ( $name:ident, $bytes_result:literal ) => {
         paste::item! {
diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs
index eacc2d2769..0e426cf46f 100644
--- a/crates/env/src/engine/on_chain/impls.rs
+++ b/crates/env/src/engine/on_chain/impls.rs
@@ -110,6 +110,7 @@ impl From<ext::Error> for Error {
             ext::Error::NewContractNotFunded => Self::NewContractNotFunded,
             ext::Error::CodeNotFound => Self::CodeNotFound,
             ext::Error::NotCallable => Self::NotCallable,
+            ext::Error::LoggingDisabled => Self::LoggingDisabled,
         }
     }
 }
@@ -255,8 +256,8 @@ impl EnvBackend for EnvInstance {
         ext::return_value(flags, enc_return_value);
     }
 
-    fn println(&mut self, content: &str) {
-        ext::println(content)
+    fn debug_message(&mut self, content: &str) {
+        ext::debug_message(content)
     }
 
     fn hash_bytes<H>(&mut self, input: &[u8], output: &mut <H as HashOutput>::Type)
diff --git a/crates/env/src/error.rs b/crates/env/src/error.rs
index 32d4a14550..babd7c2e74 100644
--- a/crates/env/src/error.rs
+++ b/crates/env/src/error.rs
@@ -46,6 +46,9 @@ pub enum Error {
     NotCallable,
     /// An unknown error has occurred.
     UnknownError,
+    /// The call to `seal_debug_message` had no effect because debug message
+    /// recording was disabled.
+    LoggingDisabled,
 }
 
 /// A result of environmental operations.
diff --git a/crates/env/src/lib.rs b/crates/env/src/lib.rs
index 9c2f21d513..ffe56c5dc5 100644
--- a/crates/env/src/lib.rs
+++ b/crates/env/src/lib.rs
@@ -102,3 +102,55 @@ pub use self::{
         RentStatus,
     },
 };
+
+cfg_if::cfg_if! {
+    if #[cfg(any(feature = "ink-debug", feature = "std"))] {
+        /// Required by the `debug_print*` macros below, because there is no guarantee that
+        /// contracts will have a direct `ink_prelude` dependency. In the future we could introduce
+        /// an "umbrella" crate containing all the `ink!` crates which could also host these macros.
+        #[doc(hidden)]
+        pub use ink_prelude::format;
+
+        /// Appends a formatted string to the `debug_message` buffer which will be:
+        ///  - Returned to the caller when the contract is invoked via RPC (*not* via an extrinsic)
+        ///  - Logged as a `debug!` message on the substrate node, which will be printed to the node
+        ///    console's `stdout` when the log level is set to `debug`.
+        ///
+        /// # Note
+        ///
+        /// This depends on the the `seal_debug_message` interface which requires the
+        /// `"pallet-contracts/unstable-interface"` feature to be enabled in the target runtime.
+        #[macro_export]
+        macro_rules! debug_print {
+            ($($arg:tt)*) => ($crate::debug_message(&$crate::format!($($arg)*)));
+        }
+
+        /// Appends a formatted string to the `debug_message` buffer, as per [`debug_print`] but
+        /// with a newline appended.
+        ///
+        /// # Note
+        ///
+        /// This depends on the the `seal_debug_message` interface which requires the
+        /// `"pallet-contracts/unstable-interface"` feature to be enabled in the target runtime.
+        #[macro_export]
+        macro_rules! debug_println {
+            () => ($crate::debug_print!("\n"));
+            ($($arg:tt)*) => (
+                $crate::debug_print!("{}\n", $crate::format!($($arg)*));
+            )
+        }
+    } else {
+        #[macro_export]
+        /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging.
+        macro_rules! debug_print {
+            ($($arg:tt)*) => ();
+        }
+
+        #[macro_export]
+        /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging.
+        macro_rules! debug_println {
+            () => ();
+            ($($arg:tt)*) => ();
+        }
+    }
+}
diff --git a/crates/lang/codegen/src/generator/item_impls.rs b/crates/lang/codegen/src/generator/item_impls.rs
index 2771187fbd..7b6a17238b 100644
--- a/crates/lang/codegen/src/generator/item_impls.rs
+++ b/crates/lang/codegen/src/generator/item_impls.rs
@@ -37,7 +37,7 @@ pub struct ItemImpls<'a> {
 
 impl AsRef<ir::Contract> for ItemImpls<'_> {
     fn as_ref(&self) -> &ir::Contract {
-        &self.contract
+        self.contract
     }
 }
 
diff --git a/crates/lang/codegen/src/generator/metadata.rs b/crates/lang/codegen/src/generator/metadata.rs
index 10bcc985e2..02acbc8485 100644
--- a/crates/lang/codegen/src/generator/metadata.rs
+++ b/crates/lang/codegen/src/generator/metadata.rs
@@ -125,7 +125,7 @@ impl Metadata<'_> {
             .map(|(trait_ident, constructor)| {
                 let span = constructor.span();
                 let attrs = constructor.attrs();
-                let docs = Self::extract_doc_comments(&attrs);
+                let docs = Self::extract_doc_comments(attrs);
                 let selector = constructor.composed_selector();
                 let selector_bytes = selector.as_bytes();
                 let constructor = constructor.callable();
@@ -216,7 +216,7 @@ impl Metadata<'_> {
             .map(|(trait_ident, message)| {
                 let span = message.span();
                 let attrs = message.attrs();
-                let docs = Self::extract_doc_comments(&attrs);
+                let docs = Self::extract_doc_comments(attrs);
                 let selector = message.composed_selector();
                 let selector_bytes = selector.as_bytes();
                 let is_payable = message.is_payable();
diff --git a/crates/lang/ir/src/ir/item_impl/callable.rs b/crates/lang/ir/src/ir/item_impl/callable.rs
index 936534c213..ddaf0b0dba 100644
--- a/crates/lang/ir/src/ir/item_impl/callable.rs
+++ b/crates/lang/ir/src/ir/item_impl/callable.rs
@@ -101,35 +101,35 @@ where
     C: Callable,
 {
     fn kind(&self) -> CallableKind {
-        <C as Callable>::kind(&self.callable)
+        <C as Callable>::kind(self.callable)
     }
 
     fn ident(&self) -> &Ident {
-        <C as Callable>::ident(&self.callable)
+        <C as Callable>::ident(self.callable)
     }
 
     fn user_provided_selector(&self) -> Option<&ir::Selector> {
-        <C as Callable>::user_provided_selector(&self.callable)
+        <C as Callable>::user_provided_selector(self.callable)
     }
 
     fn is_payable(&self) -> bool {
-        <C as Callable>::is_payable(&self.callable)
+        <C as Callable>::is_payable(self.callable)
     }
 
     fn visibility(&self) -> Visibility {
-        <C as Callable>::visibility(&self.callable)
+        <C as Callable>::visibility(self.callable)
     }
 
     fn inputs(&self) -> InputsIter {
-        <C as Callable>::inputs(&self.callable)
+        <C as Callable>::inputs(self.callable)
     }
 
     fn inputs_span(&self) -> Span {
-        <C as Callable>::inputs_span(&self.callable)
+        <C as Callable>::inputs_span(self.callable)
     }
 
     fn statements(&self) -> &[syn::Stmt] {
-        <C as Callable>::statements(&self.callable)
+        <C as Callable>::statements(self.callable)
     }
 }
 
@@ -137,7 +137,7 @@ impl<'a, C> ::core::ops::Deref for CallableWithSelector<'a, C> {
     type Target = C;
 
     fn deref(&self) -> &Self::Target {
-        &self.callable
+        self.callable
     }
 }
 
diff --git a/crates/lang/macro/src/lib.rs b/crates/lang/macro/src/lib.rs
index 4c74e4b049..82e491fcb6 100644
--- a/crates/lang/macro/src/lib.rs
+++ b/crates/lang/macro/src/lib.rs
@@ -399,7 +399,7 @@ use proc_macro::TokenStream;
 /// #
 /// #[ink::contract]
 /// mod greeter {
-///     use ink_prelude::format;
+///     use ink_env::debug_println;
 ///
 ///     #[ink(storage)]
 ///     pub struct Greeter;
@@ -408,8 +408,7 @@ use proc_macro::TokenStream;
 ///         #[ink(constructor)]
 ///         pub fn new() -> Self {
 ///             let caller = Self::env().caller();
-///             let message = format!("thanks for instantiation {:?}", caller);
-///             ink_env::debug_println(&message);
+///             debug_println!("thanks for instantiation {:?}", caller);
 ///             Greeter {}
 ///         }
 ///
@@ -417,8 +416,7 @@ use proc_macro::TokenStream;
 ///         pub fn fund(&self) {
 ///             let caller = self.env().caller();
 ///             let value = self.env().transferred_balance();
-///             let message = format!("thanks for the funding of {:?} from {:?}", value, caller);
-///             ink_env::debug_println(&message);
+///             debug_println!("thanks for the funding of {:?} from {:?}", value, caller);
 ///         }
 ///     }
 /// }
@@ -500,13 +498,13 @@ use proc_macro::TokenStream;
 ///             Self { value: init_value }
 ///         }
 ///
-///         /// Flips the current value of the Flipper's bool.
+///         /// Flips the current value of the Flipper's boolean.
 ///         #[ink(message)]
 ///         pub fn flip(&mut self) {
 ///             self.value = !self.value;
 ///         }
 ///
-///         /// Returns the current value of the Flipper's bool.
+///         /// Returns the current value of the Flipper's boolean.
 ///         #[ink(message)]
 ///         pub fn get(&self) -> bool {
 ///             self.value
diff --git a/crates/storage/src/alloc/boxed/storage.rs b/crates/storage/src/alloc/boxed/storage.rs
index 0624bdedab..6a0811d5ee 100644
--- a/crates/storage/src/alloc/boxed/storage.rs
+++ b/crates/storage/src/alloc/boxed/storage.rs
@@ -85,11 +85,11 @@ where
     }
 
     fn push_spread(&self, ptr: &mut KeyPtr) {
-        forward_push_packed::<Self>(&self, ptr)
+        forward_push_packed::<Self>(self, ptr)
     }
 
     fn clear_spread(&self, ptr: &mut KeyPtr) {
-        forward_clear_packed::<Self>(&self, ptr)
+        forward_clear_packed::<Self>(self, ptr)
     }
 }
 
diff --git a/crates/storage/src/alloc/init.rs b/crates/storage/src/alloc/init.rs
index 0e3538966b..5201956259 100644
--- a/crates/storage/src/alloc/init.rs
+++ b/crates/storage/src/alloc/init.rs
@@ -114,7 +114,7 @@ impl DynamicAllocatorState {
                 // Push all state of the global dynamic storage allocator
                 // instance back onto the contract storage.
                 push_spread_root::<DynamicAllocator>(
-                    &allocator,
+                    allocator,
                     &Key::from(DYNAMIC_ALLOCATOR_KEY_OFFSET),
                 );
                 // Prevent calling `drop` on the dynamic storage allocator
diff --git a/crates/storage/src/collections/binary_heap/children_vec.rs b/crates/storage/src/collections/binary_heap/children_vec.rs
index f3f9e91e7b..22f11f0af4 100644
--- a/crates/storage/src/collections/binary_heap/children_vec.rs
+++ b/crates/storage/src/collections/binary_heap/children_vec.rs
@@ -175,7 +175,7 @@ where
     /// Prefer using methods like `Iterator::take` in order to limit the number
     /// of yielded elements.
     pub fn iter(&self) -> Iter<T> {
-        Iter::new(&self)
+        Iter::new(self)
     }
 
     /// Returns a shared reference to the first element if any.
diff --git a/crates/storage/src/collections/hashmap/mod.rs b/crates/storage/src/collections/hashmap/mod.rs
index f06f03eb35..2ee602b8f8 100644
--- a/crates/storage/src/collections/hashmap/mod.rs
+++ b/crates/storage/src/collections/hashmap/mod.rs
@@ -415,8 +415,8 @@ where
     /// Returns a reference to this entry's key.
     pub fn key(&self) -> &K {
         match self {
-            Entry::Occupied(entry) => &entry.values_entry.key(),
-            Entry::Vacant(entry) => &entry.values_entry.key(),
+            Entry::Occupied(entry) => entry.values_entry.key(),
+            Entry::Vacant(entry) => entry.values_entry.key(),
         }
     }
 
@@ -459,7 +459,7 @@ where
     {
         match self {
             Entry::Occupied(entry) => &mut entry.values_entry.into_mut().value,
-            Entry::Vacant(entry) => Entry::insert(default(&entry.key()), entry),
+            Entry::Vacant(entry) => Entry::insert(default(entry.key()), entry),
         }
     }
 
@@ -494,7 +494,7 @@ where
 {
     /// Gets a reference to the key that would be used when inserting a value through the `VacantEntry`.
     pub fn key(&self) -> &K {
-        &self.values_entry.key()
+        self.values_entry.key()
     }
 
     /// Take ownership of the key.
@@ -520,7 +520,7 @@ where
 {
     /// Gets a reference to the key in the entry.
     pub fn key(&self) -> &K {
-        &self.values_entry.key()
+        self.values_entry.key()
     }
 
     /// Take the ownership of the key and value from the map.
diff --git a/crates/storage/src/lazy/entry.rs b/crates/storage/src/lazy/entry.rs
index 39e1fda50a..e5dde443b0 100644
--- a/crates/storage/src/lazy/entry.rs
+++ b/crates/storage/src/lazy/entry.rs
@@ -185,7 +185,7 @@ where
     /// Mainly used by lazy storage abstractions that only allow operating on
     /// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
     pub fn pull_spread_root(root_key: &Key) -> Self {
-        Self::new(pull_spread_root_opt::<T>(&root_key), EntryState::Preserved)
+        Self::new(pull_spread_root_opt::<T>(root_key), EntryState::Preserved)
     }
 
     /// Pushes the underlying associated data to the contract storage using
@@ -198,7 +198,7 @@ where
     pub fn push_spread_root(&self, root_key: &Key) {
         let old_state = self.replace_state(EntryState::Preserved);
         if old_state.is_mutated() {
-            push_spread_root_opt::<T>(self.value().into(), &root_key);
+            push_spread_root_opt::<T>(self.value().into(), root_key);
         }
     }
 
@@ -209,7 +209,7 @@ where
     /// Mainly used by lazy storage abstractions that only allow operating on
     /// packed storage entities such as [`LazyCell`][`crate::lazy::LazyCell`].
     pub fn clear_spread_root(&self, root_key: &Key) {
-        clear_spread_root_opt::<T, _>(&root_key, || self.value().into());
+        clear_spread_root_opt::<T, _>(root_key, || self.value().into());
     }
 }
 
@@ -238,7 +238,7 @@ where
     pub fn push_packed_root(&self, root_key: &Key) {
         let old_state = self.replace_state(EntryState::Preserved);
         if old_state.is_mutated() {
-            push_packed_root_opt::<T>(self.value().into(), &root_key);
+            push_packed_root_opt::<T>(self.value().into(), root_key);
         }
     }
 
@@ -250,7 +250,7 @@ where
     /// packed storage entities such as [`LazyIndexMap`][`crate::lazy::LazyIndexMap`]
     /// or [`LazyArray`][`crate::lazy::LazyArray`].
     pub fn clear_packed_root(&self, root_key: &Key) {
-        clear_packed_root::<Option<T>>(self.value(), &root_key);
+        clear_packed_root::<Option<T>>(self.value(), root_key);
     }
 }
 
diff --git a/crates/storage/src/lazy/lazy_array.rs b/crates/storage/src/lazy/lazy_array.rs
index 1287509284..bc055f27ce 100644
--- a/crates/storage/src/lazy/lazy_array.rs
+++ b/crates/storage/src/lazy/lazy_array.rs
@@ -294,7 +294,7 @@ where
             // because it requires a deep clean-up which propagates clearing to its fields,
             // for example in the case of `T` being a `storage::Box`.
             let entity = self.get(index).expect("cannot clear a non existing entity");
-            clear_packed_root::<T>(&entity, &root_key);
+            clear_packed_root::<T>(entity, &root_key);
         } else {
             // The type does not require deep clean-up so we can simply clean-up
             // its associated storage cell and be done without having to load it first.
diff --git a/crates/storage/src/lazy/lazy_hmap.rs b/crates/storage/src/lazy/lazy_hmap.rs
index bd7c573c26..b4f7c63d2e 100644
--- a/crates/storage/src/lazy/lazy_hmap.rs
+++ b/crates/storage/src/lazy/lazy_hmap.rs
@@ -271,7 +271,7 @@ where
     fn push_spread(&self, ptr: &mut KeyPtr) {
         let offset_key = ExtKeyPtr::next_for::<Self>(ptr);
         for (index, entry) in self.entries().iter() {
-            let root_key = self.to_offset_key(&offset_key, index);
+            let root_key = self.to_offset_key(offset_key, index);
             entry.push_packed_root(&root_key);
         }
     }
@@ -638,7 +638,7 @@ where
             // because it requires a deep clean-up which propagates clearing to its fields,
             // for example in the case of `T` being a `storage::Box`.
             let entity = self.get(index).expect("cannot clear a non existing entity");
-            clear_packed_root::<V>(&entity, &root_key);
+            clear_packed_root::<V>(entity, &root_key);
         } else {
             // The type does not require deep clean-up so we can simply clean-up
             // its associated storage cell and be done without having to load it first.
diff --git a/crates/storage/src/lazy/lazy_imap.rs b/crates/storage/src/lazy/lazy_imap.rs
index 5d8006e683..318189881c 100644
--- a/crates/storage/src/lazy/lazy_imap.rs
+++ b/crates/storage/src/lazy/lazy_imap.rs
@@ -284,7 +284,7 @@ where
             // because it requires a deep clean-up which propagates clearing to its fields,
             // for example in the case of `T` being a `storage::Box`.
             let entity = self.get(index).expect("cannot clear a non existing entity");
-            clear_packed_root::<V>(&entity, &root_key);
+            clear_packed_root::<V>(entity, &root_key);
         } else {
             // The type does not require deep clean-up so we can simply clean-up
             // its associated storage cell and be done without having to load it first.
diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs
index 8e907d777e..2d89145e63 100644
--- a/crates/storage/src/traits/impls/mod.rs
+++ b/crates/storage/src/traits/impls/mod.rs
@@ -118,7 +118,7 @@ pub fn forward_pull_packed<T>(ptr: &mut KeyPtr) -> T
 where
     T: PackedLayout,
 {
-    pull_packed_root::<T>(&ptr.next_for::<T>())
+    pull_packed_root::<T>(ptr.next_for::<T>())
 }
 
 /// Pushes an instance of type `T` in packed fashion to the contract storage.
@@ -135,7 +135,7 @@ pub fn forward_push_packed<T>(entity: &T, ptr: &mut KeyPtr)
 where
     T: PackedLayout,
 {
-    push_packed_root::<T>(entity, &ptr.next_for::<T>())
+    push_packed_root::<T>(entity, ptr.next_for::<T>())
 }
 
 /// Clears an instance of type `T` in packed fashion from the contract storage.
@@ -152,5 +152,5 @@ pub fn forward_clear_packed<T>(entity: &T, ptr: &mut KeyPtr)
 where
     T: PackedLayout,
 {
-    clear_packed_root::<T>(entity, &ptr.next_for::<T>())
+    clear_packed_root::<T>(entity, ptr.next_for::<T>())
 }
diff --git a/examples/contract-transfer/lib.rs b/examples/contract-transfer/lib.rs
index f705e3ca63..097b204ec5 100644
--- a/examples/contract-transfer/lib.rs
+++ b/examples/contract-transfer/lib.rs
@@ -58,11 +58,8 @@ pub mod give_me {
         /// - Panics in case the transfer failed for another reason.
         #[ink(message)]
         pub fn give_me(&mut self, value: Balance) {
-            ink_env::debug_println(&ink_prelude::format!("requested value: {}", value));
-            ink_env::debug_println(&ink_prelude::format!(
-                "contract balance: {}",
-                self.env().balance()
-            ));
+            ink_env::debug_println!("requested value: {}", value);
+            ink_env::debug_println!("contract balance: {}", self.env().balance());
 
             assert!(value <= self.env().balance(), "insufficient funds!");
 
@@ -88,11 +85,10 @@ pub mod give_me {
         /// allowed to receive value as part of the call.
         #[ink(message, payable, selector = "0xCAFEBABE")]
         pub fn was_it_ten(&self) {
-            let msg = ink_prelude::format!(
+            ink_env::debug_println!(
                 "received payment: {}",
                 self.env().transferred_balance()
             );
-            ink_env::debug_println(&msg);
             assert!(
                 self.env().transferred_balance() == 10,
                 "payment was not ten"
diff --git a/examples/delegator/accumulator/lib.rs b/examples/delegator/accumulator/lib.rs
index 01a7d9f076..74ee6efd5e 100644
--- a/examples/delegator/accumulator/lib.rs
+++ b/examples/delegator/accumulator/lib.rs
@@ -19,7 +19,7 @@ use ink_lang as ink;
 
 #[ink::contract]
 pub mod accumulator {
-    /// Holds a simple i32 value that can be incremented and decremented.
+    /// Holds a simple `i32` value that can be incremented and decremented.
     #[ink(storage)]
     pub struct Accumulator {
         value: i32,
diff --git a/examples/delegator/adder/lib.rs b/examples/delegator/adder/lib.rs
index 31e1615462..128372c258 100644
--- a/examples/delegator/adder/lib.rs
+++ b/examples/delegator/adder/lib.rs
@@ -21,21 +21,21 @@ use ink_lang as ink;
 mod adder {
     use accumulator::Accumulator;
 
-    /// Increments the underlying accumulator's value.
+    /// Increments the underlying `accumulator` value.
     #[ink(storage)]
     pub struct Adder {
-        /// The accumulator to store the value.
+        /// The `accumulator` to store the value.
         accumulator: accumulator::Accumulator,
     }
 
     impl Adder {
-        /// Creates a new adder from the given accumulator.
+        /// Creates a new `adder` from the given `accumulator`.
         #[ink(constructor)]
         pub fn new(accumulator: Accumulator) -> Self {
             Self { accumulator }
         }
 
-        /// Increases the accumulator's value by some amount.
+        /// Increases the `accumulator` value by some amount.
         #[ink(message)]
         pub fn inc(&mut self, by: i32) {
             self.accumulator.inc(by)
diff --git a/examples/delegator/lib.rs b/examples/delegator/lib.rs
index af593f54b1..5977932e00 100644
--- a/examples/delegator/lib.rs
+++ b/examples/delegator/lib.rs
@@ -55,23 +55,23 @@ mod delegator {
         Subber,
     }
 
-    /// Delegates calls to an adder or subber contract to mutate
-    /// a value in an accumulator contract.
+    /// Delegates calls to an `adder` or `subber` contract to mutate
+    /// a value in an `accumulator` contract.
     ///
     /// In order to deploy the delegator smart contract we first
-    /// have to manually put the code of the accumulator, adder
-    /// and subber smart contracts, receive their code hashes from
+    /// have to manually put the code of the `accumulator`, `adder`
+    /// and `subber` smart contracts, receive their code hashes from
     /// the signalled events and put their code hash into our
     /// delegator smart contract.
     #[ink(storage)]
     pub struct Delegator {
-        /// Says which of adder or subber is currently in use.
+        /// Says which of `adder` or `subber` is currently in use.
         which: Which,
-        /// The accumulator smart contract.
+        /// The `accumulator` smart contract.
         accumulator: Lazy<Accumulator>,
-        /// The adder smart contract.
+        /// The `adder` smart contract.
         adder: Lazy<Adder>,
-        /// The subber smart contract.
+        /// The `subber` smart contract.
         subber: Lazy<Subber>,
     }
 
@@ -113,7 +113,7 @@ mod delegator {
             }
         }
 
-        /// Returns the accumulator's value.
+        /// Returns the `accumulator` value.
         #[ink(message)]
         pub fn get(&self) -> i32 {
             self.accumulator.get()
diff --git a/examples/delegator/subber/lib.rs b/examples/delegator/subber/lib.rs
index 5ad62ae3bf..0043ff726a 100644
--- a/examples/delegator/subber/lib.rs
+++ b/examples/delegator/subber/lib.rs
@@ -21,21 +21,21 @@ use ink_lang as ink;
 mod subber {
     use accumulator::Accumulator;
 
-    /// Decreases the underlying accumulator's value.
+    /// Decreases the underlying `accumulator` value.
     #[ink(storage)]
     pub struct Subber {
-        /// The accumulator to store the value.
+        /// The `accumulator` to store the value.
         accumulator: accumulator::Accumulator,
     }
 
     impl Subber {
-        /// Creates a new subber from the given accumulator.
+        /// Creates a new `subber` from the given `accumulator`.
         #[ink(constructor)]
         pub fn new(accumulator: Accumulator) -> Self {
             Self { accumulator }
         }
 
-        /// Decreases the accumulator's value by some amount.
+        /// Decreases the `accumulator` value by some amount.
         #[ink(message)]
         pub fn dec(&mut self, by: i32) {
             self.accumulator.inc(-by)
diff --git a/examples/dns/lib.rs b/examples/dns/lib.rs
index 69b3203f10..8409f2cf08 100644
--- a/examples/dns/lib.rs
+++ b/examples/dns/lib.rs
@@ -46,7 +46,7 @@ mod dns {
         new_address: AccountId,
     }
 
-    /// Emitted whenver a name is being transferred.
+    /// Emitted whenever a name is being transferred.
     #[ink(event)]
     pub struct Transfer {
         #[ink(topic)]
@@ -70,8 +70,8 @@ mod dns {
     ///
     /// The main function of this contract is domain name resolution which
     /// refers to the retrieval of numeric values corresponding to readable
-    /// and easily memorable names such as “polka.dot” which can be used
-    /// to facilitate transfers, voting and dapp-related operations instead
+    /// and easily memorable names such as "polka.dot" which can be used
+    /// to facilitate transfers, voting and DApp-related operations instead
     /// of resorting to long IP addresses that are hard to remember.
     #[ink(storage)]
     #[derive(Default)]
@@ -232,7 +232,7 @@ mod dns {
                 Err(Error::CallerIsNotOwner)
             );
 
-            // caller is owner, set_address will be successful
+            // Caller is owner, set_address will be successful
             set_next_caller(accounts.alice);
             assert_eq!(contract.set_address(name, accounts.bob), Ok(()));
             assert_eq!(contract.get_address(name), accounts.bob);
diff --git a/examples/erc721/lib.rs b/examples/erc721/lib.rs
index d62ecdd64d..4144e6fdb9 100644
--- a/examples/erc721/lib.rs
+++ b/examples/erc721/lib.rs
@@ -12,9 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//! # ERC721
+//! # ERC-721
 //!
-//! This is an ERC721 Token implementation.
+//! This is an ERC-721 Token implementation.
 //!
 //! ## Warning
 //!
@@ -27,9 +27,9 @@
 //!
 //! ## Error Handling
 //!
-//! Any function that modifies the state returns a Result type and does not changes the state
-//! if the Error occurs.
-//! The errors are defined as an Enum type. Any other error or invariant violation
+//! Any function that modifies the state returns a `Result` type and does not changes the state
+//! if the `Error` occurs.
+//! The errors are defined as an `enum` type. Any other error or invariant violation
 //! triggers a panic and therefore rolls back the transaction.
 //!
 //! ## Token Management
@@ -54,7 +54,7 @@
 //! - An authorized operator of the current owner of a token
 //!
 //! The token owner can transfer a token by calling the `transfer` or `transfer_from` functions.
-//! An approved address can make a token transfer by calling the `transfer_from` funtion.
+//! An approved address can make a token transfer by calling the `transfer_from` function.
 //! Operators can transfer tokens on another account's behalf or can approve a token transfer
 //! for a different account.
 //!
@@ -141,7 +141,7 @@ mod erc721 {
     }
 
     impl Erc721 {
-        /// Creates a new ERC721 token contract.
+        /// Creates a new ERC-721 token contract.
         #[ink(constructor)]
         pub fn new() -> Self {
             Self {
@@ -259,7 +259,7 @@ mod erc721 {
             Ok(())
         }
 
-        /// Transfers token `id` `from` the sender to the `to` AccountId.
+        /// Transfers token `id` `from` the sender to the `to` `AccountId`.
         fn transfer_token_from(
             &mut self,
             from: &AccountId,
@@ -354,7 +354,7 @@ mod erc721 {
             }
         }
 
-        /// Approve the passed AccountId to transfer the specified token on behalf of the message's sender.
+        /// Approve the passed `AccountId` to transfer the specified token on behalf of the message's sender.
         fn approve_for(&mut self, to: &AccountId, id: TokenId) -> Result<(), Error> {
             let caller = self.env().caller();
             let owner = self.owner_of(id);
@@ -402,7 +402,7 @@ mod erc721 {
                 .unwrap_or(&false)
         }
 
-        /// Returns true if the AccountId `from` is the owner of token `id`
+        /// Returns true if the `AccountId` `from` is the owner of token `id`
         /// or it has been approved on behalf of the token `id` owner.
         fn approved_or_owner(&self, from: Option<AccountId>, id: TokenId) -> bool {
             let owner = self.owner_of(id);
@@ -430,7 +430,7 @@ mod erc721 {
         Ok(())
     }
 
-    /// Increase token counter from the `of` AccountId.
+    /// Increase token counter from the `of` `AccountId`.
     fn increase_counter_of(entry: Entry<AccountId, u32>) {
         entry.and_modify(|v| *v += 1).or_insert(1);
     }
diff --git a/examples/flipper/lib.rs b/examples/flipper/lib.rs
index 7e380414b3..7187adcb32 100644
--- a/examples/flipper/lib.rs
+++ b/examples/flipper/lib.rs
@@ -36,13 +36,13 @@ pub mod flipper {
             Self::new(Default::default())
         }
 
-        /// Flips the current value of the Flipper's bool.
+        /// Flips the current value of the Flipper's boolean.
         #[ink(message)]
         pub fn flip(&mut self) {
             self.value = !self.value;
         }
 
-        /// Returns the current value of the Flipper's bool.
+        /// Returns the current value of the Flipper's boolean.
         #[ink(message)]
         pub fn get(&self) -> bool {
             self.value
diff --git a/examples/multisig_plain/lib.rs b/examples/multisig_plain/lib.rs
index 7021d30438..590f2685ef 100755
--- a/examples/multisig_plain/lib.rs
+++ b/examples/multisig_plain/lib.rs
@@ -34,7 +34,7 @@
 //!
 //! ## Error Handling
 //!
-//! With the exeception of `execute_transaction` no error conditions are signalled
+//! With the exception of `execute_transaction` no error conditions are signalled
 //! through return types. Any error or invariant violation triggers a panic and therefore
 //! rolls back the transaction.
 //!
@@ -42,12 +42,12 @@
 //!
 //! The interface is modelled after the popular gnosis multisig wallet. However, there
 //! are subtle variations from the interface. For example the `confirm_transaction`
-//! will never trigger the execution of a `Transaction` even if the treshold is reached.
+//! will never trigger the execution of a `Transaction` even if the threshold is reached.
 //! A call of `execute_transaction` is always required. This can be called by anyone.
 //!
 //! All the messages that are declared as only callable by the wallet must go through
 //! the usual submit, confirm, execute cycle as any other transaction that should be
-//! called by the wallet. For example to add an owner you would submit a transaction
+//! called by the wallet. For example, to add an owner you would submit a transaction
 //! that calls the wallets own `add_owner` message through `submit_transaction`.
 //!
 //! ### Owner Management
@@ -107,7 +107,7 @@ mod multisig_plain {
 
     /// A wrapper that allows us to encode a blob of bytes.
     ///
-    /// We use this to pass the set of untyped (bytes) parameters to the `CallBuilder`.
+    /// We use this to pass the set of not typed (bytes) parameters to the `CallBuilder`.
     struct CallInput<'a>(&'a [u8]);
 
     impl<'a> scale::Encode for CallInput<'a> {
@@ -143,7 +143,7 @@ mod multisig_plain {
         )
     )]
     pub struct Transaction {
-        /// The AccountId of the contract that is called in this transaction.
+        /// The `AccountId` of the contract that is called in this transaction.
         pub callee: AccountId,
         /// The selector bytes that identifies the function of the callee that should be called.
         pub selector: [u8; 4],
@@ -166,7 +166,7 @@ mod multisig_plain {
     #[ink(storage)]
     pub struct MultisigPlain {
         /// Every entry in this map represents the confirmation of an owner for a
-        /// transaction. This is effecively a set rather than a map.
+        /// transaction. This is effectively a set rather than a map.
         confirmations: StorageHashMap<(TransactionId, AccountId), ()>,
         /// The amount of confirmations for every transaction. This is a redundant
         /// information and is kept in order to prevent iterating through the
@@ -204,7 +204,7 @@ mod multisig_plain {
         /// The transaction that was revoked.
         #[ink(topic)]
         transaction: TransactionId,
-        /// The owner that sent the revokation.
+        /// The owner that sent the revocation.
         #[ink(topic)]
         from: AccountId,
     }
@@ -298,7 +298,7 @@ mod multisig_plain {
         /// # Examples
         ///
         /// Since this message must be send by the wallet itself it has to be build as a
-        /// `Transaction` and dispatched through `submit_transaction` + `invoke_transaction`:
+        /// `Transaction` and dispatched through `submit_transaction` and `invoke_transaction`:
         /// ```no_run
         /// use ink_env::{DefaultEnvironment as Env, AccountId, call::{CallParams, Selector}, test::CallData};
         /// use multisig_plain::{Transaction, ConfirmationStatus};
@@ -403,7 +403,7 @@ mod multisig_plain {
             self.env().emit_event(RequirementChange { new_requirement });
         }
 
-        /// Add a new transaction candiate to the contract.
+        /// Add a new transaction candidate to the contract.
         ///
         /// This also confirms the transaction for the caller. This can be called by any owner.
         #[ink(message)]
diff --git a/examples/rand-extension/lib.rs b/examples/rand-extension/lib.rs
index 9530f197df..9c045880ac 100755
--- a/examples/rand-extension/lib.rs
+++ b/examples/rand-extension/lib.rs
@@ -25,8 +25,8 @@ use ink_lang as ink;
 pub trait FetchRandom {
     type ErrorCode = RandomReadErr;
 
-    /// Note: this gives the operation a corresponding func_id (1101 in this case),
-    /// and the chain-side chain_extension will get the func_id to do further operations.
+    /// Note: this gives the operation a corresponding `func_id` (1101 in this case),
+    /// and the chain-side chain extension will get the `func_id` to do further operations.
     #[ink(extension = 1101, returns_result = false)]
     fn fetch_random() -> [u8; 32];
 }
diff --git a/examples/trait-flipper/lib.rs b/examples/trait-flipper/lib.rs
index 4251aa1bf9..bfa9aef30e 100644
--- a/examples/trait-flipper/lib.rs
+++ b/examples/trait-flipper/lib.rs
@@ -22,11 +22,11 @@ pub trait Flip {
     #[ink(constructor)]
     fn new(init_value: bool) -> Self;
 
-    /// Flips the current value of the Flipper's bool.
+    /// Flips the current value of the Flipper's boolean.
     #[ink(message)]
     fn flip(&mut self);
 
-    /// Returns the current value of the Flipper's bool.
+    /// Returns the current value of the Flipper's boolean.
     #[ink(message)]
     fn get(&self) -> bool;
 }


Test patch:
diff --git a/crates/engine/src/test_api.rs b/crates/engine/src/test_api.rs
index 71d7b3e01c..b3dd43a5b0 100644
--- a/crates/engine/src/test_api.rs
+++ b/crates/engine/src/test_api.rs
@@ -33,41 +33,41 @@ pub struct EmittedEvent {
 }
 
 #[derive(Clone)]
-pub struct RecordedPrintlns {
-    printlns: Vec<String>,
+pub struct RecordedDebugMessages {
+    debug_messages: Vec<String>,
 }
 
-impl RecordedPrintlns {
+impl RecordedDebugMessages {
     // Creates a new `Engine instance.
     pub fn new() -> Self {
         Self {
-            printlns: Vec::new(),
+            debug_messages: Vec::new(),
         }
     }
 
-    // Records a new println.
-    pub fn record(&mut self, println: String) {
-        self.printlns.push(println);
+    // Records a new debug message.
+    pub fn record(&mut self, message: String) {
+        self.debug_messages.push(message);
     }
 
-    // Clears all recorded printlns.
+    // Clears all recorded debug messages.
     pub fn clear(&mut self) {
-        self.printlns.clear();
+        self.debug_messages.clear();
     }
 }
 
-impl Default for RecordedPrintlns {
+impl Default for RecordedDebugMessages {
     fn default() -> Self {
         Self::new()
     }
 }
 
-impl IntoIterator for RecordedPrintlns {
+impl IntoIterator for RecordedDebugMessages {
     type Item = String;
     type IntoIter = std::vec::IntoIter<Self::Item>;
 
     fn into_iter(self) -> Self::IntoIter {
-        self.printlns.into_iter()
+        self.debug_messages.into_iter()
     }
 }
 
@@ -76,7 +76,7 @@ pub struct DebugInfo {
     /// Emitted events recorder.
     emitted_events: Vec<EmittedEvent>,
     /// Emitted print messages recorder.
-    emitted_printlns: RecordedPrintlns,
+    emitted_debug_messages: RecordedDebugMessages,
     /// The total number of reads to the storage.
     count_reads: HashMap<AccountId, usize>,
     /// The total number of writes to the storage.
@@ -96,7 +96,7 @@ impl DebugInfo {
     pub fn new() -> Self {
         Self {
             emitted_events: Vec::new(),
-            emitted_printlns: RecordedPrintlns::new(),
+            emitted_debug_messages: RecordedDebugMessages::new(),
             count_reads: HashMap::new(),
             count_writes: HashMap::new(),
             cells_per_account: HashMap::new(),
@@ -108,7 +108,7 @@ impl DebugInfo {
         self.count_reads.clear();
         self.count_writes.clear();
         self.emitted_events.clear();
-        self.emitted_printlns.clear();
+        self.emitted_debug_messages.clear();
         self.cells_per_account.clear();
     }
 
@@ -159,9 +159,9 @@ impl DebugInfo {
             .unwrap_or(None)
     }
 
-    /// Records a println.
-    pub fn record_println(&mut self, println: String) {
-        self.emitted_printlns.record(println);
+    /// Records a debug message.
+    pub fn record_debug_message(&mut self, message: String) {
+        self.emitted_debug_messages.record(message);
     }
 
     /// Records an event.
@@ -215,9 +215,9 @@ impl Engine {
         self.exec_context.callee()
     }
 
-    /// Returns the contents of the past performed environmental `println` in order.
-    pub fn get_recorded_printlns(&self) -> RecordedPrintlns {
-        self.debug_info.emitted_printlns.clone()
+    /// Returns the contents of the past performed environmental `debug_message` in order.
+    pub fn get_emitted_debug_messages(&self) -> RecordedDebugMessages {
+        self.debug_info.emitted_debug_messages.clone()
     }
 
     /// Returns the recorded emitted events in order.
diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs
index ed83e45557..798f5287de 100644
--- a/crates/engine/src/tests.rs
+++ b/crates/engine/src/tests.rs
@@ -115,10 +115,10 @@ fn transfer() {
 }
 
 #[test]
-fn printlns() {
+fn debug_messages() {
     let mut engine = Engine::new();
-    engine.println("foobar");
-    let mut recorded = engine.get_recorded_printlns().into_iter();
+    engine.debug_message("foobar");
+    let mut recorded = engine.get_emitted_debug_messages().into_iter();
     assert_eq!(recorded.next(), Some("foobar".into()));
     assert_eq!(recorded.next(), None);
 }
diff --git a/crates/env/src/engine/experimental_off_chain/test_api.rs b/crates/env/src/engine/experimental_off_chain/test_api.rs
index 8608270cbe..e44c9a5d23 100644
--- a/crates/env/src/engine/experimental_off_chain/test_api.rs
+++ b/crates/env/src/engine/experimental_off_chain/test_api.rs
@@ -23,7 +23,7 @@ use crate::{
     Result,
 };
 use core::fmt::Debug;
-use ink_engine::test_api::RecordedPrintlns;
+use ink_engine::test_api::RecordedDebugMessages;
 use std::panic::UnwindSafe;
 
 /// Record for an emitted event.
@@ -129,10 +129,10 @@ where
     unimplemented!("off-chain environment does not yet support `set_block_entropy`");
 }
 
-/// Returns the contents of the past performed environmental `println` in order.
-pub fn recorded_printlns() -> RecordedPrintlns {
+/// Returns the contents of the past performed environmental debug messages in order.
+pub fn recorded_debug_messages() -> RecordedDebugMessages {
     <EnvInstance as OnInstance>::on_instance(|instance| {
-        instance.engine.get_recorded_printlns()
+        instance.engine.get_emitted_debug_messages()
     })
 }
 
diff --git a/crates/env/src/engine/off_chain/test_api.rs b/crates/env/src/engine/off_chain/test_api.rs
index 855be01a29..41c979b9d5 100644
--- a/crates/env/src/engine/off_chain/test_api.rs
+++ b/crates/env/src/engine/off_chain/test_api.rs
@@ -215,8 +215,8 @@ where
     Ok(())
 }
 
-/// Returns the contents of the past performed environmental `println` in order.
-pub fn recorded_printlns() -> impl Iterator<Item = String> {
+/// Returns the contents of the past performed environmental debug messages in order.
+pub fn recorded_debug_messages() -> impl Iterator<Item = String> {
     <EnvInstance as OnInstance>::on_instance(|instance| {
         // We return a clone of the recorded strings instead of
         // references to them since this would require the whole `on_instance`
@@ -224,8 +224,8 @@ pub fn recorded_printlns() -> impl Iterator<Item = String> {
         // ultimately allow leaking those `'static` references to the outside
         // and potentially lead to terrible bugs such as iterator invalidation.
         instance
-            .console
-            .past_prints()
+            .debug_buf
+            .past_debug_messages()
             .map(ToOwned::to_owned)
             .collect::<Vec<_>>()
             .into_iter()
diff --git a/crates/lang/macro/tests/ui/pass/05-erc721-contract.rs b/crates/lang/macro/tests/ui/pass/05-erc721-contract.rs
index 0163d71c02..e43a22670a 100644
--- a/crates/lang/macro/tests/ui/pass/05-erc721-contract.rs
+++ b/crates/lang/macro/tests/ui/pass/05-erc721-contract.rs
@@ -75,7 +75,7 @@ mod erc721 {
     }
 
     impl Erc721 {
-        /// Creates a new ERC721 token contract.
+        /// Creates a new ERC-721 token contract.
         #[ink(constructor)]
         pub fn new() -> Self {
             Self {
@@ -193,7 +193,7 @@ mod erc721 {
             Ok(())
         }
 
-        /// Transfers token `id` `from` the sender to the `to` AccountId.
+        /// Transfers token `id` `from` the sender to the `to` `AccountId`.
         fn transfer_token_from(
             &mut self,
             from: &AccountId,
@@ -336,7 +336,7 @@ mod erc721 {
                 .unwrap_or(&false)
         }
 
-        /// Returns true if the AccountId `from` is the owner of token `id`
+        /// Returns true if the `AccountId` `from` is the owner of token `id`
         /// or it has been approved on behalf of the token `id` owner.
         fn approved_or_owner(&self, from: Option<AccountId>, id: TokenId) -> bool {
             let owner = self.owner_of(id);
diff --git a/crates/storage/src/collections/stash/tests.rs b/crates/storage/src/collections/stash/tests.rs
index 4b0dc1788f..fb5fc4ff9f 100644
--- a/crates/storage/src/collections/stash/tests.rs
+++ b/crates/storage/src/collections/stash/tests.rs
@@ -24,7 +24,7 @@ use ink_primitives::Key;
 
 #[test]
 fn regression_stash_unreachable_minified() {
-    // This regression has been discovered in the ERC721 example implementation
+    // This regression has been discovered in the ERC-721 example implementation
     // `approved_for_all_works` unit test. The fix was to adjust
     // `Stash::remove_vacant_entry` to update `header.last_vacant` if the
     // removed index was the last remaining vacant index in the stash.