我們對比ethereum和ep的transaction的數據結構:
下面是ethereum的transaction的數據結構:
~~~
type Transaction struct {
inner TxData // Consensus contents of a transaction
time time.Time // Time first seen locally (spam avoidance)
// caches
hash atomic.Value
size atomic.Value
from atomic.Value
}
~~~
其中txData數據結構有三種實現:DynamicFeeTx, LegacyTx and AccessListTx.
~~~
type DynamicFeeTx struct {
ChainID *big.Int
Nonce uint64
GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *big.Int // a.k.a. maxFeePerGas
Gas uint64
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int
Data []byte
AccessList AccessList
// Signature values
//`r and s are outputs of an ECDSA signature, and`v`is the recovery id
V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s" gencodec:"required"`
}
~~~
~~~
// LegacyTx is the transaction data of regular Ethereum transactions.
type LegacyTx struct {
Nonce uint64 // nonce of sender account
GasPrice *big.Int // wei per gas
Gas uint64 // gas limit
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int // wei amount
Data []byte // contract invocation input data
V, R, S *big.Int // signature values
}
~~~
~~~
// AccessListTx is the data of EIP-2930 access list transactions.
type AccessListTx struct {
ChainID *big.Int // destination chain ID
Nonce uint64 // nonce of sender account
GasPrice *big.Int // wei per gas
Gas uint64 // gas limit
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int // wei amount
Data []byte // contract invocation input data
AccessList AccessList // EIP-2930 access list
V, R, S *big.Int // signature values
}
~~~
其中LegacyTx是歷史上的ethereum的結構,他們還是有些區別,其它兩種都與協議有關。另外,最開始的ethereum的transaction結構是沒有chainID的。
我們看看ep的transaction數據結構:
~~~
type Transaction struct {
Nonce uint64
GasPrice *big.Int
Gas uint64
To *Address
Value *big.Int
Input []byte
V *big.Int
R *big.Int
S *big.Int
Hash Hash
From Address
// Cache
size atomic.Value
}
~~~
這個結構與上面的LegacyTx相比,多了From字段和Cache字段,對比其它的結構,對跨鏈數據交換影響不大(以太坊必須向后兼容LegacyTx)。
下面是對transaction的關鍵字段的說明:
1. **nonce**: The number of transaction serial numbers sent by this account (which can be roughly understood as “this is the first transaction of this account”).
2. **gasPrice**: The fee (measured in Wei) paid per unit of gas to perform this transaction and perform calculations.
3. **gasLimit**: The maximum amount of gas that can be used when executing this transaction.
4. **to**: If this transaction is used to send ether, here is the EOA address that receives ether; if this transaction is used to send a message to the contract (for example, calling a method in a smart contract), here is the address of the contract; if this The transaction is used to create the contract, here the value is empty.
5. **value**: If this transaction is used to send and receive ether, here is the amount of tokens measured in Wei in the receiving account; if this transaction is used to send a message call to the contract, here is the amount of Wei paid to the smart contract that receives this message ; if this transaction is used to create a contract, here is the amount of ether in Wei stored in the account when the contract was initialized.
6. **v, r, s**: Values ??used in the cryptographic signature of the transaction, which can be used to determine the sender of the transaction.
7. **data**(only used for value transfer and sending message calls to smart contracts) input data that accompanies the message call (for example, if you want to execute a setter method in a smart contract, the data field should include the identifier of the setter method, and the parameter value you want to set).
All transactions in the block are also stored in the Merkle tree. And the root node hash value of this tree is saved by the block header!
- 重要更新說明
- linechain發布
- linechain新版設計
- 引言一
- 引言二
- 引言三
- vs-code設置及開發環境設置
- BoltDB數據庫應用
- 關于Go語言、VS-code的一些Tips
- 區塊鏈的架構
- 網絡通信與區塊鏈
- 單元測試
- 比特幣腳本語言
- 關于區塊鏈的一些概念
- 區塊鏈組件
- 區塊鏈第一版:基本原型
- 區塊鏈第二版:增加工作量證明
- 區塊鏈第三版:持久化
- 區塊鏈第四版:交易
- 區塊鏈第五版:實現錢包
- 區塊鏈第六版:實現UTXO集
- 區塊鏈第七版:網絡
- 階段小結
- 區塊鏈第八版:P2P
- P2P網絡架構
- 區塊鏈網絡層
- P2P區塊鏈最簡體驗
- libp2p建立P2P網絡的關鍵概念
- 區塊鏈結構層設計與實現
- 用戶交互層設計與實現
- 網絡層設計與實現
- 建立節點發現機制
- 向區塊鏈網絡請求區塊信息
- 向區塊鏈網絡發布消息
- 運行區塊鏈
- LineChain
- 系統運行流程
- Multihash
- 區塊鏈網絡的節點發現機制深入探討
- DHT
- Bootstrap
- 連接到所有引導節點
- Advertise
- 搜索其它peers
- 連接到搜到的其它peers
- 區塊鏈網絡的消息訂發布-訂閱機制深入探討
- LineChain:適用于智能合約編程的腳本語言支持
- LineChain:解決分叉問題
- LineChain:多重簽名
- libp2p升級到v0.22版本
- 以太坊基礎
- 重溫以太坊的樹結構
- 世界狀態樹
- (智能合約)賬戶存儲樹
- 交易樹
- 交易收據樹
- 小結
- 以太坊的存儲結構
- 以太坊狀態數據庫
- MPT
- 以太坊POW共識算法
- 智能合約存儲
- Polygon Edge
- block結構
- transaction數據結構
- 數據結構小結
- 關于本區塊鏈的一些說明
- UML工具-PlantUML
- libp2p介紹
- JSON-RPC
- docker制作:啟動多個應用系統
- Dockerfile
- docker-entrypoint.sh
- supervisord.conf
- docker run
- nginx.conf
- docker基礎操作整理
- jupyter計算交互環境
- git技巧一
- git技巧二
- 使用github項目的最佳實踐
- windows下package管理工具