Skip to content
Merged
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
14 changes: 8 additions & 6 deletions crates/humanode-runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ pub mod fees {
/// The multiplier to get the fee from weight.
///
/// We compute the fee to weight multiplier based on the weight of the `balances.transfer` call,
/// and try to fit the fee such that a single transfer call costs ~0.1 HMND.
pub const WEIGHT_TO_FEE: Balance = 385_000_000;
/// and try to fit the fee such that a single transfer call costs ~67 HMND:
/// the base value of `3_850_000_000` prices a single transfer at ~1 HMND.
pub const WEIGHT_TO_FEE: Balance = 67 * 3_850_000_000;

/// The multiplier to get the fee from length.
pub const LENGTH_TO_FEE: Balance = 1;
Expand All @@ -109,10 +110,11 @@ 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 ~0.2 HMND
/// - so we must charge about 0.2 * 10^18 / 21000 fee per a unit of gas
/// The value below is a nice round number that fits the requirements outlined above.
pub const FEE_PER_GAS: u128 = 10_000_000_000_000;
/// - 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;

/// The max proof size ratio per block.
/// Set to the zero as humanode is solo chain. Otherwise, additional used gas has
Expand Down
18 changes: 9 additions & 9 deletions crates/humanode-runtime/src/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn switch_block() {
AllPalletsWithSystem::on_initialize(System::block_number());
}

/// A test that validates that a simple balance transfer with a keep alive costs 0.1 HMND.
/// A test that validates that a simple balance transfer with a keep alive costs 67 HMND.
#[test]
fn simple_balances_transfer_keep_alive() {
// Build the state from the config.
Expand Down Expand Up @@ -213,8 +213,8 @@ fn simple_balances_transfer_keep_alive() {
(call, len)
};

// The expected fee that we aim to target: 0.1 HMND.
let expected_fee = ONE_BALANCE_UNIT / 10;
// The expected fee that we aim to target: 67 HMND.
let expected_fee = 67 * ONE_BALANCE_UNIT;

// The tolerance within which the actual fee is allowed to be around the expected fee.
let epsilon = expected_fee / 200;
Expand All @@ -223,7 +223,7 @@ fn simple_balances_transfer_keep_alive() {
})
}

/// A test that validates that a simple EVM balance transfer with a keep alive costs 0.2 HMND.
/// A test that validates that a simple EVM balance transfer with a keep alive costs 134 HMND.
/// Computes the fee via [`TransactionPayment::query_call_info`].
#[test]
fn simple_evm_transaction_via_query_call_info() {
Expand Down Expand Up @@ -258,8 +258,8 @@ fn simple_evm_transaction_via_query_call_info() {
}),
});

// The expected fee that we aim to target: 0.2 HMND.
let expected_fee = ONE_BALANCE_UNIT / 5;
// The expected fee that we aim to target: 134 HMND.
let expected_fee = 134 * ONE_BALANCE_UNIT;

// The tolerance within which the actual fee is allowed to be around the expected fee.
let epsilon = expected_fee / 10;
Expand All @@ -268,7 +268,7 @@ fn simple_evm_transaction_via_query_call_info() {
})
}

/// A test that validates that a simple EVM balance transfer with a keep alive costs 0.2 HMND.
/// A test that validates that a simple EVM balance transfer with a keep alive costs 134 HMND.
/// Computes the fee via an estimate EVM runner invocation.
#[test]
fn simple_evm_transaction_via_runner_estimate() {
Expand Down Expand Up @@ -334,8 +334,8 @@ fn simple_evm_transaction_via_runner_estimate() {
}
);

// The expected fee that we aim to target: 0.2 HMND.
let expected_fee = ONE_BALANCE_UNIT / 5;
// The expected fee that we aim to target: 134 HMND.
let expected_fee = 134 * ONE_BALANCE_UNIT;

// The tolerance within which the actual fee is allowed to be around the expected fee.
let epsilon = expected_fee / 10;
Expand Down
2 changes: 1 addition & 1 deletion utils/e2e-tests/ts/tests/base/rpc/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("eth rpc", () => {
describe("fee", () => {
describe("when transferring 1 eHMND", () => {
const transferValue = ethers.parseEther("1");
const expectedFee = ethers.parseEther("0.2");
const expectedFee = ethers.parseEther("134");
const tolerance = expectedFee / 10n;

it("is within the tolerance around the expected cost", async () => {
Expand Down