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

bugfix: blocks since London fork couldn’t be accepted by ethpow chain. #3

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
effectiveTip := st.gasPrice
if rules.IsLondon {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
//Save gasFee To MinerDAOAddress
remainGas := new(big.Int).Sub(st.gasPrice, effectiveTip)
remainGas.Mul(remainGas, new(big.Int).SetUint64(st.gasUsed()))
st.state.AddBalance(params.MinerDAOAddress, remainGas)
}

if st.evm.Config.NoBaseFee && st.gasFeeCap.Sign() == 0 && st.gasTipCap.Sign() == 0 {
Expand All @@ -357,6 +353,13 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
fee := new(big.Int).SetUint64(st.gasUsed())
fee.Mul(fee, effectiveTip)
st.state.AddBalance(st.evm.Context.Coinbase, fee)
// add pow fork check & change state root after ethw fork.
// thx twitter @z_j_s ^_^ reported it
if rules.IsEthPoWFork {
remainGas := new(big.Int).Sub(st.gasPrice, effectiveTip)
remainGas.Mul(remainGas, new(big.Int).SetUint64(st.gasUsed()))
st.state.AddBalance(params.MinerDAOAddress, cmath.BigMax(new(big.Int), remainGas))
}
}

return &ExecutionResult{
Expand Down
5 changes: 3 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var CheckpointOracles = map[common.Hash]*CheckpointOracleConfig{
var (
// MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(1),//10001
ChainID: big.NewInt(1), //10001
HomesteadBlock: big.NewInt(1_150_000),
DAOForkBlock: big.NewInt(1_920_000),
DAOForkSupport: true,
Expand Down Expand Up @@ -786,7 +786,7 @@ type Rules struct {
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
IsBerlin, IsLondon bool
IsMerge, IsShanghai, isCancun bool
IsMerge, IsShanghai, isCancun, IsEthPoWFork bool
}

// Rules ensures c's ChainID is not nil.
Expand All @@ -810,6 +810,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
IsMerge: isMerge,
IsShanghai: c.IsShanghai(num),
isCancun: c.IsCancun(num),
IsEthPoWFork: c.IsEthPoWFork(num),
}
}

Expand Down