Skip to content

Finalize state after each call in callMany#6381

Merged
AskAlexSharov merged 2 commits into
erigontech:develfrom
ArielTM:devel
Dec 21, 2022
Merged

Finalize state after each call in callMany#6381
AskAlexSharov merged 2 commits into
erigontech:develfrom
ArielTM:devel

Conversation

@ArielTM

@ArielTM ArielTM commented Dec 20, 2022

Copy link
Copy Markdown
Contributor

In debug_traceCallMany and eth_callMany the IntraBlockState is not being finalized after each replayed transaction and after each call. This can cause several problems:

  • False gas consumption calculation. Specifically in SSTORE dynamic gas calculation being affected by "warm" and "cold" storage slots, and by "original" value comparison.
  • Ability to call contracts that were SELFDESTRUCTed in the replayed transactions or during previous calls, as the self-destruction has not been finalized.

see #6373 as an example.

This pull request adds a call to FinalizeTx after each ApplyMessage and TraceTx

return nil, err
}

_ = st.FinalizeTx(rules, state.NewNoopWriter())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you please check, if SoftFinalise also fixing your problem?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems like it doesn't

@ArielTM ArielTM Dec 20, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me know if any more changes or checks are required :)

@AskAlexSharov AskAlexSharov merged commit 870b5ba into erigontech:devel Dec 21, 2022
@AskAlexSharov

Copy link
Copy Markdown
Collaborator

thank you. will be great if you can add some unit-test

AlexeyAkhunov pushed a commit that referenced this pull request Jan 12, 2023
Continuing the work of #6381 .
We encountered a problem in blocks with type 2 transactions,
specifically blocks with two transactions with the same `tx.from`. When
the first tx is replayed, a high `gasPrice` is being calculate in
`txn.AsMessage` causing the second replayed tx to fail with the
following error:
```
insufficient funds for gas * price + value: address ...
```
This happens in both `eth_callMany` and `debug_traceCallMany`.
This pull request follows the `debug_traceTransaction` usage of
`tx.AsMessage` in `ComputeTxEnv`
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.

2 participants