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 compile api #1007

Merged
merged 17 commits into from May 27, 2020
Merged

Algod compile api #1007

merged 17 commits into from May 27, 2020

Conversation

stechu
Copy link
Contributor

@stechu stechu commented Apr 28, 2020

Summary

New v2 API endpoint for compile teal code:
/v2/compile
POST text/plain utf-8 encoded source code
Return json if succeed
{
“result”:base64 encoded bytes,
“hash”:base32 sha512_256 of program bytes (Address style),
}
Otherwise 400 error (bad request) with actual error message


Resolve #1093

Test Plan

Tested locally.

Copy link
Contributor

@algobolson algobolson left a comment

Choose a reason for hiding this comment

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

one input validation TODO

daemon/algod/api/server/v2/handlers.go Show resolved Hide resolved
@pzbitskiy
Copy link
Contributor

I guess we need a simple int 1 unit test for this.

@stechu
Copy link
Contributor Author

stechu commented Apr 30, 2020

@pzbitskiy currently we don't have any unit test for rest API. The tests are done by SDK separately. I plan to add python sdk support as well as test after python sdk support v2 APIs.

@@ -595,7 +595,60 @@
"required": true
}
]
}
},
"/v2/compile": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider giving it it's own segment - /v2/teal/compile and the other one will be /v2/teal/dryrun

Copy link
Contributor

Choose a reason for hiding this comment

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

I had the other as /v2/transactions/dryrun , but /v2/teal/... makes sense too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/v2/teal/compile makes sense. Will change to that.

"operationId": "TealCompile",
"parameters": [
{
"description": "Teal source code to be compiled",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - TEAL

@@ -1,423 +1,643 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this file contains many irrelevant changes. @winder is that the map random order issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I have (in an unrelated pull) something that changes this to sorted keys for stable diffs.

daemon/algod/api/server/v2/handlers.go Show resolved Hide resolved
@algobolson
Copy link
Contributor

This endpoint could unit test pretty easily since it doesn't rely on setting up any node or ledger state, but the endpoint is a pretty thin wrapper on logic.AssembleString() which is well tested. I don't think it needs a unit test. I kinda expect setting up a test to fake up an echo.Context() and call the handler would be annoying.

@stechu
Copy link
Contributor Author

stechu commented May 20, 2020

@algobolson @pzbitskiy @winder @rotemh I have fixed all the comments and this is ready to merge.

Copy link
Contributor

@brianolson brianolson left a comment

Choose a reason for hiding this comment

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

LGTM

@tsachiherman tsachiherman linked an issue May 21, 2020 that may be closed by this pull request
@tsachiherman tsachiherman dismissed algobolson’s stale review May 21, 2020 01:46

Brian approved with a different username.

@brianolson
Copy link
Contributor

Switched primary accounts, this is the new me. LGTM. I guess we're waiting on @rotemh to see if his concerns have been addressed?

@stechu
Copy link
Contributor Author

stechu commented May 21, 2020

ping @rotemh

@brianolson brianolson merged commit 287fb3a into algorand:master May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Teal Compile Rest Endpoint
6 participants