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: standardize test outputs #475

Open
s1na opened this issue Oct 3, 2023 · 6 comments
Open

graphql: standardize test outputs #475

s1na opened this issue Oct 3, 2023 · 6 comments

Comments

@s1na
Copy link
Contributor

s1na commented Oct 3, 2023

There are multiple GraphQL hive tests where due to historical reasons 2 responses are accepted. This is unfortunate. The aim of this issue to discuss and agree on one output. The following tests have 2 acceptable responses:

  • 17_eth_getBlock_byNumberInvalid.json tries to get a block by a number that doesn't exist in the chain (88888888)
  • 07_eth_gasPrice.json accepts both 0x10 and 0x1 as valid responses
  • 30_eth_getTransaction_byHash.json this returns a transaction object. it accepts 2 responses. As far as I can tell these are the differences:
    • index being 0 vs 0x0. We should use 0x0 here now that all integer values are hex-encoded
    • log.index being 0 vs 0x0. Same as above.
    • status being null vs 0x0. I'm not sure why status should be null here. IMO we should return 0x0.
  • 33_eth_getTransactionReceipt.json as far as I can tell only difference is index being 0 vs 0x0. Should use 0x0.

The following testcase also accepts 2 responses. Either an error, or simply a nil value. It gets the balance of an account against a block which shouldnt exist. However since we've added new block the query has now actually a correct response. It needs to be updated with another block number.

  • 12_eth_getBalance_toobig_bn.json

We need to agree what to do for 12 and 17. It boils down to this: when a resource does not exist, return null or error. IMO to stay consistent with JSON-RPC we should return null. Also this is not really an exception.

Not sure what to do for 07_eth_gasPrice.

@s1na
Copy link
Contributor Author

s1na commented Oct 16, 2023

As for status, as @shemnon pointed out it goes back to pre-byzantium blocks where status was not a part of the block. Therefore clients should return null for pre-byzantium and an integer value if the block is post-byzantium.

@s1na
Copy link
Contributor Author

s1na commented Oct 17, 2023

Here is a proposal for a single response for the test cases mentioned above:

  • 17_eth_getBlock_byNumberInvalid.json: To stay consistent with JSON-RPC return null in case the requested block doesn't exist. Status code 200.
  • 07_eth_gasPrice.json: gas price is an estimate and clients can produce a different estimate. I believe we should remove this test case.
  • 30_eth_getTransaction_byHash.json:
    • index: hex encoded integer
    • log.index: hex-encoded integer
    • status: null before byzantium
  • 33_eth_getTransactionReceipt.json:
    • index: hex encoded integer
  • 12_eth_getBalance_toobig_bn.json: geth returns an error "header not found" when using eth_getBalance on a block that doesn't exist. Not sure about other clients. Propose to return an error. Status code 400. Also update the block number in the test case to a non-existent block.

Note for geth:

  • 43_graphql_blocks_byWrongRange.json: Return an error as indicated by the test.

@jsvisa
Copy link
Contributor

jsvisa commented Oct 19, 2023

  • 17_eth_getBlock_byNumberInvalid.json: To stay consistent with JSON-RPC return null in case the requested block doesn't exist. Status code 200.

updated, as below:

>> {block(number: 88888888) {number}}
<< {"data":{"block":null}}
  • 07_eth_gasPrice.json: gas price is an estimate and clients can produce a different estimate. I believe we should remove this test case.

removed

  • 30_eth_getTransaction_byHash.json:

    • index: hex encoded integer
    • log.index: hex-encoded integer
    • status: null before byzantium

index, log.index now is hex encoded, seems this chain.rlp is very old, the tx rereceipt is before byzantium, so the status is null, maybe we can update the chain.rlp to a new one, and update the status to 0x1

  • 33_eth_getTransactionReceipt.json:

    • index: hex encoded integer

updated

  • 12_eth_getBalance_toobig_bn.json: geth returns an error "header not found" when using eth_getBalance on a block that doesn't exist. Not sure about other clients. Propose to return an error. Status code 400. Also update the block number in the test case to a non-existent block.

besu and go-etherum return null when the block doesn't exist, so we update the test case to null, as below:

>> {block(number: 133) {account(address: "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f") {balance}}}
<< {"data":{"block":null}}

Note for geth:

  • 43_graphql_blocks_byWrongRange.json: Return an error as indicated by the test.

as besu and go-ethereum all return empty arry, so I adjust it into:

>> {blocks(from: "0x1e", to: "0x1c") {number gasUsed gasLimit hash nonce stateRoot receiptsRoot transactionCount}}
<< {"data":{"blocks":[]}}

@shemnon
Copy link
Contributor

shemnon commented Oct 19, 2023

I don't think the 07_eth_gasPrice.json test should be removed. Instead I think we need to write the response in such a way that it accepts any value. We need to verify it does return a value rather than an error. Perhaps regexp?

@shemnon
Copy link
Contributor

shemnon commented Oct 19, 2023

43_graphql_blocks_byWrongRange.json - a bad range should return an error, not an empty array. we may need to figure out a way to encode that in the response without dictating a specific error. But it should not return anything interpretable as a valid response.

@shemnon
Copy link
Contributor

shemnon commented Oct 19, 2023

30_eth_getTransaction_byHash.json The genesis is indeed frontier until block 33. As long as querying ancient blocks is permissible I think this test should remain to prove status=null for pre byzantium and a new test that tests after block 33 be used.

holiman pushed a commit to ethereum/go-ethereum that referenced this issue Oct 23, 2023
holiman pushed a commit to ethereum/go-ethereum that referenced this issue Oct 25, 2023
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this issue Nov 10, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this issue Nov 10, 2023
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this issue Jan 31, 2024
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this issue Jan 31, 2024
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
isman-usoh pushed a commit to bitkub-chain/bkc that referenced this issue May 27, 2024
isman-usoh pushed a commit to bitkub-chain/bkc that referenced this issue May 27, 2024
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
lai8983166 pushed a commit to sunnyjqs/nddn that referenced this issue Aug 13, 2024
lai8983166 pushed a commit to sunnyjqs/nddn that referenced this issue Aug 13, 2024
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
colinlyguo pushed a commit to scroll-tech/go-ethereum that referenced this issue Oct 31, 2024
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants