-
Notifications
You must be signed in to change notification settings - Fork 474
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: Migrate internal uses of v1 algod API to v2 #4684
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4684 +/- ##
==========================================
- Coverage 54.49% 54.43% -0.07%
==========================================
Files 407 407
Lines 52425 52499 +74
==========================================
+ Hits 28569 28576 +7
- Misses 21472 21540 +68
+ Partials 2384 2383 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…ges line up with v2 response
* Delete extraneous function makeTestBlock inline * Add test for blockstats event details * Delete another comment
…gorand into v2-goal-migration
Co-authored-by: Will Winder <wwinder.unh@gmail.com>
I looked at |
@brianolson Thanks a lot for confirming the pingpong files 👍
Yes, we can do that - I noted down things we can delete in a near future PR (deleting all deprecated libgoal/client code, tests, deprecated goal commands) to keep diffs smaller for reviewers and narrow the scope of work here. |
…gorand into v2-goal-migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@algochoi Thanks for covering a lot of ground here - Looks ready to go from my side.
algod, err := c.ensureAlgodClient() | ||
if err == nil { | ||
var resp []byte | ||
resp, err = algod.RawBlock(round) | ||
if err == nil { | ||
var b rpcs.EncodedBlockCert | ||
err = protocol.DecodeReflect(resp, &b) | ||
err = protocol.DecodeReflect(resp, &blockCert) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I know you didn't write the original code, but rpcs.EncodedBlockCert
has generated msgp methods, so it would benefit slightly from using protocol.Decode
instead of protocol.DecodeReflect
} | ||
|
||
reserve, err := client.AccountInformation(params.ReserveAddr) | ||
reserve, err := client.AccountInformationV2(*asset.Params.Reserve, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think client.AccountAssetInformation(*asset.Params.Reserve, assetID)
could be used instead of client.AccountInformationV2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followed up offline: It looks like we'd want to change the behavior so that goal asset info
fails if the reserve doesn’t hold the asset - this will likely involve changing a test (test/scripts/e2e_subs/asset-misc.sh
) to address this in a follow-up PR.
} else { | ||
// Fetch the current state, to fill in as a template | ||
current, err := c.AccountInformation(creator) | ||
current, err := c.AccountInformationV2(creator, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest this could be improved with client.AccountAssetInformation
, but I don't think this side of the if statement needs to exist at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I agree - I'll follow up on this in another PR
Merging - Have agreed with @algochoi that the remaining open threads will be addressed in a prior PR before closing the story. Merging the PR to minimize merge conflicts. |
Summary
As part of sunsetting v1 algod APIs, we want to only use v2 algod APIs in the internal REST client. Relates to #2976.
This PR changes the client code and internal tests/tooling to use v2 models and endpoints.
There are two v1 endpoints that do not have an equivalent endpoint in v2:
/v1/account/%s/transactions
restClient_test.go
that uses this endpoint - resolve/delete test when v1 API is sunsetted./v1/account/%s/transactions/%s
/v2/account/%s/transactions/pending
Major Changes:
restClient.go
,libgoal
: Add v2 endpoints and use v2 models/responses. Add helper function inlibgoal
to parse pending transaction responses into a struct by decoding from msgpack.algoh
: Use v2 Block instead of v1 Block. Since the v2Block
API does not return the Proposer information, we get the raw block and parse it for the block + certificate.loadgenerator
(along with tests) now uses the v2 endpoint to send transactionspingpong
now uses the v2 models and endpointsasset
information with v2 responses - they now have pointer fields to denote whether a field is empty or notTesting:
master
branch is <5%loadgenerator
!Future work
For the sake of keeping diffs small in a single PR, we should do the following in a future ticket:
legacyListParticipationKeysCommand
)