Skip to content

Commit

Permalink
modify EIP-3607 to accept tx type 4 (#11944)
Browse files Browse the repository at this point in the history
- bug found by Mario/Pari from EF.
- needs to be cp'ed into docker_pectra branch
  • Loading branch information
sudeepdino008 authored Sep 11, 2024
1 parent f3f4fe6 commit 5d335c5
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions eth/stagedsync/stage_mining_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"io"
"math/big"
"sync/atomic"
"time"

Expand Down Expand Up @@ -308,15 +307,15 @@ func getNextTransactions(
}

blockNum := executionAt + 1
txs, err := filterBadTransactions(txs, cfg.chainConfig, blockNum, header.BaseFee, simStateReader, simStateWriter, logger)
txs, err := filterBadTransactions(txs, cfg.chainConfig, blockNum, header, simStateReader, simStateWriter, logger)
if err != nil {
return nil, 0, err
}

return types.NewTransactionsFixedOrder(txs), count, nil
}

func filterBadTransactions(transactions []types.Transaction, config chain.Config, blockNumber uint64, baseFee *big.Int, simStateReader state.StateReader, simStateWriter state.StateWriter, logger log.Logger) ([]types.Transaction, error) {
func filterBadTransactions(transactions []types.Transaction, config chain.Config, blockNumber uint64, header *types.Header, simStateReader state.StateReader, simStateWriter state.StateWriter, logger log.Logger) ([]types.Transaction, error) {
initialCnt := len(transactions)
var filtered []types.Transaction
gasBailout := false
Expand Down Expand Up @@ -361,15 +360,28 @@ func filterBadTransactions(transactions []types.Transaction, config chain.Config

// Make sure the sender is an EOA (EIP-3607)
if !account.IsEmptyCodeHash() {
transactions = transactions[1:]
notEOACnt++
continue
isEoaCodeAllowed := false
if config.IsPrague(header.Time) {
code, err := simStateReader.ReadAccountCode(sender, account.Incarnation, account.CodeHash)
if err != nil {
return nil, err
}

_, isDelegated := types.ParseDelegation(code)
isEoaCodeAllowed = isDelegated // non-empty code allowed for eoa if it points to delegation
}

if !isEoaCodeAllowed {
transactions = transactions[1:]
notEOACnt++
continue
}
}

if config.IsLondon(blockNumber) {
baseFee256 := uint256.NewInt(0)
if overflow := baseFee256.SetFromBig(baseFee); overflow {
return nil, fmt.Errorf("bad baseFee %s", baseFee)
if overflow := baseFee256.SetFromBig(header.BaseFee); overflow {
return nil, fmt.Errorf("bad baseFee %s", header.BaseFee)
}
// Make sure the transaction gasFeeCap is greater than the block's baseFee.
if !transaction.GetFeeCap().IsZero() || !transaction.GetTip().IsZero() {
Expand Down

0 comments on commit 5d335c5

Please sign in to comment.