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: Modify simulate endpoint request type #5292

Merged
merged 17 commits into from
Apr 18, 2023

Conversation

jasonpaulos
Copy link
Contributor

@jasonpaulos jasonpaulos commented Apr 10, 2023

Summary

Currently the /v2/transactions/simulate endpoint has the same request format as /v2/transactions, the transaction submission endpoint. This format is a concatenated byte array of all of the encoded transactions in an atomic group. Unfortunately this format has the following shortcomings for simulate:

  • Only a single atomic group can be expressed (without assuming correct group IDs)
  • There is no space for additional parameters, which would be required for configuring the simulation environment

To solve these problems, this PR creates a new SimulationRequest object that serves as the /v2/transactions/simulate endpoint's request type. This object can be encoded using either JSON or msgpack. At the moment this object does not offer any additional features, but the goal is to introduce new fields in the future for this purpose.

NOTE: this new request object is a backwards-incompatible change. Normally we would not advocate for this, but since simulate is such a new feature and this change would vastly improve our ability to add related features, we think this is a tradeoff that makes sense.

If you already have a transaction group formatted for /v2/transactions or the old version of /v2/transactions/simulate prior to this PR, you can use the new flag --request-only-out for goal clerk simulate to create a properly-formed simulate request:

goal clerk simulate -t <input_txn_group_file> --request-only-out <request_output_file>

The --request-only-out flag indicates that you want goal to help you format a simulate request. It will create the request and write it to the specified file, then exit. No simulation will happen.

Test Plan

Modified current tests and added additional tests

Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am generally good on this, maybe a few details we want to be clear for following steps:

  1. unlimited-log should go under simulate/extended
  2. minor questions on erroring early in SimulateTxnExtended handler

@jasonpaulos jasonpaulos changed the title algod: Extended simulate endpoint algod: Modify simulate endpoint request type Apr 12, 2023
cmd/goal/clerk.go Outdated Show resolved Hide resolved
@jasonpaulos jasonpaulos marked this pull request as ready for review April 12, 2023 22:18
ahangsu
ahangsu previously approved these changes Apr 13, 2023
Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally lookin good, and testing looks nice!

cmd/goal/clerk.go Outdated Show resolved Hide resolved
cmd/goal/clerk.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few things to be fixed in clerk.go, but others should be fine.

cmd/goal/clerk.go Outdated Show resolved Hide resolved
cmd/goal/clerk.go Outdated Show resolved Hide resolved
ahangsu
ahangsu previously approved these changes Apr 18, 2023
@jasonpaulos jasonpaulos requested a review from ahangsu April 18, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants