-
Notifications
You must be signed in to change notification settings - Fork 471
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
api: Txn Group Delta Apis #5350
Conversation
@@ -91,6 +92,7 @@ type LedgerForAPI interface { | |||
Block(rnd basics.Round) (blk bookkeeping.Block, err error) | |||
AddressTxns(id basics.Address, r basics.Round) ([]transactions.SignedTxnWithAD, error) | |||
GetStateDeltaForRound(rnd basics.Round) (ledgercore.StateDelta, error) | |||
GetTracer() logic.EvalTracer |
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: Should this return an interface that gets cast to the EvalTracer?
Nevermind, this appears to be the interface
tracer, ok := v2.Node.LedgerForAPI().GetTracer().(*eval.TxnGroupDeltaTracer) | ||
if !ok { | ||
return serviceUnavailable(ctx, err, errFailedRetrievingTracer, v2.Log) | ||
} |
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.
Does this handle a nil tracer?
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.
Yes, I've added a test for this case as well just to be sure.
I'm not sure that 503 is the exactly the correct http response though--open to suggestions on better responses there.
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 don't think 503 is a good choice, isn't it supposed to be fore temporary conditions? I'd probably go with 501 or 500.
@@ -72,29 +102,34 @@ func (tracer *TxnGroupDeltaTracer) AfterTxnGroup(ep *logic.EvalParams, deltas *l | |||
} | |||
|
|||
// GetDeltasForRound supplies all StateDelta objects for txn groups in a given rnd | |||
func (tracer *TxnGroupDeltaTracer) GetDeltasForRound(rnd basics.Round) ([]ledgercore.StateDelta, error) { | |||
func (tracer *TxnGroupDeltaTracer) GetDeltasForRound(rnd basics.Round) ([]TxnGroupDeltaWithIds, error) { | |||
rndEntries, exists := tracer.txnGroupDeltas[rnd] |
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.
It looks like txnGroupDeltas
needs a RW lock.
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 created a child PR while going through this PR to add some additional handler checks for my own sanity: Eric-Warehime#7
Add extra tests for sanity check
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.
Just need to regenerate the specs if we change the 503 to 501?
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.
LGTM, I am not particularly opinionated about what error should be returned for a nil tracer.
@@ -22,6 +22,7 @@ import ( | |||
"encoding/base64" | |||
"errors" | |||
"fmt" | |||
"github.com/algorand/go-algorand/ledger/eval" |
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: import groups
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.
Just one small change needed in the OpenAPI, otherwise LGTM.
Codecov Report
@@ Coverage Diff @@
## master #5350 +/- ##
==========================================
+ Coverage 55.28% 55.30% +0.02%
==========================================
Files 454 454
Lines 63772 63827 +55
==========================================
+ Hits 35254 35300 +46
- Misses 26115 26129 +14
+ Partials 2403 2398 -5
... and 14 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Summary
Implements two new APIs:
These expose the state delta objects for groups of transactions.
Test Plan
Adding handler tests as the PR progresses.