Skip to content

Commit

Permalink
dirty fix for unaccesible Pending storage
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Mar 18, 2024
1 parent acd8e2b commit 975060d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pallets/ethereum-transaction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,23 @@ pub mod pallet {
// NOTE: The Ethereuem side of things never returns a DispatchError
// if the execution failed. But we can check that manually by
// querying the `Pending` storage of the pallet-ethereum.
let pending = pallet_ethereum::Pending::<T>::get();
let (_, _, receipt) = pending.last().ok_or(DispatchError::Other(
"Ethereum not adding pending storage. Unexpected.",
))?;
let receipt = frame_support::storage::transactional::with_transaction(|| {
// We do not want to apply an on_finalize, we just want to emulate the value
// after it to fet the resulting receipt.
pallet_ethereum::Pallet::<T>::on_finalize(frame_system::Pallet::<T>::block_number());

let receipt = match pallet_ethereum::CurrentReceipts::<T>::get() {
Some(list) => list.last().cloned().ok_or(DispatchError::Other(
"Ethereum not adding pending storage. Unexpected.",
)),
None => Err(DispatchError::Other("Should have some receipts")),
};

// only check if there is no error in applying it
sp_runtime::TransactionOutcome::Rollback(receipt)
})?;

if Pallet::<T>::valid_code(receipt) {
if Pallet::<T>::valid_code(&receipt) {
Ok(info)
} else {
Err(Error::<T>::EvmExecutionFailed.into())
Expand Down

0 comments on commit 975060d

Please sign in to comment.