Skip to content

IS-1459 Fix Berlin replay state-root compatibility and DB usage recovery#2482

Merged
badrogger merged 6 commits into
v5.2.0from
is-1459-berlin-state-root-fix
Jun 5, 2026
Merged

IS-1459 Fix Berlin replay state-root compatibility and DB usage recovery#2482
badrogger merged 6 commits into
v5.2.0from
is-1459-berlin-state-root-fix

Conversation

@badrogger
Copy link
Copy Markdown
Contributor

Description

Fixed a Berlin fork replay compatibility issue where EIP-2929 access sets could be initialized at the wrong time or with incomplete data, especially around contract creation. This caused 5.2.0 to replay some 5.1.0-produced blocks with different warm/cold access
accounting, leading to gas/receipt differences and potential state-root mismatches.

Also fixed pieceUsageBytes handling for block DB rotation accounting. The value could be missing or incorrect, causing storage/rotation logic to use bad accounting data instead of recovering it from existing block/extras DB contents.

Tests

Validated with hardfork compatibility replay focused on 5.1.0-produced blocks replayed by 5.2.0, including blocks containing legacy, Type1/Type2, contract deployment, and CREATE/CREATE2 transactions.

Also verified that the Berlin fork path no longer produces state-root mismatches during replay.

Performance Impact

No expected runtime performance regression.

The Berlin fix affects per-transaction access-set initialization/restoration only in Berlin-enabled execution paths. The pieceUsageBytes fix affects DB accounting/recovery and rotation bookkeeping, not normal EVM execution. No benchmarks were required.

Copilot AI review requested due to automatic review settings June 3, 2026 10:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates transaction RLP decoding to incorporate BerlinForkPatch state, aiming to make Berlin-era replay behavior deterministic (notably around access-list parsing / downstream warm-cold accounting), by threading a Berlin flag through Transaction/TransactionBase construction and using it during access-list validation.

Changes:

  • Add a _berlinForkPatchEnabled flag to Transaction and TransactionBase constructors and propagate it through major transaction-decode call sites (RPC, txqueue, block import, host, precompiles, etc.).
  • Gate strict EIP-2930 access-list address/storage-key length validation behind BerlinForkPatch during typed-transaction decoding.

Findings (sorted by severity)

  • Critical: eth_inspectTransaction is currently passing patch flags in the wrong argument positions to Transaction(...), which can inadvertently enable allowInvalid and disable intended patch flags.
  • Medium: StateProgressLog::loadProgressData() decodes stored CTX transactions using isEnabledInWorkingBlock() instead of the persisted data.timestamp, which can mis-decode transactions when crash recovery occurs across a patch activation boundary.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libweb3jsonrpc/Eth.cpp Passes Berlin patch flag into RPC transaction decoding (but currently has a critical argument-order bug in eth_inspectTransaction).
libskale/StateProgressLog.cpp Adds Berlin patch flag to crash-recovery CTX decoding (should key off persisted timestamp, not working-block state).
libethereum/TransactionQueue.cpp Threads Berlin patch enable into txpool import/verification decoding.
libethereum/Transaction.h Extends Transaction constructor signature with _berlinForkPatchEnabled.
libethereum/Transaction.cpp Forwards Berlin patch enable flag into TransactionBase.
libethereum/SkaleHost.cpp Threads Berlin patch enable into broadcast/regular/CTX transaction decoding.
libethereum/Precompiled.cpp Threads Berlin patch enable into precompile-created transaction decoding.
libethereum/ClientBase.cpp Threads Berlin patch enable into historical transaction decoding keyed by block timestamp.
libethereum/BlockChain.cpp Threads Berlin patch enable into block verification and pending CTX decoding keyed by timestamp.
libethcore/TransactionBase.h Extends TransactionBase ctor and typed-decode helpers with _berlinForkPatchEnabled.
libethcore/TransactionBase.cpp Uses _berlinForkPatchEnabled to gate strict access-list entry length validation during typed-tx decoding.

Comment thread libweb3jsonrpc/Eth.cpp Outdated
Comment thread libskale/StateProgressLog.cpp Outdated
Comment on lines 157 to 161
dev::eth::Transaction tx( item[0].data(), dev::eth::CheckTransaction::None, true,
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
InvalidTransactionFormatPatch::isEnabledInWorkingBlock(),
BerlinForkPatch::isEnabledInWorkingBlock(),
Bite2Patch::isEnabledInWorkingBlock() );
@badrogger badrogger changed the title IS-1459 Handle pieceUsageBytes IS-1459 Fix Berlin changes related state-root Jun 3, 2026
@badrogger badrogger changed the title IS-1459 Fix Berlin changes related state-root Fix Berlin replay state-root compatibility and DB usage recovery Jun 3, 2026
@badrogger badrogger changed the title Fix Berlin replay state-root compatibility and DB usage recovery IS-1459 Fix Berlin replay state-root compatibility and DB usage recovery Jun 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.

Comment on lines +71 to +80
os.environ["HARDFORK_COMPAT_CFG_JSON"] = cfg_file
pytest.main(
[
str(SUITE_DIR / "test_hardfork_compat.py"),
"-v",
"--tb=short",
"-p", "no:cacheprovider",
],
plugins=[collector],
)
@badrogger badrogger merged commit 0449cf8 into v5.2.0 Jun 5, 2026
12 checks passed
@badrogger badrogger deleted the is-1459-berlin-state-root-fix branch June 5, 2026 14:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants