algorand / algorand/go-algorand

AVM: Allow larger LogicSig programs with fee-based pricing

未关闭
#6,582 6 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
Enhancement
主要语言
Go
星标
1.4k
派生
537
平均合并
1 天 7 小时
30 天内合并 PR
18

描述

## Background

Currently, LogicSig size is limited by `MaxLogicSigMaxSize`, which applies to `program + args` combined. I propose relaxing that limit to allow larger LogicSig programs (tentatively 16× the current size), with appropriate fee charging.

## The core difficulty: args are not committed

LogicSig args are part of the \"signature\" envelope but are **not signed**. The LogicSig program, by contrast, is committed to by the LogicSig address (it hashes to the address), so it is effectively signed.

This asymmetry creates a constraint:

> **Fee and cost requirements must be determinable from committed (signed) data only.**

If arg size contributed to required fee, an attacker holding a signed transaction could inflate the args, causing the transaction to fail (liveness attack). More importantly, once a RefundableFee model is introduced (where transactions are charged for actual usage and the remainder refunded, similar to Ethereum's gas model), this would become a **cost attack**: the attacker reduces the sender's refund without their consent.

This means args can **never** factor into fee or cost calculations — it is a permanent protocol invariant, not just a current-model workaround.

## Proposed design

Split the current combined `MaxLogicSigMaxSize` limit into two independent limits:

1. **`MaxLogicSigProgramSize`** — a new, larger limit (e.g., 16× current). Extra fee is charged based on program size beyond the old threshold, since the program is committed to via the address hash.

2. **`MaxLogicSigArgsTotalSize`** — a fixed hard cap equal to the existing `MaxLogicSigMaxSize`). No fee charging — only a hard limit to bound unchargeable deserialization and memory work.

### Backward compatibility

Set the "free threshold" for extra program fees at the old `MaxLogicSigMaxSize`. Any program that was valid before pays no extra fee.

By splitting the program and arg caps, and requiring backward fee compatibility, we end up doubling the size of allowed logicsigs, if they split themselves in half perfectly. I guess there's nothing to be done about that.

### Why the args cap matters more in a RefundableFee world

In a RefundableFee model, the args cap bounds the amount of work the network must absorb for free on every logicsig transaction. The actual execution cost of args is largely captured by opcode charges (you pay when you read/use them), so the main unchargeable work is deserialization and allocation — but the cap should be set with that budget in mind.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。