Skip to content
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

loads and stores opcodes that take scratch slot from stack #2853

Merged
merged 4 commits into from
Sep 8, 2021
Merged
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
4 changes: 2 additions & 2 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,15 +1087,15 @@ var dryrunCmd = &cobra.Command{
if uint64(txn.Lsig.Len()) > params.LogicSigMaxSize {
reportErrorf("program size too large: %d > %d", len(txn.Lsig.Logic), params.LogicSigMaxSize)
}
ep := logic.EvalParams{Txn: &txn, Proto: &params, GroupIndex: i, TxnGroup: txgroup}
ep := logic.EvalParams{Txn: &txn, Proto: &params, GroupIndex: uint64(i), TxnGroup: txgroup}
err := logic.Check(txn.Lsig.Logic, ep)
if err != nil {
reportErrorf("program failed Check: %s", err)
}
sb := strings.Builder{}
ep = logic.EvalParams{
Txn: &txn,
GroupIndex: i,
GroupIndex: uint64(i),
Proto: &params,
Trace: &sb,
TxnGroup: txgroup,
Expand Down
10 changes: 5 additions & 5 deletions cmd/tealdbg/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ type evaluation struct {
source string
offsetToLine map[int]int
name string
groupIndex int
groupIndex uint64
pastSideEffects []logic.EvalSideEffects
mode modeType
aidx basics.AppIndex
Expand Down Expand Up @@ -387,7 +387,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
r.runs[i].source = source
}
}
r.runs[i].groupIndex = dp.GroupIndex
r.runs[i].groupIndex = uint64(dp.GroupIndex)
r.runs[i].pastSideEffects = dp.PastSideEffects
r.runs[i].name = dp.ProgramNames[i]

Expand Down Expand Up @@ -431,7 +431,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
if len(stxn.Lsig.Logic) > 0 {
run := evaluation{
program: stxn.Lsig.Logic,
groupIndex: gi,
groupIndex: uint64(gi),
mode: modeLogicsig,
}
r.runs = append(r.runs, run)
Expand All @@ -452,7 +452,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
}
run := evaluation{
program: stxn.Txn.ApprovalProgram,
groupIndex: gi,
groupIndex: uint64(gi),
pastSideEffects: dp.PastSideEffects,
mode: modeStateful,
aidx: appIdx,
Expand Down Expand Up @@ -488,7 +488,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
}
run := evaluation{
program: program,
groupIndex: gi,
groupIndex: uint64(gi),
pastSideEffects: dp.PastSideEffects,
mode: modeStateful,
aidx: appIdx,
Expand Down
26 changes: 13 additions & 13 deletions cmd/tealdbg/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func TestDebugFromPrograms(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.Nil(l.runs[0].ba)
a.Equal(modeLogicsig, l.runs[0].mode)
a.Empty(l.runs[0].aidx)
Expand All @@ -587,8 +587,8 @@ func TestDebugFromPrograms(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(2, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(0, l.runs[1].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[1].groupIndex)
a.Nil(l.runs[0].ba)
a.Equal(modeLogicsig, l.runs[0].mode)
a.Empty(l.runs[0].aidx)
Expand Down Expand Up @@ -617,7 +617,7 @@ func TestRunMode(t *testing.T) {
err := l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.NotNil(l.runs[0].ba)
a.Equal(modeStateful, l.runs[0].mode)
Expand All @@ -640,7 +640,7 @@ func TestRunMode(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Nil(l.runs[0].ba)
a.Equal(modeLogicsig, l.runs[0].mode)
Expand All @@ -659,7 +659,7 @@ func TestRunMode(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.NotNil(l.runs[0].ba)
a.Equal(modeStateful, l.runs[0].mode)
Expand All @@ -677,7 +677,7 @@ func TestRunMode(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Nil(l.runs[0].ba)
a.Equal(modeLogicsig, l.runs[0].mode)
Expand Down Expand Up @@ -738,7 +738,7 @@ func TestDebugFromTxn(t *testing.T) {
err = l.Setup(&dp)
a.NoError(err)
a.Equal(1, len(l.runs))
a.Equal(1, l.runs[0].groupIndex)
a.Equal(uint64(1), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{3}, l.runs[0].program)
a.Nil(l.runs[0].ba)
Expand All @@ -764,7 +764,7 @@ func TestDebugFromTxn(t *testing.T) {
a.NoError(err)
a.Equal(2, len(l.txnGroup))
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{1}, l.runs[0].program)
a.NotNil(l.runs[0].ba)
Expand All @@ -787,7 +787,7 @@ func TestDebugFromTxn(t *testing.T) {
a.NoError(err)
a.Equal(2, len(l.txnGroup))
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{1, 1}, l.runs[0].program)
a.NotNil(l.runs[0].ba)
Expand All @@ -812,7 +812,7 @@ func TestDebugFromTxn(t *testing.T) {
a.NoError(err)
a.Equal(1, len(l.txnGroup))
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{4}, l.runs[0].program)
a.NotNil(l.runs[0].ba)
Expand Down Expand Up @@ -949,7 +949,7 @@ func TestLocalBalanceAdapter(t *testing.T) {
a.NoError(err)
a.Equal(2, len(l.txnGroup))
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{1}, l.runs[0].program)
a.NotNil(l.runs[0].ba)
Expand Down Expand Up @@ -1039,7 +1039,7 @@ func TestLocalBalanceAdapterIndexer(t *testing.T) {
a.NoError(err)
a.Equal(2, len(l.txnGroup))
a.Equal(1, len(l.runs))
a.Equal(0, l.runs[0].groupIndex)
a.Equal(uint64(0), l.runs[0].groupIndex)
a.NotNil(l.runs[0].eval)
a.Equal([]byte{1}, l.runs[0].program)
a.NotNil(l.runs[0].ba)
Expand Down
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func doDryrunRequest(dr *DryrunRequest, response *generated.DryrunResponse) {
Txn: &stxn,
Proto: &proto,
TxnGroup: dr.Txns,
GroupIndex: ti,
GroupIndex: uint64(ti),
PastSideEffects: pse,
PooledApplicationBudget: &pooledAppBudget,
}
Expand Down
10 changes: 6 additions & 4 deletions data/transactions/logic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,21 @@ Some of these have immediate data in the byte or bytes after the opcode.
| `txn f` | push field F of current transaction to stack |
| `gtxn t f` | push field F of the Tth transaction in the current group |
| `txna f i` | push Ith value of the array field F of the current transaction |
| `txnas f` | push Xth value of the array field F of the current transaction |
| `gtxna t f i` | push Ith value of the array field F from the Tth transaction in the current group |
| `gtxnas t f` | push Xth value of the array field F from the Tth transaction in the current group |
| `gtxns f` | push field F of the Xth transaction in the current group |
| `gtxnsa f i` | push Ith value of the array field F from the Xth transaction in the current group |
| `gtxnsas f` | pop an index A and an index B. push Bth value of the array field F from the Ath transaction in the current group |
| `global f` | push value from globals to stack |
| `load i` | copy a value from scratch space to the stack |
| `store i` | pop a value from the stack and store to scratch space |
| `loads` | copy a value from the Xth scratch space to the stack |
| `store i` | pop value X. store X to the Ith scratch space |
| `stores` | pop indexes A and B. store B to the Ath scratch space |
| `gload t i` | push Ith scratch space index of the Tth transaction in the current group |
| `gloads i` | push Ith scratch space index of the Xth transaction in the current group |
| `gaid t` | push the ID of the asset or application created in the Tth transaction of the current group |
| `gaids` | push the ID of the asset or application created in the Xth transaction of the current group |
| `txnas f` | push Xth value of the array field F of the current transaction |
| `gtxnas t f` | push Xth value of the array field F from the Tth transaction in the current group |
| `gtxnsas f` | pop an index A and an index B. push Bth value of the array field F from the Ath transaction in the current group |
| `args` | push Xth LogicSig argument to stack |

**Transaction Fields**
Expand Down
18 changes: 17 additions & 1 deletion data/transactions/logic/TEAL_opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ for notes on transaction fields available, see `txn`. If this transaction is _i_
- Opcode: 0x35 {uint8 position in scratch space to store to}
- Pops: *... stack*, any
- Pushes: _None_
- pop a value from the stack and store to scratch space
- pop value X. store X to the Ith scratch space

## txna f i

Expand Down Expand Up @@ -569,6 +569,22 @@ for notes on transaction fields available, see `txn`. If top of stack is _i_, `g

`gaids` fails unless the requested transaction created an asset or application and X < GroupIndex.

## loads

- Opcode: 0x3e
- Pops: *... stack*, uint64
- Pushes: any
- copy a value from the Xth scratch space to the stack
- LogicSigVersion >= 5

## stores

- Opcode: 0x3f
- Pops: *... stack*, {uint64 A}, {any B}
- Pushes: _None_
- pop indexes A and B. store B to the Ath scratch space
- LogicSigVersion >= 5

## bnz target

- Opcode: 0x40 {int16 branch offset, big endian}
Expand Down
Loading