Skip to content

Commit e3bb6d3

Browse files
nhussein11eshaben
andcommitted
Create "Blocks transactions and fees" page in sc basics section (#392)
* fix: wip * fix: updating page * fix: wording * fix: removing last paragraph * fix: gas model * Apply suggestions from code review Co-authored-by: Erin Shaben <[email protected]> * fix: adding link to eth json apis --------- Co-authored-by: Erin Shaben <[email protected]>
1 parent 4e0b8ac commit e3bb6d3

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

polkadot-protocol/smart-contract-basics/.pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ nav:
44
- 'Overview': overview.md
55
- 'PolkaVM Design': polkavm-design.md
66
- 'EVM vs PolkaVM': evm-vs-polkavm.md
7-
- 'Networks': networks.md
87
- 'Accounts': accounts.md
8+
- 'Networks': networks.md
9+
- 'Blocks, Transactions and Fees' : blocks-transactions-fees.md
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Blocks, Transactions and Fees for Asset Hub Smart Contracts
3+
description: Explore how Asset Hub smart contracts handle blocks, transactions, and fees with EVM compatibility, supporting various Ethereum transaction types.
4+
---
5+
6+
# Blocks, Transactions, and Fees
7+
8+
## Introduction
9+
10+
Asset Hub smart contracts operate within the Polkadot ecosystem using the [`pallet_revive`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/){target=\_blank} implementation, which provides EVM compatibility. While many aspects of blocks and transactions are inherited from the underlying parachain architecture, there are specific considerations and mechanisms unique to smart contract operations on Asset Hub.
11+
12+
## Smart Contract Blocks
13+
14+
Smart contract blocks in Asset Hub follow the same fundamental structure as parachain blocks, inheriting all standard parachain block components. The `pallet_revive` implementation maintains this consistency while adding necessary [EVM-specific features](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm){target=\_blank}. For detailed implementation specifics, the [`Block`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm/struct.Block.html){target=\_blank} struct in `pallet_revive` demonstrates how parachain and smart contract block implementations align.
15+
16+
## Smart Contract Transactions
17+
18+
Asset Hub implements a sophisticated transaction system that supports various transaction types and formats, encompassing both traditional parachain operations and EVM-specific interactions.
19+
20+
### EVM Transaction Types
21+
22+
The system provides a fundamental [`eth_transact`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/pallet/dispatchables/fn.eth_transact.html){target=\_blank} interface for processing raw EVM transactions dispatched through [Ethereum JSON-RPC APIs](/develop/smart-contracts/json-rpc-apis/){target=\_blank}. This interface acts as a wrapper for Ethereum transactions, requiring an encoded signed transaction payload, though it cannot be dispatched directly. Building upon this foundation, the system supports multiple transaction formats to accommodate different use cases and optimization needs:
23+
24+
- [**Legacy transactions**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm/struct.TransactionLegacyUnsigned.html){target=\_blank} - the original Ethereum transaction format, providing basic transfer and contract interaction capabilities. These transactions use a simple pricing mechanism and are supported for backward compatibility
25+
26+
- [**EIP-1559 transactions**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm/struct.Transaction1559Unsigned.html){target=\_blank} - an improved transaction format that introduces a more predictable fee mechanism with base fee and priority fee components. This format helps optimize gas fee estimation and network congestion management
27+
28+
- [**EIP-2930 transactions**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm/struct.Transaction2930Unsigned.html){target=\_blank} - introduces access lists to optimize gas costs for contract interactions by pre-declaring accessed addresses and storage slots
29+
30+
- [**EIP-4844 transactions**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/evm/struct.Transaction4844Unsigned.html){target=\_blank} - implements blob-carrying transactions, designed to optimize Layer 2 scaling solutions by providing dedicated space for roll-up data
31+
32+
Each transaction type can exist in both signed and unsigned states, with appropriate validation and processing mechanisms for each.
33+
34+
## Fees and Gas
35+
36+
Asset Hub implements a sophisticated resource management system that combines parachain transaction fees with EVM gas mechanics, providing both Ethereum compatibility and enhanced features.
37+
38+
### Gas Model Overview
39+
40+
Gas serves as the fundamental unit for measuring computational costs, with each network operation consuming a specified amount. This implementation maintains compatibility with Ethereum's approach while adding parachain-specific optimizations.
41+
42+
- **Dynamic gas scaling** - Asset Hub implements a dynamic pricing mechanism that reflects actual execution performance. This results in:
43+
- More efficient pricing for computational instructions relative to I/O operations
44+
- Better correlation between gas costs and actual resource consumption
45+
- Need for developers to implement flexible gas calculation rather than hardcoding values
46+
47+
- **Multi-dimensional resource metering** - Asset Hub extends beyond the traditional single-metric gas model to track three distinct resources:
48+
49+
- `ref_time` (computation time)
50+
51+
- Functions as traditional gas equivalent
52+
- Measures actual computational resource usage
53+
- Primary metric for basic operation costs
54+
55+
56+
- `proof_size` (verification overhead)
57+
58+
- Tracks state proof size required for validator verification
59+
- Helps manage consensus-related resource consumption
60+
- Important for cross-chain operations
61+
62+
63+
- `storage_deposit` (state management)
64+
65+
- Manages blockchain state growth
66+
- Implements a deposit-based system for long-term storage
67+
- Refundable when storage is freed
68+
69+
These resources can be limited at both transaction and contract levels, similar to Ethereum's gas limits. For more information, check the [Gas Model](/polkadot-protocol/smart-contract-basics/evm-vs-polkavm#gas-model){target=\_blank} section in the [EVM vs PolkaVM](/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/){target=\_blank} article.
70+
71+
### Fee Components
72+
73+
- **Base fees**
74+
75+
- Storage deposit for contract deployment
76+
- Minimum transaction fee for network access
77+
- Network maintenance costs
78+
79+
- **Execution fees**
80+
81+
- Computed based on gas consumption
82+
- Converted to native currency using network-defined rates
83+
- Reflects actual computational resource usage
84+
85+
- **Storage fees**
86+
87+
- Deposit for long-term storage usage
88+
- Refundable when storage is freed
89+
- Helps prevent state bloat
90+
91+
### Gas Calculation and Conversion
92+
93+
The system maintains precise conversion mechanisms between:
94+
95+
- Substrate weights and EVM gas units
96+
- Native currency and gas costs
97+
- Different resource metrics within the multi-dimensional model
98+
99+
This ensures accurate fee calculation while maintaining compatibility with existing Ethereum tools and workflows.

0 commit comments

Comments
 (0)