Skip to content

Commit

Permalink
op-conductor: adds miner_setMaxDASize to conductor execution proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwrd committed Nov 7, 2024
1 parent b1efd7c commit 9111977
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
5 changes: 5 additions & 0 deletions op-conductor/conductor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ func (oc *OpConductor) initRPCServer(ctx context.Context) error {
Namespace: conductorrpc.ExecutionRPCNamespace,
Service: executionProxy,
})
execMinerProxy := conductorrpc.NewExecutionMinerProxyBackend(oc.log, oc, execClient)
server.AddAPI(rpc.API{
Namespace: conductorrpc.ExecutionMinerRPCNamespace,
Service: execMinerProxy,
})

nodeClient, err := dial.DialRollupClientWithTimeout(ctx, 1*time.Minute, oc.log, oc.cfg.NodeRPC)
if err != nil {
Expand Down
13 changes: 10 additions & 3 deletions op-conductor/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"

"github.com/ethereum-optimism/optimism/op-conductor/consensus"
Expand Down Expand Up @@ -61,21 +62,27 @@ type API interface {
CommitUnsafePayload(ctx context.Context, payload *eth.ExecutionPayloadEnvelope) error
}

// ExecutionProxyAPI defines the methods proxied to the execution rpc backend
// ExecutionProxyAPI defines the methods proxied to the execution 'eth_' rpc backend
// This should include all methods that are called by op-batcher or op-proposer
type ExecutionProxyAPI interface {
GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
}

// NodeProxyAPI defines the methods proxied to the node rpc backend
// ExecutionMinerProxyAPI defines the methods proxied to the execution 'miner_' rpc backend
// This should include all methods that are called by op-batcher or op-proposer
type ExecutionMinerProxyAPI interface {
SetMaxDASize(ctx context.Context, maxTxSize hexutil.Big, maxBlockSize hexutil.Big) bool
}

// NodeProxyAPI defines the methods proxied to the node 'optimism_' rpc backend
// This should include all methods that are called by op-batcher or op-proposer
type NodeProxyAPI interface {
OutputAtBlock(ctx context.Context, blockNumString string) (*eth.OutputResponse, error)
SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
RollupConfig(ctx context.Context) (*rollup.Config, error)
}

// NodeProxyAPI defines the methods proxied to the node rpc backend
// NodeAdminProxyAPI defines the methods proxied to the node 'admin_' rpc backend
// This should include all methods that are called by op-batcher or op-proposer
type NodeAdminProxyAPI interface {
SequencerActive(ctx context.Context) (bool, error)
Expand Down
40 changes: 40 additions & 0 deletions op-conductor/rpc/excecution_miner_proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package rpc

import (
"context"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
)

var ExecutionMinerRPCNamespace = "miner"

// ExecutionMinerProxyBackend implements an execution rpc proxy with a leadership check before each call.
type ExecutionMinerProxyBackend struct {
log log.Logger
con conductor
client *ethclient.Client
}

var _ ExecutionMinerProxyAPI = (*ExecutionMinerProxyBackend)(nil)

func NewExecutionMinerProxyBackend(log log.Logger, con conductor, client *ethclient.Client) *ExecutionMinerProxyBackend {
return &ExecutionMinerProxyBackend{
log: log,
con: con,
client: client,
}
}

func (api *ExecutionMinerProxyBackend) SetMaxDASize(ctx context.Context, maxTxSize hexutil.Big, maxBlockSize hexutil.Big) bool {
var result bool
if !api.con.Leader(ctx) {
return false
}
err := api.client.Client().Call(&result, "miner_setMaxDASize", maxTxSize, maxBlockSize)
if err != nil {
return false
}
return result
}
13 changes: 13 additions & 0 deletions op-conductor/rpc/execution_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rpc
import (
"context"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
Expand Down Expand Up @@ -38,3 +39,15 @@ func (api *ExecutionProxyBackend) GetBlockByNumber(ctx context.Context, number r
}
return result, nil
}

func (api *ExecutionProxyBackend) SetMaxDASize(ctx context.Context, maxTxSize hexutil.Big, maxBlockSize hexutil.Big) bool {
var result bool
if !api.con.Leader(ctx) {
return false
}
err := api.client.Client().Call(&result, "miner_setMaxDASize", maxTxSize, maxBlockSize)
if err != nil {
return false
}
return result
}

0 comments on commit 9111977

Please sign in to comment.