diff --git a/.envrc b/.envrc deleted file mode 100644 index 720e019335c..00000000000 --- a/.envrc +++ /dev/null @@ -1,5 +0,0 @@ -if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM=" -fi - -use flake diff --git a/.github/workflows/docker-build-scan.yaml b/.github/workflows/docker-build-scan.yaml index df5fb19c61d..ef44026e59f 100644 --- a/.github/workflows/docker-build-scan.yaml +++ b/.github/workflows/docker-build-scan.yaml @@ -21,7 +21,7 @@ jobs: id: detect-files-changed uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 with: - separator: "," + separator: ',' # Build op-node op-batcher op-proposer using docker-bake build-op-stack: @@ -55,8 +55,8 @@ jobs: - name: Login at GCP Artifact Registry uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@v2.0 with: - workload-id-provider: "projects/1094498259535/locations/global/workloadIdentityPools/gh-optimism/providers/github-by-repos" - service-account: "celo-optimism-gh@devopsre.iam.gserviceaccount.com" + workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-optimism/providers/github-by-repos' + service-account: 'celo-optimism-gh@devopsre.iam.gserviceaccount.com' docker-gcp-registries: us-west1-docker.pkg.dev # We need a custom steps as it's using docker bake - name: Set up Docker Buildx diff --git a/.github/workflows/enclave.yaml b/.github/workflows/espresso-enclave.yaml similarity index 100% rename from .github/workflows/enclave.yaml rename to .github/workflows/espresso-enclave.yaml diff --git a/.gitignore b/.gitignore index b08cc2028d2..fa9386d35d6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ packages/contracts-bedrock/deployments/anvil .secrets .env +.envrc !espresso/.env !.env.example !.envrc.example diff --git a/op-alt-da/cmd/daserver/entrypoint.go b/op-alt-da/cmd/daserver/entrypoint.go index ba107b5dea7..32ff7d29f65 100644 --- a/op-alt-da/cmd/daserver/entrypoint.go +++ b/op-alt-da/cmd/daserver/entrypoint.go @@ -39,9 +39,6 @@ func StartDAServer(cliCtx *cli.Context) error { return fmt.Errorf("failed to create S3 store: %w", err) } store = s3 - } else if cfg.EspressoEnabled() { - l.Info("Using Espresso DA", "url", cfg.EspressoBaseUrl) - store = NewEspressoStore(cfg.EspressoBaseUrl, l) } server := altda.NewDAServer(cliCtx.String(ListenAddrFlagName), cliCtx.Int(PortFlagName), store, l, cfg.UseGenericComm) diff --git a/op-alt-da/cmd/daserver/flags.go b/op-alt-da/cmd/daserver/flags.go index a8914f9d645..82c48321d01 100644 --- a/op-alt-da/cmd/daserver/flags.go +++ b/op-alt-da/cmd/daserver/flags.go @@ -13,7 +13,6 @@ import ( const ( ListenAddrFlagName = "addr" PortFlagName = "port" - EspressoBaseUrlFlagName = "espresso.url" S3BucketFlagName = "s3.bucket" S3EndpointFlagName = "s3.endpoint" S3AccessKeyIDFlagName = "s3.access-key-id" @@ -75,12 +74,6 @@ var ( Value: "", EnvVars: prefixEnvVars("S3_ACCESS_KEY_SECRET"), } - EspressoBaseUrlFlag = &cli.StringFlag{ - Name: EspressoBaseUrlFlagName, - Usage: "espresso network base url", - Value: "", - EnvVars: prefixEnvVars("ESPRESSO_BASE_URL"), - } ) var requiredFlags = []cli.Flag{ @@ -94,7 +87,6 @@ var optionalFlags = []cli.Flag{ S3EndpointFlag, S3AccessKeyIDFlag, S3AccessKeySecretFlag, - EspressoBaseUrlFlag, GenericCommFlag, } @@ -112,7 +104,6 @@ type CLIConfig struct { S3Endpoint string S3AccessKeyID string S3AccessKeySecret string - EspressoBaseUrl string UseGenericComm bool } @@ -123,38 +114,23 @@ func ReadCLIConfig(ctx *cli.Context) CLIConfig { S3Endpoint: ctx.String(S3EndpointFlagName), S3AccessKeyID: ctx.String(S3AccessKeyIDFlagName), S3AccessKeySecret: ctx.String(S3AccessKeySecretFlagName), - EspressoBaseUrl: ctx.String(EspressoBaseUrlFlagName), UseGenericComm: ctx.Bool(GenericCommFlagName), } } func (c CLIConfig) Check() error { - enabledCount := 0 - if c.S3Enabled() { - enabledCount++ - if c.S3Bucket == "" || c.S3Endpoint == "" || c.S3AccessKeyID == "" || c.S3AccessKeySecret == "" { - return errors.New("all S3 flags must be set") - } - } - if c.FileStoreEnabled() { - enabledCount++ - } - if c.EspressoEnabled() { - enabledCount++ - } - if enabledCount == 0 { + if !c.S3Enabled() && !c.FileStoreEnabled() { return errors.New("at least one storage backend must be enabled") } - if enabledCount > 1 { - return errors.New("only one storage backend must be enabled") + if c.S3Enabled() && c.FileStoreEnabled() { + return errors.New("only one storage backend can be enabled") + } + if c.S3Enabled() && (c.S3Bucket == "" || c.S3Endpoint == "" || c.S3AccessKeyID == "" || c.S3AccessKeySecret == "") { + return errors.New("all S3 flags must be set") } return nil } -func (c CLIConfig) EspressoEnabled() bool { - return c.EspressoBaseUrl != "" -} - func (c CLIConfig) S3Enabled() bool { return !(c.S3Bucket == "" && c.S3Endpoint == "" && c.S3AccessKeyID == "" && c.S3AccessKeySecret == "") } diff --git a/op-batcher/batcher/config.go b/op-batcher/batcher/config.go index 440649bad1a..9dc12216ab3 100644 --- a/op-batcher/batcher/config.go +++ b/op-batcher/batcher/config.go @@ -53,8 +53,6 @@ type CLIConfig struct { // and creating a new batch. PollInterval time.Duration - EspressoPollInterval time.Duration - // MaxPendingTransactions is the maximum number of concurrent pending // transactions sent to the transaction manager (0 == no limit). MaxPendingTransactions uint64 @@ -126,6 +124,7 @@ type CLIConfig struct { RPC oprpc.CLIConfig AltDA altda.CLIConfig + EspressoPollInterval time.Duration EspressoUrls []string EspressoLightClientAddr string TestingEspressoBatcherPrivateKey string @@ -193,41 +192,42 @@ func (c *CLIConfig) Check() error { func NewConfig(ctx *cli.Context) *CLIConfig { return &CLIConfig{ /* Required Flags */ - L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name), - L2EthRpc: ctx.String(flags.L2EthRpcFlag.Name), - RollupRpc: ctx.String(flags.RollupRpcFlag.Name), - SubSafetyMargin: ctx.Uint64(flags.SubSafetyMarginFlag.Name), - PollInterval: ctx.Duration(flags.PollIntervalFlag.Name), - EspressoPollInterval: ctx.Duration(flags.EspressoPollIntervalFlag.Name), + L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name), + L2EthRpc: ctx.String(flags.L2EthRpcFlag.Name), + RollupRpc: ctx.String(flags.RollupRpcFlag.Name), + SubSafetyMargin: ctx.Uint64(flags.SubSafetyMarginFlag.Name), + PollInterval: ctx.Duration(flags.PollIntervalFlag.Name), /* Optional Flags */ - MaxPendingTransactions: ctx.Uint64(flags.MaxPendingTransactionsFlag.Name), - MaxChannelDuration: ctx.Uint64(flags.MaxChannelDurationFlag.Name), - MaxL1TxSize: ctx.Uint64(flags.MaxL1TxSizeBytesFlag.Name), - MaxBlocksPerSpanBatch: ctx.Int(flags.MaxBlocksPerSpanBatch.Name), - TargetNumFrames: ctx.Int(flags.TargetNumFramesFlag.Name), - ApproxComprRatio: ctx.Float64(flags.ApproxComprRatioFlag.Name), - Compressor: ctx.String(flags.CompressorFlag.Name), - CompressionAlgo: derive.CompressionAlgo(ctx.String(flags.CompressionAlgoFlag.Name)), - Stopped: ctx.Bool(flags.StoppedFlag.Name), - WaitNodeSync: ctx.Bool(flags.WaitNodeSyncFlag.Name), - CheckRecentTxsDepth: ctx.Int(flags.CheckRecentTxsDepthFlag.Name), - BatchType: ctx.Uint(flags.BatchTypeFlag.Name), - DataAvailabilityType: flags.DataAvailabilityType(ctx.String(flags.DataAvailabilityTypeFlag.Name)), - ActiveSequencerCheckDuration: ctx.Duration(flags.ActiveSequencerCheckDurationFlag.Name), - TxMgrConfig: txmgr.ReadCLIConfig(ctx), - LogConfig: oplog.ReadCLIConfig(ctx), - MetricsConfig: opmetrics.ReadCLIConfig(ctx), - PprofConfig: oppprof.ReadCLIConfig(ctx), - RPC: oprpc.ReadCLIConfig(ctx), - AltDA: altda.ReadCLIConfig(ctx), - ThrottleThreshold: ctx.Uint64(flags.ThrottleThresholdFlag.Name), - ThrottleTxSize: ctx.Uint64(flags.ThrottleTxSizeFlag.Name), - ThrottleBlockSize: ctx.Uint64(flags.ThrottleBlockSizeFlag.Name), - ThrottleAlwaysBlockSize: ctx.Uint64(flags.ThrottleAlwaysBlockSizeFlag.Name), - PreferLocalSafeL2: ctx.Bool(flags.PreferLocalSafeL2Flag.Name), + MaxPendingTransactions: ctx.Uint64(flags.MaxPendingTransactionsFlag.Name), + MaxChannelDuration: ctx.Uint64(flags.MaxChannelDurationFlag.Name), + MaxL1TxSize: ctx.Uint64(flags.MaxL1TxSizeBytesFlag.Name), + MaxBlocksPerSpanBatch: ctx.Int(flags.MaxBlocksPerSpanBatch.Name), + TargetNumFrames: ctx.Int(flags.TargetNumFramesFlag.Name), + ApproxComprRatio: ctx.Float64(flags.ApproxComprRatioFlag.Name), + Compressor: ctx.String(flags.CompressorFlag.Name), + CompressionAlgo: derive.CompressionAlgo(ctx.String(flags.CompressionAlgoFlag.Name)), + Stopped: ctx.Bool(flags.StoppedFlag.Name), + WaitNodeSync: ctx.Bool(flags.WaitNodeSyncFlag.Name), + CheckRecentTxsDepth: ctx.Int(flags.CheckRecentTxsDepthFlag.Name), + BatchType: ctx.Uint(flags.BatchTypeFlag.Name), + DataAvailabilityType: flags.DataAvailabilityType(ctx.String(flags.DataAvailabilityTypeFlag.Name)), + ActiveSequencerCheckDuration: ctx.Duration(flags.ActiveSequencerCheckDurationFlag.Name), + TxMgrConfig: txmgr.ReadCLIConfig(ctx), + LogConfig: oplog.ReadCLIConfig(ctx), + MetricsConfig: opmetrics.ReadCLIConfig(ctx), + PprofConfig: oppprof.ReadCLIConfig(ctx), + RPC: oprpc.ReadCLIConfig(ctx), + AltDA: altda.ReadCLIConfig(ctx), + ThrottleThreshold: ctx.Uint64(flags.ThrottleThresholdFlag.Name), + ThrottleTxSize: ctx.Uint64(flags.ThrottleTxSizeFlag.Name), + ThrottleBlockSize: ctx.Uint64(flags.ThrottleBlockSizeFlag.Name), + ThrottleAlwaysBlockSize: ctx.Uint64(flags.ThrottleAlwaysBlockSizeFlag.Name), + PreferLocalSafeL2: ctx.Bool(flags.PreferLocalSafeL2Flag.Name), + EspressoUrls: ctx.StringSlice(flags.EspressoUrlsFlag.Name), EspressoLightClientAddr: ctx.String(flags.EspressoLCAddrFlag.Name), TestingEspressoBatcherPrivateKey: ctx.String(flags.TestingEspressoBatcherPrivateKeyFlag.Name), + EspressoPollInterval: ctx.Duration(flags.EspressoPollIntervalFlag.Name), } } diff --git a/op-batcher/batcher/driver.go b/op-batcher/batcher/driver.go index 121fc54a802..fdf4f5a8ccc 100644 --- a/op-batcher/batcher/driver.go +++ b/op-batcher/batcher/driver.go @@ -28,7 +28,7 @@ import ( altda "github.com/ethereum-optimism/optimism/op-alt-da" "github.com/ethereum-optimism/optimism/op-batcher/metrics" "github.com/ethereum-optimism/optimism/op-node/rollup" - derive "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto" "github.com/ethereum-optimism/optimism/op-service/dial" "github.com/ethereum-optimism/optimism/op-service/eth" @@ -94,17 +94,18 @@ type AltDAClient interface { // DriverSetup is the collection of input/output interfaces and configuration that the driver operates on. type DriverSetup struct { - Log log.Logger - Metr metrics.Metricer - RollupConfig *rollup.Config - Config BatcherConfig - Txmgr txmgr.TxManager - L1Client L1Client - EndpointProvider dial.L2EndpointProvider - ChannelConfig ChannelConfigProvider - AltDA AltDAClient - ChannelOutFactory ChannelOutFactory - ActiveSeqChanged chan struct{} // optional + Log log.Logger + Metr metrics.Metricer + RollupConfig *rollup.Config + Config BatcherConfig + Txmgr txmgr.TxManager + L1Client L1Client + EndpointProvider dial.L2EndpointProvider + ChannelConfig ChannelConfigProvider + AltDA AltDAClient + ChannelOutFactory ChannelOutFactory + ActiveSeqChanged chan struct{} // optional + Espresso *espressoClient.MultipleNodesClient EspressoLightClient *espressoLightClient.LightclientCaller ChainSigner opcrypto.ChainSigner @@ -124,8 +125,6 @@ type BatchSubmitter struct { mutex sync.Mutex running bool - submitter *espressoTransactionSubmitter - streamer espresso.EspressoStreamer[derive.EspressoBatch] txpoolMutex sync.Mutex // guards txpoolState and txpoolBlockedBlob txpoolState TxPoolState txpoolBlockedBlob bool @@ -133,11 +132,9 @@ type BatchSubmitter struct { channelMgrMutex sync.Mutex // guards channelMgr and prevCurrentL1 channelMgr *channelManager prevCurrentL1 eth.L1BlockRef // cached CurrentL1 from the last syncStatus -} -// EspressoStreamer returns the batch submitter's Espresso streamer instance -func (l *BatchSubmitter) EspressoStreamer() *espresso.EspressoStreamer[derive.EspressoBatch] { - return &l.streamer + espressoSubmitter *espressoTransactionSubmitter + espressoStreamer espresso.EspressoStreamer[derive.EspressoBatch] } // NewBatchSubmitter initializes the BatchSubmitter driver from a preconfigured DriverSetup @@ -152,7 +149,7 @@ func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter { channelMgr: state, } - batchSubmitter.streamer = espresso.NewEspressoStreamer( + batchSubmitter.espressoStreamer = espresso.NewEspressoStreamer( batchSubmitter.RollupConfig.L2ChainID.Uint64(), NewAdaptL1BlockRefClient(batchSubmitter.L1Client), batchSubmitter.Espresso, @@ -164,7 +161,7 @@ func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter { 2*time.Second, ) - log.Info("Streamer started", "streamer", batchSubmitter.streamer) + log.Info("Streamer started", "streamer", batchSubmitter.espressoStreamer) return batchSubmitter } @@ -219,26 +216,29 @@ func (l *BatchSubmitter) StartBatchSubmitting() error { return fmt.Errorf("could not register with batch inbox contract: %w", err) } - l.submitter = NewEspressoTransactionSubmitter( + l.espressoSubmitter = NewEspressoTransactionSubmitter( WithContext(l.shutdownCtx), WithWaitGroup(l.wg), WithEspressoClient(l.Espresso), ) - l.submitter.SpawnWorkers(4, 4) - l.submitter.Start() + l.espressoSubmitter.SpawnWorkers(4, 4) + l.espressoSubmitter.Start() l.wg.Add(4) go l.receiptsLoop(l.wg, receiptsCh) // ranges over receiptsCh channel go l.espressoBatchQueueingLoop(l.shutdownCtx, l.wg) go l.espressoBatchLoadingLoop(l.shutdownCtx, l.wg, publishSignal) go l.publishingLoop(l.killCtx, l.wg, receiptsCh, publishSignal) // ranges over publishSignal, spawns routines which send on receiptsCh. Closes receiptsCh when done. - } else { - l.wg.Add(3) - go l.receiptsLoop(l.wg, receiptsCh) // ranges over receiptsCh channel - go l.publishingLoop(l.killCtx, l.wg, receiptsCh, publishSignal) // ranges over publishSignal, spawns routines which send on receiptsCh. Closes receiptsCh when done. - go l.blockLoadingLoop(l.shutdownCtx, l.wg, pendingBytesUpdated, publishSignal) // sends on pendingBytesUpdated (if throttling enabled), and publishSignal. Closes them both when done + + l.Log.Info("Batch Submitter started in Espresso mode") + return nil } + l.wg.Add(3) + go l.receiptsLoop(l.wg, receiptsCh) // ranges over receiptsCh channel + go l.publishingLoop(l.killCtx, l.wg, receiptsCh, publishSignal) // ranges over publishSignal, spawns routines which send on receiptsCh. Closes receiptsCh when done. + go l.blockLoadingLoop(l.shutdownCtx, l.wg, pendingBytesUpdated, publishSignal) // sends on pendingBytesUpdated (if throttling enabled), and publishSignal. Closes them both when done + l.Log.Info("Batch Submitter started") return nil } @@ -779,7 +779,7 @@ func (l *BatchSubmitter) clearState(ctx context.Context) { defer l.channelMgrMutex.Unlock() l.channelMgr.Clear(l1SafeOrigin) if l.Config.UseEspresso { - l.streamer.Reset() + l.espressoStreamer.Reset() } return true } @@ -931,8 +931,6 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef if !l.Config.UseAltDA { l.Log.Crit("Received AltDA type txdata without AltDA being enabled") } - - // if Alt DA is enabled we post the txdata to the DA Provider and replace it with the commitment. if txdata.altDACommitment == nil { // This means the txdata was not sent to the DA Provider yet. // This will send the txdata to the DA Provider and store the commitment in the channelMgr. diff --git a/op-batcher/batcher/espresso.go b/op-batcher/batcher/espresso.go index fe9b32f4098..3cf56e3ea0f 100644 --- a/op-batcher/batcher/espresso.go +++ b/op-batcher/batcher/espresso.go @@ -19,6 +19,8 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum-optimism/optimism/espresso" + espressoLocal "github.com/ethereum-optimism/optimism/espresso" "github.com/ethereum-optimism/optimism/op-batcher/bindings" "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-service/eth" @@ -634,6 +636,25 @@ func (s *espressoTransactionSubmitter) Start() { go s.handleVerifyReceiptJobResponse() } +func (bs *BatcherService) EspressoStreamer() *espressoLocal.EspressoStreamer[derive.EspressoBatch] { + return &bs.driver.espressoStreamer +} + +func (bs *BatcherService) initKeyPair() error { + key, err := crypto.GenerateKey() + if err != nil { + return fmt.Errorf("failed to generate key pair for batcher: %w", err) + } + bs.BatcherPrivateKey = key + bs.BatcherPublicKey = &key.PublicKey + return nil +} + +// EspressoStreamer returns the batch submitter's Espresso streamer instance +func (l *BatchSubmitter) EspressoStreamer() *espresso.EspressoStreamer[derive.EspressoBatch] { + return &l.espressoStreamer +} + // Converts a block to an EspressoBatch and starts a goroutine that publishes it to Espresso // Returns error only if batch conversion fails, otherwise it is infallible, as the goroutine // will retry publishing until successful. @@ -650,13 +671,13 @@ func (l *BatchSubmitter) queueBlockToEspresso(ctx context.Context, block *types. return fmt.Errorf("failed to create Espresso transaction from a batch: %w", err) } - l.submitter.SubmitTransaction(transaction) + l.espressoSubmitter.SubmitTransaction(transaction) return nil } func (l *BatchSubmitter) espressoSyncAndRefresh(ctx context.Context, newSyncStatus *eth.SyncStatus) { - err := l.streamer.Refresh(ctx, newSyncStatus.FinalizedL1, newSyncStatus.SafeL2.Number, newSyncStatus.SafeL2.L1Origin) + err := l.espressoStreamer.Refresh(ctx, newSyncStatus.FinalizedL1, newSyncStatus.SafeL2.Number, newSyncStatus.SafeL2.L1Origin) if err != nil { l.Log.Warn("Failed to refresh Espresso streamer", "err", err) } @@ -671,7 +692,7 @@ func (l *BatchSubmitter) espressoSyncAndRefresh(ctx context.Context, newSyncStat l.prevCurrentL1 = newSyncStatus.CurrentL1 if syncActions.clearState != nil { l.channelMgr.Clear(*syncActions.clearState) - l.streamer.Reset() + l.espressoStreamer.Reset() } else { l.channelMgr.PruneSafeBlocks(syncActions.blocksToPrune) l.channelMgr.PruneChannels(syncActions.channelsToPrune) @@ -720,8 +741,8 @@ func (l *BatchSubmitter) espressoBatchLoadingLoop(ctx context.Context, wg *sync. l.espressoSyncAndRefresh(ctx, newSyncStatus) - err = l.streamer.Update(ctx) - remainingListLen := len(l.streamer.RemainingBatches) + err = l.espressoStreamer.Update(ctx) + remainingListLen := len(l.espressoStreamer.RemainingBatches) if remainingListLen > 0 { l.Log.Warn("Remaining list not empty.", "Number items", remainingListLen) } @@ -730,7 +751,7 @@ func (l *BatchSubmitter) espressoBatchLoadingLoop(ctx context.Context, wg *sync. for { - batch = l.streamer.Next(ctx) + batch = l.espressoStreamer.Next(ctx) if batch == nil { break @@ -758,7 +779,7 @@ func (l *BatchSubmitter) espressoBatchLoadingLoop(ctx context.Context, wg *sync. if err != nil { l.Log.Error("failed to add L2 block to channel manager", "err", err) l.clearState(ctx) - l.streamer.Reset() + l.espressoStreamer.Reset() } l.Log.Info("Added L2 block to channel manager") diff --git a/op-batcher/batcher/service.go b/op-batcher/batcher/service.go index 8c97f913fc3..06c0224931d 100644 --- a/op-batcher/batcher/service.go +++ b/op-batcher/batcher/service.go @@ -12,8 +12,6 @@ import ( espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client" espressoLightClient "github.com/EspressoSystems/espresso-network/sdks/go/light-client" - espressoLocal "github.com/ethereum-optimism/optimism/espresso" - derive "github.com/ethereum-optimism/optimism/op-node/rollup/derive" opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -49,38 +47,35 @@ type BatcherConfig struct { // UseAltDA is true if the rollup config has a DA challenge address so the batcher // will post inputs to the DA server and post commitments to blobs or calldata. - UseAltDA bool - UseEspresso bool + UseAltDA bool // maximum number of concurrent blob put requests to the DA server MaxConcurrentDARequests uint64 - // public key and private key of the batcher - BatcherPublicKey *ecdsa.PublicKey - BatcherPrivateKey *ecdsa.PrivateKey - - WaitNodeSync bool - CheckRecentTxsDepth int + WaitNodeSync bool + CheckRecentTxsDepth int // For throttling DA. See CLIConfig in config.go for details on these parameters. ThrottleThreshold, ThrottleTxSize uint64 ThrottleBlockSize, ThrottleAlwaysBlockSize uint64 PreferLocalSafeL2 bool + + // public key and private key of the batcher + BatcherPublicKey *ecdsa.PublicKey + BatcherPrivateKey *ecdsa.PrivateKey + UseEspresso bool } // BatcherService represents a full batch-submitter instance and its resources, // and conforms to the op-service CLI Lifecycle interface. type BatcherService struct { - Log log.Logger - Metrics metrics.Metricer - L1Client *ethclient.Client - EndpointProvider dial.L2EndpointProvider - TxManager txmgr.TxManager - AltDA *altda.DAClient - Espresso *espressoClient.MultipleNodesClient - EspressoLightClient *espressoLightClient.LightclientCaller + Log log.Logger + Metrics metrics.Metricer + L1Client *ethclient.Client + EndpointProvider dial.L2EndpointProvider + TxManager txmgr.TxManager + AltDA *altda.DAClient BatcherConfig - opcrypto.ChainSigner ChannelConfig ChannelConfigProvider RollupConfig *rollup.Config @@ -98,11 +93,10 @@ type BatcherService struct { NotSubmittingOnStart bool - Attestation *nitrite.Result -} - -func (bs *BatcherService) EspressoStreamer() *espressoLocal.EspressoStreamer[derive.EspressoBatch] { - return &bs.driver.streamer + opcrypto.ChainSigner + Espresso *espressoClient.MultipleNodesClient + EspressoLightClient *espressoLightClient.LightclientCaller + Attestation *nitrite.Result } type DriverSetupOption func(setup *DriverSetup) @@ -115,7 +109,6 @@ func BatcherServiceFromCLIConfig(ctx context.Context, version string, cfg *CLICo if err := bs.initFromCLIConfig(ctx, version, cfg, log, opts...); err != nil { return nil, errors.Join(err, bs.Stop(ctx)) // try to clean up our failed initialization attempt } - return &bs, nil } @@ -127,7 +120,6 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string, bs.initMetrics(cfg) bs.PollInterval = cfg.PollInterval - bs.EspressoPollInterval = cfg.EspressoPollInterval bs.MaxPendingTransactions = cfg.MaxPendingTransactions bs.MaxConcurrentDARequests = cfg.AltDA.MaxConcurrentRequests bs.NetworkTimeout = cfg.TxMgrConfig.NetworkTimeout @@ -147,6 +139,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string, opts = append(optsFromRPC, opts...) if len(cfg.EspressoUrls) > 0 { + bs.EspressoPollInterval = cfg.EspressoPollInterval client, err := espressoClient.NewMultipleNodesClient(cfg.EspressoUrls) if err != nil { return fmt.Errorf("failed to create Espresso client: %w", err) @@ -301,16 +294,6 @@ func (bs *BatcherService) initRollupConfig(ctx context.Context) error { return nil } -func (bs *BatcherService) initKeyPair() error { - key, err := crypto.GenerateKey() - if err != nil { - return fmt.Errorf("failed to generate key pair for batcher: %w", err) - } - bs.BatcherPrivateKey = key - bs.BatcherPublicKey = &key.PublicKey - return nil -} - func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error { channelTimeout := bs.RollupConfig.ChannelTimeoutBedrock // Use lower channel timeout if granite is scheduled. @@ -458,17 +441,18 @@ func (bs *BatcherService) initMetricsServer(cfg *CLIConfig) error { func (bs *BatcherService) initDriver(opts ...DriverSetupOption) { ds := DriverSetup{ - Log: bs.Log, - Metr: bs.Metrics, - RollupConfig: bs.RollupConfig, - Config: bs.BatcherConfig, - ChainSigner: bs.ChainSigner, + Log: bs.Log, + Metr: bs.Metrics, + RollupConfig: bs.RollupConfig, + Config: bs.BatcherConfig, + Txmgr: bs.TxManager, + L1Client: bs.L1Client, + EndpointProvider: bs.EndpointProvider, + ChannelConfig: bs.ChannelConfig, + AltDA: bs.AltDA, + SequencerAddress: bs.TxManager.From(), - Txmgr: bs.TxManager, - L1Client: bs.L1Client, - EndpointProvider: bs.EndpointProvider, - ChannelConfig: bs.ChannelConfig, - AltDA: bs.AltDA, + ChainSigner: bs.ChainSigner, Espresso: bs.Espresso, EspressoLightClient: bs.EspressoLightClient, Attestation: bs.Attestation, diff --git a/op-chain-ops/genesis/config.go b/op-chain-ops/genesis/config.go index 25a3d8b3a18..59e9c72a381 100644 --- a/op-chain-ops/genesis/config.go +++ b/op-chain-ops/genesis/config.go @@ -1057,14 +1057,13 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *eth.BlockRef, l2GenesisBlockHa L2Time: l1StartBlock.Time, SystemConfig: d.GenesisSystemConfig(), }, - BlockTime: d.L2BlockTime, - MaxSequencerDrift: d.MaxSequencerDrift, - SeqWindowSize: d.SequencerWindowSize, - ChannelTimeoutBedrock: d.ChannelTimeoutBedrock, - L1ChainID: new(big.Int).SetUint64(d.L1ChainID), - L2ChainID: new(big.Int).SetUint64(d.L2ChainID), - BatchInboxAddress: d.BatchInboxAddress, - BatchAuthenticatorAddress: d.BatchAuthenticatorAddress, + BlockTime: d.L2BlockTime, + MaxSequencerDrift: d.MaxSequencerDrift, + SeqWindowSize: d.SequencerWindowSize, + ChannelTimeoutBedrock: d.ChannelTimeoutBedrock, + L1ChainID: new(big.Int).SetUint64(d.L1ChainID), + L2ChainID: new(big.Int).SetUint64(d.L2ChainID), + BatchInboxAddress: d.BatchInboxAddress, DepositContractAddress: d.OptimismPortalProxy, L1SystemConfigAddress: d.SystemConfigProxy, @@ -1083,6 +1082,8 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *eth.BlockRef, l2GenesisBlockHa AltDAConfig: altDA, ChainOpConfig: chainOpConfig, Cel2Time: d.RegolithTime(l1StartTime), + + BatchAuthenticatorAddress: d.BatchAuthenticatorAddress, }, nil } @@ -1151,8 +1152,9 @@ type L1Deployments struct { ProtocolVersionsProxy common.Address `json:"ProtocolVersionsProxy"` DataAvailabilityChallenge common.Address `json:"DataAvailabilityChallenge"` DataAvailabilityChallengeProxy common.Address `json:"DataAvailabilityChallengeProxy"` - BatchInbox common.Address `json:"BatchInbox"` - BatchAuthenticator common.Address `json:"BatchAuthenticator"` + + BatchInbox common.Address `json:"BatchInbox"` + BatchAuthenticator common.Address `json:"BatchAuthenticator"` } // GetName will return the name of the contract given an address. diff --git a/op-deployer/pkg/deployer/state/deploy_config.go b/op-deployer/pkg/deployer/state/deploy_config.go index 5fd392d0ac7..0bc0dba42cf 100644 --- a/op-deployer/pkg/deployer/state/deploy_config.go +++ b/op-deployer/pkg/deployer/state/deploy_config.go @@ -97,6 +97,7 @@ func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State, ChannelTimeoutBedrock: 300, SystemConfigStartBlock: 0, BatchInboxAddress: calculateBatchInboxAddr(chainState), + BatchAuthenticatorAddress: chainState.BatchAuthenticatorAddress, }, OperatorDeployConfig: genesis.OperatorDeployConfig{ diff --git a/op-e2e/config/init.go b/op-e2e/config/init.go index 8e63a4a8098..238b6b8fecd 100644 --- a/op-e2e/config/init.go +++ b/op-e2e/config/init.go @@ -51,11 +51,12 @@ const ( type AllocType string const ( - AllocTypeStandard AllocType = "standard" - AllocTypeAltDA AllocType = "alt-da" - AllocTypeAltDAGeneric AllocType = "alt-da-generic" - AllocTypeL2OO AllocType = "l2oo" - AllocTypeMTCannon AllocType = "mt-cannon" + AllocTypeStandard AllocType = "standard" + AllocTypeAltDA AllocType = "alt-da" + AllocTypeAltDAGeneric AllocType = "alt-da-generic" + AllocTypeL2OO AllocType = "l2oo" + AllocTypeMTCannon AllocType = "mt-cannon" + AllocTypeEspressoWithoutEnclave AllocType = "espresso-no-enclave" AllocTypeEspressoWithEnclave AllocType = "espresso-enclave" diff --git a/op-e2e/system/e2esys/setup.go b/op-e2e/system/e2esys/setup.go index 713fafbab94..95d61e21ac1 100644 --- a/op-e2e/system/e2esys/setup.go +++ b/op-e2e/system/e2esys/setup.go @@ -710,35 +710,36 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System, L2Time: uint64(cfg.DeployConfig.L1GenesisBlockTimestamp), SystemConfig: e2eutils.SystemConfigFromDeployConfig(cfg.DeployConfig), }, - BlockTime: cfg.DeployConfig.L2BlockTime, - MaxSequencerDrift: cfg.DeployConfig.MaxSequencerDrift, - SeqWindowSize: cfg.DeployConfig.SequencerWindowSize, - ChannelTimeoutBedrock: cfg.DeployConfig.ChannelTimeoutBedrock, - L1ChainID: cfg.L1ChainIDBig(), - L2ChainID: cfg.L2ChainIDBig(), - BatchInboxAddress: cfg.DeployConfig.BatchInboxAddress, - BatchAuthenticatorAddress: cfg.DeployConfig.BatchAuthenticatorAddress, - DepositContractAddress: cfg.DeployConfig.OptimismPortalProxy, - L1SystemConfigAddress: cfg.DeployConfig.SystemConfigProxy, - RegolithTime: cfg.DeployConfig.RegolithTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - CanyonTime: cfg.DeployConfig.CanyonTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - DeltaTime: cfg.DeployConfig.DeltaTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - EcotoneTime: cfg.DeployConfig.EcotoneTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - FjordTime: cfg.DeployConfig.FjordTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - GraniteTime: cfg.DeployConfig.GraniteTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - HoloceneTime: cfg.DeployConfig.HoloceneTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - PectraBlobScheduleTime: cfg.DeployConfig.PectraBlobScheduleTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - IsthmusTime: cfg.DeployConfig.IsthmusTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - JovianTime: cfg.DeployConfig.JovianTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - InteropTime: cfg.DeployConfig.InteropTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - Cel2Time: cfg.DeployConfig.RegolithTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), - ProtocolVersionsAddress: cfg.L1Deployments.ProtocolVersionsProxy, - AltDAConfig: rollupAltDAConfig, + BlockTime: cfg.DeployConfig.L2BlockTime, + MaxSequencerDrift: cfg.DeployConfig.MaxSequencerDrift, + SeqWindowSize: cfg.DeployConfig.SequencerWindowSize, + ChannelTimeoutBedrock: cfg.DeployConfig.ChannelTimeoutBedrock, + L1ChainID: cfg.L1ChainIDBig(), + L2ChainID: cfg.L2ChainIDBig(), + BatchInboxAddress: cfg.DeployConfig.BatchInboxAddress, + DepositContractAddress: cfg.DeployConfig.OptimismPortalProxy, + L1SystemConfigAddress: cfg.DeployConfig.SystemConfigProxy, + RegolithTime: cfg.DeployConfig.RegolithTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + CanyonTime: cfg.DeployConfig.CanyonTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + DeltaTime: cfg.DeployConfig.DeltaTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + EcotoneTime: cfg.DeployConfig.EcotoneTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + FjordTime: cfg.DeployConfig.FjordTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + GraniteTime: cfg.DeployConfig.GraniteTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + HoloceneTime: cfg.DeployConfig.HoloceneTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + PectraBlobScheduleTime: cfg.DeployConfig.PectraBlobScheduleTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + IsthmusTime: cfg.DeployConfig.IsthmusTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + JovianTime: cfg.DeployConfig.JovianTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + InteropTime: cfg.DeployConfig.InteropTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + Cel2Time: cfg.DeployConfig.RegolithTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)), + ProtocolVersionsAddress: cfg.L1Deployments.ProtocolVersionsProxy, + AltDAConfig: rollupAltDAConfig, ChainOpConfig: ¶ms.OptimismConfig{ EIP1559Elasticity: cfg.DeployConfig.EIP1559Elasticity, EIP1559Denominator: cfg.DeployConfig.EIP1559Denominator, EIP1559DenominatorCanyon: &cfg.DeployConfig.EIP1559DenominatorCanyon, }, + + BatchAuthenticatorAddress: cfg.DeployConfig.BatchAuthenticatorAddress, } } defaultConfig := makeRollupConfig() diff --git a/op-e2e/system/helpers/tx_helper.go b/op-e2e/system/helpers/tx_helper.go index 21d17995af2..4ee973592d4 100644 --- a/op-e2e/system/helpers/tx_helper.go +++ b/op-e2e/system/helpers/tx_helper.go @@ -7,15 +7,14 @@ import ( "testing" "time" - "github.com/holiman/uint256" - "github.com/ethereum-optimism/optimism/op-e2e/system/e2esys" - "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/holiman/uint256" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" "github.com/ethereum-optimism/optimism/op-e2e/bindings" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/transactions" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types"