Skip to content

Commit d2594fb

Browse files
authored
Feature/contract to contract (#3395)
* Three new globals for to help contract-to-contract usability * detritis * Check error * doc comments * Impose limits on the entire "tree" of inner calls. This also increases the realism of testing of multiple app calls in a group by creating the EvalParams with the real constructor, thus getting the pooling stuff tested here without playing games manipulating the ep after construction. * Move appID tracking into EvalContext, out of LedgerForLogic This change increases the seperation between AVM execution and the ledger being used to lookup resources. Previously, the ledger kept track of the appID being executed, to offer a narrower interface to those resources. But now, with app-to-app calls, the appID being executed must change, and the AVM needs to maintain the current appID. * Stupid linter * Fix unit tests error messages * Allow access to resources created in the same transaction group The method will be reworked, but the tests are correct and want to get them visible to team. * Access to apps created in group Also adds some tests that are currently skipped for testing - access to addresses of newly created apps - use of gaid in inner transactions Both require some work to implement the thing being tested. * Remove tracked created mechanism in favor of examining applydata. * Allow v6 AVM code to use in-group created asas, apps (& their accts) One exception - apps can not mutate (put or del) keys from the app accounts, because EvalDelta cannot encode such changes. * lint docs * typo * The review dog needs obedience training. * Use one EvalParams for logic evals, another for apps in dry run We used to use one ep per transaction, shared between sig and and app. But the new model of ep usage is to keep using one while evaluating an entire group. The app ep is now built logic.NewAppEvalParams which, hopefully, will prevent some bugs when we change something in the EvalParams and don't reflect it in what was a "raw" EvalParams construction in debugger and dry run. * Use logic.NewAppEvalParams to decrease copying and bugs in debugger * Simplify use of NewEvalParams. No more nil return when no apps. This way, NewEvalParams can be used for all creations of EvalParams, whether they are intended for logicsig or app use, greatly simplifying the way we make them for use by dry run or debugger (where they serve double duty). * Remove explicit PastSideEffects handling in tealdbg * Always create EvalParams to evaluate a transaction group. We used to have an optimization to avoid creating EvalParams unless there was an app call in the transaction group. But the interface to allow transaction processing to communicate changes into the EvalParams is complicated by that (we must only do it if there is one!) This also allows us to use the same construction function for eps created for app and logic evaluation, simplifying dry-run and debugger. The optimization is less needed now anyway: 1) The ep is now shared for the whole group, so it's only one. 2) The ep is smaller now, as we only store nil pointers instead of larger scratch space objects for non-app calls. * Correct mistaken commit * Spec improvments * More spec improvments, including resource "availability" * Recursively return inner transaction tree * Lint * No need for ConfirmedRound, so don't deref a nil pointer! * license check * Shut up, dawg. * base64 merge cleanup
1 parent 4e717ce commit d2594fb

File tree

3 files changed

+10
-61
lines changed

3 files changed

+10
-61
lines changed

data/transactions/logic/TEAL_opcodes.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -778,17 +778,6 @@ When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on
778778

779779
Decodes A using the base64 encoding E. Specify the encoding with an immediate arg either as URL and Filename Safe (`URLEncoding`) or Standard (`StdEncoding`). See <a href="https://rfc-editor.org/rfc/rfc4648.html#section-4">RFC 4648</a> (sections 4 and 5). It is assumed that the encoding ends with the exact number of `=` padding characters as required by the RFC. When padding occurs, any unused pad bits in the encoding must be set to zero or the decoding will fail. The special cases of `\n` and `\r` are allowed but completely ignored. An error will result when attempting to decode a string with a character that is not in the encoding alphabet or not one of `=`, `\r`, or `\n`.
780780

781-
## base64_decode e
782-
783-
- Opcode: 0x5c {uint8 encoding index}
784-
- Pops: *... stack*, []byte
785-
- Pushes: []byte
786-
- decode X which was base64-encoded using _encoding_ E. Fail if X is not base64 encoded with encoding E
787-
- **Cost**: 25
788-
- LogicSigVersion >= 6
789-
790-
Decodes X using the base64 encoding E. Specify the encoding with an immediate arg either as URL and Filename Safe (`URLEncoding`) or Standard (`StdEncoding`). See <a href="https://rfc-editor.org/rfc/rfc4648.html#section-4">RFC 4648</a> (sections 4 and 5). It is assumed that the encoding ends with the exact number of `=` padding characters as required by the RFC. When padding occurs, any unused pad bits in the encoding must be set to zero or the decoding will fail. The special cases of `\n` and `\r` are allowed but completely ignored. An error will result when attempting to decode a string with a character that is not in the encoding alphabet or not one of `=`, `\r`, or `\n`.
791-
792781
## balance
793782

794783
- Opcode: 0x60

data/transactions/logic/doc.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,6 @@ var globalFieldDocs = map[string]string{
482482
"CallerApplicationAddress": "The application address of the application that called this application. ZeroAddress if this application is at the top-level.",
483483
}
484484

485-
type extractor interface {
486-
getExtraFor(string) string
487-
}
488-
489485
func addExtra(original string, extra string) string {
490486
if len(original) == 0 {
491487
return extra
@@ -500,15 +496,6 @@ func addExtra(original string, extra string) string {
500496
return original + sep + extra
501497
}
502498

503-
func fieldsDocWithExtra(source map[string]string, ex extractor) map[string]string {
504-
result := make(map[string]string, len(source))
505-
for name, doc := range source {
506-
extra := ex.getExtraFor(name)
507-
result[name] = addExtra(doc, extra)
508-
}
509-
return result
510-
}
511-
512499
// AssetHoldingFieldDocs are notes on fields available in `asset_holding_get`
513500
var assetHoldingFieldDocs = map[string]string{
514501
"AssetBalance": "Amount of the asset unit held by this account",

data/transactions/logic/fields.go

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package logic
1818

1919
import (
20-
"fmt"
21-
2220
"github.com/algorand/go-algorand/data/transactions"
2321
"github.com/algorand/go-algorand/protocol"
2422
)
@@ -557,49 +555,24 @@ var base64EncodingSpecByName base64EncodingSpecMap
557555

558556
type base64EncodingSpecMap map[string]base64EncodingSpec
559557

560-
func (s base64EncodingSpecMap) getExtraFor(name string) (extra string) {
561-
// Uses 6 here because base64_decode fields were introduced in 6
562-
if s[name].version > 6 {
563-
extra = fmt.Sprintf("Introduced v%d.", s[name].version)
564-
}
565-
return
558+
func (fs *base64EncodingSpec) Type() StackType {
559+
return fs.ftype
566560
}
567561

568-
// Base64Encoding is an enum for the `base64decode` opcode
569-
type Base64Encoding int
570-
571-
const (
572-
// URLEncoding represents the base64url encoding defined in https://www.rfc-editor.org/rfc/rfc4648.html
573-
URLEncoding Base64Encoding = iota
574-
// StdEncoding represents the standard encoding of the RFC
575-
StdEncoding
576-
invalidBase64Alphabet
577-
)
578-
579-
// After running `go generate` these strings will be available:
580-
var base64EncodingNames [2]string = [...]string{URLEncoding.String(), StdEncoding.String()}
581-
582-
type base64EncodingSpec struct {
583-
field Base64Encoding
584-
ftype StackType
585-
version uint64
562+
func (fs *base64EncodingSpec) OpVersion() uint64 {
563+
return 6
586564
}
587565

588-
var base64EncodingSpecs = []base64EncodingSpec{
589-
{URLEncoding, StackBytes, 6},
590-
{StdEncoding, StackBytes, 6},
566+
func (fs *base64EncodingSpec) Version() uint64 {
567+
return fs.version
591568
}
592569

593-
var base64EncodingSpecByField map[Base64Encoding]base64EncodingSpec
594-
var base64EncodingSpecByName base64EncodingSpecMap
595-
596-
type base64EncodingSpecMap map[string]base64EncodingSpec
597-
570+
func (fs *base64EncodingSpec) Note() string {
571+
note := "" // no doc list?
572+
return note
573+
}
598574
func (s base64EncodingSpecMap) getExtraFor(name string) (extra string) {
599575
// Uses 6 here because base64_decode fields were introduced in 6
600-
if s[name].version > 6 {
601-
extra = fmt.Sprintf("LogicSigVersion >= %d.", s[name].version)
602-
}
603576
return
604577
}
605578

0 commit comments

Comments
 (0)