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

Simulate: Add State Change to Exec Trace #5659

Merged
merged 19 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
simulateEnableRequestTrace bool
simulateStackChange bool
simulateScratchChange bool
simulateAppStateChange bool
simulateAllowUnnamedResources bool
)

Expand Down Expand Up @@ -172,6 +173,7 @@
simulateCmd.Flags().BoolVar(&simulateEnableRequestTrace, "trace", false, "Enable simulation time execution trace of app calls")
simulateCmd.Flags().BoolVar(&simulateStackChange, "stack", false, "Report stack change during simulation time")
simulateCmd.Flags().BoolVar(&simulateScratchChange, "scratch", false, "Report scratch change during simulation time")
simulateCmd.Flags().BoolVar(&simulateAppStateChange, "state", false, "Report application state changes during simulation time")
simulateCmd.Flags().BoolVar(&simulateAllowUnnamedResources, "allow-unnamed-resources", false, "Allow access to unnamed resources during simulation")
}

Expand Down Expand Up @@ -1380,11 +1382,13 @@
Enable: true,
Stack: true,
Scratch: true,
State: true,

Check warning on line 1385 in cmd/goal/clerk.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/clerk.go#L1385

Added line #L1385 was not covered by tests
}
}
traceConfig.Enable = traceConfig.Enable || simulateEnableRequestTrace
traceConfig.Stack = traceConfig.Stack || simulateStackChange
traceConfig.Scratch = traceConfig.Scratch || simulateScratchChange
traceConfig.State = traceConfig.State || simulateAppStateChange

Check warning on line 1391 in cmd/goal/clerk.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/clerk.go#L1391

Added line #L1391 was not covered by tests

return traceConfig
}
42 changes: 42 additions & 0 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3684,6 +3684,10 @@
"scratch-change": {
"description": "A boolean option enabling returning scratch slot changes together with execution trace during simulation.",
"type": "boolean"
},
"state-change": {
"description": "A boolean option enabling returning application state changes (global, local, and box changes) with the execution trace during simulation.",
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -4092,6 +4096,37 @@
}
}
},
"ApplicationStateOperation": {
"description": "An operation against an application's global/local/box state.",
"required": [
"operation",
"app-state-type",
"key"
],
"properties": {
"operation": {
"description": "Operation type. Value `w` is **write**, `d` is **delete**.",
"type": "string"
},
"app-state-type": {
"description": "Type of application state. Value `g` is **global state**, `l` is **local state**, `b` is **boxes**.",
ahangsu marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
},
"key": {
"description": "The key (name) of the global/local/box state.",
"type": "string",
"format": "byte"
},
"new-value": {
"$ref": "#/definitions/AvmValue"
},
"account": {
"description": "For local state changes, the address of the account associated with the local state.",
"type": "string",
"x-algorand-format": "Address"
}
}
},
"SimulationOpcodeTraceUnit": {
"description": "The set of trace information and effect from evaluating a single opcode.",
"type": "object",
Expand All @@ -4110,6 +4145,13 @@
"$ref": "#/definitions/ScratchChange"
}
},
"state-changes": {
"description": "The operations against the current application's states.",
"type": "array",
"items": {
"$ref": "#/definitions/ApplicationStateOperation"
}
},
"spawned-inners": {
"description": "The indexes of the traces for inner transactions spawned by this opcode, if any.",
"type": "array",
Expand Down
44 changes: 44 additions & 0 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,39 @@
],
"type": "object"
},
"ApplicationStateOperation": {
"description": "An operation against an application's global/local/box state.",
"properties": {
"account": {
"description": "For local state changes, the address of the account associated with the local state.",
"type": "string",
"x-algorand-format": "Address"
},
"app-state-type": {
"description": "Type of application state. Value `g` is **global state**, `l` is **local state**, `b` is **boxes**.",
"type": "string"
},
"key": {
"description": "The key (name) of the global/local/box state.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"new-value": {
"$ref": "#/components/schemas/AvmValue"
},
"operation": {
"description": "Operation type. Value `w` is **write**, `d` is **delete**.",
"type": "string"
}
},
"required": [
"app-state-type",
"key",
"operation"
],
"type": "object"
},
"ApplicationStateSchema": {
"description": "Specifies maximums on the number of each type that may be stored.",
"properties": {
Expand Down Expand Up @@ -2101,6 +2134,10 @@
"stack-change": {
"description": "A boolean option enabling returning stack changes together with execution trace during simulation.",
"type": "boolean"
},
"state-change": {
"description": "A boolean option enabling returning application state changes (global, local, and box changes) with the execution trace during simulation.",
"type": "boolean"
}
},
"type": "object"
Expand Down Expand Up @@ -2281,6 +2318,13 @@
"stack-pop-count": {
"description": "The number of deleted stack values by this opcode.",
"type": "integer"
},
"state-changes": {
"description": "The operations against the current application's states.",
"items": {
"$ref": "#/components/schemas/ApplicationStateOperation"
},
"type": "array"
}
},
"required": [
Expand Down
6 changes: 3 additions & 3 deletions daemon/algod/api/server/v2/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,11 @@ func AssetParamsToAsset(creator string, idx basics.AssetIndex, params *basics.As
Decimals: uint64(params.Decimals),
DefaultFrozen: &frozen,
Name: omitEmpty(printableUTF8OrEmpty(params.AssetName)),
NameB64: byteOrNil([]byte(params.AssetName)),
NameB64: sliceOrNil([]byte(params.AssetName)),
UnitName: omitEmpty(printableUTF8OrEmpty(params.UnitName)),
UnitNameB64: byteOrNil([]byte(params.UnitName)),
UnitNameB64: sliceOrNil([]byte(params.UnitName)),
Url: omitEmpty(printableUTF8OrEmpty(params.URL)),
UrlB64: byteOrNil([]byte(params.URL)),
UrlB64: sliceOrNil([]byte(params.URL)),
Clawback: addrOrNil(params.Clawback),
Freeze: addrOrNil(params.Freeze),
Manager: addrOrNil(params.Manager),
Expand Down