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

fix: eth_getTransactionByHash + eth_getTransactionReceipt fixes #9933

Merged
merged 8 commits into from
Dec 23, 2022

Conversation

raulk
Copy link
Member

@raulk raulk commented Dec 23, 2022

Related Issues

  • Hash was 0, thus leading to issues with Hardhat and other tools.
  • BlockHash, BlockNumber, and TransactionIndex must be null (not zero) when tx is returned from mpool.
  • Transaction receipt with no logs should return an empty logs array (instead of null).
  • For correctness, a transaction receipt with no logs should return a 256 bytes sized bloom.
  • Return nonce.

Proposed Changes

Fix these issues and add coverage in FEVM integration tests.

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@raulk raulk requested a review from a team as a code owner December 23, 2022 12:05
@raulk raulk requested a review from ychiaoli18 December 23, 2022 12:05
ychiaoli18 and others added 4 commits December 23, 2022 23:26
Hardhat doesn't like logs: null in transaction receipts when no logs
were emitted. Wants empty array.

Size logsBloom correctly.
@raulk raulk changed the title fix: eth_getTransactionByHash: several issues when returning from mpool fix: eth_getTransactionByHash + eth_getTransactionReceipt fixes Dec 23, 2022
Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

Approved if we want a quick merge, but would like to see the suggested changes to the test implemented (can wait until we do the feat/nv18-fevm -> master merge if necessary).

// require that the hashes are identical
require.Equal(t, hash, mpoolTx.Hash)

// these fields should be nil because the tx hasn't landed on chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's not play this game, we're inviting flakiness here.

Can we just try to lookup the receipt before making these assertions? If found, let's simply skip them (with a log saying that we're doing so).

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually a pretty important assertion (we had bugs here before, so want to lock these for regression testing). I'm onboard with deflaking, as long as we don't withdraw coverage we need.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Miners in the itest framework have pause and unpause functions exposed, but we should implement a function for the test kit that allows us to pause and unpause all mining.

blockTime := 100 * time.Millisecond
// reasonable blocktime so that the tx sits in the mpool for a bit during the test.
// although this is non-deterministic...
blockTime := 1 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider increasing this -- this test isn't really constrained by epochs (needs ~3 epochs), so even if the blocktime were like 5 seconds, it would still finish pretty quickly

Copy link
Member Author

Choose a reason for hiding this comment

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

Plus the boot up time for the chain (around 10 epochs).

var receipt *api.EthTxReceipt
for i := 0; i < 10000000000; i++ {
for i := 0; i < 20; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just actually StateWaitMsg here instead of this funkiness -- if we don't have the tooling to easily get the msgCid, slap a TODO on it for now (I think the work @geoff-vball is doing will make this easy to do).

Copy link
Member Author

Choose a reason for hiding this comment

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

We do need to check that the receipt is null while the transaction hasn't landed on chain -- it's part of the test's coverage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, keep doing that every 500ms, but the cue to stop is StateWaitMsg returning (not "i waited 10 seconds").

Copy link
Member Author

Choose a reason for hiding this comment

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

We still need a timeout for the test (should not let it run indefinitely). We could have a timed context with StateWaitMsg, but at that point we're achieving the same effect as here with more complicated code, so it's a matter of choice.

@raulk
Copy link
Member Author

raulk commented Dec 23, 2022

In case you're wondering if I'm making up the how this API should behave, I am not. Sources include:

@raulk raulk merged commit c7efaaa into feat/nv18-fevm Dec 23, 2022
@raulk raulk deleted the raulk/fix-ethapi-tx branch December 23, 2022 17:20
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.

4 participants