Skip to content

Types: Preliminary changes to match PR #6286 in go-algorand #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions protocol/config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
48 changes: 42 additions & 6 deletions types/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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
Expand Down
Loading