Skip to content

Commit

Permalink
fix: add missing part when preparing env in SimulateBundle (bnb-cha…
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Apr 18, 2024
1 parent 30c5d53 commit a00f223
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/systemcontracts"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
Expand Down Expand Up @@ -327,6 +329,25 @@ func (miner *Miner) SimulateBundle(bundle *types.Bundle) (*big.Int, error) {
return nil, err
}

// Apply EIP-4844, EIP-4788.
if miner.worker.chainConfig.IsCancun(header.Number, header.Time) {
var excessBlobGas uint64
if miner.worker.chainConfig.IsCancun(parent.Number, parent.Time) {
excessBlobGas = eip4844.CalcExcessBlobGas(*parent.ExcessBlobGas, *parent.BlobGasUsed)
} else {
// For the first post-fork block, both parent.data_gas_used and parent.excess_data_gas are evaluated as 0
excessBlobGas = eip4844.CalcExcessBlobGas(0, 0)
}
header.BlobGasUsed = new(uint64)
header.ExcessBlobGas = &excessBlobGas
if miner.worker.chainConfig.Parlia != nil {
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
}
// if miner.worker.chainConfig.Parlia == nil {
// header.ParentBeaconRoot = genParams.beaconRoot
// }
}

state, err := miner.eth.BlockChain().StateAt(parent.Root)
if err != nil {
return nil, err
Expand All @@ -338,6 +359,11 @@ func (miner *Miner) SimulateBundle(bundle *types.Bundle) (*big.Int, error) {
signer: types.MakeSigner(miner.worker.chainConfig, header.Number, header.Time),
}

if !miner.worker.chainConfig.IsFeynman(header.Number, header.Time) {
// Handle upgrade build-in system contract code
systemcontracts.UpgradeBuildInSystemContract(miner.worker.chainConfig, header.Number, parent.Time, header.Time, env.state)
}

s, err := miner.worker.simulateBundles(env, []*types.Bundle{bundle})
if err != nil {
return nil, err
Expand Down

0 comments on commit a00f223

Please sign in to comment.