-
Notifications
You must be signed in to change notification settings - Fork 251
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
Adding transaction_call endpoint #832
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #832 +/- ##
==========================================
- Coverage 61.52% 60.95% -0.57%
==========================================
Files 218 218
Lines 22756 23037 +281
==========================================
+ Hits 14001 14043 +42
- Misses 7624 7858 +234
- Partials 1131 1136 +5 ☔ View full report in Codecov by Sentry. |
This pull request has been marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions. |
6e7853e
to
da734f1
Compare
} | ||
} | ||
|
||
return c.ResponseWriter.Write(b) |
Check warning
Code scanning / CodeQL
Reflected cross-site scripting Medium
user-provided value
Cross-site scripting vulnerability due to
user-provided value
@@ -300,6 +301,25 @@ func TestClient_GetTransaction(t *testing.T) { | |||
assert.Equal(t, expectedTx, tx) | |||
} | |||
|
|||
func TestClient_CallTransaction(t *testing.T) { |
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.
can we also add negative tests ?
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 guess we can but those are mock tests afaik. So not sure what the benefit of returning a hardcoded "error" response will be and checking if its what we expect.
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.
Very minor bits, but lgtm - should there be a couple of e2e to go with this as well ?
I can't approve, but perhaps @libotony can have a final review and approve ?
@@ -191,6 +191,177 @@ paths: | |||
type: string | |||
example: 'Invalid transaction ID' | |||
|
|||
/transactions/call: |
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 haven't tried but when this yml gets generated, does it contain a working example ? (like the other endpoints)
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 so, but do you mean examples for values? like here
or code/usage example?
|
||
// Record VM error if present | ||
if ctxWriter.VMError != "" { | ||
metricTxCallVMErrors().AddWithLabel(1, map[string]string{ |
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.
What happens if there are a high number of different errors here ?
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.
From the code I read, there is always at most only 1 possible vmerror per transaction, that doesn't depend on the amount of clauses in a transaction. Was that the question?
if rt != nil && rt.GetName() != "" { | ||
enabled = true | ||
name = rt.GetName() | ||
if name == "transactions_call_tx" { |
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.
What is the goal of this particular case ?
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 guess to separate errors that happened specifically on that endpoint, the name for it is set here. Not sure if that metric is needed, since it's the errors that happened on transactions, that are not mined
@@ -74,6 +79,16 @@ func TestTransaction(t *testing.T) { | |||
} { | |||
t.Run(name, tt) | |||
} | |||
|
|||
// Call transaction | |||
for name, tt := range map[string]func(*testing.T){ |
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.
Can another test be added here that does the same checks, or a summarized version, of the checks that the mempool does to verify tx integrity ?
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.
Ah! These seem to be covered already yeah ?
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.
Yeah, I am pretty sure this is the one
Discussed offline, @otherview pointed that including runtime features is potentially providing values for devs, I would like to have a further investigation into the purpose of this PR. |
Description
This PR adds a new endpoint that allows to simulate and estimate based on transactions instead of clauses.
The added value is to bring api communication to the transaction level. This allows for gotchas like, chaintag, expiration, nonce, etc to be more visible and allows executing transactions in a given block revision
Summary of the endpoint:
Goal: Execute a transaction at the head of a specified block. Retrieve the total gas cost at the transaction level.
(Note: Can be expanded to execute in a block at a given tx position.)
Fixes # (issue)
Type of change
How Has This Been Tested?
Checklist: