algorand / algorand/go-algorand

AVM: Allow larger LogicSig programs with fee-based pricing

Open
#6,582 6 comments 1 reaction 0 assignees View on GitHub
Enhancement
Dominant language
Go
Stars
1.4k
Forks
537
Avg merge
1d 6h
Merged PRs (30d)
17

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.