-
Notifications
You must be signed in to change notification settings - Fork 546
Add catching Ethereum info #1547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // This file is part of Frontier. | ||
| // | ||
| // Copyright (c) 2020-2022 Parity Technologies (UK) Ltd. | ||
| // | ||
| // 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 | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.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. | ||
|
|
||
| use fp_evm::CallOrCreateInfo; | ||
|
|
||
| environmental::environmental!(GLOBAL: Option<CallOrCreateInfo>); | ||
|
|
||
| // Allow to catch informations of an ethereum execution inside the provided closure. | ||
| pub fn catch_exec_info<R, F: FnOnce() -> R>( | ||
| execution_info: &mut Option<CallOrCreateInfo>, | ||
| f: F, | ||
| ) -> R { | ||
| GLOBAL::using(execution_info, f) | ||
| } | ||
|
|
||
| pub(super) fn fill_exec_info(execution_info: &CallOrCreateInfo) { | ||
| GLOBAL::with(|exec_info| exec_info.replace(execution_info.clone())); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,17 +27,20 @@ | |
|
|
||
| extern crate alloc; | ||
|
|
||
| mod catch_exec_info; | ||
| #[cfg(all(feature = "std", test))] | ||
| mod mock; | ||
| #[cfg(all(feature = "std", test))] | ||
| mod tests; | ||
|
|
||
| use alloc::{vec, vec::Vec}; | ||
| pub use catch_exec_info::catch_exec_info; | ||
| use core::marker::PhantomData; | ||
| pub use ethereum::{ | ||
| AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt, | ||
| TransactionAction, TransactionV2 as Transaction, | ||
| }; | ||
|
|
||
| use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; | ||
| use evm::ExitReason; | ||
| use scale_codec::{Decode, Encode, MaxEncodedLen}; | ||
|
|
@@ -597,6 +600,8 @@ impl<T: Config> Pallet<T> { | |
| ) -> Result<(PostDispatchInfo, CallOrCreateInfo), DispatchErrorWithPostInfo> { | ||
| let (to, _, info) = Self::execute(source, &transaction, None)?; | ||
|
|
||
| catch_exec_info::fill_exec_info(&info); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious in which case will this be used.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any idea to this? @pLabarta |
||
|
|
||
| let pending = Pending::<T>::get(); | ||
| let transaction_hash = transaction.hash(); | ||
| let transaction_index = pending.len() as u32; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.