Skip to content

Commit

Permalink
Merge pull request #84 from jannotti/avm-v9
Browse files Browse the repository at this point in the history
v9 availability rules
  • Loading branch information
algofoundation authored Mar 15, 2023
2 parents a9d8d19 + 36d7e98 commit 61879ef
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
39 changes: 37 additions & 2 deletions dev/TEAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _immediate_ arguments that are encoded directly into the instruction,
rather than coming from the stack.

The maximum stack depth is 1000. If the stack depth is exceeded or if
a byte-array element exceed 4096 bytes, the program fails. If an
a byte-array element exceeds 4096 bytes, the program fails. If an
opcode is documented to access a position in the stack that does not
exist, the operation fails. Most often, this is an attempt to access
an element below the stack -- the simplest example is an operation
Expand Down Expand Up @@ -201,6 +201,41 @@ _available_.

* Since v7, the account associated with any contract present in the
`txn.ForeignApplications` field is _available_.

* Since v9, there is group-level resource sharing. Any resource that
is available in _some_ top-level transaction in a transaction group
is available in _all_ v9 or later application calls in the group,
whether those application calls are top-level or inner.

* When considering whether an asset holding or application local
state is available by group-level resource sharing, the holding or
local state must be available in a top-level transaction without
considering group sharing. For example, if account A is made
available in one transaction, and asset X is made available in
another, group resource sharing does _not_ make A's X holding
available.

* Top-level transactions that are not application calls also make
resources available to group-level resource sharing. The following
resources are made available by other transaction types.

1. `pay` - `txn.Sender`, `txn.Receiver`, and
`txn.CloseRemainderTo` (if set).

1. `keyreg` - `txn.Sender`

1. `acfg` - `txn.Sender`, `txn.ConfigAsset`, and the
`txn.ConfigAsset` holding of `txn.Sender`.

1. `axfer` - `txn.Sender`, `txn.AssetReceiver`, `txn.AssetSender`
(if set), `txnAssetCloseTo` (if set), `txn.XferAsset`, and the
`txn.XferAsset` holding of each of those accounts.

1. `afrz` - `txn.Sender`, `txn.FreezeAccount`, `txn.FreezeAsset`,
and the `txn.FreezeAsset` holding of `txn.FreezeAccount`. The
`txn.FreezeAsset` holding of `txn.Sender` is _not_ made
available.


* A Box is _available_ to an Approval Program if _any_ transaction in
the same group contains a box reference (`txn.Boxes`) that denotes
Expand All @@ -220,7 +255,7 @@ Constants can be pushed onto the stack in two different ways:

2. Constants can be loaded into storage separate from the stack and
scratch space, using two opcodes `intcblock` and
`bytecblock`. Then, constants from this storage can be pushed
`bytecblock`. Then, constants from this storage can be
pushed onto the stack by referring to the type and index using
`intc`, `intc_[0123]`, `bytec`, and `bytec_[0123]`. This method is
more efficient for constants that are used multiple times.
Expand Down
14 changes: 7 additions & 7 deletions dev/TEAL_opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ The notation J,K indicates that two uint64 values J and K are interpreted as a u

## bytecblock bytes ...

- Opcode: 0x26 {varuint count} [({varuint value length} bytes), ...]
- Opcode: 0x26 {varuint count} [({varuint length} bytes), ...]
- Stack: ... → ...
- prepare block of byte-array constants for use by bytec

Expand Down Expand Up @@ -326,7 +326,7 @@ The notation J,K indicates that two uint64 values J and K are interpreted as a u

## arg n

- Opcode: 0x2c {uint8 arg index N}
- Opcode: 0x2c {uint8 arg index}
- Stack: ... → ..., []byte
- Nth LogicSig argument
- Mode: Signature
Expand Down Expand Up @@ -819,7 +819,7 @@ When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on

## json_ref r

- Opcode: 0x5f {uint8 return type}
- Opcode: 0x5f {uint8 return type index}
- Stack: ..., A: []byte, B: []byte → ..., any
- key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A
- **Cost**: 25 + 2 per 7 bytes of A
Expand All @@ -846,7 +846,7 @@ Almost all smart contracts should use simpler and smaller methods (such as the [
- Availability: v2
- Mode: Application

params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.
params: Txn.Accounts offset (or, since v4, an _available_ account address). Return: value.

## app_opted_in

Expand Down Expand Up @@ -1045,7 +1045,7 @@ params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag
- Availability: v3
- Mode: Application

params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.
params: Txn.Accounts offset (or, since v4, an _available_ account address). Return: value.

## pushbytes bytes

Expand All @@ -1067,7 +1067,7 @@ pushint args are not added to the intcblock during assembly processes

## pushbytess bytes ...

- Opcode: 0x82 {varuint count} [({varuint value length} bytes), ...]
- Opcode: 0x82 {varuint count} [({varuint length} bytes), ...]
- Stack: ... → ..., [N items]
- push sequences of immediate byte arrays to stack (first byte array being deepest)
- Availability: v8
Expand Down Expand Up @@ -1556,7 +1556,7 @@ For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `bo

## block f

- Opcode: 0xd1 {uint8 block field}
- Opcode: 0xd1 {uint8 block field index}
- Stack: ..., A: uint64 → ..., any
- field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)
- Availability: v7
Expand Down

0 comments on commit 61879ef

Please sign in to comment.