diff --git a/op-node/rollup/derive/engine_controller.go b/op-node/rollup/derive/engine_controller.go index d9103fcd5cbc..f8de6e3ea921 100644 --- a/op-node/rollup/derive/engine_controller.go +++ b/op-node/rollup/derive/engine_controller.go @@ -73,6 +73,8 @@ type EngineController struct { buildingInfo eth.PayloadInfo buildingSafe bool safeAttrs *AttributesWithParent + + dacClient rollup.DACClient } func NewEngineController(engine ExecEngine, log log.Logger, metrics Metrics, rollupCfg *rollup.Config, syncMode sync.Mode) *EngineController { @@ -81,6 +83,10 @@ func NewEngineController(engine ExecEngine, log log.Logger, metrics Metrics, rol syncStatus = syncStatusWillStartEL } + var dacClient rollup.DACClient + if rollupCfg.DACConfig != nil { + dacClient = rollupCfg.DACConfig.Client() + } return &EngineController{ engine: engine, log: log, @@ -89,6 +95,7 @@ func NewEngineController(engine ExecEngine, log log.Logger, metrics Metrics, rol syncMode: syncMode, syncStatus: syncStatus, clock: clock.SystemClock, + dacClient: dacClient, } } @@ -209,7 +216,7 @@ func (e *EngineController) ConfirmPayload(ctx context.Context, agossip async.Asy } // Update the safe head if the payload is built with the last attributes in the batch. updateSafe := e.buildingSafe && e.safeAttrs != nil && e.safeAttrs.isLastInSpan - envelope, errTyp, err := confirmPayload(ctx, e.log, e.engine, fc, e.buildingInfo, updateSafe, agossip, sequencerConductor) + envelope, errTyp, err := confirmPayload(ctx, e.log, e.engine, fc, e.buildingInfo, updateSafe, agossip, sequencerConductor, e.dacClient) if err != nil { return nil, errTyp, fmt.Errorf("failed to complete building on top of L2 chain %s, id: %s, error (%d): %w", e.buildingOnto, e.buildingInfo.ID, errTyp, err) } diff --git a/op-node/rollup/derive/engine_update.go b/op-node/rollup/derive/engine_update.go index b23a27004004..b76c8fe47e43 100644 --- a/op-node/rollup/derive/engine_update.go +++ b/op-node/rollup/derive/engine_update.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup/async" "github.com/ethereum-optimism/optimism/op-node/rollup/conductor" "github.com/ethereum-optimism/optimism/op-service/eth" @@ -128,6 +129,7 @@ func confirmPayload( updateSafe bool, agossip async.AsyncGossiper, sequencerConductor conductor.SequencerConductor, + dacClient rollup.DACClient, ) (out *eth.ExecutionPayloadEnvelope, errTyp BlockInsertionErrType, err error) { var envelope *eth.ExecutionPayloadEnvelope // if the payload is available from the async gossiper, it means it was not yet imported, so we reuse it @@ -150,6 +152,17 @@ func confirmPayload( if err := sanityCheckPayload(payload); err != nil { return nil, BlockInsertPayloadErr, err } + if envelope.BlobsBundle != nil && len(envelope.BlobsBundle.Blobs) > 0 { + if updateSafe { + return nil, BlockInsertPayloadErr, fmt.Errorf("got blobs when updateSafe") + } + if dacClient != nil { + err = dacClient.UploadBlobs(envelope) + if err != nil { + return nil, BlockInsertTemporaryErr, fmt.Errorf("UploadBlobs failed: %w", err) + } + } + } if err := sequencerConductor.CommitUnsafePayload(ctx, envelope); err != nil { return nil, BlockInsertTemporaryErr, fmt.Errorf("failed to commit unsafe payload to conductor: %w", err) } diff --git a/op-node/rollup/types.go b/op-node/rollup/types.go index 1ad45272e8aa..da027d8aa054 100644 --- a/op-node/rollup/types.go +++ b/op-node/rollup/types.go @@ -122,6 +122,20 @@ type Config struct { // UsePlasma is activated when the chain is in plasma mode. UsePlasma bool `json:"use_plasma"` + + DACConfig *DACConfig `json:"dac_config,omitempty"` +} + +type DACConfig struct { + URL string +} + +type DACClient interface { + UploadBlobs(*eth.ExecutionPayloadEnvelope) error +} + +func (dacConfig *DACConfig) Client() DACClient { + return nil } // ValidateL1Config checks L1 config variables for errors. diff --git a/op-service/eth/types.go b/op-service/eth/types.go index 58d16c3cdd22..3d09cfa0ebdc 100644 --- a/op-service/eth/types.go +++ b/op-service/eth/types.go @@ -161,8 +161,9 @@ type ( ) type ExecutionPayloadEnvelope struct { - ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot,omitempty"` - ExecutionPayload *ExecutionPayload `json:"executionPayload"` + ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot,omitempty"` + ExecutionPayload *ExecutionPayload `json:"executionPayload"` + BlobsBundle *engine.BlobsBundleV1 `json:"blobsBundle"` } type ExecutionPayload struct {