Skip to content
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

Backport 0.25 changes -> 0.24.1 #91

Open
wants to merge 1 commit into
base: moonbeam-polkadot-v0.9.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/rpc-core/src/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ pub struct Receipt {
pub status_code: Option<U64>,
/// Effective gas price. Pre-eip1559 this is just the gasprice. Post-eip1559 this is base fee + priority fee.
pub effective_gas_price: U256,
/// EIP-2718 type
#[serde(rename = "type")]
pub transaction_type: U256,
}
9 changes: 3 additions & 6 deletions client/rpc/src/eth/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,20 @@ impl Formatter for Geth {
// https://github.com/ethereum/go-ethereum/blob/794c6133efa2c7e8376d9d141c900ea541790bce/core/error.go
match err.into_pool_error() {
Ok(PError::AlreadyImported(_)) => "already known".to_string(),
// In Frontier the only case there is a `TemporarilyBanned` is because
// the same transaction was received before and returned
// `InvalidTransaction::Stale`. Thus we return the same error.
Ok(PError::TemporarilyBanned) => "nonce too low".into(),
Ok(PError::TemporarilyBanned) => "already known".into(),
Ok(PError::TooLowPriority { .. }) => "replacement transaction underpriced".into(),
Ok(PError::InvalidTransaction(inner)) => match inner {
InvalidTransaction::Stale => "nonce too low".into(),
InvalidTransaction::Payment => "insufficient funds for gas * price + value".into(),
InvalidTransaction::ExhaustsResources => "gas limit reached".into(),
InvalidTransaction::ExhaustsResources => "exceeds block gas limit".into(),
InvalidTransaction::Custom(inner) => match inner.into() {
VError::UnknownError => "unknown error".into(),
VError::InvalidChainId => "invalid chain id".into(),
VError::InvalidSignature => "invalid sender".into(),
VError::GasLimitTooLow => "intrinsic gas too low".into(),
VError::GasLimitTooHigh => "exceeds block gas limit".into(),
VError::InsufficientFundsForTransfer => {
"insufficient funds for transfer".into()
"insufficient funds for gas * price + value".into()
}
VError::MaxFeePerGasTooLow => {
"max priority fee per gas higher than max fee per gas".into()
Expand Down
17 changes: 11 additions & 6 deletions client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ where
if !is_eip1559 {
// Pre-london frontier update stored receipts require cumulative gas calculation.
match receipt {
ethereum::ReceiptV3::Legacy(d) => {
ethereum::ReceiptV3::Legacy(ref d) => {
let index = core::cmp::min(receipts.len(), index + 1);
let cumulative_gas: u32 = receipts[..index]
.iter()
Expand All @@ -349,7 +349,7 @@ where
})
.sum::<Result<u32>>()?;
(
d.logs,
d.logs.clone(),
d.logs_bloom,
d.status_code,
U256::from(cumulative_gas),
Expand All @@ -365,9 +365,9 @@ where
}
} else {
match receipt {
ethereum::ReceiptV3::Legacy(d)
| ethereum::ReceiptV3::EIP2930(d)
| ethereum::ReceiptV3::EIP1559(d) => {
ethereum::ReceiptV3::Legacy(ref d)
| ethereum::ReceiptV3::EIP2930(ref d)
| ethereum::ReceiptV3::EIP1559(ref d) => {
let cumulative_gas = d.used_gas;
let gas_used = if index > 0 {
let previous_receipt = receipts[index - 1].clone();
Expand All @@ -381,7 +381,7 @@ where
cumulative_gas
};
(
d.logs,
d.logs.clone(),
d.logs_bloom,
d.status_code,
cumulative_gas,
Expand Down Expand Up @@ -454,6 +454,11 @@ where
logs_bloom,
state_root: None,
effective_gas_price,
transaction_type: match receipt {
ethereum::ReceiptV3::Legacy(_) => U256::from(0),
ethereum::ReceiptV3::EIP2930(_) => U256::from(1),
ethereum::ReceiptV3::EIP1559(_) => U256::from(2),
}
}));
}
_ => Ok(None),
Expand Down