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

feat (internal/ethapi): implement eth_getBlockReceipts #2284

Conversation

kamikazechaser
Copy link
Contributor

@kamikazechaser kamikazechaser commented Mar 19, 2024

Description

Addition of a new ETH RPC method eth_getBlockReceipts.

ethereum/execution-apis#438

Standardized and implemented in several eth clients e.g. geth, nethermind, nimbus, besu e.t.c.

Other changes

None.

Tested

internal/ethapi/api.go is not covered by any tests.

To be tested on a devnet/testnet with existing chaindata.

Related issues

Resolves #2187

Backwards compatibility

Backwards compatible.

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 55.76%. Comparing base (f0adb14) to head (d77ad8e).
Report is 26 commits behind head on master.

❗ Current head d77ad8e differs from pull request most recent head 33d4baa. Consider uploading reports for the commit 33d4baa to get more accurate results

Files Patch % Lines
internal/ethapi/api.go 0.00% 15 Missing ⚠️
ethclient/ethclient.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2284      +/-   ##
==========================================
+ Coverage   55.06%   55.76%   +0.70%     
==========================================
  Files         684      684              
  Lines      114596    92000   -22596     
==========================================
- Hits        63097    51308   -11789     
+ Misses      47617    36795   -10822     
- Partials     3882     3897      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@palango palango left a comment

Choose a reason for hiding this comment

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

Looks good so far, please add the missing docstring.

ethclient/ethclient.go Show resolved Hide resolved
@palango
Copy link
Contributor

palango commented Mar 26, 2024

For future reference, upstream PR: ethereum/go-ethereum#27702

@palango
Copy link
Contributor

palango commented Mar 28, 2024

@kamikazechaser I had another look and I think we need to add the effective gas price to the receipts as it is done in GetTransactionReceipt, otherwise the receipts will differ.

if !s.b.ChainConfig().IsLondon(bigblock) {
fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
} else {
// var gasPrice *big.Int = new(big.Int)
if tx.Type() == types.DynamicFeeTxType || tx.Type() == types.CeloDynamicFeeTxType || tx.Type() == types.CeloDynamicFeeTxV2Type {
header, err := s.b.HeaderByHash(ctx, blockHash)
if err != nil {
return nil, err
}
gasPriceMinimum, err := s.b.GasPriceMinimumForHeader(ctx, tx.FeeCurrency(), header)
if err == nil {
fields["effectiveGasPrice"] = hexutil.Uint64(new(big.Int).Add(gasPriceMinimum, tx.EffectiveGasTipValue(gasPriceMinimum)).Uint64())
}
// if err != nil, it's due to a state prune. In this case no effectiveGasPrice will be returned.
} else {
fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
}
}

* generateReceiptResponse now receives a context and a backend interface so as to also compute the effectiveGasPrice field in transaction receipts
@kamikazechaser
Copy link
Contributor Author

kamikazechaser commented Mar 29, 2024

@palango I have refactored the generateReceiptResponse helper to also accept a context and a backend interface. Tested on devnet.

I have also noticed there is an GetBlockReceipt method that is not a standardized API (added in #1628) that calls into generateReceiptResponse. because the tx passed by this method is nil, no effectiveGasPrice is assigned to that response. I would personally propose to deprecate that method and strictly follow the standardized spec. Anyways let me know what should be done for this case.

@palango
Copy link
Contributor

palango commented Apr 2, 2024

@palango I have refactored the generateReceiptResponse helper to also accept a context and a backend interface. Tested on devnet.

Thanks, the changes look good. Needs a merge from master, where a new transaction type was added in the meantime, but the conflict is easy to resolve.

I have also noticed there is an GetBlockReceipt method that is not a standardized API (added in #1628) that calls into generateReceiptResponse. because the tx passed by this method is nil, no effectiveGasPrice is assigned to that response. I would personally propose to deprecate that method and strictly follow the standardized spec. Anyways let me know what should be done for this case.

Yes, this is the RPC API to get receipts for celo system transactions. Not having the field added for them is fine.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 55.76%. Comparing base (f0adb14) to head (d77ad8e).
Report is 26 commits behind head on master.

❗ Current head d77ad8e differs from pull request most recent head 9eeeb3d. Consider uploading reports for the commit 9eeeb3d to get more accurate results

Files Patch % Lines
internal/ethapi/api.go 0.00% 15 Missing ⚠️
ethclient/ethclient.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2284      +/-   ##
==========================================
+ Coverage   55.06%   55.76%   +0.70%     
==========================================
  Files         684      684              
  Lines      114596    92000   -22596     
==========================================
- Hits        63097    51308   -11789     
+ Misses      47617    36795   -10822     
- Partials     3882     3897      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kamikazechaser
Copy link
Contributor Author

Not having the field added for them is fine.

Sounds good. I have also added the DenominatedFeeCurrency changes.

@carterqw2 carterqw2 merged commit 6351612 into celo-org:master Apr 3, 2024
20 of 22 checks passed
Copy link

github-actions bot commented Apr 3, 2024

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit 6351612

coverage: 51.1% of statements across all listed packages
coverage:  63.4% of statements in consensus/istanbul
coverage:  43.3% of statements in consensus/istanbul/announce
coverage:  56.0% of statements in consensus/istanbul/backend
coverage:   0.0% of statements in consensus/istanbul/backend/backendtest
coverage:  24.3% of statements in consensus/istanbul/backend/internal/replica
coverage:  65.6% of statements in consensus/istanbul/core
coverage:  50.0% of statements in consensus/istanbul/db
coverage:   0.0% of statements in consensus/istanbul/proxy
coverage:  64.2% of statements in consensus/istanbul/uptime
coverage:  51.8% of statements in consensus/istanbul/validator
coverage:  79.2% of statements in consensus/istanbul/validator/random

Copy link

github-actions bot commented Apr 3, 2024

5882 passed, 45 skipped

@piersy piersy mentioned this pull request Apr 9, 2024
ezdac pushed a commit that referenced this pull request Apr 18, 2024
* feat (internal/ethapi): implement eth_getBlockReceipts

* ref: #2187

* inline-docs (eth-client): add description for BlockReceipts

* refactor (ethapi/api.go): generateReceiptResponse helper

* generateReceiptResponse now receives a context and a backend interface so as to also compute the effectiveGasPrice field in transaction receipts

* reconcile: receipt changes from master 272982b (#2278)
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.

Feature request (ethapi): eth_getBlockReceipts
4 participants