Skip to content
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

GraphQL returns transaction.status = 0 (failed) for successful pre-Byzantium transactions #24124

Closed
amyodov opened this issue Dec 16, 2021 · 3 comments · Fixed by #24188
Closed
Labels

Comments

@amyodov
Copy link

amyodov commented Dec 16, 2021

System information

Geth version: 1.10.13
OS & Version: Linux

Expected behaviour

CLI, JSON-RPC:

> eth.getTransactionReceipt("0x8fda3564427d18f119aa2309306babc7cd137893bd32260e4c75b9f74d3eeff6").status
undefined
> eth.getTransactionReceipt("0x78d9eac1a59562696c3b33acf5e32d9e27bb774e307b3c4aa53f8e4626277081").status
"0x1"

GraphQL:

{
  old: transaction(hash: "0x8fda3564427d18f119aa2309306babc7cd137893bd32260e4c75b9f74d3eeff6") { status }
  new: transaction(hash: "0x78d9eac1a59562696c3b33acf5e32d9e27bb774e307b3c4aa53f8e4626277081") { status }
}

GraphQL result:

{
  "data": {
    "old": {
      "status": null
    },
    "new": {
      "status": 1
    }
  }
}

Actual behaviour

CLI, JSON-RPC:

> eth.getTransactionReceipt("0x8fda3564427d18f119aa2309306babc7cd137893bd32260e4c75b9f74d3eeff6").status
undefined
> eth.getTransactionReceipt("0x78d9eac1a59562696c3b33acf5e32d9e27bb774e307b3c4aa53f8e4626277081").status
"0x1"

GraphQL:

{
  old: transaction(hash: "0x8fda3564427d18f119aa2309306babc7cd137893bd32260e4c75b9f74d3eeff6") { status }
  new: transaction(hash: "0x78d9eac1a59562696c3b33acf5e32d9e27bb774e307b3c4aa53f8e4626277081") { status }
}

GraphQL result:

{
  "data": {
    "old": {
      "status": 0
    },
    "new": {
      "status": 1
    }
  }
}

Steps to reproduce the behaviour

Check the "status" field of the transactions via JSON-RPC/CLI, and via GraphQL.
I haven’t checked with many transactions but seems like the bug happens on block 4369999 and doesn’t happen in block 4370000, meaning it is a pre-Byzantium-specific problem.
In general I believe the GraphQL should return the very same data as the JSON-RPC interface; if it does smart detection "which transactions actually considered successful and which don’t" it could be great, too; but it definitely should not return 0/failed for transactions which are valid in any current interpretations.

amyodov added a commit to UniversaBlockchain/UniCherryGarden that referenced this issue Dec 16, 2021
…"status" for the transactions

(ethereum/go-ethereum#24124).
Unit tests should pass and be equivalent now for both JSON-RPC and GraphQL access.
amyodov added a commit to UniversaBlockchain/UniCherryGarden that referenced this issue Dec 16, 2021
…"status" for the transactions

(ethereum/go-ethereum#24124).
Unit tests should pass and be equivalent now for both JSON-RPC and GraphQL access.
@basharz1
Copy link

I would like to contribute for the project

@s1na
Copy link
Contributor

s1na commented Dec 17, 2021

This patch should fix it. Will test and submit a PR.

diff --git a/graphql/graphql.go b/graphql/graphql.go
index e92f1126f..2c71eb2ec 100644
--- a/graphql/graphql.go
+++ b/graphql/graphql.go
@@ -372,8 +372,11 @@ func (t *Transaction) Status(ctx context.Context) (*Long, error) {
        if err != nil || receipt == nil {
                return nil, err
        }
-       ret := Long(receipt.Status)
-       return &ret, nil
+       var ret *Long
+       if len(receipt.PostState) == 0 {
+               *ret = Long(receipt.Status)
+       }
+       return ret, nil
 }

 func (t *Transaction) GasUsed(ctx context.Context) (*Long, error) {

@amyodov
Copy link
Author

amyodov commented Dec 27, 2021

Merry Christmas!

Just a friendly expression of curiosity how’s the PR going, and may it hit the upcoming Geth release...

@fjl fjl closed this as completed in #24188 Jan 5, 2022
fjl pushed a commit that referenced this issue Jan 5, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this issue Jan 6, 2022
amyodov added a commit to UniversaBlockchain/UniCherryGarden that referenced this issue Jan 11, 2022
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this issue May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants