fix broken tests

This commit is contained in:
Jared Wasinger 2026-01-15 10:54:33 +09:00
parent 040dccd10c
commit 5dbbf3dc8e
4 changed files with 16 additions and 16 deletions

View file

@ -336,6 +336,9 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
} }
// Withdrawals processing. // Withdrawals processing.
for _, w := range body.Withdrawals { for _, w := range body.Withdrawals {
// always read the target account regardless of withdrawal amt to include it in the BAL
state.GetBalance(w.Address)
// Convert amount from gwei to wei. // Convert amount from gwei to wei.
amount := new(uint256.Int).SetUint64(w.Amount) amount := new(uint256.Int).SetUint64(w.Amount)
amount = amount.Mul(amount, uint256.NewInt(params.GWei)) amount = amount.Mul(amount, uint256.NewInt(params.GWei))
@ -361,6 +364,7 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
return nil, errors.New("withdrawals set before Shanghai activation") return nil, errors.New("withdrawals set before Shanghai activation")
} }
} }
// Finalize and assemble the block. // Finalize and assemble the block.
beacon.Finalize(chain, header, state, body) beacon.Finalize(chain, header, state, body)

View file

@ -100,21 +100,6 @@ var (
blockExecutionTimer = metrics.NewRegisteredResettingTimer("chain/execution", nil) blockExecutionTimer = metrics.NewRegisteredResettingTimer("chain/execution", nil)
blockWriteTimer = metrics.NewRegisteredResettingTimer("chain/write", nil) blockWriteTimer = metrics.NewRegisteredResettingTimer("chain/write", nil)
// BAL-specific timers
blockPreprocessingTimer = metrics.NewRegisteredResettingTimer("chain/preprocess", nil)
txExecutionTimer = metrics.NewRegisteredResettingTimer("chain/txexecution", nil)
stateTrieHashTimer = metrics.NewRegisteredResettingTimer("chain/statetriehash", nil)
accountTriesUpdateTimer = metrics.NewRegisteredResettingTimer("chain/accounttriesupdate", nil)
stateTriePrefetchTimer = metrics.NewRegisteredResettingTimer("chain/statetrieprefetch", nil)
stateTrieUpdateTimer = metrics.NewRegisteredResettingTimer("chain/statetrieupdate", nil)
originStorageLoadTimer = metrics.NewRegisteredResettingTimer("chain/originstorageload", nil)
stateRootComputeTimer = metrics.NewRegisteredResettingTimer("chain/staterootcompute", nil)
stateCommitTimer = metrics.NewRegisteredResettingTimer("chain/statetriecommit", nil)
blockPostprocessingTimer = metrics.NewRegisteredResettingTimer("chain/postprocess", nil)
blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil) blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil) blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil) blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil)
@ -2217,9 +2202,11 @@ func (bc *BlockChain) ProcessBlock(parentRoot common.Hash, block *types.Block, s
vtime = time.Since(vstart) vtime = time.Since(vstart)
if enableBALFork { if enableBALFork {
computedAccessListHash := balTracer.AccessList().ToEncodingObj().Hash() computedAccessList := balTracer.AccessList().ToEncodingObj()
computedAccessListHash := computedAccessList.Hash()
if *block.Header().BlockAccessListHash != computedAccessListHash { if *block.Header().BlockAccessListHash != computedAccessListHash {
//fmt.Printf("remote:\n%s\nlocal:\n%s\n", block.Body().AccessList.JSONString(), computedAccessList.JSONString())
err := fmt.Errorf("block header access list hash mismatch with computed (header=%x computed=%x)", *block.Header().BlockAccessListHash, computedAccessListHash) err := fmt.Errorf("block header access list hash mismatch with computed (header=%x computed=%x)", *block.Header().BlockAccessListHash, computedAccessListHash)
bc.reportBadBlock(block, res, err) bc.reportBadBlock(block, res, err)
return nil, err return nil, err

View file

@ -556,6 +556,10 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
} else { } else {
fee := new(uint256.Int).SetUint64(st.gasUsed()) fee := new(uint256.Int).SetUint64(st.gasUsed())
fee.Mul(fee, effectiveTipU256) fee.Mul(fee, effectiveTipU256)
// always read the coinbase account to include it in the BAL (TODO check this is actually part of the spec)
st.state.GetBalance(st.evm.Context.Coinbase)
st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee) st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee)
// add the coinbase to the witness iff the fee is greater than 0 // add the coinbase to the witness iff the fee is greater than 0

View file

@ -69,6 +69,11 @@ func (e *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
return nil return nil
} }
func (e *BlockAccessList) JSONString() string {
res, _ := json.MarshalIndent(e.StringableRepresentation(), "", " ")
return string(res)
}
// StringableRepresentation returns an instance of the block access list // StringableRepresentation returns an instance of the block access list
// which can be converted to a human-readable JSON representation. // which can be converted to a human-readable JSON representation.
func (e *BlockAccessList) StringableRepresentation() interface{} { func (e *BlockAccessList) StringableRepresentation() interface{} {