Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing part when preparing env in SimulateBundle #19

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading