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

feature(op-geth): add opbnb gasless solution #130

Merged
merged 35 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
04d0f76
feature(op-geth): add opbnb gasless solution
redhdx Jul 18, 2024
711fee4
fix(op-geth): fix ut for cycle import
redhdx Jul 18, 2024
5d1162c
Revert "fix(op-geth): fix ut for cycle import"
redhdx Jul 18, 2024
0b3189e
fix(op-geth): fix test for cycle import
redhdx Jul 18, 2024
ed4e69b
feature(op-geth): add some config
redhdx Jul 19, 2024
d38ca5f
fix(op-geth): fix nil issue
redhdx Jul 19, 2024
600e647
fix(op-geth): fix test issue
redhdx Jul 22, 2024
ba22582
feature(op-geth): refine code
redhdx Jul 24, 2024
ed8a579
feature(op-geth): refine code mainly simplify config
redhdx Jul 24, 2024
a4d0a85
feature(op-geth): change qa net chain config
redhdx Jul 24, 2024
8b8e3b4
feature(op-geth): refine code
redhdx Jul 24, 2024
ec06717
Merge branch 'develop' into feature/opbnb_for_gasless
redhdx Jul 24, 2024
12809f0
fix(op-geth): fix gasless l1 cost
redhdx Jul 24, 2024
cbb1c03
fix(op-geth): fix gasless l1 cost
redhdx Jul 24, 2024
6f7deff
fix(op-geth): fix gasless l1 cost receipt
redhdx Jul 24, 2024
e8d6512
feature(op-geth): refine gasless code
redhdx Jul 26, 2024
5f314a8
feature(op-geth): refine totalfees
redhdx Jul 26, 2024
ed7ab15
feature(op-geth): generate new gen_config.go
redhdx Jul 26, 2024
f0b8112
fix(op-geth): fix nil issue and add metrics
redhdx Jul 30, 2024
17986c9
fix(op-geth): fix gaslimit issue
redhdx Jul 30, 2024
3642aee
fix(op-geth): fix merge bundle logic
redhdx Jul 30, 2024
f343264
feature(op-geth): optimize bundle pool reset
redhdx Jul 31, 2024
0d3f46b
fix(op-geth): fix reset bundle
redhdx Jul 31, 2024
a249bc2
fix(op-geth): fix some issue and change some const value
redhdx Jul 31, 2024
a292ab1
fix(op-geth): fix ErrBundleGasPriceLow logic
redhdx Jul 31, 2024
bfdf54a
feature(op-geth): refine logic and fix issue
redhdx Aug 1, 2024
18b50d9
feature(op-geth): refine log print content
redhdx Aug 1, 2024
0b6ea28
fix(op-geth): fix time stop logic
redhdx Aug 1, 2024
24e8c85
fix(op-geth): fix issue
redhdx Aug 1, 2024
fdae74b
feature(op-geth): change BundleGasLimit
redhdx Aug 1, 2024
c5d81ed
feature(op-geth): change BundleGasLimit
redhdx Aug 1, 2024
eb5c5ed
feature(op-geth): change simulateGaslessBundle return logic
redhdx Aug 2, 2024
81a33bb
feature(op-geth): change simulateGaslessBundle return value
redhdx Aug 2, 2024
167d08f
fix(op-geth): fix sort bundles
redhdx Aug 5, 2024
6ccb086
feature(op-geth): add Wright hard fork time
redhdx Aug 5, 2024
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
4 changes: 4 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var (
utils.TxPoolLifetimeFlag,
utils.TxPoolReannounceTimeFlag,
utils.TxPoolReannounceRemotesFlag,
utils.BundlePoolGlobalSlotsFlag,
utils.BlobPoolDataDirFlag,
utils.BlobPoolDataCapFlag,
utils.BlobPoolPriceBumpFlag,
Expand Down Expand Up @@ -135,6 +136,9 @@ var (
utils.MinerExtraDataFlag,
utils.MinerRecommitIntervalFlag,
utils.MinerNewPayloadTimeout,
utils.MevEnabledFlag,
utils.MevBundleReceiverUrlFlag,
utils.MevBundleGasPriceFloorFlag,
utils.NATFlag,
utils.NoDiscoverFlag,
utils.DiscoveryV4Flag,
Expand Down
41 changes: 41 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/core/txpool/bundlepool"
"math"
"math/big"
"net"
Expand Down Expand Up @@ -440,6 +441,13 @@ var (
Value: ethconfig.Defaults.TxPool.ReannounceRemotes,
Category: flags.TxPoolCategory,
}
// bundle pool settings
BundlePoolGlobalSlotsFlag = &cli.Uint64Flag{
Name: "bundlepool.globalslots",
Usage: "Maximum number of executable bundle slots for all accounts",
Value: ethconfig.Defaults.BundlePool.GlobalSlots,
Category: flags.BundlePoolCategory,
}
// Blob transaction pool settings
BlobPoolDataDirFlag = &cli.StringFlag{
Name: "blobpool.datadir",
Expand Down Expand Up @@ -558,6 +566,22 @@ var (
Value: ethconfig.Defaults.Miner.NewPayloadTimeout,
Category: flags.MinerCategory,
}
MevEnabledFlag = &cli.BoolFlag{
owen-reorg marked this conversation as resolved.
Show resolved Hide resolved
Name: "mev.enable",
Usage: "Enable mev",
Category: flags.MEVCategory,
}
MevBundleReceiverUrlFlag = &cli.StringFlag{
Name: "mev.bundle.receiver.url",
Usage: "Url of bundle receiver endpoint to use. Multiple urls are supported, separated by commas",
Category: flags.MEVCategory,
}
MevBundleGasPriceFloorFlag = &cli.Int64Flag{
Name: "mev.bundle.gasprice.floor",
Usage: "Minimum bundle gas price for mev",
Value: ethconfig.Defaults.Miner.Mev.MevBundleGasPriceFloor,
Category: flags.MEVCategory,
}

// Account settings
UnlockedAccountFlag = &cli.StringFlag{
Expand Down Expand Up @@ -1699,6 +1723,12 @@ func setTxPool(ctx *cli.Context, cfg *legacypool.Config) {
}
}

func setBundlePool(ctx *cli.Context, cfg *bundlepool.Config) {
if ctx.IsSet(BundlePoolGlobalSlotsFlag.Name) {
cfg.GlobalSlots = ctx.Uint64(BundlePoolGlobalSlotsFlag.Name)
}
}

func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.IsSet(MinerExtraDataFlag.Name) {
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
Expand All @@ -1718,6 +1748,16 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
if ctx.IsSet(RollupComputePendingBlock.Name) {
cfg.RollupComputePendingBlock = ctx.Bool(RollupComputePendingBlock.Name)
}
if ctx.IsSet(MevEnabledFlag.Name) {
cfg.Mev.MevEnabled = ctx.Bool(MevEnabledFlag.Name)
}
if ctx.IsSet(MevBundleReceiverUrlFlag.Name) {
url := ctx.String(MevBundleReceiverUrlFlag.Name)
cfg.Mev.MevReceivers = strings.Split(url, ",")
}
if ctx.IsSet(MevBundleGasPriceFloorFlag.Name) {
cfg.Mev.MevBundleGasPriceFloor = ctx.Int64(MevBundleGasPriceFloorFlag.Name)
}
}

func setRequiredBlocks(ctx *cli.Context, cfg *ethconfig.Config) {
Expand Down Expand Up @@ -1799,6 +1839,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
setEtherbase(ctx, cfg)
setGPO(ctx, &cfg.GPO)
setTxPool(ctx, &cfg.TxPool)
setBundlePool(ctx, &cfg.BundlePool)
setMiner(ctx, &cfg.Miner)
setRequiredBlocks(ctx, cfg)
setLes(ctx, cfg)
Expand Down
3 changes: 3 additions & 0 deletions consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
// CalcBaseFee calculates the basefee of the header.
// The time belongs to the new block to check if Canyon is activted or not
func CalcBaseFee(config *params.ChainConfig, parent *types.Header, time uint64) *big.Int {
if config.IsWright(time) {
return new(big.Int).SetUint64(params.OpBNBBaseFeeForGasLess)
}
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
if !config.IsLondon(parent.Number) {
return new(big.Int).SetUint64(params.InitialBaseFee)
Expand Down
16 changes: 13 additions & 3 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ func (st *StateTransition) buyGas() error {
mgval = mgval.Mul(mgval, st.msg.GasPrice)
var l1Cost *big.Int
if st.evm.Context.L1CostFunc != nil && !st.msg.SkipAccountChecks {
l1Cost = st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time)
if st.msg.GasPrice.Cmp(big.NewInt(0)) == 0 && st.evm.ChainConfig().IsWright(st.evm.Context.Time) {
l1Cost = big.NewInt(0)
} else {
l1Cost = st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time)
}
if l1Cost != nil {
mgval = mgval.Add(mgval, l1Cost)
}
Expand Down Expand Up @@ -546,8 +550,14 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
// Note optimismConfig will not be nil if rules.IsOptimismBedrock is true
if optimismConfig := st.evm.ChainConfig().Optimism; optimismConfig != nil && rules.IsOptimismBedrock && !st.msg.IsDepositTx {
st.state.AddBalance(params.OptimismBaseFeeRecipient, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee))
if cost := st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time); cost != nil {
st.state.AddBalance(params.OptimismL1FeeRecipient, cost)
var l1Cost *big.Int
if st.msg.GasPrice.Cmp(big.NewInt(0)) == 0 && st.evm.ChainConfig().IsWright(st.evm.Context.Time) {
l1Cost = big.NewInt(0)
} else {
l1Cost = st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time)
}
if l1Cost != nil {
st.state.AddBalance(params.OptimismL1FeeRecipient, l1Cost)
}
}

Expand Down
Loading
Loading