-
Notifications
You must be signed in to change notification settings - Fork 20.9k
internal/ethapi: add status code to receipt rpc return #15042
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
Conversation
da59b0f
to
b25f260
Compare
@rjl493456442 result: {"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xf81f9f905ac74e2832fc93c50566827055b4f0df6db2e12ce092f66ec154b813","blockNumber":"0x3ffca4","contractAddress":null,"cumulativeGasUsed":"0x5dde46","from":"0x3aeda7405558a096b620315c01d3d2af383632ec","gasUsed":"0x8fb1","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","root":"0xcdb37dc9126181d14d1d4846f5246750672242fa460d84b4315c0b6edc246590","to":"0xa74476443119a942de498590fe1f2454d7d4ac0d","transactionHash":"0x839517dc0f8a73f6e259745ba60badcf8016c0a7ee783ee6246ccf1157408cb3","transactionIndex":"0x34"}} txHash "0x839517dc0f8a73f6e259745ba60badcf8016c0a7ee783ee6246ccf1157408cb3" is Bad jump destination I use commit b25f260 |
@mi2zha Hey, since status field is added only after metropolish fork. So before that |
@rjl493456442 [out of gas] [Bad jump destination] or successful |
As Ethereum EIP658 described, a transaction is regarded as failed only if the outermost execution failed. Any error returned (includes OutOfGas, Bad jump destination you mentioned) by the outermost call/create will make it. |
thank you for your patient answer how did etherscan.io acquire the state of failure debug.traceTransaction is ok? testing |
Yeah, ethereum provides lots of tools to trace the execution state of the virtual machine. You can use |
Actually i have added the |
@rjl493456442 is this ? |
@rjl493456442 failed: true is failed,false is successful thank u |
internal/ethapi/api.go
Outdated
if receipt.Failed { | ||
fields["statusCode"] = receiptStatusFailed | ||
} | ||
} |
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.
Receipt already has statusEncoding()
. Can't we expose that one and use it instead?
Also, the EIP describes the status as a single byte, either 0 or 1. In the RPC bytes are hex encoded so this should be something like: fields["statusCode"] = hexutil.Bytes(receipt.StatusEncoding())
. Even if it is be a number they need to be hex encoded as per RPC spec. The EIP also doesn't mention that the field name is statusCode
, that should probably be amended to the EIP.
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.
b25f260
to
054e2f1
Compare
@bas-vk Because PTAL |
but, there are multiple failures |
@mi2zha The statusCode could be only 1 or 0, the former represents transaction executuon successful and the latter represents failed. If you want obtain the detailed error, i think |
@rjl493456442 i will use debug.traceTransaction thank you again |
I don't think creating a new EIP is the way to go. The original EIP should imo specify how this new field is exposed. There is also a separate repository (https://github.com/ethereum/interfaces) that describes RPC changes. Also I prefer to have the new field called |
@bas-vk RPC interfaces aren't properly defined in core EIPs, IMO. There's no reason to name the status field there. |
internal/ethapi/api.go
Outdated
if receipt.PostState != nil { | ||
fields["root"] = hexutil.Bytes(receipt.PostState) | ||
} else { | ||
fields["statusCode"] = hexutil.Uint(receiptStatusSuccessful) |
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.
Please use status
instead
Updated docs: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt |
@holiman The wiki has the inaccurate part. The status should be either '0x0' or '0x1'. Since all rpc responses are encoded in hex format |
054e2f1
to
9f82cfe
Compare
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, thanks for your contribution.
I have also updated the wiki.
The PR was missing the parsing part of the status field. Adding that was not really trivial because we've previously used a After a few variations and feedback from @fjl, the consensus was to have Receipt represent the true format of the consensus type, and replace |
@bas-vk PTAL |
@karalabe LGTM |
No description provided.