Skip to content
Closed
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ environmental = { version = "1.1.4", default-features = false }
equivocation-detector = { path = "bridges/relays/equivocation" }
ethabi = { version = "2.0.0", default-features = false, package = "ethabi-decode" }
ethbloom = { version = "0.14.1", default-features = false }
ethereum = { version = "0.18.2", default-features = false }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? If yes we should use a modern crate: https://docs.rs/alloy-consensus/latest/alloy_consensus/

ethereum-types = { version = "0.15.1", default-features = false }
exit-future = { version = "0.2.0" }
expander = { version = "2.0.0" }
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/revive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ alloy-core = { workspace = true, features = ["sol-types"] }
codec = { features = ["derive", "max-encoded-len"], workspace = true }
derive_more = { workspace = true, features = ["from", "try_into"] }
environmental = { workspace = true }
# ethereum = { workspace = true, features = ["with-scale"] }
ethereum-standards = { workspace = true }
ethereum-types = { workspace = true, features = ["codec", "rlp", "serialize"] }
hex-literal = { workspace = true }
Expand Down Expand Up @@ -48,6 +49,7 @@ pallet-revive-fixtures = { workspace = true, optional = true }
pallet-revive-proc-macro = { workspace = true }
pallet-revive-uapi = { workspace = true, features = ["scale"] }
pallet-transaction-payment = { workspace = true }
pallet-timestamp = { workspace = true, default-features = true }
ripemd = { workspace = true }
sp-api = { workspace = true }
sp-arithmetic = { workspace = true }
Expand All @@ -71,7 +73,6 @@ serde_json = { workspace = true }
pallet-balances = { workspace = true, default-features = true }
pallet-proxy = { workspace = true, default-features = true }
pallet-revive-fixtures = { workspace = true, default-features = true }
pallet-timestamp = { workspace = true, default-features = true }
pallet-utility = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }
Expand Down
8 changes: 6 additions & 2 deletions substrate/frame/revive/rpc/src/receipt_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ impl ReceiptExtractor {
let events = ext.events().await?;

let success = events.has::<ExtrinsicSuccess>().inspect_err(|err| {
log::debug!(target: LOG_TARGET, "Failed to lookup for ExtrinsicSuccess event in block {block_number}: {err:?}")
})?;
log::debug!(
target: LOG_TARGET,
"Failed to lookup for ExtrinsicSuccess event in block {block_number}: {err:?}"
);
})?;

let tx_fees = events
.find_first::<TransactionFeePaid>()?
.ok_or(ClientError::TxFeeNotFound)
Expand Down
52 changes: 39 additions & 13 deletions substrate/frame/revive/src/evm/api/rpc_types_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ fn deserialize_input_or_data<'d, D: Deserializer<'d>>(d: D) -> Result<InputOrDat
}

/// Block object
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Block {
/// Base fee per gas
#[serde(rename = "baseFeePerGas", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -398,7 +400,9 @@ impl Default for SyncingStatus {
}

/// Transaction information
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct TransactionInfo {
/// block hash
#[serde(rename = "blockHash")]
Expand Down Expand Up @@ -480,7 +484,9 @@ pub enum BlockTag {
/// Filter Topics
pub type FilterTopics = Vec<FilterTopic>;

#[derive(Debug, Clone, Serialize, Deserialize, From, TryInto, Eq, PartialEq)]
#[derive(
Debug, Clone, Serialize, Deserialize, From, TryInto, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
#[serde(untagged)]
pub enum HashesOrTransactionInfos {
/// Transaction hashes
Expand Down Expand Up @@ -540,7 +546,9 @@ pub struct SyncingProgress {
}

/// EIP-1559 transaction.
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction1559Unsigned {
/// accessList
/// EIP-2930 access list
Expand Down Expand Up @@ -580,7 +588,9 @@ pub struct Transaction1559Unsigned {
}

/// EIP-2930 transaction.
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction2930Unsigned {
/// accessList
/// EIP-2930 access list
Expand Down Expand Up @@ -609,7 +619,9 @@ pub struct Transaction2930Unsigned {
}

/// EIP-4844 transaction.
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction4844Unsigned {
/// accessList
/// EIP-2930 access list
Expand Down Expand Up @@ -651,7 +663,9 @@ pub struct Transaction4844Unsigned {
}

/// Legacy transaction.
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct TransactionLegacyUnsigned {
/// chainId
/// Chain ID that this transaction is valid on.
Expand All @@ -675,7 +689,9 @@ pub struct TransactionLegacyUnsigned {
pub value: U256,
}

#[derive(Debug, Clone, Serialize, Deserialize, From, TryInto, Eq, PartialEq)]
#[derive(
Debug, Clone, Serialize, Deserialize, From, TryInto, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
#[serde(untagged)]
pub enum TransactionSigned {
Transaction4844Signed(Transaction4844Signed),
Expand All @@ -690,7 +706,9 @@ impl Default for TransactionSigned {
}

/// Validator withdrawal
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Withdrawal {
/// recipient address for withdrawal value
pub address: Address,
Expand Down Expand Up @@ -729,7 +747,9 @@ impl Default for FilterTopic {
}

/// Signed 1559 Transaction
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction1559Signed {
#[serde(flatten)]
pub transaction_1559_unsigned: Transaction1559Unsigned,
Expand All @@ -749,7 +769,9 @@ pub struct Transaction1559Signed {
}

/// Signed 2930 Transaction
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction2930Signed {
#[serde(flatten)]
pub transaction_2930_unsigned: Transaction2930Unsigned,
Expand All @@ -769,7 +791,9 @@ pub struct Transaction2930Signed {
}

/// Signed 4844 Transaction
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct Transaction4844Signed {
#[serde(flatten)]
pub transaction_4844_unsigned: Transaction4844Unsigned,
Expand All @@ -784,7 +808,9 @@ pub struct Transaction4844Signed {
}

/// Signed Legacy Transaction
#[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)]
#[derive(
Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq, TypeInfo, Encode, Decode,
)]
pub struct TransactionLegacySigned {
#[serde(flatten)]
pub transaction_legacy_unsigned: TransactionLegacyUnsigned,
Expand Down
21 changes: 15 additions & 6 deletions substrate/frame/revive/src/evm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ where

fn check(self, lookup: &Lookup) -> Result<Self::Checked, TransactionValidityError> {
if !self.0.is_signed() {
if let Some(crate::Call::eth_transact { payload }) = self.0.function.is_sub_type() {
let checked = E::try_into_checked_extrinsic(payload.to_vec(), self.encoded_size())?;
if let Some(crate::Call::eth_transact { payload, raw_bytes }) =
self.0.function.is_sub_type()
{
let checked = E::try_into_checked_extrinsic(
payload.to_vec(),
raw_bytes.to_vec(),
self.encoded_size(),
)?;

return Ok(checked)
};
}
Expand Down Expand Up @@ -270,11 +277,10 @@ pub trait EthExtra {
///
/// # Parameters
/// - `payload`: The RLP-encoded Ethereum transaction.
/// - `gas_limit`: The gas limit for the extrinsic
/// - `storage_deposit_limit`: The storage deposit limit for the extrinsic,
/// - `encoded_len`: The encoded length of the extrinsic.
/// - `raw_bytes`: The raw bytes of the Ethereum transaction.
fn try_into_checked_extrinsic(
payload: Vec<u8>,
_raw_bytes: Vec<u8>,
encoded_len: usize,
) -> Result<
CheckedExtrinsic<AccountIdOf<Self::Config>, CallOf<Self::Config>, Self::Extension>,
Expand Down Expand Up @@ -563,7 +569,10 @@ mod test {
let payload = account
.sign_transaction(tx.clone().try_into_unsigned().unwrap())
.signed_payload();
let call = RuntimeCall::Contracts(crate::Call::eth_transact { payload });
let call = RuntimeCall::Contracts(crate::Call::eth_transact {
payload,
raw_bytes: vec![],
});

let encoded_len = call.encoded_size();
let uxt: Ex = generic::UncheckedExtrinsic::new_bare(call).into();
Expand Down
Loading
Loading