Fungible tokens with time-to-live (TTL) semantics require tracking individual expiration times for each deposited unit. A naive implementation creates a new balance record per deposit, leading to unbounded storage growth and vulnerability to denial-of-service attacks. We present time-bucketed balance records, a data structure that bounds storage to O(k) records per account while guaranteeing that tokens never expire before their configured TTL. Our approach discretizes time into k buckets, coalescing deposits within the same bucket to limit unique expiration timestamps. We prove three key properties: (1) storage is bounded by k+1 records regardless of deposit frequency, (2) actual expiration time is always at least the configured TTL, and (3) adversaries cannot increase a victim's operation cost beyond O(k)[amortized] worst case. We provide a reference implementation in Solidity with measured gas costs demonstrating practical efficiency.
翻译:具有生存时间语义的同质化令牌需要追踪每个存入单位的独立过期时间。一种简单实现为每次存入创建新的余额记录,导致存储空间无限增长并易受拒绝服务攻击。本文提出时间分桶余额记录数据结构,将每个账户的存储记录限制在O(k)条,同时保证令牌永远不会在配置的生存时间之前过期。该方法将时间离散化为k个桶,合并同一桶内的存入操作以限制独立过期时间戳数量。我们证明了三个关键特性:(1)无论存入频率如何,存储记录始终不超过k+1条;(2)实际过期时间始终不小于配置的生存时间;(3)攻击者无法使受害者的操作成本超过O(k)[均摊]最坏情况。我们在Solidity中提供了参考实现,并通过实测燃气成本验证了实际效率。