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

Implementation of endpoints eth_getBlockReceipts and eth_getBlockTransactionCountByHash #169

Open
wants to merge 1 commit into
base: portal
Choose a base branch
from

Conversation

r4f4ss
Copy link

@r4f4ss r4f4ss commented Sep 24, 2024

Implementations follows specs.

Reference file: internal/ethapi/api.go

Note that is WIP since eth_getBlockReceipts returns the error "parameter not implemented" if called with string tag (e.g. "latest") or block number. Block search by number is not implemented.

Integration test of eth_getBlockReceipts

Using curl:

curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305"],"id":1}'
curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["latest"],"id":1}'
curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["0x1234"],"id":1}'

Apparently ethers Js do not implement this method: ethers-io/ethers.js#4768

Intregration test of eth_getBlockTransactionCountByHash

Using curl:

curl 127.0.0.1:8545/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305"],"id":1}'

Using web3.js:

import { Web3 } from 'web3'

const provider = new Web3("http://localhost:8545/");
const tc = await provider.eth.getBlockTransactionCount("0xb81fcfee29cea2922aa9f553644463bee1c49895e56bc87f4417834e681ad305")
console.log(tc)

var errParameterNotImplemented = errors.New("parameter not implemented")

// marshalReceipt marshals a transaction receipt into a JSON object.
func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int) map[string]interface{} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the origin function public to avoid copying it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we could, and it'd be better because avoid redundant code. My only concern is in the scenario:

  1. We make marshalReceipt public (MarshalReceipt)
  2. Someone developing geth calls marshalReceipt
  3. Geth is merged into Shisui

I am not entirely sure but it potentially may cause a merge conflict. Anyway this conflict is simple to solve.

@GrapeBaBa should I make the origin function public?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your thoughts, and I have similar considerations. I feel this method should be relatively easy to merge, what do you think? @fearlessfe @thinkAfCod

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if take issue #22 into consideration, may be copy will be better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@GrapeBaBa GrapeBaBa self-requested a review September 25, 2024 04:33
@fearlessfe fearlessfe assigned fearlessfe and unassigned fearlessfe Sep 25, 2024
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

Successfully merging this pull request may close these issues.

3 participants