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

Pbs fix #19

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions op-node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ type Metrics struct {

L1ReorgDepth prometheus.Histogram

TransactionsSequencedTotal prometheus.Counter
TransactionsSequenced *prometheus.CounterVec
TransactionsSequencedTotal prometheus.Counter
TransactionsSequencedSourceTotal *prometheus.CounterVec

PlasmaMetrics plasma.Metricer

Expand Down Expand Up @@ -253,9 +253,9 @@ func NewMetrics(procName string) *Metrics {
Name: "transactions_sequenced_total",
Help: "Count of total transactions sequenced",
}),
TransactionsSequenced: factory.NewCounterVec(prometheus.CounterOpts{
TransactionsSequencedSourceTotal: factory.NewCounterVec(prometheus.CounterOpts{
Namespace: ns,
Name: "transactions_sequenced",
Name: "transactions_sequenced_source_total",
Help: "Count of transactions sequenced by sources",
}, []string{
"source",
Expand Down Expand Up @@ -551,7 +551,7 @@ func (m *Metrics) CountSequencedTxs(count int) {
}

func (m *Metrics) CountSequencedTxsBySource(count int, source string) {
m.TransactionsSequenced.WithLabelValues(source).Add(float64(count))
m.TransactionsSequencedSourceTotal.WithLabelValues(source).Add(float64(count))
}

func (m *Metrics) RecordL1ReorgDepth(d uint64) {
Expand Down
17 changes: 12 additions & 5 deletions op-node/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
builderSpec "github.com/attestantio/go-builder-client/spec"
consensusspec "github.com/attestantio/go-eth2-client/spec"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -28,10 +29,11 @@ type BuilderAPIConfig struct {
type BuilderAPIClient struct {
log log.Logger
config *BuilderAPIConfig
rollupCfg *rollup.Config
httpClient *client.BasicHTTPClient
}

func NewBuilderClient(log log.Logger, endpoint string, timeout time.Duration) *BuilderAPIClient {
func NewBuilderClient(log log.Logger, rollupCfg *rollup.Config, endpoint string, timeout time.Duration) *BuilderAPIClient {
httpClient := client.NewBasicHTTPClient(endpoint, log)
config := &BuilderAPIConfig{
Timeout: timeout,
Expand All @@ -41,6 +43,7 @@ func NewBuilderClient(log log.Logger, endpoint string, timeout time.Duration) *B
return &BuilderAPIClient{
httpClient: httpClient,
config: config,
rollupCfg: rollupCfg,
log: log,
}
}
Expand Down Expand Up @@ -120,8 +123,12 @@ func (s *BuilderAPIClient) versionedExecutionPayloadToExecutionPayloadEnvelope(r

ws := types.Withdrawals(withdrawals)

blobGasUsed := eth.Uint64Quantity(payload.BlobGasUsed)
excessBlobGas := eth.Uint64Quantity(payload.ExcessBlobGas)
var blobGasUsed *eth.Uint64Quantity
var excessBlobGas *eth.Uint64Quantity
if s.rollupCfg.IsEcotone(payload.Timestamp) {
blobGasUsed = (*eth.Uint64Quantity)(&payload.BlobGasUsed)
excessBlobGas = (*eth.Uint64Quantity)(&payload.ExcessBlobGas)
}

var blockValue eth.Uint256Quantity
v, err := resp.Value()
Expand All @@ -148,8 +155,8 @@ func (s *BuilderAPIClient) versionedExecutionPayloadToExecutionPayloadEnvelope(r
BlockHash: common.BytesToHash(payload.BlockHash[:]),
Transactions: txs,
Withdrawals: &ws,
BlobGasUsed: &blobGasUsed,
ExcessBlobGas: &excessBlobGas,
BlobGasUsed: blobGasUsed,
ExcessBlobGas: excessBlobGas,
},
// ParentBeaconBlockRoot will be filled by the engine payload.
ParentBeaconBlockRoot: nil,
Expand Down
4 changes: 2 additions & 2 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger

var payloadBuilder builder.PayloadBuilder = &builder.NoOpBuilder{}
if cfg.BuilderEnabled {
payloadBuilder = NewBuilderClient(n.log, cfg.BuilderEndpoint, cfg.BuilderTimeout)
payloadBuilder = NewBuilderClient(n.log, &cfg.Rollup, cfg.BuilderEndpoint, cfg.BuilderTimeout)
}

// if plasma is not explicitly activated in the node CLI, the config + any error will be ignored.
Expand Down Expand Up @@ -630,7 +630,7 @@ func (n *OpNode) PublishL2Attributes(ctx context.Context, attrs *derive.Attribut
n.log.Warn("failed to marshal payload attributes", "err", err)
return err
}
n.log.Debug("Publishing execution payload attributes on event stream", "attrs", builderAttrs, "json", string(jsonBytes))
n.log.Info("Publishing execution payload attributes on event stream", "attrs", builderAttrs)
n.httpEventStream.Publish("payload_attributes", &sse.Event{Data: jsonBytes})
return nil
}
Expand Down
24 changes: 16 additions & 8 deletions op-node/rollup/derive/engine_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,30 @@ func confirmPayload(
return nil, BlockInsertTemporaryErr, fmt.Errorf("failed to get execution payload from engine: %w", err)
}
}
metrics.RecordSequencerProfit(float64(WeiToGwei(engineEnvelope.BlockValue)), opMetrics.PayloadSourceEngine)
metrics.RecordPayloadGas(float64(engineEnvelope.ExecutionPayload.GasUsed), opMetrics.PayloadSourceEngine)
metrics.CountSequencedTxsBySource(len(engineEnvelope.ExecutionPayload.Transactions), opMetrics.PayloadSourceEngine)

if builderPayload != nil && builderPayload.success {
errTyp, err := insertPayload(ctx, log, eng, fc, updateSafe, agossip, sequencerConductor, builderPayload.envelope)
if errTyp == BlockInsertOK {
if builderPayload.envelope.ExecutionPayload.GasUsed >= engineEnvelope.ExecutionPayload.GasUsed {
log.Info("builder payload has higher gas usage than engine payload", "builder_gas", builderPayload.envelope.ExecutionPayload.GasUsed, "engine_gas", engineEnvelope.ExecutionPayload.GasUsed)
metrics.RecordSequencerProfit(float64(WeiToGwei(builderPayload.envelope.BlockValue)), opMetrics.PayloadSourceBuilder)
metrics.RecordSequencerPayloadInserted(opMetrics.PayloadSourceBuilder)
metrics.RecordPayloadGas(float64(builderPayload.envelope.ExecutionPayload.GasUsed), opMetrics.PayloadSourceBuilder)
log.Info("succeessfully inserted payload from builder")
return builderPayload.envelope, errTyp, err
metrics.CountSequencedTxsBySource(len(builderPayload.envelope.ExecutionPayload.Transactions), opMetrics.PayloadSourceBuilder)

errTyp, err := insertPayload(ctx, log, eng, fc, updateSafe, agossip, sequencerConductor, builderPayload.envelope)
if errTyp == BlockInsertOK {
metrics.RecordSequencerPayloadInserted(opMetrics.PayloadSourceBuilder)
log.Info("succeessfully inserted payload from builder")
return builderPayload.envelope, errTyp, err
}
log.Error("failed to insert payload from builder", "errType", errTyp, "error", err)
} else {
log.Warn("builder payload has lower gas usage than engine payload", "builder_gas", builderPayload.envelope.ExecutionPayload.GasUsed, "engine_gas", engineEnvelope.ExecutionPayload.GasUsed)
}
log.Error("failed to insert payload from builder", "errType", errTyp, "error", err)
}

metrics.RecordSequencerProfit(float64(WeiToGwei(engineEnvelope.BlockValue)), opMetrics.PayloadSourceEngine)
metrics.RecordSequencerPayloadInserted(opMetrics.PayloadSourceEngine)
metrics.RecordPayloadGas(float64(engineEnvelope.ExecutionPayload.GasUsed), opMetrics.PayloadSourceEngine)
errType, err := insertPayload(ctx, log, eng, fc, updateSafe, agossip, sequencerConductor, engineEnvelope)
return engineEnvelope, errType, err
}
Expand Down
2 changes: 1 addition & 1 deletion ops-bedrock/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ services:
- "--builder.seconds_in_slot=2"
- "--builder.block_resubmit_interval=200ms"
- "--builder.submission_offset=1s"
- "--verbosity=5"
- "--builder.algotype=greedy"
environment:
GETH_MINER_RECOMMIT: 100ms
BUILDER_TX_SIGNING_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
Expand Down