diff --git a/bin/node/runtime/pangolin/src/lib.rs b/bin/node/runtime/pangolin/src/lib.rs index 1cf3fe7280..30f0a2907a 100644 --- a/bin/node/runtime/pangolin/src/lib.rs +++ b/bin/node/runtime/pangolin/src/lib.rs @@ -660,7 +660,7 @@ impl_runtime_apis! { } fn author() -> H160 { - >::find_author() + >::find_author() } fn storage_at(address: H160, index: U256) -> H256 { diff --git a/frame/bridge/ethereum/issuing/src/lib.rs b/frame/bridge/ethereum/issuing/src/lib.rs index 0a2efaf909..d5caf9f36c 100644 --- a/frame/bridge/ethereum/issuing/src/lib.rs +++ b/frame/bridge/ethereum/issuing/src/lib.rs @@ -279,7 +279,7 @@ impl Module { let factory_address = MappingFactoryAddress::get(); let bytes = Abi::encode_mapping_token(backing, source) .map_err(|_| Error::::InvalidIssuingAccount)?; - let mapped_address = dvm_ethereum::Module::::do_call(factory_address, bytes) + let mapped_address = dvm_ethereum::Pallet::::do_call(factory_address, bytes) .map_err(|e| -> &'static str { e.into() })?; if mapped_address.len() != 32 { return Err(Error::::InvalidAddressLen.into()); @@ -370,7 +370,7 @@ impl Module { pub fn transact_mapping_factory(input: Vec) -> DispatchResult { let contract = MappingFactoryAddress::get(); - let result = dvm_ethereum::Module::::internal_transact(contract, input).map_err( + let result = dvm_ethereum::Pallet::::internal_transact(contract, input).map_err( |e| -> &'static str { log::debug!("call mapping factory contract error {:?}", &e); e.into() diff --git a/frame/dvm/rpc/runtime-api/src/lib.rs b/frame/dvm/rpc/runtime-api/src/lib.rs index b74f56fc58..d475d122ff 100644 --- a/frame/dvm/rpc/runtime-api/src/lib.rs +++ b/frame/dvm/rpc/runtime-api/src/lib.rs @@ -1,19 +1,20 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Substrate is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - +// along with Darwinia. If not, see . #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; diff --git a/frame/dvm/rpc/src/eth.rs b/frame/dvm/rpc/src/eth.rs index f85a438991..7e2bc18aa1 100644 --- a/frame/dvm/rpc/src/eth.rs +++ b/frame/dvm/rpc/src/eth.rs @@ -1,18 +1,20 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Open Ethereum is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Open Ethereum. If not, see . +// along with Darwinia. If not, see . //! Eth rpc interface. diff --git a/frame/dvm/rpc/src/eth_pubsub.rs b/frame/dvm/rpc/src/eth_pubsub.rs index de0f8a614c..74ac8e3644 100644 --- a/frame/dvm/rpc/src/eth_pubsub.rs +++ b/frame/dvm/rpc/src/eth_pubsub.rs @@ -1,19 +1,20 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Open Ethereum is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Open Ethereum. If not, see . - +// along with Darwinia. If not, see . //! Eth PUB-SUB rpc interface. use jsonrpc_core::Result; diff --git a/frame/dvm/rpc/src/lib.rs b/frame/dvm/rpc/src/lib.rs index 78bb772521..025bbb9280 100644 --- a/frame/dvm/rpc/src/lib.rs +++ b/frame/dvm/rpc/src/lib.rs @@ -1,3 +1,21 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + mod eth; mod eth_pubsub; mod net; diff --git a/frame/dvm/rpc/src/net.rs b/frame/dvm/rpc/src/net.rs index 8f5638f7cd..06553ea56f 100644 --- a/frame/dvm/rpc/src/net.rs +++ b/frame/dvm/rpc/src/net.rs @@ -1,18 +1,20 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Open Ethereum is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Open Ethereum. If not, see . +// along with Darwinia. If not, see . //! Net rpc interface. use dp_rpc::PeerCount; diff --git a/frame/dvm/rpc/src/web3.rs b/frame/dvm/rpc/src/web3.rs index 522aea4e8f..ee26b5a6ab 100644 --- a/frame/dvm/rpc/src/web3.rs +++ b/frame/dvm/rpc/src/web3.rs @@ -1,18 +1,20 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Open Ethereum is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Open Ethereum. If not, see . +// along with Darwinia. If not, see . //! Web3 rpc interface. use ethereum_types::H256; diff --git a/frame/dvm/src/account_basic.rs b/frame/dvm/src/account_basic.rs index 4131e3ede8..ccd7457544 100644 --- a/frame/dvm/src/account_basic.rs +++ b/frame/dvm/src/account_basic.rs @@ -1,9 +1,26 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + use crate::{Config, KtonBalance, RemainingKtonBalance, RemainingRingBalance, RingBalance}; use darwinia_evm::{Account as EVMAccount, AccountBasic, AddressMapping}; use darwinia_support::evm::POW_9; use evm::ExitError; -use frame_support::ensure; -use frame_support::{storage::StorageMap, traits::Currency}; +use frame_support::{ensure, traits::Currency}; use sp_core::{H160, U256}; use sp_runtime::{ traits::{Saturating, UniqueSaturatedInto}, diff --git a/frame/dvm/src/lib.rs b/frame/dvm/src/lib.rs index b90c9bb5a9..a2c9362076 100644 --- a/frame/dvm/src/lib.rs +++ b/frame/dvm/src/lib.rs @@ -1,18 +1,20 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Substrate is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . +// along with Darwinia. If not, see . //! # Ethereum pallet //! @@ -44,7 +46,6 @@ use sha3::{Digest, Keccak256}; #[cfg(feature = "std")] use frame_support::storage::unhashed; use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResultWithPostInfo, ensure, traits::FindAuthor, @@ -76,58 +77,85 @@ pub type KtonCurrency = ::KtonCurrency; pub type RingBalance = as Currency>>::Balance; pub type KtonBalance = as Currency>>::Balance; -/// Config for Ethereum pallet. -pub trait Config: - frame_system::Config + pallet_timestamp::Config + darwinia_evm::Config -{ - /// The overarching event type. - type Event: From + Into<::Event>; - /// Find author for Ethereum. - type FindAuthor: FindAuthor; - /// How Ethereum state root is calculated. - type StateRoot: Get; - // RING Balance module - type RingCurrency: Currency; - // KTON Balance module - type KtonCurrency: Currency; -} +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: + frame_system::Config + pallet_timestamp::Config + darwinia_evm::Config + { + /// The overarching event type. + type Event: From + IsType<::Event>; + /// Find author for Ethereum. + type FindAuthor: FindAuthor; + /// How Ethereum state root is calculated. + type StateRoot: Get; + // RING Balance module + type RingCurrency: Currency; + // KTON Balance module + type KtonCurrency: Currency; + } + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(PhantomData); + + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_finalize(_block_number: T::BlockNumber) { + >::store_block( + dp_consensus::find_pre_log(&>::digest()).is_err(), + U256::from(UniqueSaturatedInto::::unique_saturated_into( + frame_system::Pallet::::block_number(), + )), + ); + } + + fn on_initialize(_block_number: T::BlockNumber) -> Weight { + Pending::::kill(); + if let Ok(log) = dp_consensus::find_pre_log(&>::digest()) { + let PreLog::Block(block) = log; -decl_storage! { - trait Store for Module as Ethereum { - /// Current building block's transactions and receipts. - Pending: Vec<(ethereum::Transaction, TransactionStatus, ethereum::Receipt)>; - /// The current Ethereum block. - CurrentBlock: Option; - /// The current Ethereum receipts. - CurrentReceipts: Option>; - /// The current transaction statuses. - CurrentTransactionStatuses: Option>; - /// Remaining ring balance for account - RemainingRingBalance get(fn get_ring_remaining_balances): map hasher(blake2_128_concat) T::AccountId => RingBalance; - /// Remaining kton balance for account - RemainingKtonBalance get(fn get_kton_remaining_balances): map hasher(blake2_128_concat) T::AccountId => KtonBalance; + for transaction in block.transactions { + Self::do_transact(transaction).expect( + "pre-block transaction verification failed; the block cannot be built", + ); + } + } + 0 + } } - add_extra_genesis { - build(|_config: &GenesisConfig| { - >::store_block(false, U256::zero()); - // Initialize the storage schema at the well known key. - unhashed::put::(&PALLET_ETHEREUM_SCHEMA, &EthereumStorageSchema::V1); - }); + #[pallet::call] + impl Pallet { + /// Transact an Ethereum transaction. + #[pallet::weight(::GasWeightMapping::gas_to_weight(transaction.gas_limit.unique_saturated_into()))] + pub fn transact( + origin: OriginFor, + transaction: ethereum::Transaction, + ) -> DispatchResultWithPostInfo { + ensure_none(origin)?; + + Self::do_transact(transaction) + } } -} -decl_event!( + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] /// Ethereum pallet events. pub enum Event { /// An ethereum transaction was successfully executed. [from, to/contract_address, transaction_hash, exit_reason] Executed(H160, H160, H256, ExitReason), } -); -decl_error! { + #[pallet::error] /// Ethereum pallet errors. - pub enum Error for Module { + pub enum Error { /// Signature is invalid. InvalidSignature, /// Pre-log is present, therefore transact is not allowed. @@ -135,114 +163,133 @@ decl_error! { /// Call failed InvalidCall, } -} - -decl_module! { - /// Ethereum pallet module. - pub struct Module for enum Call where origin: T::Origin { - /// Deposit one of this pallet's events by using the default implementation. - fn deposit_event() = default; - - /// Transact an Ethereum transaction. - #[weight = ::GasWeightMapping::gas_to_weight(transaction.gas_limit.unique_saturated_into())] - fn transact(origin, transaction: ethereum::Transaction) -> DispatchResultWithPostInfo { - ensure_none(origin)?; - Self::do_transact(transaction) - } - - fn on_finalize(_block_number: T::BlockNumber) { - >::store_block( - dp_consensus::find_pre_log(&>::digest()).is_err(), U256::from( - UniqueSaturatedInto::::unique_saturated_into( - frame_system::Pallet::::block_number() - ) - ), - ); - } - - fn on_initialize(_block_number: T::BlockNumber) -> Weight { - Pending::kill(); - if let Ok(log) = dp_consensus::find_pre_log(&>::digest()) { - let PreLog::Block(block) = log; - - for transaction in block.transactions { - Self::do_transact(transaction).expect("pre-block transaction verification failed; the block cannot be built"); + #[pallet::validate_unsigned] + impl frame_support::unsigned::ValidateUnsigned for Pallet { + type Call = Call; + + fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { + if let Call::transact(transaction) = call { + if let Some(chain_id) = transaction.signature.chain_id() { + if chain_id != T::ChainId::get() { + return InvalidTransaction::Custom( + TransactionValidationError::InvalidChainId as u8, + ) + .into(); + } } - } - 0 - } - } -} -impl frame_support::unsigned::ValidateUnsigned for Module { - type Call = Call; + let origin = Self::recover_signer(&transaction).ok_or_else(|| { + InvalidTransaction::Custom(TransactionValidationError::InvalidSignature as u8) + })?; - fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { - if let Call::transact(transaction) = call { - if let Some(chain_id) = transaction.signature.chain_id() { - if chain_id != T::ChainId::get() { + if transaction.gas_limit >= T::BlockGasLimit::get() { return InvalidTransaction::Custom( - TransactionValidationError::InvalidChainId as u8, + TransactionValidationError::InvalidGasLimit as u8, ) .into(); } - } - let origin = Self::recover_signer(&transaction).ok_or_else(|| { - InvalidTransaction::Custom(TransactionValidationError::InvalidSignature as u8) - })?; + let account_data = + ::RingAccountBasic::account_basic(&origin); - if transaction.gas_limit >= T::BlockGasLimit::get() { - return InvalidTransaction::Custom( - TransactionValidationError::InvalidGasLimit as u8, - ) - .into(); - } + if transaction.nonce < account_data.nonce { + return InvalidTransaction::Stale.into(); + } - let account_data = - ::RingAccountBasic::account_basic(&origin); + let fee = transaction.gas_price.saturating_mul(transaction.gas_limit); + let total_payment = transaction.value.saturating_add(fee); + if account_data.balance < total_payment { + return InvalidTransaction::Payment.into(); + } - if transaction.nonce < account_data.nonce { - return InvalidTransaction::Stale.into(); - } + let min_gas_price = T::FeeCalculator::min_gas_price(); - let fee = transaction.gas_price.saturating_mul(transaction.gas_limit); - let total_payment = transaction.value.saturating_add(fee); - if account_data.balance < total_payment { - return InvalidTransaction::Payment.into(); - } + if transaction.gas_price < min_gas_price { + return InvalidTransaction::Payment.into(); + } - let min_gas_price = T::FeeCalculator::min_gas_price(); + let mut builder = ValidTransactionBuilder::default() + .and_provides((origin, transaction.nonce)) + .priority(if min_gas_price == U256::zero() { + 0 + } else { + let target_gas = + (transaction.gas_limit * transaction.gas_price) / min_gas_price; + T::GasWeightMapping::gas_to_weight(target_gas.unique_saturated_into()) + }); + + if transaction.nonce > account_data.nonce { + if let Some(prev_nonce) = transaction.nonce.checked_sub(1.into()) { + builder = builder.and_requires((origin, prev_nonce)) + } + } - if transaction.gas_price < min_gas_price { - return InvalidTransaction::Payment.into(); + builder.build() + } else { + Err(InvalidTransaction::Call.into()) } + } + } - let mut builder = ValidTransactionBuilder::default() - .and_provides((origin, transaction.nonce)) - .priority(if min_gas_price == U256::zero() { - 0 - } else { - let target_gas = - (transaction.gas_limit * transaction.gas_price) / min_gas_price; - T::GasWeightMapping::gas_to_weight(target_gas.unique_saturated_into()) - }); - - if transaction.nonce > account_data.nonce { - if let Some(prev_nonce) = transaction.nonce.checked_sub(1.into()) { - builder = builder.and_requires((origin, prev_nonce)) - } - } + /// Current building block's transactions and receipts. + #[pallet::storage] + pub type Pending = StorageValue< + _, + Vec<(ethereum::Transaction, TransactionStatus, ethereum::Receipt)>, + ValueQuery, + >; + + /// The current Ethereum block. + #[pallet::storage] + pub type CurrentBlock = StorageValue<_, ethereum::Block>; + + /// The current Ethereum receipts. + #[pallet::storage] + pub type CurrentReceipts = StorageValue<_, Vec>; + + /// The current transaction statuses. + #[pallet::storage] + pub type CurrentTransactionStatuses = StorageValue<_, Vec>; + + /// Remaining ring balance for account + #[pallet::storage] + #[pallet::getter(fn get_ring_remaining_balances)] + pub type RemainingRingBalance = + StorageMap<_, Blake2_128Concat, T::AccountId, RingBalance, ValueQuery>; + + /// Remaining kton balance for account + #[pallet::storage] + #[pallet::getter(fn get_kton_remaining_balances)] + pub(super) type RemainingKtonBalance = + StorageMap<_, Blake2_128Concat, T::AccountId, KtonBalance, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig {} + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self {} + } + } - builder.build() - } else { - Err(InvalidTransaction::Call.into()) + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + let extra_genesis_builder: fn(&Self) = |_config: &GenesisConfig| { + >::store_block(false, U256::zero()); + unhashed::put::( + &PALLET_ETHEREUM_SCHEMA, + &EthereumStorageSchema::V1, + ); + }; + extra_genesis_builder(self); } } } -impl Module { +impl Pallet { fn recover_signer(transaction: ðereum::Transaction) -> Option { let mut sig = [0u8; 65]; let mut msg = [0u8; 32]; @@ -274,7 +321,7 @@ impl Module { let mut statuses = Vec::new(); let mut receipts = Vec::new(); let mut logs_bloom = Bloom::default(); - for (transaction, status, receipt) in Pending::get() { + for (transaction, status, receipt) in Pending::::get() { transactions.push(transaction); statuses.push(status); receipts.push(receipt.clone()); @@ -284,7 +331,7 @@ impl Module { let ommers = Vec::::new(); let partial_header = ethereum::PartialHeader { parent_hash: Self::current_block_hash().unwrap_or_default(), - beneficiary: >::find_author(), + beneficiary: >::find_author(), // TODO: figure out if there's better way to get a sort-of-valid state root. state_root: H256::default(), receipts_root: H256::from_slice( @@ -308,9 +355,9 @@ impl Module { let mut block = ethereum::Block::new(partial_header, transactions.clone(), ommers); block.header.state_root = T::StateRoot::get(); - CurrentBlock::put(block.clone()); - CurrentReceipts::put(receipts.clone()); - CurrentTransactionStatuses::put(statuses.clone()); + CurrentBlock::::put(block.clone()); + CurrentReceipts::::put(receipts.clone()); + CurrentTransactionStatuses::::put(statuses.clone()); if post_log { let digest = DigestItem::::Consensus( @@ -375,7 +422,7 @@ impl Module { fn raw_transact(transaction: DVMTransaction) -> DispatchResultWithPostInfo { let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(&transaction.tx)).as_slice()); - let transaction_index = Pending::get().len() as u32; + let transaction_index = Pending::::get().len() as u32; let (to, contract_address, info) = Self::execute( transaction.source, @@ -437,7 +484,7 @@ impl Module { logs: status.clone().logs, }; - Pending::append((transaction.tx, status, receipt)); + Pending::::append((transaction.tx, status, receipt)); Self::deposit_event(Event::Executed( transaction.source, @@ -461,11 +508,11 @@ impl Module { /// Get the transaction status with given index. pub fn current_transaction_statuses() -> Option> { - CurrentTransactionStatuses::get() + CurrentTransactionStatuses::::get() } /// Get current block. pub fn current_block() -> Option { - CurrentBlock::get() + CurrentBlock::::get() } /// Get current block hash @@ -475,7 +522,7 @@ impl Module { /// Get receipts by number. pub fn current_receipts() -> Option> { - CurrentReceipts::get() + CurrentReceipts::::get() } /// Execute an Ethereum transaction diff --git a/frame/dvm/src/mock.rs b/frame/dvm/src/mock.rs index ce9c1aabac..8a3faa6064 100644 --- a/frame/dvm/src/mock.rs +++ b/frame/dvm/src/mock.rs @@ -1,18 +1,20 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Substrate is free software: you can redistribute it and/or modify +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, +// +// Darwinia is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - +// // You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . +// along with Darwinia. If not, see . //! Test utilities diff --git a/frame/dvm/src/tests.rs b/frame/dvm/src/tests.rs index dcb788e62e..dc0438e1e1 100644 --- a/frame/dvm/src/tests.rs +++ b/frame/dvm/src/tests.rs @@ -1,21 +1,20 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// This file is part of Darwinia. // -// http://www.apache.org/licenses/LICENSE-2.0 +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Consensus extension module tests for BABE consensus. +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . use crate::{ account_basic::{RemainBalanceOp, RingRemainBalance},