我们对比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管理工具