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): opbnb gasless #129

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feature(op-geth): code refine for gasless
  • Loading branch information
redhdx committed Jul 18, 2024
commit 9b795db1c0fb46ee4531bd57db3694c3deacebbc
321 changes: 321 additions & 0 deletions README.md

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions common/bidutil/bidutil.go

This file was deleted.

197 changes: 0 additions & 197 deletions core/types/bid.go

This file was deleted.

45 changes: 0 additions & 45 deletions core/types/bid_error.go

This file was deleted.

Binary file removed docs/assets/pbs_workflow.png
Binary file not shown.
11 changes: 8 additions & 3 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
config.TxPool.Journal = stack.ResolvePath(config.TxPool.Journal)
}
legacyPool := legacypool.New(config.TxPool, eth.blockchain)
bundlePool := bundlepool.New(config.BundlePool, config.Miner.Mev)

txPools := []txpool.SubPool{legacyPool}
if !eth.BlockChain().Config().IsOptimism() {
blobPool := blobpool.New(config.BlobPool, eth.blockchain)
txPools = append(txPools, blobPool)
}
txPools = append(txPools, bundlePool)
bundlePool := &bundlepool.BundlePool{}
if config.Miner.Mev.Enabled || config.Miner.Mev.BuilderEnabled {
bundlePool = bundlepool.New(config.BundlePool, config.Miner.Mev)
txPools = append(txPools, bundlePool)
}
eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, txPools)
if err != nil {
return nil, err
Expand All @@ -293,7 +296,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {

eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
bundlePool.SetBundleSimulator(eth.miner)
if config.Miner.Mev.Enabled || config.Miner.Mev.BuilderEnabled {
bundlePool.SetBundleSimulator(eth.miner)
}

eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, config.RollupDisableTxPoolAdmission, eth, nil}
if eth.APIBackend.allowUnprotectedTxs {
Expand Down
47 changes: 0 additions & 47 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ func DialContext(ctx context.Context, rawurl string) (*Client, error) {
return NewClient(c), nil
}

// DialOptions creates a new RPC client for the given URL. You can supply any of the
// pre-defined client options to configure the underlying transport.
func DialOptions(ctx context.Context, rawurl string, opts ...rpc.ClientOption) (*Client, error) {
c, err := rpc.DialOptions(ctx, rawurl, opts...)
if err != nil {
return nil, err
}
return NewClient(c), nil
}

// NewClient creates a client that uses the given RPC client.
func NewClient(c *rpc.Client) *Client {
return &Client{c}
Expand Down Expand Up @@ -636,33 +626,6 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(data))
}

// MevRunning returns whether MEV is running
func (ec *Client) MevRunning(ctx context.Context) (bool, error) {
var result bool
err := ec.c.CallContext(ctx, &result, "mev_running")
return result, err
}

// SendBid sends a bid
func (ec *Client) SendBid(ctx context.Context, args types.BidArgs) (common.Hash, error) {
var hash common.Hash
err := ec.c.CallContext(ctx, &hash, "mev_sendBid", args)
if err != nil {
return common.Hash{}, err
}
return hash, nil
}

// BestBidGasFee returns the gas fee of the best bid for the given parent hash.
func (ec *Client) BestBidGasFee(ctx context.Context, parentHash common.Hash) (*big.Int, error) {
var fee *big.Int
err := ec.c.CallContext(ctx, &fee, "mev_bestBidGasFee", parentHash)
if err != nil {
return nil, err
}
return fee, nil
}

// SendBundle sends a bundle
func (ec *Client) SendBundle(ctx context.Context, args types.SendBundleArgs) (common.Hash, error) {
var hash common.Hash
Expand All @@ -680,16 +643,6 @@ func (ec *Client) BundlePrice(ctx context.Context) *big.Int {
return price
}

// MevParams returns the static params of mev
func (ec *Client) MevParams(ctx context.Context) (*types.MevParams, error) {
var params types.MevParams
err := ec.c.CallContext(ctx, &params, "mev_params")
if err != nil {
return nil, err
}
return &params, err
}

func toBlockNumArg(number *big.Int) string {
if number == nil {
return "latest"
Expand Down
16 changes: 0 additions & 16 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,22 +771,6 @@ func (b testBackend) HistoricalRPCService() *rpc.Client {
func (b testBackend) Genesis() *types.Block {
panic("implement me")
}
func (b testBackend) MevRunning() bool { return false }
func (b testBackend) MevParams() *types.MevParams {
return &types.MevParams{}
}
func (b testBackend) StartMev() {}
func (b testBackend) StopMev() {}
func (b testBackend) AddBuilder(builder common.Address, builderUrl string) error { return nil }
func (b testBackend) RemoveBuilder(builder common.Address) error { return nil }
func (b testBackend) SendBid(ctx context.Context, bid *types.BidArgs) (common.Hash, error) {
panic("implement me")
}
func (b testBackend) MinerInTurn() bool { return false }
func (b testBackend) BestBidGasFee(parentHash common.Hash) *big.Int {
//TODO implement me
panic("implement me")
}

func TestEstimateGas(t *testing.T) {
t.Parallel()
Expand Down
Loading
Loading