Skip to content

Commit e32b2c2

Browse files
authored
Application transactions (#2661)
Allow AVM 1.0 programs to "execute transactions" 1. An app now has authority over an account which is the hash of its appid. 2. The app can create transactions with three new opcodes, tx_begin, tx_field, and tx_submit. 3. If the transaction so created would need to be authorized by that app account from 1, the effects occur. 4. Fees on inner transactions are paid from the app account, though overpaying at the top-level can be pooled. So far, only pay and axfer are allowed. acfg and afrz are under consideration, but have separate issues written. This makes ApplyData a recursive datastructure, so that the "inner" transactions of app calls can be encoded in EvalDelta and, themselves, have ApplyData.
1 parent ac51e70 commit e32b2c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4877
-3204
lines changed

cmd/opdoc/tmLanguage.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ func buildSyntaxHighlight() *tmLanguage {
172172
Name: "keyword.other.unit.teal",
173173
Match: fmt.Sprintf("^(%s)\\b", strings.Join(names, "|")),
174174
})
175-
// For these four, accumulate into allArithmetics,
175+
// For these, accumulate into allArithmetics,
176176
// and only add to keyword.Patterns later, when all
177177
// have been collected.
178-
case "Arithmetic", "Byte Array Slicing", "Byteslice Arithmetic", "Byteslice Logic":
178+
case "Arithmetic", "Byte Array Slicing", "Byte Array Arithmetic",
179+
"Byte Array Logic", "Inner Transactions":
179180
escape := map[rune]bool{
180181
'*': true,
181182
'+': true,

config/consensus.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ type ConsensusParams struct {
283283
// maximum sum of the lengths of the key and value of one app state entry
284284
MaxAppSumKeyValueLens int
285285

286+
// maximum number of inner transactions that can be created by an app call
287+
MaxInnerTransactions int
288+
286289
// maximum number of applications a single account can create and store
287290
// AppParams for at once
288291
MaxAppsCreated int
@@ -431,6 +434,9 @@ var MaxStateDeltaKeys int
431434
// any version, used only for decoding purposes. Never decrease this value.
432435
var MaxLogCalls int
433436

437+
// MaxInnerTransactions is the maximum number of inner transactions that may be created in an app call.
438+
var MaxInnerTransactions int
439+
434440
// MaxLogicSigMaxSize is the largest logical signature appear in any of the supported
435441
// protocols, used for decoding purposes.
436442
var MaxLogicSigMaxSize int
@@ -494,6 +500,7 @@ func checkSetAllocBounds(p ConsensusParams) {
494500
// There is no consensus parameter for MaxLogCalls and MaxAppProgramLen as an approximation
495501
// Its value is much larger than any possible reasonable MaxLogCalls value in future
496502
checkSetMax(p.MaxAppProgramLen, &MaxLogCalls)
503+
checkSetMax(p.MaxInnerTransactions, &MaxInnerTransactions)
497504
}
498505

499506
// SaveConfigurableConsensus saves the configurable protocols file to the provided data directory.
@@ -1015,6 +1022,7 @@ func initConsensusProtocols() {
10151022

10161023
// Enable App calls to pool budget in grouped transactions
10171024
vFuture.EnableAppCostPooling = true
1025+
vFuture.MaxInnerTransactions = 16
10181026

10191027
// Allow 50 app opt ins
10201028
vFuture.MaxAppsOptedIn = 50

daemon/algod/api/algod.oas2.json

Lines changed: 71 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,10 @@
811811
],
812812
"responses": {
813813
"200": {
814-
"$ref": "#/responses/PendingTransactionResponse"
814+
"description": "Given a transaction id of a recently submitted transaction, it returns information about it. There are several cases when this might succeed:\n- transaction committed (committed round \u003e 0)\n- transaction still in the pool (committed round = 0, pool error = \"\")\n- transaction removed from pool due to error (committed round = 0, pool error != \"\")\n\nOr the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error.",
815+
"schema": {
816+
"$ref": "#/definitions/PendingTransactionResponse"
817+
}
815818
},
816819
"400": {
817820
"description": "Bad Request",
@@ -1748,7 +1751,7 @@
17481751
"logs": {
17491752
"type": "array",
17501753
"items": {
1751-
"$ref": "#/definitions/LogItem"
1754+
"type": "string"
17521755
}
17531756
},
17541757
"cost": {
@@ -1921,21 +1924,79 @@
19211924
}
19221925
}
19231926
},
1924-
"LogItem": {
1925-
"description": "Application Log",
1927+
"PendingTransactionResponse": {
1928+
"description": "Details about a pending transaction. If the transaction was recently confirmed, includes confirmation details like the round and reward details.",
19261929
"type": "object",
19271930
"required": [
1928-
"id",
1929-
"value"
1931+
"txn",
1932+
"pool-error"
19301933
],
19311934
"properties": {
1932-
"id": {
1933-
"description": "unique application identifier",
1935+
"asset-index": {
1936+
"description": "The asset index if the transaction was found and it created an asset.",
1937+
"type": "integer"
1938+
},
1939+
"application-index": {
1940+
"description": "The application index if the transaction was found and it created an application.",
19341941
"type": "integer"
19351942
},
1936-
"value": {
1937-
"description": " base64 encoded log message",
1943+
"close-rewards": {
1944+
"description": "Rewards in microalgos applied to the close remainder to account.",
1945+
"type": "integer"
1946+
},
1947+
"closing-amount": {
1948+
"description": "Closing amount for the transaction.",
1949+
"type": "integer"
1950+
},
1951+
"asset-closing-amount": {
1952+
"description": "The number of the asset's unit that were transferred to the close-to address.",
1953+
"type": "integer"
1954+
},
1955+
"confirmed-round": {
1956+
"description": "The round where this transaction was confirmed, if present.",
1957+
"type": "integer"
1958+
},
1959+
"pool-error": {
1960+
"description": "Indicates that the transaction was kicked out of this node's transaction pool (and specifies why that happened). An empty string indicates the transaction wasn't kicked out of this node's txpool due to an error.\n",
19381961
"type": "string"
1962+
},
1963+
"receiver-rewards": {
1964+
"description": "Rewards in microalgos applied to the receiver account.",
1965+
"type": "integer"
1966+
},
1967+
"sender-rewards": {
1968+
"description": "Rewards in microalgos applied to the sender account.",
1969+
"type": "integer"
1970+
},
1971+
"local-state-delta": {
1972+
"description": "\\[ld\\] Local state key/value changes for the application being executed by this transaction.",
1973+
"type": "array",
1974+
"items": {
1975+
"$ref": "#/definitions/AccountStateDelta"
1976+
}
1977+
},
1978+
"global-state-delta": {
1979+
"description": "\\[gd\\] Global state key/value changes for the application being executed by this transaction.",
1980+
"$ref": "#/definitions/StateDelta"
1981+
},
1982+
"logs": {
1983+
"description": "\\[lg\\] Logs for the application being executed by this transaction.",
1984+
"type": "array",
1985+
"items": {
1986+
"type": "string"
1987+
}
1988+
},
1989+
"inner-txns": {
1990+
"description": "Inner transactions produced by application execution.",
1991+
"type": "array",
1992+
"items": {
1993+
"$ref": "#/definitions/PendingTransactionResponse"
1994+
}
1995+
},
1996+
"txn": {
1997+
"description": "The raw signed transaction.",
1998+
"type": "object",
1999+
"x-algorand-format": "SignedTransaction"
19392000
}
19402001
}
19412002
}
@@ -2278,78 +2339,6 @@
22782339
}
22792340
}
22802341
},
2281-
"PendingTransactionResponse": {
2282-
"description": "Given a transaction id of a recently submitted transaction, it returns information about it. There are several cases when this might succeed:\n- transaction committed (committed round \u003e 0)\n- transaction still in the pool (committed round = 0, pool error = \"\")\n- transaction removed from pool due to error (committed round = 0, pool error != \"\")\n\nOr the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error.",
2283-
"schema": {
2284-
"description": "Details about a pending transaction. If the transaction was recently confirmed, includes confirmation details like the round and reward details.",
2285-
"type": "object",
2286-
"required": [
2287-
"txn",
2288-
"pool-error"
2289-
],
2290-
"properties": {
2291-
"asset-index": {
2292-
"description": "The asset index if the transaction was found and it created an asset.",
2293-
"type": "integer"
2294-
},
2295-
"application-index": {
2296-
"description": "The application index if the transaction was found and it created an application.",
2297-
"type": "integer"
2298-
},
2299-
"close-rewards": {
2300-
"description": "Rewards in microalgos applied to the close remainder to account.",
2301-
"type": "integer"
2302-
},
2303-
"closing-amount": {
2304-
"description": "Closing amount for the transaction.",
2305-
"type": "integer"
2306-
},
2307-
"asset-closing-amount": {
2308-
"description": "The number of the asset's unit that were transferred to the close-to address.",
2309-
"type": "integer"
2310-
},
2311-
"confirmed-round": {
2312-
"description": "The round where this transaction was confirmed, if present.",
2313-
"type": "integer"
2314-
},
2315-
"pool-error": {
2316-
"description": "Indicates that the transaction was kicked out of this node's transaction pool (and specifies why that happened). An empty string indicates the transaction wasn't kicked out of this node's txpool due to an error.\n",
2317-
"type": "string"
2318-
},
2319-
"receiver-rewards": {
2320-
"description": "Rewards in microalgos applied to the receiver account.",
2321-
"type": "integer"
2322-
},
2323-
"sender-rewards": {
2324-
"description": "Rewards in microalgos applied to the sender account.",
2325-
"type": "integer"
2326-
},
2327-
"local-state-delta": {
2328-
"description": "\\[ld\\] Local state key/value changes for the application being executed by this transaction.",
2329-
"type": "array",
2330-
"items": {
2331-
"$ref": "#/definitions/AccountStateDelta"
2332-
}
2333-
},
2334-
"global-state-delta": {
2335-
"description": "\\[gd\\] Global state key/value changes for the application being executed by this transaction.",
2336-
"$ref": "#/definitions/StateDelta"
2337-
},
2338-
"logs": {
2339-
"description": "\\[lg\\] Logs for the application being executed by this transaction.",
2340-
"type": "array",
2341-
"items": {
2342-
"$ref": "#/definitions/LogItem"
2343-
}
2344-
},
2345-
"txn": {
2346-
"description": "The raw signed transaction.",
2347-
"type": "object",
2348-
"x-algorand-format": "SignedTransaction"
2349-
}
2350-
}
2351-
}
2352-
},
23532342
"PendingTransactionsResponse": {
23542343
"description": "A potentially truncated list of transactions currently in the node's transaction pool. You can compute whether or not the list is truncated if the number of elements in the **top-transactions** array is fewer than **total-transactions**.",
23552344
"schema": {

0 commit comments

Comments
 (0)