diff --git a/protocol/config/consensus.go b/protocol/config/consensus.go index 87afbc5c..f83621b0 100644 --- a/protocol/config/consensus.go +++ b/protocol/config/consensus.go @@ -262,8 +262,9 @@ type ConsensusParams struct { // be read in the transaction MaxAppTxnForeignAssets int - // maximum number of "foreign references" (accounts, asa, app, boxes) - // that can be attached to a single app call. + // maximum number of "foreign references" (accounts, asa, app, boxes) that + // can be attached to a single app call. Modern transactions can use + // MaxAccess references in txn.Access to access more. MaxAppTotalTxnReferences int // maximum cost of application approval program or clear state program @@ -335,6 +336,9 @@ type ConsensusParams struct { // Number of box references allowed MaxAppBoxReferences int + // Number of references allowed in txn.Access + MaxAppAccess int + // Amount added to a txgroup's box I/O budget per box ref supplied. // For reads: the sum of the sizes of all boxes in the group must be less than I/O budget // For writes: the sum of the sizes of all boxes created or written must be less than I/O budget @@ -1289,6 +1293,11 @@ func initConsensusProtocols() { vFuture.EnableAppVersioning = true // if not promoted when v12 goes into effect, update logic/field.go vFuture.EnableSha512BlockHash = true + // txn.Access work + vFuture.MaxAppTxnAccounts = 8 // Accounts are no worse than others, they should be the same + vFuture.MaxAppAccess = 16 // Twice as many, though cross products are explicit + vFuture.BytesPerBoxReference = 2048 // Count is more important that bytes, loosen up + Consensus[protocol.ConsensusFuture] = vFuture // vAlphaX versions are an separate series of consensus parameters and versions for alphanet diff --git a/types/applications.go b/types/applications.go index da3f4b20..b912980e 100644 --- a/types/applications.go +++ b/types/applications.go @@ -32,6 +32,35 @@ type BoxReference struct { Name []byte `codec:"n"` } +// ResourceRef names a single resource +type ResourceRef struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + + // Only one of these may be set + Address Address `codec:"d"` + Asset AssetIndex `codec:"s"` + App AppIndex `codec:"p"` + Holding HoldingRef `codec:"h"` + Locals LocalsRef `codec:"l"` + Box BoxReference `codec:"b"` +} + +// HoldingRef names a holding by referring to an Address and Asset that appear +// earlier in the Access list (0 is special cased) +type HoldingRef struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + Address uint64 `codec:"d"` // 0=Sender,n-1=index into the Access list, which must be an Address + Asset uint64 `codec:"s"` // n-1=index into the Access list, which must be an Asset +} + +// LocalsRef names a local state by referring to an Address and App that appear +// earlier in the Access list (0 is special cased) +type LocalsRef struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + Address uint64 `codec:"d"` // 0=Sender,n-1=index into the Access list, which must be an Address + App uint64 `codec:"p"` // 0=ApplicationID,n-1=index into the Access list, which must be an App +} + // OnCompletion is an enum representing some layer 1 side effect that an // ApplicationCall transaction will have if it is included in a block. // @@ -93,22 +122,29 @@ type ApplicationCallTxnFields struct { // the app or asset id). Accounts []Address `codec:"apat"` + // ForeignAssets are asset IDs for assets whose AssetParams + // (and since v4, Holdings) may be read by the executing + // ApprovalProgram or ClearStateProgram. + ForeignAssets []AssetIndex `codec:"apas"` + // ForeignApps are application IDs for applications besides // this one whose GlobalState (or Local, since v4) may be read // by the executing ApprovalProgram or ClearStateProgram. ForeignApps []AppIndex `codec:"apfa"` + // Access unifies `Accounts`, `ForeignApps`, `ForeignAssets`, and `Boxes` + // under a single list. It removes all implicitly available resources, so + // "cross-product" resources (holdings and locals) must be explicitly + // listed, as well as app accounts, even the app account of the called app! + // Transactions using Access may not use the other lists. + Access []ResourceRef `codec:"al"` + // Boxes are the boxes that can be accessed by this transaction (and others // in the same group). The Index in the BoxRef is the slot of ForeignApps // that the name is associated with (shifted by 1, so 0 indicates "current - // app") + // app") If Access is used, the indexes refer to it. BoxReferences []BoxReference `codec:"apbx"` - // ForeignAssets are asset IDs for assets whose AssetParams - // (and since v4, Holdings) may be read by the executing - // ApprovalProgram or ClearStateProgram. - ForeignAssets []AssetIndex `codec:"apas"` - // LocalStateSchema specifies the maximum number of each type that may // appear in the local key/value store of users who opt in to this // application. This field is only used during application creation