go-algorand icon indicating copy to clipboard operation
go-algorand copied to clipboard

Algod: Basic simulation endpoint with pass/reject

Open jdtzmn opened this issue 2 years ago • 1 comments

Summary

This PR adds a basic simulation endpoint which accepts transaction groups exactly as they would be received by the /v2/transactions endpoint. The endpoint executes transaction groups using the real BlockEvaluator and will respond with a failure message if the transaction group would have been rejected during evaluation.

The endpoint does not error if transactions are given with invalid signatures, however it will inform you if that is the case.

Test Plan

  • [x] Simulation route handlers in handlers_test.go
    • [x] Invalid transaction group
    • [x] Node without developer mode enabled
    • [x] Successful API call
  • [x] Simulation method tests in simulate_test.go
    • [x] Basic pay transaction
    • [x] Overspend transaction
    • [x] Simple group transaction
    • [x] Simple app create and call
    • [x] Reject app create and call
    • [x] Signature check
    • [x] Invalid transaction group check
    • [x] Confirm balance change within app call

Additional Information

  • The response type is msgpack only because we plan to return a large trace in the future and want to keep response size small

jdtzmn avatar Jul 28 '22 20:07 jdtzmn

Codecov Report

Merging #4322 (ca59421) into feature/simulate-endpoint (82f31c8) will decrease coverage by 0.06%. The diff coverage is 37.36%.

@@                      Coverage Diff                      @@
##           feature/simulate-endpoint    #4322      +/-   ##
=============================================================
- Coverage                      55.24%   55.17%   -0.07%     
=============================================================
  Files                            398      399       +1     
  Lines                          50165    50244      +79     
=============================================================
+ Hits                           27713    27723      +10     
- Misses                         20139    20201      +62     
- Partials                        2313     2320       +7     
Impacted Files Coverage Δ
config/localTemplate.go 42.85% <ø> (ø)
daemon/algod/api/server/v2/handlers.go 0.00% <0.00%> (ø)
node/node.go 4.41% <0.00%> (-0.02%) :arrow_down:
ledger/simulation/simulator.go 73.33% <73.33%> (ø)
daemon/algod/api/server/v2/test/helpers.go 74.12% <100.00%> (+0.18%) :arrow_up:
network/phonebook.go 83.49% <0.00%> (-5.83%) :arrow_down:
agreement/cryptoVerifier.go 67.60% <0.00%> (-2.12%) :arrow_down:
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) :arrow_down:
network/wsNetwork.go 64.63% <0.00%> (-1.05%) :arrow_down:
catchup/peerSelector.go 98.95% <0.00%> (-1.05%) :arrow_down:
... and 4 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Jul 29 '22 15:07 codecov[bot]