Skip to content

Commit

Permalink
BUGFIX:All blocks since London fork couldn’t be accepted by ethpow ch…
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul authored and Paul committed Aug 15, 2022
1 parent 4b273d6 commit 50794ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 50794ae

Please sign in to comment.