Skip to content

fix base fee byte order#258

Open
BitWonka wants to merge 10 commits into
migalabs:devfrom
BitWonka:fix-basefee-byte-order
Open

fix base fee byte order#258
BitWonka wants to merge 10 commits into
migalabs:devfrom
BitWonka:fix-basefee-byte-order

Conversation

@BitWonka
Copy link
Copy Markdown

@BitWonka BitWonka commented Apr 21, 2026

Motivation

Bellatrix and Capella blocks store BaseFeePerGas as a 32-byte SSZ field in little-endian format. The current code reads the first 8 bytes using binary.BigEndian.Uint64(), which interprets them in the wrong byte order, producing a massively inflated base fee value (~11.8 ETH per gas instead of ~13 Gwei).

This causes every transaction in Bellatrix/Capella blocks to be skipped in the priority fee calculation (gasPrice < baseFeePerGas is always true), resulting in f_reward_fees and f_burnt_fees being written as 0 for all blocks from the merge (slot 4,700,013) through the Deneb upgrade (slot 8,626,175).

Related links:
https://github.com/attestantio/go-eth2-client/blob/master/spec/bellatrix/executionpayload.go#L61

Description

Change binary.BigEndian.Uint64() to binary.LittleEndian.Uint64() for both Bellatrix and Capella BaseFeePerGas parsing inpkg/spec/block.go. This matches how SSZ encodes integers and aligns with the Uint64() behavior used by Deneb/Electra/Fulu.

Tasks

  • Fix Bellatrix BaseFeePerGas byte order
  • Fix Capella BaseFeePerGas byte order

Proof of Success

Slot 4700853 has a base fee of ~11.9 Gwei (11913161380 Wei) per the beacon API.

Before fix, goteth reads this as 11847304610421145600 (~11.8 ETH) due to wrong byte order. Since every transaction's gas price is below this inflated value, all are skipped and f_reward_fees/f_burnt_fees are persisted as 0.

After fix, the base fee reads correctly and priority fees calculate as expected.

leobago and others added 10 commits February 17, 2026 16:29
Fix Lighthouse v8.1.0 SSE race condition and reward calculation bugs
fix: historical deadlock, attestation flag, concurrent map race, orphan duties
fix: propagate block changes to dependent epochs after reorg + v3.8.0
Fix RoutineBook.Acquire deadlock causing missing block rewards
fix: transaction value uint64 overflow and Float32 precision loss
Fix ProcessSlashings accumulation + ManualReward race condition + block rewards validation
fix: prevent Wait() deadlocks, remove dead relays, add relay circuit breaker
fix(relay): remove securerpc and wenmerge mainnet relays
@Zyra-V21
Copy link
Copy Markdown
Collaborator

Hey @BitWonka, thanks for opening this PR! We'll review it on our end and follow up shortly. 🙌

@Zyra-V21
Copy link
Copy Markdown
Collaborator

Zyra-V21 commented May 7, 2026

Hello @BitWonka ! Could you please point the PR to DEV branch so we can test it before merging to main branch? Thanks! Same for the #259 !

@BitWonka BitWonka changed the base branch from master to dev May 7, 2026 15:23
@BitWonka
Copy link
Copy Markdown
Author

BitWonka commented May 7, 2026

@Zyra-V21 updated, worth considering making dev the default branch so forks would inherit it and PRs would target dev automatically

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.

3 participants