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: handle "transaction underpriced" and other unknown server error responses #1617

Merged
merged 6 commits into from
Jul 8, 2020

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented Jul 1, 2020

Closes #1615

Overview

Adds "transaction underpriced" and unknown server error response to block submission response handling, preventing unnecessary BlockQueue crashes.

Changes

  • Add "transaction underpriced" response handling to BlockQueue.Core.process_submit_result/3
  • Add code >= -32_099 and code <= -32_000 server error fallback
  • Minimum code changes without refactoring because refactoring the BlockQueue already started as part of feat: poisson regression and gas price feature flag #1575

Testing

On local environments, set geth --miner.gas_price to a very high value e.g. 200Gwei. Then trigger a block submission. The error should be handled and logged.

@unnawut unnawut self-assigned this Jul 1, 2020
@unnawut unnawut marked this pull request as ready for review July 1, 2020 13:26
Copy link
Contributor

@boolafish boolafish left a comment

Choose a reason for hiding this comment

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

⛽️⛽️⛽️⛽️⛽️⛽️

# Returns `:ok` so that BlockQueue can continue and do a retry, similar to a low replacement price error.
def process_submit_result(submission, {:error, %{"code" => code} = error}, _newest_mined_blknum)
when code >= -32_099 and code <= -32_000 do
_ = Logger.error("Submission #{inspect(submission)} resulted in an unknown server error: #{inspect(error)}.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we alarm on all error log. If not let's make sure we add alarm on this, either via Datadog parsing the error message or do the direct alarm (?) from code?

Copy link
Contributor Author

@unnawut unnawut Jul 2, 2020

Choose a reason for hiding this comment

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

Good idea! I think we can do with an app alarm when a block submission is pending for more than 2 blocks (since we're aiming for next-block inclusion, but I'll make number configurable in case of too many false panics). Then Datadog can consume this app alarm similar to :ethereum_stalled_sync and friends.

Since we're losing this visibility because this PR is suppressing the exception, I'll add :block_submission_stalled alarm to this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're losing this visibility because this PR is suppressing the exception, I'll add :block_submission_stalled alarm to this PR.

Queue observability size. Hell yeah!

@@ -616,6 +636,11 @@ defmodule OMG.ChildChain.BlockQueue.Core do
:ok
end

defp log_tx_underpriced(submission) do
_ = Logger.debug("Submission #{inspect(submission)} got rejected due to low gas price - ignored")
Copy link
Contributor

Choose a reason for hiding this comment

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

I again don't think debug log brings much value (probably 0 in this case as this would probably only happen on mainnet env).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@unnawut unnawut changed the title Handle "transaction underpriced" and other unknown server error responses fix: handle "transaction underpriced" and other unknown server error responses Jul 3, 2020
@unnawut
Copy link
Contributor Author

unnawut commented Jul 3, 2020

Adding @InoMurko as reviewer as this relates to block submission

@unnawut unnawut requested a review from InoMurko July 3, 2020 07:15
@@ -281,6 +281,17 @@ defmodule OMG.ChildChain.BlockQueue.Core do
:ok
end

# https://github.com/ethereum/go-ethereum/blob/v1.9.15/core/tx_pool.go#L62-L64
def process_submit_result(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure why do we even bother "handling" results. We don't do anything with them, we're just spending effort defining all function headers and then we ... log and return :ok?
I've never understood the purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering the same. It turns about the block queue uses these :ok, {:error, ...} returns to determine if the submission was successful or if it needs to retry the submission :(

I don't like it too but it's not a small refactor. I'm kind of unbundling this in #1575 though

Copy link
Contributor

@InoMurko InoMurko left a comment

Choose a reason for hiding this comment

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

Okay, I'll approve after you add block_submission_stalled alarm.

@unnawut unnawut marked this pull request as draft July 8, 2020 04:47
@unnawut unnawut marked this pull request as ready for review July 8, 2020 07:11
@unnawut
Copy link
Contributor Author

unnawut commented Jul 8, 2020

I'll follow up with :block_submission_stalled in a separate PR

Update: this tracking #1629

@boolafish boolafish merged commit e6f0c23 into master Jul 8, 2020
@boolafish boolafish deleted the unnawut/block-queue-log branch July 8, 2020 08:21
@unnawut unnawut added the bug Something isn't working label Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle "transaction underpriced" error response from Ethereum client
3 participants