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

Algod: Replace logic.DebuggerHook with logic.EvalTracer interface #4438

Merged
merged 139 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
8f840dc
Add simulate endpoint to OpenAPI file
jdtzmn Jul 20, 2022
62f4b59
Basic simulation endpoint with failure message
jdtzmn Jul 25, 2022
505bc50
Return msgpack response instead of JSON
jdtzmn Jul 26, 2022
58846a3
Test Simulator class with basic pay transactions
jdtzmn Jul 27, 2022
e242bc4
Use genesis methods for block header creation
jdtzmn Jul 27, 2022
63805af
Test simple group transaction
jdtzmn Jul 27, 2022
5d93ceb
Trivial app create and call test
jdtzmn Jul 27, 2022
2c8c912
Remove budget error gatekeeping for now
jdtzmn Jul 27, 2022
b9f96ee
Add invalid signature check
jdtzmn Jul 28, 2022
e52d1bf
Lowercase simulate test methods to make them private
jdtzmn Jul 28, 2022
a9f4d1a
Add balance change test
jdtzmn Jul 28, 2022
8a54d2e
Merge branch 'feature/simulate-endpoint' into psuedo-eval-endpoint
jdtzmn Jul 29, 2022
301a366
Implement newly included ledger methods introduced in the merge
jdtzmn Jul 29, 2022
06d0063
Fix unkeyed struct fields
jdtzmn Jul 29, 2022
0631333
Fix golint errors
jdtzmn Jul 29, 2022
7f0b564
Spec file changes
jdtzmn Aug 1, 2022
6e5c9ce
Use new flag for configuring simulation endpoint visibility
jdtzmn Aug 2, 2022
64567aa
Check node status separately from transaction decoding
jdtzmn Aug 2, 2022
fc76cb2
Write interface annotations
jdtzmn Aug 2, 2022
760bbfb
Add docstring to MakeLedgerForRound
jdtzmn Aug 2, 2022
cc6e605
Use error type to fix fragile signature error check
jdtzmn Aug 2, 2022
c51926f
Fix signature check and add invalid signature test
jdtzmn Aug 2, 2022
deb330f
Test reject app call
jdtzmn Aug 2, 2022
19cdb73
Disable transaction simulator by default
jdtzmn Aug 4, 2022
462a9dd
Fix API spec descriptions
jdtzmn Aug 5, 2022
b2c4f51
Improve `decodeTxGroup`
jdtzmn Aug 4, 2022
6ec12f1
Clean up simulator ledger
jdtzmn Aug 5, 2022
b5473ae
Add invalid transaction group test
jdtzmn Aug 5, 2022
307709d
Make `SignatureError` a struct
jdtzmn Aug 5, 2022
7995700
Cleanup simulator tests
jdtzmn Aug 5, 2022
02d0947
Remove “contact us” language and cut helper function used in only one…
jdtzmn Aug 5, 2022
a3e0f59
Handle returned error from `attachGroupID`
jdtzmn Aug 5, 2022
dad0197
Cleaner implementation by going through `Node` instead of `LedgerForAPI`
jdtzmn Aug 8, 2022
ac72228
Rename `makeSimulateEnv` to `prepareSimulatorTest`
jdtzmn Aug 8, 2022
50304a3
Use `MissingSignatures` boolean instead of `SignatureFailureMessage`
jdtzmn Aug 8, 2022
33dda59
Implement renamed `MissingSignatures`
jdtzmn Aug 8, 2022
f1c0b05
Improve Simulator `check` to catch badly formed transactions when sig…
jdtzmn Aug 8, 2022
f90c19a
Document allowing unsigned transactions
jdtzmn Aug 8, 2022
394f7e7
Correctly catch CompactCert special case
jdtzmn Aug 9, 2022
be38467
Simplify TxnIsMissingSig logic
jdtzmn Aug 9, 2022
970d9f4
Fix linter errors
jdtzmn Aug 9, 2022
595ca6b
Refactor Simulator to be more general
jdtzmn Aug 9, 2022
5f45dfe
Deprecate no longer needed `SimulationResult`
jdtzmn Aug 9, 2022
7897a2e
Fix shortened property names in API spec
jdtzmn Aug 9, 2022
051cbef
Test pooled fees
jdtzmn Aug 9, 2022
65cba5c
Support verifying transaction groups with missing signatures
jdtzmn Aug 9, 2022
b78e899
Test non-overriden `data.Ledger` methods used during evaluation have …
jdtzmn Aug 9, 2022
7324c0e
Redesign DebuggerHook to support more hooks
jdtzmn Jul 29, 2022
ad3be73
Remove unnecessary cx.Debugger checks
jdtzmn Jul 29, 2022
2176d2d
Support `afterTealOp` hook
jdtzmn Jul 29, 2022
cb381d8
Fix test name typo
jdtzmn Aug 10, 2022
195ac07
Support `beforeInnerTxn` and `afterInnerTxn` hooks
jdtzmn Aug 11, 2022
e2eb402
Support `beforeTxn` and `afterTxn` hooks
jdtzmn Aug 11, 2022
2d92ad4
Return error in `LookupLatest` override since panics within API handl…
jdtzmn Aug 10, 2022
2f189d2
Add missing `PartitionTest()`
jdtzmn Aug 11, 2022
5bf32e7
Improve test step description
jdtzmn Aug 12, 2022
c7996d3
Favor explicit returns within `txnGroupBatchVerify`
jdtzmn Aug 18, 2022
08f8e5e
Remove unused `ScopedSimulatorError` artifact
jdtzmn Aug 18, 2022
f16d378
Fix dryrun hooks and docstrings
jdtzmn Aug 18, 2022
83fae5c
Fix incorrect debugger hooks lifecycle test
jdtzmn Aug 18, 2022
2a30a89
Implement additional `BeforeTxn` and `AfterTxn` responsibilities
jdtzmn Aug 18, 2022
f32981a
Rename inner transaction hooks and add documentation
jdtzmn Aug 18, 2022
8c90301
Fix dryrun debugger hooks so the logic stays consistent with previous…
jdtzmn Aug 18, 2022
251cc15
Use correctly named debugger hooks within the TEAL debugger
jdtzmn Aug 18, 2022
9bbd757
Fix tealdbg debugger hooks so the logic stays consistent with previou…
jdtzmn Aug 18, 2022
b9acbf7
Fix unnecessary calls to `cx.refreshDebugState`
jdtzmn Aug 18, 2022
0c99043
Support LogicSigs within `logic.DebuggerHook`
jdtzmn Aug 18, 2022
6e448a8
Remove extra space (#4435)
jdtzmn Aug 19, 2022
139672a
Undo changes to txn verification code, use proxy signer instead
jasonpaulos Aug 23, 2022
6ad7387
More simulator tests
jasonpaulos Aug 23, 2022
47e83dc
Merge branch 'master' into psuedo-eval-endpoint
jasonpaulos Aug 23, 2022
ba5d43e
Fix merge issues
jasonpaulos Aug 23, 2022
82f31c8
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Aug 23, 2022
d3e4253
Merge branch 'feature/simulate-endpoint' into psuedo-eval-endpoint
jasonpaulos Aug 23, 2022
bf3907b
Revert unintended change
jasonpaulos Aug 23, 2022
1e518be
Not sure what happened, but fix routes again
jasonpaulos Aug 23, 2022
5da2cd8
Merge branch 'psuedo-eval-endpoint' into extend-debugger-interface
jasonpaulos Aug 24, 2022
e7ce7fc
Add comments about future LogicSig support
jasonpaulos Aug 24, 2022
6e106ba
Merge branch 'psuedo-eval-endpoint' into extend-debugger-interface
jasonpaulos Aug 24, 2022
75d5326
Rename TxnGroupForDebugger -> TxnGroupWithDebugger
jasonpaulos Aug 24, 2022
dd27558
Fix debugger not being able to handle logicsigs
jasonpaulos Aug 24, 2022
4cf359e
godog
jasonpaulos Aug 24, 2022
042704a
Make a copy of the txgroup when checking sigs
jasonpaulos Aug 29, 2022
ca59421
CR feedback
jasonpaulos Aug 29, 2022
a0a0550
Merge pull request #4322 from jdtzmn/psuedo-eval-endpoint
jasonpaulos Aug 29, 2022
6673103
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Aug 29, 2022
488d748
Split debugger code into current and legacy
jasonpaulos Aug 30, 2022
ce98909
Separate debugger tests better and fix error
jasonpaulos Aug 30, 2022
8bdbd5f
Remove DebugState from EvalContext, bring back DebuggerHook helper me…
jasonpaulos Aug 30, 2022
d7981a8
More legacy debugger tests
jasonpaulos Aug 30, 2022
82b75e9
Fix missed debugger
jasonpaulos Aug 30, 2022
959261f
Combine app and logicsig eval hooks into one & expose logic.RunMode
jasonpaulos Aug 30, 2022
25899d0
More testing
jasonpaulos Aug 30, 2022
1908046
Remove debugger arg from PrepareGroupContext, enhance evaluator and v…
jasonpaulos Aug 31, 2022
e5fd2a1
Make all debugger methods required
jasonpaulos Sep 19, 2022
b99b80b
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Oct 31, 2022
ad5f515
Fix generate config files
jasonpaulos Oct 31, 2022
2a2b8a9
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Oct 31, 2022
115421f
Reorder debugger hook functions
jasonpaulos Oct 31, 2022
533c239
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Nov 1, 2022
1219bef
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Nov 1, 2022
1c7c406
WIP
jasonpaulos Nov 8, 2022
807b384
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Dec 8, 2022
3f4e74e
Clarify group transactions are also acceptable
jasonpaulos Dec 8, 2022
4a74a24
Try to appease the new parallel linter
jasonpaulos Dec 8, 2022
2f083e8
Classify simulation endpoint as experimental
jasonpaulos Dec 9, 2022
3c5bc99
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Dec 9, 2022
70ddd43
Rename EnableTransactionSimulator to EnableExperimentalAPI
jasonpaulos Dec 12, 2022
6de00a4
Update config.json.example
jasonpaulos Dec 12, 2022
c2dfb80
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Dec 12, 2022
a76ce0c
File renames
jasonpaulos Dec 12, 2022
3ef9112
Rename DebuggerHook to EvalTracer and remove error return values from…
jasonpaulos Dec 14, 2022
f153f4a
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Dec 14, 2022
d1f0d0e
Make experimental routes public
jasonpaulos Dec 14, 2022
845425b
Add to API docs
jasonpaulos Dec 14, 2022
075e288
Missing change to README
jasonpaulos Dec 14, 2022
b1ee178
Linter bug
jasonpaulos Dec 14, 2022
336038e
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Dec 14, 2022
f3ea97e
debuggerEvalTracerAdaptor embeds NullEvalTracer
jasonpaulos Dec 14, 2022
987fd51
Rename EvalTracer methods
jasonpaulos Dec 14, 2022
a932450
Get rid of legacy names
jasonpaulos Dec 14, 2022
b20f6a7
Better use of txntest package
jasonpaulos Dec 14, 2022
cfe8496
Let's see if the export linter yells at this
jasonpaulos Dec 15, 2022
0e19762
Rename DebuggerHook to Debugger
jasonpaulos Dec 15, 2022
76ca4cd
Ensure tracer implements don't drift from interface
jasonpaulos Dec 15, 2022
82d3f2c
Add back export comments
jasonpaulos Dec 15, 2022
942901c
Improve EvalTracer method docs
jasonpaulos Dec 15, 2022
84c5dff
Add experimental warning to swagger file
jasonpaulos Dec 15, 2022
446d158
Merge branch 'master' into feature/simulate-endpoint
jasonpaulos Dec 15, 2022
3d57840
Merge branch 'feature/simulate-endpoint' into extend-debugger-interface
jasonpaulos Dec 15, 2022
f588511
Merge branch 'master' into extend-debugger-interface
jasonpaulos Jan 12, 2023
8b4384b
Fix test issue
jasonpaulos Jan 12, 2023
0c43566
Update license headers
jasonpaulos Jan 12, 2023
54b7534
minor updates from CR
jasonpaulos Jan 12, 2023
5927a63
Use assembler instead of hardcoding program bytes
jasonpaulos Jan 12, 2023
0b02d9e
Make tracer a field in BlockEvaluator and generalize txn group hooks
jasonpaulos Jan 17, 2023
10e74cb
Don't add tracer to GroupContext
jasonpaulos Jan 17, 2023
c0489c7
Fix incorrect txn depth logic in debuggerEvalTracerAdaptor
jasonpaulos Jan 17, 2023
b4e0999
Merge branch 'master' into extend-debugger-interface
jasonpaulos Jan 20, 2023
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
2 changes: 1 addition & 1 deletion cmd/tealdbg/debugger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestDebuggerSimple(t *testing.T) {
debugger.AddAdapter(da)

ep := logic.NewEvalParams(make([]transactions.SignedTxnWithAD, 1), &proto, nil)
ep.Debugger = debugger
ep.Debugger = logic.MakeLegacyDebuggerAdaptor(debugger)
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
ep.SigLedger = logic.NoHeaderLedger{}

source := `int 0
Expand Down
2 changes: 1 addition & 1 deletion cmd/tealdbg/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func (r *LocalRunner) RunAll() error {
// ep.Debugger = r.debugger
// if ep.Debugger != nil // FALSE
if r.debugger != nil {
ep.Debugger = r.debugger
ep.Debugger = logic.MakeLegacyDebuggerAdaptor(r.debugger)
}
}

Expand Down
3 changes: 3 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ type Local struct {
// MaxAcctLookback sets the maximum lookback range for account states,
// i.e. the ledger can answer account states questions for the range Latest-MaxAcctLookback...Latest
MaxAcctLookback uint64 `version[23]:"4"`

// EnableTransactionSimulator enables the simulation API endpoint.
EnableTransactionSimulator bool `version[23]:"false"`
}

// DNSBootstrapArray returns an array of one or more DNS Bootstrap identifiers
Expand Down
1 change: 1 addition & 0 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var defaultLocal = Local{
EnableRequestLogger: false,
EnableRuntimeMetrics: false,
EnableTopAccountsReporting: false,
EnableTransactionSimulator: false,
EnableVerbosedTransactionSyncLogging: false,
EndpointAddress: "127.0.0.1:0",
FallbackDNSResolverAddress: "",
Expand Down
2 changes: 1 addition & 1 deletion crypto/merklesignature/committablePublicKeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type (
keyLifetime uint64
}

// CommittablePublicKey is used to create a binary representation of public keys in the merkle
// CommittablePublicKey is used to create a binary representation of public keys in the merkle
// signature scheme.
CommittablePublicKey struct {
VerifyingKey crypto.FalconVerifier
Expand Down
79 changes: 79 additions & 0 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,65 @@
}
}
},
"/v2/transactions/simulate": {
"post": {
"consumes": [
"application/x-binary"
],
"produces": [
"application/msgpack"
],
"schemes": [
"http"
],
"summary": "Simulates a raw transaction as it would be evaluated on the network.",
"operationId": "SimulateTransaction",
"parameters": [
{
"description": "The byte encoded transaction to simulate",
"name": "rawtxn",
"in": "body",
"required": true,
"schema": {
"type": "string",
"format": "binary"
}
}
],
"responses": {
"200": {
"$ref": "#/responses/SimulationResponse"
},
"400": {
"description": "Bad Request - Malformed Algorand transaction",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"401": {
"description": "Invalid API Token",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"500": {
"description": "Internal Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"503": {
"description": "Service Temporarily Unavailable",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"default": {
"description": "Unknown Error"
}
}
}
},
"/v2/transactions/params": {
"get": {
"produces": [
Expand Down Expand Up @@ -3237,6 +3296,26 @@
}
}
},
"SimulationResponse": {
"description": "Result of a transaction group simulation.",
"schema": {
"type": "object",
"required": [
"failure-message",
"missing-signatures"
],
"properties": {
"failure-message": {
"description": "\\[fm\\] Failure message, if the transaction would have failed during a live broadcast.",
"type": "string"
},
"missing-signatures": {
"description": "\\[ms\\] Whether any transactions would have failed during a live broadcast because they were missing signatures.",
"type": "boolean"
}
}
}
},
"SupplyResponse": {
"description": "Supply represents the current supply of MicroAlgos in the system.",
"schema": {
Expand Down
113 changes: 113 additions & 0 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@
},
"description": "Transaction ID of the submission."
},
"SimulationResponse": {
"content": {
"application/json": {
"schema": {
"properties": {
"failure-message": {
"description": "\\[fm\\] Failure message, if the transaction would have failed during a live broadcast.",
"type": "string"
},
"missing-signatures": {
"description": "\\[ms\\] Whether any transactions would have failed during a live broadcast because they were missing signatures.",
"type": "boolean"
}
},
"required": [
"failure-message",
"missing-signatures"
],
"type": "object"
}
}
},
"description": "Result of a transaction group simulation."
},
"StateProofResponse": {
"content": {
"application/json": {
Expand Down Expand Up @@ -4586,6 +4610,95 @@
"summary": "Get a specific pending transaction."
}
},
"/v2/transactions/simulate": {
"post": {
"operationId": "SimulateTransaction",
"requestBody": {
"content": {
"application/x-binary": {
"schema": {
"format": "binary",
"type": "string"
}
}
},
"description": "The byte encoded transaction to simulate",
"required": true
},
"responses": {
"200": {
"content": {
"application/msgpack": {
"schema": {
"properties": {
"failure-message": {
"description": "\\[fm\\] Failure message, if the transaction would have failed during a live broadcast.",
"type": "string"
},
"missing-signatures": {
"description": "\\[ms\\] Whether any transactions would have failed during a live broadcast because they were missing signatures.",
"type": "boolean"
}
},
"required": [
"failure-message",
"missing-signatures"
],
"type": "object"
}
}
},
"description": "Result of a transaction group simulation."
},
"400": {
"content": {
"application/msgpack": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request - Malformed Algorand transaction"
},
"401": {
"content": {
"application/msgpack": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Invalid API Token"
},
"500": {
"content": {
"application/msgpack": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Internal Error"
},
"503": {
"content": {
"application/msgpack": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Service Temporarily Unavailable"
},
"default": {
"content": {},
"description": "Unknown Error"
}
},
"summary": "Simulates a raw transaction as it would be evaluated on the network.",
"x-codegen-request-body-name": "rawtxn"
}
},
"/versions": {
"get": {
"description": "Retrieves the supported API versions, binary build versions, and genesis information.",
Expand Down
10 changes: 5 additions & 5 deletions daemon/algod/api/server/v2/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,22 @@ func (ddr *dryrunDebugReceiver) stateToState(state *logic.DebugState) generated.
return st
}

// Register is fired on program creation (DebuggerHook interface)
// Register is fired on program creation (LegacyDebuggerHook interface)
func (ddr *dryrunDebugReceiver) Register(state *logic.DebugState) error {
ddr.disassembly = state.Disassembly
ddr.lines = strings.Split(state.Disassembly, "\n")
return nil
}

// Update is fired on every step (DebuggerHook interface)
// Update is fired on every step (LegacyDebuggerHook interface)
func (ddr *dryrunDebugReceiver) Update(state *logic.DebugState) error {
st := ddr.stateToState(state)
ddr.history = append(ddr.history, st)
ddr.updateScratch()
return nil
}

// Complete is called when the program exits (DebuggerHook interface)
// Complete is called when the program exits (LegacyDebuggerHook interface)
func (ddr *dryrunDebugReceiver) Complete(state *logic.DebugState) error {
return ddr.Update(state)
}
Expand Down Expand Up @@ -417,7 +417,7 @@ func doDryrunRequest(dr *DryrunRequest, response *generated.DryrunResponse) {
var result generated.DryrunTxnResult
if len(stxn.Lsig.Logic) > 0 {
var debug dryrunDebugReceiver
ep.Debugger = &debug
ep.Debugger = logic.MakeLegacyDebuggerAdaptor(&debug)
ep.SigLedger = &dl
pass, err := logic.EvalSignature(ti, ep)
var messages []string
Expand Down Expand Up @@ -501,7 +501,7 @@ func doDryrunRequest(dr *DryrunRequest, response *generated.DryrunResponse) {
messages[0] = fmt.Sprintf("uploaded state did not include app id %d referenced in txn[%d]", appIdx, ti)
} else {
var debug dryrunDebugReceiver
ep.Debugger = &debug
ep.Debugger = logic.MakeLegacyDebuggerAdaptor(&debug)
var program []byte
messages = make([]string, 1)
if stxn.Txn.OnCompletion == transactions.ClearStateOC {
Expand Down
Loading