From af13373fc882b33a5a22183ac47ff9a8ac8877b2 Mon Sep 17 00:00:00 2001 From: MOZGIII Date: Sat, 29 Aug 2026 18:50:04 +0400 Subject: [PATCH] Reduce the EVM tx fee to 90 eHMND --- crates/humanode-runtime/src/constants.rs | 15 ++++++++++----- crates/humanode-runtime/src/tests/fees.rs | 18 ++++++++++++------ utils/e2e-tests/ts/tests/base/rpc/eth.ts | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/humanode-runtime/src/constants.rs b/crates/humanode-runtime/src/constants.rs index d2450a359..b637453b1 100644 --- a/crates/humanode-runtime/src/constants.rs +++ b/crates/humanode-runtime/src/constants.rs @@ -110,11 +110,16 @@ pub mod evm_fees { /// The amount of fee per gas unit. /// Comes from the following rationale: /// - a simple transfer costs 21000 gas - /// - we want the cost of this transfer to be around ~134 HMND - /// - so we must charge about 134 * 10^18 / 21000 fee per a unit of gas - /// The value below is a nice round number that fits the requirements outlined above: - /// the base value of `100_000_000_000_000` prices a single transfer at ~2 HMND. - pub const FEE_PER_GAS: u128 = 67 * 100_000_000_000_000; + /// - we want the cost of this transfer to be around ~90 HMND + /// - so we must charge about 90 * 10^18 / 21000 fee per a unit of gas + /// The value below is a nice round number that fits the requirements outlined above. + /// + /// Note: this value is intentionally decoupled from the weight-based fee + /// (see [`crate::constants::fees::WEIGHT_TO_FEE`]): pricing the gas-to-weight mapping of the + /// same transfer through the weight-based fee would give ~135 HMND, but Ethereum transactions + /// pay their fees through the EVM gas accounting and not through the transaction payment, + /// so we set the gas price to target the fee we actually want. + pub const FEE_PER_GAS: u128 = 4_300_000_000_000_000; /// The max proof size ratio per block. /// Set to the zero as humanode is solo chain. Otherwise, additional used gas has diff --git a/crates/humanode-runtime/src/tests/fees.rs b/crates/humanode-runtime/src/tests/fees.rs index c9b1cc7c7..d68e29ed5 100644 --- a/crates/humanode-runtime/src/tests/fees.rs +++ b/crates/humanode-runtime/src/tests/fees.rs @@ -223,8 +223,13 @@ fn simple_balances_transfer_keep_alive() { }) } -/// A test that validates that a simple EVM balance transfer with a keep alive costs 134 HMND. +/// A test that validates the substrate-side fee estimate of a simple EVM balance transfer. /// Computes the fee via [`TransactionPayment::query_call_info`]. +/// +/// This estimate is weight-based and is intentionally decoupled from the actual gas-based +/// charge (~90 HMND, see [`constants::evm_fees::FEE_PER_GAS`]): Ethereum transactions do not pay +/// their fees through the transaction payment, so this value is what substrate-side tooling +/// would display, not what is charged. #[test] fn simple_evm_transaction_via_query_call_info() { // Build the state from the config. @@ -258,8 +263,9 @@ fn simple_evm_transaction_via_query_call_info() { }), }); - // The expected fee that we aim to target: 134 HMND. - let expected_fee = 134 * ONE_BALANCE_UNIT; + // The weight-derived fee estimate: ~135 HMND (21000 gas mapped to weight and priced + // via `WEIGHT_TO_FEE`). This is not what an EVM transaction actually pays. + let expected_fee = 135 * ONE_BALANCE_UNIT; // The tolerance within which the actual fee is allowed to be around the expected fee. let epsilon = expected_fee / 10; @@ -268,7 +274,7 @@ fn simple_evm_transaction_via_query_call_info() { }) } -/// A test that validates that a simple EVM balance transfer with a keep alive costs 134 HMND. +/// A test that validates that a simple EVM balance transfer with a keep alive costs 90 HMND. /// Computes the fee via an estimate EVM runner invocation. #[test] fn simple_evm_transaction_via_runner_estimate() { @@ -334,8 +340,8 @@ fn simple_evm_transaction_via_runner_estimate() { } ); - // The expected fee that we aim to target: 134 HMND. - let expected_fee = 134 * ONE_BALANCE_UNIT; + // The expected fee that we aim to target: 90 HMND. + let expected_fee = 90 * ONE_BALANCE_UNIT; // The tolerance within which the actual fee is allowed to be around the expected fee. let epsilon = expected_fee / 10; diff --git a/utils/e2e-tests/ts/tests/base/rpc/eth.ts b/utils/e2e-tests/ts/tests/base/rpc/eth.ts index 5a116291c..c7e3f4838 100644 --- a/utils/e2e-tests/ts/tests/base/rpc/eth.ts +++ b/utils/e2e-tests/ts/tests/base/rpc/eth.ts @@ -43,7 +43,7 @@ describe("eth rpc", () => { describe("fee", () => { describe("when transferring 1 eHMND", () => { const transferValue = ethers.parseEther("1"); - const expectedFee = ethers.parseEther("134"); + const expectedFee = ethers.parseEther("90"); const tolerance = expectedFee / 10n; it("is within the tolerance around the expected cost", async () => {