Skip to content

Commit d70afdd

Browse files
committed
consensus/misc: move eip1559 into a package (ethereum#27828)
1 parent b8f44a4 commit d70afdd

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
lines changed

consensus/XDPoS/engines/engine_v1/engine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
2020
"github.com/XinFinOrg/XDPoSChain/consensus/clique"
2121
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
22+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
2223
"github.com/XinFinOrg/XDPoSChain/core/state"
2324
"github.com/XinFinOrg/XDPoSChain/core/types"
2425
"github.com/XinFinOrg/XDPoSChain/crypto"
@@ -242,7 +243,7 @@ func (x *XDPoS_v1) verifyCascadingFields(chain consensus.ChainReader, header *ty
242243
return utils.ErrInvalidTimestamp
243244
}
244245
// Verify the header's EIP-1559 attributes.
245-
if err := misc.VerifyEip1559Header(chain.Config(), header); err != nil {
246+
if err := eip1559.VerifyEip1559Header(chain.Config(), header); err != nil {
246247
return err
247248
}
248249

consensus/XDPoS/engines/engine_v2/verifyHeader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/XinFinOrg/XDPoSChain/consensus"
1010
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
1111
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
12+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
1213
"github.com/XinFinOrg/XDPoSChain/core/types"
1314
"github.com/XinFinOrg/XDPoSChain/log"
1415
)
@@ -95,7 +96,7 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
9596
return utils.ErrInvalidUncleHash
9697
}
9798
// Verify the header's EIP-1559 attributes.
98-
if err := misc.VerifyEip1559Header(chain.Config(), header); err != nil {
99+
if err := eip1559.VerifyEip1559Header(chain.Config(), header); err != nil {
99100
return err
100101
}
101102
if header.Difficulty.Cmp(big.NewInt(1)) != 0 {

consensus/ethash/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/XinFinOrg/XDPoSChain/common/math"
2929
"github.com/XinFinOrg/XDPoSChain/consensus"
3030
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
31+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
3132
"github.com/XinFinOrg/XDPoSChain/core/state"
3233
"github.com/XinFinOrg/XDPoSChain/core/types"
3334
"github.com/XinFinOrg/XDPoSChain/params"
@@ -254,7 +255,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
254255
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
255256
}
256257
// Verify the header's EIP-1559 attributes.
257-
if err := misc.VerifyEip1559Header(chain.Config(), header); err != nil {
258+
if err := eip1559.VerifyEip1559Header(chain.Config(), header); err != nil {
258259
return err
259260
}
260261

consensus/misc/eip1559.go renamed to consensus/misc/eip1559/eip1559.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package misc
17+
package eip1559
1818

1919
import (
2020
"fmt"

core/chain_makers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"fmt"
2121
"math/big"
2222

23-
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
24-
2523
"github.com/XinFinOrg/XDPoSChain/common"
2624
"github.com/XinFinOrg/XDPoSChain/consensus"
2725
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
26+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
27+
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
2828
"github.com/XinFinOrg/XDPoSChain/core/state"
2929
"github.com/XinFinOrg/XDPoSChain/core/types"
3030
"github.com/XinFinOrg/XDPoSChain/core/vm"
@@ -285,7 +285,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
285285
Time: time,
286286
}
287287

288-
header.BaseFee = misc.CalcBaseFee(chain.Config(), header)
288+
header.BaseFee = eip1559.CalcBaseFee(chain.Config(), header)
289289

290290
return header
291291
}

core/txpool/txpool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/XinFinOrg/XDPoSChain/common"
3030
"github.com/XinFinOrg/XDPoSChain/common/prque"
3131
"github.com/XinFinOrg/XDPoSChain/consensus"
32-
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
32+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
3333
"github.com/XinFinOrg/XDPoSChain/core"
3434
"github.com/XinFinOrg/XDPoSChain/core/state"
3535
"github.com/XinFinOrg/XDPoSChain/core/types"
@@ -1319,7 +1319,7 @@ func (pool *TxPool) runReorg(done chan struct{}, reset *txpoolResetRequest, dirt
13191319
if reset != nil {
13201320
pool.demoteUnexecutables()
13211321
if reset.newHead != nil && pool.chainconfig.IsEIP1559(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) {
1322-
pendingBaseFee := misc.CalcBaseFee(pool.chainconfig, reset.newHead)
1322+
pendingBaseFee := eip1559.CalcBaseFee(pool.chainconfig, reset.newHead)
13231323
pool.priced.SetBaseFee(pendingBaseFee)
13241324
}
13251325
// Update all accounts to the latest known pending nonce

eth/gasprice/feehistory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"sync/atomic"
2828

2929
"github.com/XinFinOrg/XDPoSChain/common"
30-
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
30+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
3131
"github.com/XinFinOrg/XDPoSChain/core/types"
3232
"github.com/XinFinOrg/XDPoSChain/log"
3333
"github.com/XinFinOrg/XDPoSChain/rpc"
@@ -89,7 +89,7 @@ func (oracle *Oracle) processBlock(bf *blockFees, percentiles []float64) {
8989
bf.results.baseFee = new(big.Int)
9090
}
9191
if chainconfig.IsEIP1559(big.NewInt(int64(bf.blockNumber + 1))) {
92-
bf.results.nextBaseFee = misc.CalcBaseFee(chainconfig, bf.header)
92+
bf.results.nextBaseFee = eip1559.CalcBaseFee(chainconfig, bf.header)
9393
} else {
9494
bf.results.nextBaseFee = new(big.Int)
9595
}

internal/ethapi/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
4040
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
4141
"github.com/XinFinOrg/XDPoSChain/consensus/ethash"
42-
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
42+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
4343
contractValidator "github.com/XinFinOrg/XDPoSChain/contracts/validator/contract"
4444
"github.com/XinFinOrg/XDPoSChain/core"
4545
"github.com/XinFinOrg/XDPoSChain/core/state"
@@ -1933,7 +1933,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
19331933
func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction {
19341934
var baseFee *big.Int
19351935
if current != nil {
1936-
baseFee = misc.CalcBaseFee(config, current)
1936+
baseFee = eip1559.CalcBaseFee(config, current)
19371937
}
19381938
return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFee)
19391939
}

miner/worker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/XinFinOrg/XDPoSChain/consensus"
3333
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
3434
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
35+
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
3536
"github.com/XinFinOrg/XDPoSChain/contracts"
3637
"github.com/XinFinOrg/XDPoSChain/core"
3738
"github.com/XinFinOrg/XDPoSChain/core/state"
@@ -616,7 +617,7 @@ func (self *worker) commitNewWork() {
616617
Time: big.NewInt(tstamp),
617618
}
618619
// Set baseFee if we are on an EIP-1559 chain
619-
header.BaseFee = misc.CalcBaseFee(self.config, header)
620+
header.BaseFee = eip1559.CalcBaseFee(self.config, header)
620621

621622
// Only set the coinbase if we are mining (avoid spurious block rewards)
622623
if atomic.LoadInt32(&self.mining) == 1 {

0 commit comments

Comments
 (0)