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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
${{ runner.os }}-cargo-

- name: Run sccache
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].9

- name: Install Rust toolchain
run: make setup
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
${{ runner.os }}-cargo-

- name: Run sccache
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].9

- name: Install Rust toolchain
run: make setup
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
${{ runner.os }}-cargo-

- name: Run sccache
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].9

- name: Install Rust toolchain
run: make setup
Expand Down
28 changes: 17 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ sc-transaction-pool = { git = "https://github.com/moonbeam-foundation/polkadot-s
sc-transaction-pool-api = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409" }
sc-utils = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409" }
# Substrate Primitive
sp-trie = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-api = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-block-builder = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-blockchain = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409" }
Expand All @@ -131,6 +130,7 @@ sp-std = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch =
sp-storage = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-timestamp = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-transaction-pool = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-trie = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-version = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
sp-weights = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
# Substrate FRAME
Expand Down Expand Up @@ -158,8 +158,8 @@ substrate-test-runtime-client = { git = "https://github.com/moonbeam-foundation/
substrate-wasm-builder = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409" }

# Cumulus primitives
cumulus-primitives-proof-size-hostfunction = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }
cumulus-primitives-storage-weight-reclaim = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }

# XCM
xcm = { package = "staging-xcm", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-stable2409", default-features = false }

Expand Down
13 changes: 6 additions & 7 deletions client/rpc-core/src/types/block_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::convert::Into;
use std::{fmt, str::FromStr};

use ethereum_types::U256;
Expand Down Expand Up @@ -57,18 +56,18 @@ impl Serialize for BlockCount {

struct BlockCountVisitor;

impl Into<U256> for BlockCount {
fn into(self) -> U256 {
match self {
impl From<BlockCount> for U256 {
fn from(val: BlockCount) -> Self {
match val {
BlockCount::U256(n) => n,
BlockCount::Num(n) => U256::from(n),
}
}
}

impl Into<u64> for BlockCount {
fn into(self) -> u64 {
match self {
impl From<BlockCount> for u64 {
fn from(val: BlockCount) -> Self {
match val {
BlockCount::U256(n) => n.as_u64(),
BlockCount::Num(n) => n,
}
Expand Down
6 changes: 3 additions & 3 deletions client/rpc-core/src/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ where
if vec.len() <= VARIADIC_MULTIPLE_MAX_SIZE {
Ok(VariadicValue::Multiple(vec))
} else {
Err(D::Error::custom(format!(
"Invalid variadic value type: too big array"
)))
Err(D::Error::custom(
"Invalid variadic value type: too big array".to_string(),
))
}
}
Err(err) => Err(D::Error::custom(format!(
Expand Down
3 changes: 0 additions & 3 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ use crate::{
frontier_backend_client, internal_err,
};

/// Default JSONRPC error code return by geth
pub const JSON_RPC_ERROR_DEFAULT: i32 = -32000;

/// The types contained in this module are required for backwards compatility when decoding
/// results produced by old versions of substrate.
/// The changes contained in https://github.com/paritytech/substrate/pull/10776 changed the
Expand Down
3 changes: 3 additions & 0 deletions frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ fp-evm = { workspace = true }
fp-rpc = { workspace = true }
fp-storage = { workspace = true }
pallet-evm = { workspace = true }
# Cumulus
cumulus-primitives-storage-weight-reclaim = { workspace = true, default-features = false }

[dev-dependencies]
hex = { workspace = true }
Expand Down Expand Up @@ -65,6 +67,7 @@ std = [
"fp-rpc/std",
"fp-storage/std",
"pallet-evm/std",
"cumulus-primitives-storage-weight-reclaim/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
Expand Down
33 changes: 17 additions & 16 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mod tests;
use alloc::{vec, vec::Vec};
pub use catch_exec_info::catch_exec_info;
use core::marker::PhantomData;
use cumulus_primitives_storage_weight_reclaim::get_proof_size;
pub use ethereum::{
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
TransactionAction, TransactionV2 as Transaction,
Expand Down Expand Up @@ -393,16 +394,16 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
pub fn transaction_weight(transaction_data: &TransactionData) -> (Option<Weight>, Option<u64>) {
match <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
pub fn transaction_pov(transaction_data: &TransactionData) -> (Option<Weight>, Option<u64>) {
let weight_limit = <T as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
transaction_data.gas_limit.unique_saturated_into(),
true,
) {
weight_limit if weight_limit.proof_size() > 0 => (
Some(weight_limit),
Some(transaction_data.proof_size_base_cost()),
),
_ => (None, None),
);

if weight_limit.proof_size() > 0 {
(Some(weight_limit), get_proof_size())
} else {
(None, None)
}
}

Expand Down Expand Up @@ -528,7 +529,7 @@ impl<T: Config> Pallet<T> {
) -> TransactionValidity {
let transaction_data: TransactionData = transaction.into();
let transaction_nonce = transaction_data.nonce;
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let (base_fee, _) = T::FeeCalculator::min_gas_price();
let (who, _) = pallet_evm::Pallet::<T>::account_basic(&origin);

Expand All @@ -542,7 +543,7 @@ impl<T: Config> Pallet<T> {
},
transaction_data.clone().into(),
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
);
check_transaction
.validate_in_pool_for(&who)
Expand Down Expand Up @@ -769,7 +770,7 @@ impl<T: Config> Pallet<T> {
maybe_force_create_address: Option<H160>,
) -> Result<(Option<H160>, Option<H160>, CallOrCreateInfo), DispatchErrorWithPostInfo> {
let transaction_data: TransactionData = transaction.into();
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let is_transactional = true;
let validate = false;

Expand Down Expand Up @@ -848,7 +849,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -879,7 +880,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
force_address,
) {
Expand Down Expand Up @@ -907,7 +908,7 @@ impl<T: Config> Pallet<T> {
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
config.as_ref().unwrap_or_else(|| T::config()),
) {
Ok(res) => res,
Expand Down Expand Up @@ -937,7 +938,7 @@ impl<T: Config> Pallet<T> {
transaction: &Transaction,
) -> Result<(), TransactionValidityError> {
let transaction_data: TransactionData = transaction.into();
let (weight_limit, proof_size_base_cost) = Self::transaction_weight(&transaction_data);
let (weight_limit, proof_size_pre_execution) = Self::transaction_pov(&transaction_data);
let (base_fee, _) = T::FeeCalculator::min_gas_price();
let (who, _) = pallet_evm::Pallet::<T>::account_basic(&origin);

Expand All @@ -951,7 +952,7 @@ impl<T: Config> Pallet<T> {
},
transaction_data.into(),
weight_limit,
proof_size_base_cost,
proof_size_pre_execution,
);
check_transaction
.validate_in_block_for(&who)
Expand Down
33 changes: 0 additions & 33 deletions frame/ethereum/src/tests/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,39 +568,6 @@ fn validated_transaction_apply_zero_gas_price_works() {
});
}

#[test]
fn proof_size_weight_limit_validation_works() {
let (pairs, mut ext) = new_test_ext(1);
let alice = &pairs[0];

ext.execute_with(|| {
let mut tx = EIP1559UnsignedTransaction {
nonce: U256::from(2),
max_priority_fee_per_gas: U256::zero(),
max_fee_per_gas: U256::from(1),
gas_limit: U256::from(0x100000),
action: ethereum::TransactionAction::Call(alice.address),
value: U256::from(1),
input: Vec::new(),
};

let gas_limit: u64 = 1_000_000;
tx.gas_limit = U256::from(gas_limit);

let weight_limit =
<Test as pallet_evm::Config>::GasWeightMapping::gas_to_weight(gas_limit, true);

// Gas limit cannot afford the extra byte and thus is expected to exhaust.
tx.input = vec![0u8; (weight_limit.proof_size() + 1) as usize];
let tx = tx.sign(&alice.private_key, None);

// Execute
assert!(
Ethereum::transact(RawOrigin::EthereumTransaction(alice.address).into(), tx,).is_err()
);
});
}

#[test]
fn proof_size_base_cost_should_keep_the_same_in_execution_and_estimate() {
let (pairs, mut ext) = new_test_ext(1);
Expand Down
Loading
Loading