Skip to content

core/vm: price the 0x68 double-sign-evidence precompile per input byte at Pasteur - #3772

Merged
zlacfzy merged 1 commit into
bnb-chain:developfrom
zlacfzy:fix/0x68-doublesign-perbyte-gas
Sep 8, 2026
Merged

zlacfzy merged 1 commit into
bnb-chain:developfrom
zlacfzy:fix/0x68-doublesign-perbyte-gas

Conversation

@zlacfzy

@zlacfzy zlacfzy commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

@hashdit-bot

hashdit-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Pull Request Review

This PR updates the Go-based EVM implementation to use a Pasteur-specific variant of the double-sign evidence precompile at address 0x68. After Pasteur activation, the precompile charges a 10,000 gas base fee plus 16 gas per input byte, while retaining the existing verification logic and pre-Pasteur pricing.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@zlacfzy zlacfzy closed this Jul 30, 2026
@zlacfzy
zlacfzy deleted the fix/0x68-doublesign-perbyte-gas branch July 30, 2026 07:55
@zlacfzy
zlacfzy restored the fix/0x68-doublesign-perbyte-gas branch September 2, 2026 06:22
@zlacfzy zlacfzy reopened this Sep 2, 2026
@hashdit-bot

hashdit-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

Pull Request Review

This PR updates an Ethereum-compatible Go EVM so that, from the Pasteur fork, the double-sign-evidence precompile at 0x68 uses a fork-specific implementation with gas charged per input byte. It adds a 16-gas-per-byte protocol parameter while preserving the existing verification logic and base gas charge.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

…e at Jenner

verifyDoubleSignEvidence charges a flat DoubleSignEvidenceVerifyGas regardless of
input size, while Run computes SealHash over both RLP-decoded headers whose Extra
fields are not size-bounded, so the metered cost does not track the hashing work.

Add a Jenner-gated variant (verifyDoubleSignEvidenceJenner) pricing per input
byte (DoubleSignEvidenceVerifyPerByteGas = 16), mirroring 0x67's
cometBFTLightBlockValidatePasteur. Verification logic inherited unchanged;
pre-Jenner tables (including Pasteur) keep the flat-gas contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@zlacfzy
zlacfzy force-pushed the fix/0x68-doublesign-perbyte-gas branch from 539afa5 to 20c1f8d Compare September 2, 2026 06:29
@hashdit-bot

hashdit-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

Pull Request Review

This PR updates the Go-based EVM implementation so the double-sign-evidence precompile at address byte 0x68 uses a Jenner-specific gas calculator while retaining the existing verification logic. It adds a gas charge of 16 per input byte on top of the existing 10,000 base gas, mitigating underpriced processing of oversized RLP-encoded headers.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@joey0612

joey0612 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

core/vm: price the 0x68 double-sign-evidence precompile per input byte at Pasteur -> Jenner ?

@zlacfzy
zlacfzy merged commit 1b276b9 into bnb-chain:develop Sep 8, 2026
8 checks passed
chee-chyuan added a commit to bnb-chain/reth-bsc that referenced this pull request Sep 10, 2026
…yte at Jenner (#498)

Ports bnb-chain/bsc#3772. Precompile 0x68 (DoubleSignEvidenceValidation) charges a
flat 10,000 gas no matter how large the RLP-encoded headers in the evidence are, even
though the work it does -- decoding both headers and computing two seal hashes over
their full encoding -- scales with input size. A caller can therefore impose unbounded
hashing for a fixed fee.

From Jenner the cost becomes `10_000 + len(input) * 16`, mirroring go-bsc's
`verifyDoubleSignEvidenceJenner.RequiredGas` and matching what Pasteur already did for
0x67 (`COMETBFT_LIGHT_BLOCK_VALIDATE_PER_BYTE_GAS`). The verification logic is
untouched, so the accepted-input set is unchanged; only the price moves.

Because the change is consensus-visible -- a call that succeeds at a 10,000 gas
allowance before Jenner runs out of gas from Jenner -- it is fork-gated the same way go
gates it, via a new cumulative Jenner precompile table that inherits Pasteur's and
overrides 0x68. `traced_precompiles_for_spec` gains the matching arm ahead of Pasteur.

Like go-bsc, the Jenner variant keeps the pre-Jenner precompile name
("VERIFY_DOUBLE_SIGN_EVIDENCE"): `verifyDoubleSignEvidenceJenner` embeds
`verifyDoubleSignEvidence` and overrides only `RequiredGas`, inheriting `Name()`.

BEP-706's 0x70 milli-timestamp precompile is deliberately not in the new table -- it
reads block context and stays dynamically registered by `BscEvm::new`.

Tests cover the per-byte charge on success, on revert (go charges `RequiredGas` before
`Run`, so a rejected evidence still pays), the empty-input base-fee edge, the
pre-Jenner/Jenner out-of-gas split at the same allowance, and that a Jenner-spec EVM
resolves to the Jenner table rather than falling through to Pasteur's.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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