Skip to content

Commit b465587

Browse files
committed
loads and stores opcodes that take scratch slot from stack
1 parent cde7eed commit b465587

File tree

16 files changed

+200
-116
lines changed

16 files changed

+200
-116
lines changed

cmd/goal/clerk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,15 +1087,15 @@ var dryrunCmd = &cobra.Command{
10871087
if uint64(txn.Lsig.Len()) > params.LogicSigMaxSize {
10881088
reportErrorf("program size too large: %d > %d", len(txn.Lsig.Logic), params.LogicSigMaxSize)
10891089
}
1090-
ep := logic.EvalParams{Txn: &txn, Proto: &params, GroupIndex: i, TxnGroup: txgroup}
1090+
ep := logic.EvalParams{Txn: &txn, Proto: &params, GroupIndex: uint64(i), TxnGroup: txgroup}
10911091
err := logic.Check(txn.Lsig.Logic, ep)
10921092
if err != nil {
10931093
reportErrorf("program failed Check: %s", err)
10941094
}
10951095
sb := strings.Builder{}
10961096
ep = logic.EvalParams{
10971097
Txn: &txn,
1098-
GroupIndex: i,
1098+
GroupIndex: uint64(i),
10991099
Proto: &params,
11001100
Trace: &sb,
11011101
TxnGroup: txgroup,

cmd/tealdbg/local.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ type evaluation struct {
209209
source string
210210
offsetToLine map[int]int
211211
name string
212-
groupIndex int
212+
groupIndex uint64
213213
pastSideEffects []logic.EvalSideEffects
214214
mode modeType
215215
aidx basics.AppIndex
@@ -387,7 +387,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
387387
r.runs[i].source = source
388388
}
389389
}
390-
r.runs[i].groupIndex = dp.GroupIndex
390+
r.runs[i].groupIndex = uint64(dp.GroupIndex)
391391
r.runs[i].pastSideEffects = dp.PastSideEffects
392392
r.runs[i].name = dp.ProgramNames[i]
393393

@@ -431,7 +431,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
431431
if len(stxn.Lsig.Logic) > 0 {
432432
run := evaluation{
433433
program: stxn.Lsig.Logic,
434-
groupIndex: gi,
434+
groupIndex: uint64(gi),
435435
mode: modeLogicsig,
436436
}
437437
r.runs = append(r.runs, run)
@@ -452,7 +452,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
452452
}
453453
run := evaluation{
454454
program: stxn.Txn.ApprovalProgram,
455-
groupIndex: gi,
455+
groupIndex: uint64(gi),
456456
pastSideEffects: dp.PastSideEffects,
457457
mode: modeStateful,
458458
aidx: appIdx,
@@ -488,7 +488,7 @@ func (r *LocalRunner) Setup(dp *DebugParams) (err error) {
488488
}
489489
run := evaluation{
490490
program: program,
491-
groupIndex: gi,
491+
groupIndex: uint64(gi),
492492
pastSideEffects: dp.PastSideEffects,
493493
mode: modeStateful,
494494
aidx: appIdx,

cmd/tealdbg/local_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func TestDebugFromPrograms(t *testing.T) {
571571
err = l.Setup(&dp)
572572
a.NoError(err)
573573
a.Equal(1, len(l.runs))
574-
a.Equal(0, l.runs[0].groupIndex)
574+
a.Equal(uint64(0), l.runs[0].groupIndex)
575575
a.Nil(l.runs[0].ba)
576576
a.Equal(modeLogicsig, l.runs[0].mode)
577577
a.Empty(l.runs[0].aidx)
@@ -587,8 +587,8 @@ func TestDebugFromPrograms(t *testing.T) {
587587
err = l.Setup(&dp)
588588
a.NoError(err)
589589
a.Equal(2, len(l.runs))
590-
a.Equal(0, l.runs[0].groupIndex)
591-
a.Equal(0, l.runs[1].groupIndex)
590+
a.Equal(uint64(0), l.runs[0].groupIndex)
591+
a.Equal(uint64(0), l.runs[1].groupIndex)
592592
a.Nil(l.runs[0].ba)
593593
a.Equal(modeLogicsig, l.runs[0].mode)
594594
a.Empty(l.runs[0].aidx)
@@ -617,7 +617,7 @@ func TestRunMode(t *testing.T) {
617617
err := l.Setup(&dp)
618618
a.NoError(err)
619619
a.Equal(1, len(l.runs))
620-
a.Equal(0, l.runs[0].groupIndex)
620+
a.Equal(uint64(0), l.runs[0].groupIndex)
621621
a.NotNil(l.runs[0].eval)
622622
a.NotNil(l.runs[0].ba)
623623
a.Equal(modeStateful, l.runs[0].mode)
@@ -640,7 +640,7 @@ func TestRunMode(t *testing.T) {
640640
err = l.Setup(&dp)
641641
a.NoError(err)
642642
a.Equal(1, len(l.runs))
643-
a.Equal(0, l.runs[0].groupIndex)
643+
a.Equal(uint64(0), l.runs[0].groupIndex)
644644
a.NotNil(l.runs[0].eval)
645645
a.Nil(l.runs[0].ba)
646646
a.Equal(modeLogicsig, l.runs[0].mode)
@@ -659,7 +659,7 @@ func TestRunMode(t *testing.T) {
659659
err = l.Setup(&dp)
660660
a.NoError(err)
661661
a.Equal(1, len(l.runs))
662-
a.Equal(0, l.runs[0].groupIndex)
662+
a.Equal(uint64(0), l.runs[0].groupIndex)
663663
a.NotNil(l.runs[0].eval)
664664
a.NotNil(l.runs[0].ba)
665665
a.Equal(modeStateful, l.runs[0].mode)
@@ -677,7 +677,7 @@ func TestRunMode(t *testing.T) {
677677
err = l.Setup(&dp)
678678
a.NoError(err)
679679
a.Equal(1, len(l.runs))
680-
a.Equal(0, l.runs[0].groupIndex)
680+
a.Equal(uint64(0), l.runs[0].groupIndex)
681681
a.NotNil(l.runs[0].eval)
682682
a.Nil(l.runs[0].ba)
683683
a.Equal(modeLogicsig, l.runs[0].mode)
@@ -738,7 +738,7 @@ func TestDebugFromTxn(t *testing.T) {
738738
err = l.Setup(&dp)
739739
a.NoError(err)
740740
a.Equal(1, len(l.runs))
741-
a.Equal(1, l.runs[0].groupIndex)
741+
a.Equal(uint64(1), l.runs[0].groupIndex)
742742
a.NotNil(l.runs[0].eval)
743743
a.Equal([]byte{3}, l.runs[0].program)
744744
a.Nil(l.runs[0].ba)
@@ -764,7 +764,7 @@ func TestDebugFromTxn(t *testing.T) {
764764
a.NoError(err)
765765
a.Equal(2, len(l.txnGroup))
766766
a.Equal(1, len(l.runs))
767-
a.Equal(0, l.runs[0].groupIndex)
767+
a.Equal(uint64(0), l.runs[0].groupIndex)
768768
a.NotNil(l.runs[0].eval)
769769
a.Equal([]byte{1}, l.runs[0].program)
770770
a.NotNil(l.runs[0].ba)
@@ -787,7 +787,7 @@ func TestDebugFromTxn(t *testing.T) {
787787
a.NoError(err)
788788
a.Equal(2, len(l.txnGroup))
789789
a.Equal(1, len(l.runs))
790-
a.Equal(0, l.runs[0].groupIndex)
790+
a.Equal(uint64(0), l.runs[0].groupIndex)
791791
a.NotNil(l.runs[0].eval)
792792
a.Equal([]byte{1, 1}, l.runs[0].program)
793793
a.NotNil(l.runs[0].ba)
@@ -812,7 +812,7 @@ func TestDebugFromTxn(t *testing.T) {
812812
a.NoError(err)
813813
a.Equal(1, len(l.txnGroup))
814814
a.Equal(1, len(l.runs))
815-
a.Equal(0, l.runs[0].groupIndex)
815+
a.Equal(uint64(0), l.runs[0].groupIndex)
816816
a.NotNil(l.runs[0].eval)
817817
a.Equal([]byte{4}, l.runs[0].program)
818818
a.NotNil(l.runs[0].ba)
@@ -949,7 +949,7 @@ func TestLocalBalanceAdapter(t *testing.T) {
949949
a.NoError(err)
950950
a.Equal(2, len(l.txnGroup))
951951
a.Equal(1, len(l.runs))
952-
a.Equal(0, l.runs[0].groupIndex)
952+
a.Equal(uint64(0), l.runs[0].groupIndex)
953953
a.NotNil(l.runs[0].eval)
954954
a.Equal([]byte{1}, l.runs[0].program)
955955
a.NotNil(l.runs[0].ba)
@@ -1039,7 +1039,7 @@ func TestLocalBalanceAdapterIndexer(t *testing.T) {
10391039
a.NoError(err)
10401040
a.Equal(2, len(l.txnGroup))
10411041
a.Equal(1, len(l.runs))
1042-
a.Equal(0, l.runs[0].groupIndex)
1042+
a.Equal(uint64(0), l.runs[0].groupIndex)
10431043
a.NotNil(l.runs[0].eval)
10441044
a.Equal([]byte{1}, l.runs[0].program)
10451045
a.NotNil(l.runs[0].ba)

daemon/algod/api/server/v2/dryrun.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func doDryrunRequest(dr *DryrunRequest, response *generated.DryrunResponse) {
420420
Txn: &stxn,
421421
Proto: &proto,
422422
TxnGroup: dr.Txns,
423-
GroupIndex: ti,
423+
GroupIndex: uint64(ti),
424424
PastSideEffects: pse,
425425
PooledApplicationBudget: &pooledAppBudget,
426426
}

data/transactions/logic/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,21 @@ Some of these have immediate data in the byte or bytes after the opcode.
233233
| `txn f` | push field F of current transaction to stack |
234234
| `gtxn t f` | push field F of the Tth transaction in the current group |
235235
| `txna f i` | push Ith value of the array field F of the current transaction |
236+
| `txnas f` | push Xth value of the array field F of the current transaction |
236237
| `gtxna t f i` | push Ith value of the array field F from the Tth transaction in the current group |
238+
| `gtxnas t f` | push Xth value of the array field F from the Tth transaction in the current group |
237239
| `gtxns f` | push field F of the Xth transaction in the current group |
238240
| `gtxnsa f i` | push Ith value of the array field F from the Xth transaction in the current group |
241+
| `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 |
239242
| `global f` | push value from globals to stack |
240243
| `load i` | copy a value from scratch space to the stack |
241-
| `store i` | pop a value from the stack and store to scratch space |
244+
| `loads` | copy a value from the Xth scratch space to the stack |
245+
| `store i` | pop value X. store X to the Ith scratch space |
246+
| `stores` | pop indexes A and B. store A to the Bth scratch space |
242247
| `gload t i` | push Ith scratch space index of the Tth transaction in the current group |
243248
| `gloads i` | push Ith scratch space index of the Xth transaction in the current group |
244249
| `gaid t` | push the ID of the asset or application created in the Tth transaction of the current group |
245250
| `gaids` | push the ID of the asset or application created in the Xth transaction of the current group |
246-
| `txnas f` | push Xth value of the array field F of the current transaction |
247-
| `gtxnas t f` | push Xth value of the array field F from the Tth transaction in the current group |
248-
| `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 |
249251
| `args` | push Xth LogicSig argument to stack |
250252

251253
**Transaction Fields**

data/transactions/logic/TEAL_opcodes.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ for notes on transaction fields available, see `txn`. If this transaction is _i_
489489
- Opcode: 0x35 {uint8 position in scratch space to store to}
490490
- Pops: *... stack*, any
491491
- Pushes: _None_
492-
- pop a value from the stack and store to scratch space
492+
- pop value X. store X to the Ith scratch space
493493

494494
## txna f i
495495

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

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

572+
## loads
573+
574+
- Opcode: 0x3e
575+
- Pops: *... stack*, uint64
576+
- Pushes: any
577+
- copy a value from the Xth scratch space to the stack
578+
- LogicSigVersion >= 5
579+
580+
## stores
581+
582+
- Opcode: 0x3f
583+
- Pops: *... stack*, {any A}, {uint64 B}
584+
- Pushes: _None_
585+
- pop indexes A and B. store A to the Bth scratch space
586+
- LogicSigVersion >= 5
587+
572588
## bnz target
573589

574590
- Opcode: 0x40 {int16 branch offset, big endian}

0 commit comments

Comments
 (0)