Skip to content

Commit 7c95ebd

Browse files
authored
consensus/misc: move eip1559 into a package (#27828)
* consensus/misc: move eip1559 as a sub directory Signed-off-by: jsvisa <delweng@gmail.com> * consensus/misc: package name Signed-off-by: jsvisa <delweng@gmail.com> * all: eip1559 Signed-off-by: jsvisa <delweng@gmail.com> --------- Signed-off-by: jsvisa <delweng@gmail.com>
1 parent 2fd77a6 commit 7c95ebd

File tree

15 files changed

+32
-28
lines changed

15 files changed

+32
-28
lines changed

cmd/evm/internal/t8ntool/transition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/common/hexutil"
31-
"github.com/ethereum/go-ethereum/consensus/misc"
31+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3232
"github.com/ethereum/go-ethereum/core"
3333
"github.com/ethereum/go-ethereum/core/state"
3434
"github.com/ethereum/go-ethereum/core/types"
@@ -256,7 +256,7 @@ func Transition(ctx *cli.Context) error {
256256
GasUsed: prestate.Env.ParentGasUsed,
257257
GasLimit: prestate.Env.ParentGasLimit,
258258
}
259-
prestate.Env.BaseFee = misc.CalcBaseFee(chainConfig, parent)
259+
prestate.Env.BaseFee = eip1559.CalcBaseFee(chainConfig, parent)
260260
} else {
261261
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
262262
}

consensus/beacon/consensus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
"github.com/ethereum/go-ethereum/common"
2525
"github.com/ethereum/go-ethereum/consensus"
26-
"github.com/ethereum/go-ethereum/consensus/misc"
26+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
2727
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
2828
"github.com/ethereum/go-ethereum/core/state"
2929
"github.com/ethereum/go-ethereum/core/types"
@@ -258,7 +258,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
258258
return consensus.ErrInvalidNumber
259259
}
260260
// Verify the header's EIP-1559 attributes.
261-
if err := misc.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
261+
if err := eip1559.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
262262
return err
263263
}
264264
// Verify existence / non-existence of withdrawalsHash.

consensus/clique/clique.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
lru "github.com/ethereum/go-ethereum/common/lru"
3434
"github.com/ethereum/go-ethereum/consensus"
3535
"github.com/ethereum/go-ethereum/consensus/misc"
36+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3637
"github.com/ethereum/go-ethereum/core/state"
3738
"github.com/ethereum/go-ethereum/core/types"
3839
"github.com/ethereum/go-ethereum/crypto"
@@ -343,7 +344,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
343344
if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil {
344345
return err
345346
}
346-
} else if err := misc.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
347+
} else if err := eip1559.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
347348
// Verify the header's EIP-1559 attributes.
348349
return err
349350
}

consensus/ethash/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/ethereum/go-ethereum/common/math"
2828
"github.com/ethereum/go-ethereum/consensus"
2929
"github.com/ethereum/go-ethereum/consensus/misc"
30+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3031
"github.com/ethereum/go-ethereum/core/state"
3132
"github.com/ethereum/go-ethereum/core/types"
3233
"github.com/ethereum/go-ethereum/params"
@@ -254,7 +255,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
254255
if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil {
255256
return err
256257
}
257-
} else if err := misc.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
258+
} else if err := eip1559.VerifyEIP1559Header(chain.Config(), parent, header); err != nil {
258259
// Verify the header's EIP-1559 attributes.
259260
return err
260261
}

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

Lines changed: 3 additions & 2 deletions
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
"errors"
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/ethereum/go-ethereum/common"
2525
"github.com/ethereum/go-ethereum/common/math"
26+
"github.com/ethereum/go-ethereum/consensus/misc"
2627
"github.com/ethereum/go-ethereum/core/types"
2728
"github.com/ethereum/go-ethereum/params"
2829
)
@@ -36,7 +37,7 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
3637
if !config.IsLondon(parent.Number) {
3738
parentGasLimit = parent.GasLimit * config.ElasticityMultiplier()
3839
}
39-
if err := VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
40+
if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
4041
return err
4142
}
4243
// Verify the header is not malformed

consensus/misc/eip1559_test.go renamed to consensus/misc/eip1559/eip1559_test.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
"math/big"

core/chain_makers.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/ethereum/go-ethereum/common"
2424
"github.com/ethereum/go-ethereum/consensus"
2525
"github.com/ethereum/go-ethereum/consensus/misc"
26+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
2627
"github.com/ethereum/go-ethereum/core/rawdb"
2728
"github.com/ethereum/go-ethereum/core/state"
2829
"github.com/ethereum/go-ethereum/core/types"
@@ -202,7 +203,7 @@ func (b *BlockGen) AddUncle(h *types.Header) {
202203
// The gas limit and price should be derived from the parent
203204
h.GasLimit = parent.GasLimit
204205
if b.config.IsLondon(h.Number) {
205-
h.BaseFee = misc.CalcBaseFee(b.config, parent)
206+
h.BaseFee = eip1559.CalcBaseFee(b.config, parent)
206207
if !b.config.IsLondon(parent.Number) {
207208
parentGasLimit := parent.GasLimit * b.config.ElasticityMultiplier()
208209
h.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)
@@ -380,7 +381,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
380381
Time: time,
381382
}
382383
if chain.Config().IsLondon(header.Number) {
383-
header.BaseFee = misc.CalcBaseFee(chain.Config(), parent.Header())
384+
header.BaseFee = eip1559.CalcBaseFee(chain.Config(), parent.Header())
384385
if !chain.Config().IsLondon(parent.Number()) {
385386
parentGasLimit := parent.GasLimit() * chain.Config().ElasticityMultiplier()
386387
header.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)

core/state_processor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/ethereum/go-ethereum/consensus"
2727
"github.com/ethereum/go-ethereum/consensus/beacon"
2828
"github.com/ethereum/go-ethereum/consensus/ethash"
29-
"github.com/ethereum/go-ethereum/consensus/misc"
29+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3030
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3131
"github.com/ethereum/go-ethereum/core/rawdb"
3232
"github.com/ethereum/go-ethereum/core/types"
@@ -377,7 +377,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
377377
UncleHash: types.EmptyUncleHash,
378378
}
379379
if config.IsLondon(header.Number) {
380-
header.BaseFee = misc.CalcBaseFee(config, parent.Header())
380+
header.BaseFee = eip1559.CalcBaseFee(config, parent.Header())
381381
}
382382
if config.IsShanghai(header.Number, header.Time) {
383383
header.WithdrawalsHash = &types.EmptyWithdrawalsHash

core/txpool/blobpool/blobpool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"time"
3030

3131
"github.com/ethereum/go-ethereum/common"
32-
"github.com/ethereum/go-ethereum/consensus/misc"
32+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3333
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3434
"github.com/ethereum/go-ethereum/core"
3535
"github.com/ethereum/go-ethereum/core/state"
@@ -399,7 +399,7 @@ func (p *BlobPool) Init(gasTip *big.Int, head *types.Header, reserve txpool.Addr
399399
p.recheck(addr, nil)
400400
}
401401
var (
402-
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), p.head))
402+
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head))
403403
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
404404
)
405405
if p.head.ExcessBlobGas != nil {
@@ -773,7 +773,7 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
773773
}
774774
// Reset the price heap for the new set of basefee/blobfee pairs
775775
var (
776-
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), newHead))
776+
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), newHead))
777777
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
778778
)
779779
if newHead.ExcessBlobGas != nil {

core/txpool/blobpool/blobpool_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"time"
3131

3232
"github.com/ethereum/go-ethereum/common"
33-
"github.com/ethereum/go-ethereum/consensus/misc"
33+
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
3434
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
3535
"github.com/ethereum/go-ethereum/core"
3636
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -109,7 +109,7 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
109109
mid := new(big.Int).Add(lo, hi)
110110
mid.Div(mid, big.NewInt(2))
111111

112-
if misc.CalcBaseFee(bc.config, &types.Header{
112+
if eip1559.CalcBaseFee(bc.config, &types.Header{
113113
Number: blockNumber,
114114
GasLimit: gasLimit,
115115
GasUsed: 0,

0 commit comments

Comments
 (0)