-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add Name to Events, Name to Subscription #71
Conversation
* allows for solc0.6.8 * go1.14 has changes to json `Number` treatment. This resulted in some of our negative tests returning a different error message due to alphabet input for "bad number"
For correctness and also because go1.14 is messy when parsing incorrect numbers. For us, when parsing our test events from our file that has `0x0` into a "Number", the resulting slice does not have the right data. ref: golang/go#14702 https://github.com/ethereum/go-ethereum/blob/4bcc0a37ab70cb79b16893556cffdaad6974e7d8/core/types/log.go#L47
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
=======================================
Coverage 97.96% 97.96%
=======================================
Files 50 50
Lines 5460 5464 +4
=======================================
+ Hits 5349 5353 +4
Misses 79 79
Partials 32 32
Continue to review full report at Codecov.
|
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.
on request for a change around the customName
field
Also, noticed in the PR description:
Allow Solidity versions <= 0.6.8
Think from the code, what is meant is:
Allow Solidity versions > 0.6.8
Have I understood correctly?
internal/kldevents/subscription.go
Outdated
ID string `json:"id,omitempty"` | ||
Path string `json:"path"` | ||
Name string `json:"name"` | ||
CustomName string `json:"customName,omitempty"` |
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 it's going to be confusing to have customName
here.
I'm guessing the problem was we auto-generate the name
field previously from combination of the event signature and the scope - which is useful information regardless of whether a user has a custom name.
With that in mind, please can we make the new field summary
, and have that always be auto-generated (cannot be user-submitted - works just like name
does today). Then name
defaults to the value of summary
if it's empty/null, but if supplied the user can put anything they like?
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.
Added a new field summary
(not returned in API response). name
is now set to whatever is provided by the user or is set to summary
if it is empty.
* Sets name to whatever is provided by end user, if present in the body * Sets name to `summary`, if one is not provided by end user. summary is auto generated and not returned in the API response * Removed a comment from test file based on review comment
@@ -608,7 +608,7 @@ func TestOnSendTransactionMessageBadNonce(t *testing.T) { | |||
testTxnContext.jsonMsg = "{" + | |||
" \"headers\":{\"type\": \"SendTransaction\"}," + | |||
" \"from\":\"0x83dBC8e329b38cBA0Fc4ed99b1Ce9c2a390ABdC1\"," + | |||
" \"nonce\":\"abc\"" + | |||
" \"nonce\":\"123.4\"" + |
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.
Guessing this is a go version behavior change: using abc
for nonce throws an error in parsing the json in the test file: "json: invalid number literal, trying to unmarshal ""abc"" into Number" instead of throwing an error in txn processing logic
@@ -630,7 +630,7 @@ func TestOnSendTransactionMessageBadMsg(t *testing.T) { | |||
" \"headers\":{\"type\": \"SendTransaction\"}," + | |||
" \"from\":\"0x83dBC8e329b38cBA0Fc4ed99b1Ce9c2a390ABdC1\"," + | |||
" \"nonce\":\"123\"," + | |||
" \"value\":\"abc\"," + | |||
" \"value\":\"123.456\"," + |
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.
Guessing this is a go version behavior change: using abc
for nonce throws an error in parsing the json in the test file: "json: invalid number literal, trying to unmarshal ""abc"" into Number" instead of throwing an error in txn processing logic
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.
@peterbroadhurst Thanks for the review. Updated the PR with requested changes re:summary
.
To your other question, the contract files do not require > 0.6.0
(I was using 0.6.8
) to test locally and hence only changed the upper limit of the version.
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.
👍 📛 📨
* Add name to Events * Allow sol 0.6.8, go1.14 tweaks for json number parsing * allows for solc0.6.8 * go1.14 has changes to json `Number` treatment. This resulted in some of our negative tests returning a different error message due to alphabet input for "bad number" * Change logEntry tx index type to hex uint For correctness and also because go1.14 is messy when parsing incorrect numbers. For us, when parsing our test events from our file that has `0x0` into a "Number", the resulting slice does not have the right data. ref: golang/go#14702 https://github.com/ethereum/go-ethereum/blob/4bcc0a37ab70cb79b16893556cffdaad6974e7d8/core/types/log.go#L47 * Add CustomName to Subscriptions * Fix json for event name * Add tests with event stream name in smartcontract gw * Sub auto-generated summary, accept name from end user * Sets name to whatever is provided by end user, if present in the body * Sets name to `summary`, if one is not provided by end user. summary is auto generated and not returned in the API response * Removed a comment from test file based on review comment Signed-off-by: Vinod Damle <vinod.damle@kaleido.io>
name
to EventStreamsummary
to Subscription - there's already a system generatedname
(set using address and event signature). If noname
is provided,name
is set tosummary
in the response to the user. If aname
is provided for the subscription, that name is returned in the response to the user.transactionIndex
inlogEntry
to be a hex uint instead of jsonNumber
to match https://github.com/ethereum/go-ethereum/blob/4bcc0a37ab70cb79b16893556cffdaad6974e7d8/core/types/log.go#L47. This was exposed by a behavior change ingo1.14
(Resulted in a corrupted slice) when parsing invalidNumber
in json (see commit for more details)0.6.0
& <0.6.9
Partial fix for: #68