Skip to main content

2 posts tagged with "Ethereum"

Ethereum 交易机制与客户端源码分析

View All Tags

从 TRON 与 Ethereum 源码看交易排序:为什么先代理能量,转账仍可能先执行?

· 33 min read
Chris Gayle
Chris Gayle
Backend Engineer @CatFee

先购买能量,再发送 USDT,为什么转账仍然可能燃烧 TRX,甚至因为能量不足而失败?

在钱包、交易所和支付系统的代码里,这个流程往往只有两步:先广播资源代理交易,再广播用户的转账交易。两次请求顺序明确,第一笔还返回了成功,看起来应该没有问题。

问题在于:应用提交请求的顺序,不等于出块节点最终执行交易的顺序。

常见的解释是“波场没有 nonce,所以不能按顺序打包;以太坊有 nonce,所以可以”。这句话抓住了一个差异,却省略了最关键的适用范围:TRON 会按区块内的交易顺序执行,只是不提供 Ethereum 那样的发送账户 nonce 约束;Ethereum 的 nonce 约束同一账户的交易,也不会自动替不同账户建立业务依赖。

对于能量服务,真正需要解决的是:当用户交易开始执行时,它依赖的资源状态是否已经生效,而且仍然足够。

Transaction Ordering in TRON and Ethereum: Why Energy Delegation Can Arrive Too Late

· 20 min read
Chris Gayle
Chris Gayle
Backend Engineer @CatFee

You purchase Energy before sending USDT. Why does the transfer still burn TRX—or fail because it runs out of Energy?

In a wallet, exchange, or payment backend, the implementation often looks straightforward: broadcast the resource delegation transaction, then broadcast the user's transfer. The requests are sequential, and the first one returns a successful response. What could go wrong?

The order in which an application submits transactions is not necessarily the order in which a block producer executes them.

A common explanation is that TRON has no transaction nonce, while Ethereum does. That identifies an important difference, but leaves out its scope. TRON executes transactions in block order; it simply lacks Ethereum's per-sender nonce constraint. Ethereum's nonce, in turn, constrains transactions from the same account. It does not automatically establish dependencies between different accounts.

For Energy services, the requirement is more specific: when the user's transaction starts executing, the resources it needs must already be available—and still sufficient.