Skip to content
Closed
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
2 changes: 1 addition & 1 deletion espresso/environment/optitmism_espresso_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ func (l *EspressoDevNodeLauncherDocker) StartDevNet(ctx context.Context, t *test

system, err := sysConfig.Start(
t,

startOptions...,
)

Expand Down Expand Up @@ -863,6 +862,7 @@ func launchEspressoDevNodeStartOption(ct *DevNetLauncherContext) e2esys.StartOpt
}
ct.EspressoDevNode = espressoDevNode

c.UseEspresso = true
c.EspressoUrls = espressoDevNode.espressoUrls
c.LogConfig.Level = slog.LevelDebug
c.TestingEspressoBatcherPrivateKey = "0x" + config.ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY
Expand Down
1 change: 1 addition & 0 deletions op-batcher/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type CLIConfig struct {
RPC oprpc.CLIConfig
AltDA altda.CLIConfig

UseEspresso bool
EspressoUrls []string
EspressoLightClientAddr string
TestingEspressoBatcherPrivateKey string
Expand Down
22 changes: 19 additions & 3 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ func (l *BatchSubmitter) EspressoStreamer() *espresso.EspressoStreamer[derive.Es
return &l.streamer
}

// isEspressoEnabled returns true if Espresso integration is currently active based on the timestamp.
// It checks both that Espresso client is configured and that the activation timestamp has been reached.
func (l *BatchSubmitter) isEspressoEnabled() bool {
// First check if Espresso is configured (we need the client and the authenticator address)
if l.Espresso == nil || l.RollupConfig.BatchAuthenticatorAddress == (common.Address{}) {
l.Log.Info("Espresso is not enabled", "espresso", l.Espresso, "batchAuthenticatorAddress", l.RollupConfig.BatchAuthenticatorAddress)
return false
}
// Check if the EspressoCeloIntegration fork is active based on current timestamp
currentTime := uint64(time.Now().Unix())
l.Log.Info("Checking if EspressoCeloIntegration is active", "currentTime", currentTime, "espressoCeloIntegrationTime", l.RollupConfig.EspressoCeloIntegrationTime)
return l.RollupConfig.IsEspressoCeloIntegration(currentTime)
}

// NewBatchSubmitter initializes the BatchSubmitter driver from a preconfigured DriverSetup
func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter {
state := NewChannelManager(setup.Log, setup.Metr, setup.ChannelConfig, setup.RollupConfig)
Expand Down Expand Up @@ -212,7 +226,8 @@ func (l *BatchSubmitter) StartBatchSubmitting() error {
l.Log.Warn("Throttling loop is DISABLED due to 0 throttle-threshold. This should not be disabled in prod.")
}

if l.Config.UseEspresso {
// There are two ways to use Espresso, one is to enable `UseEspresso` to force the use, the other is to set the timestamp and it will be activated automatically after the timestamp.
if l.Config.UseEspresso || l.isEspressoEnabled() {

err := l.registerBatcher(l.killCtx)
if err != nil {
Expand Down Expand Up @@ -778,7 +793,7 @@ func (l *BatchSubmitter) clearState(ctx context.Context) {
l.channelMgrMutex.Lock()
defer l.channelMgrMutex.Unlock()
l.channelMgr.Clear(l1SafeOrigin)
if l.Config.UseEspresso {
if l.Config.UseEspresso || l.isEspressoEnabled() {
l.streamer.Reset()
}
return true
Expand Down Expand Up @@ -978,7 +993,8 @@ type TxSender[T any] interface {
// sendTx uses the txmgr queue to send the given transaction candidate after setting its
// gaslimit. It will block if the txmgr queue has reached its MaxPendingTransactions limit.
func (l *BatchSubmitter) sendTx(txdata txData, isCancel bool, candidate *txmgr.TxCandidate, queue TxSender[txRef], receiptsCh chan txmgr.TxReceipt[txRef], daGroup *errgroup.Group) {
if l.Config.UseEspresso && !isCancel {
// There are two ways to use Espresso, one is to enable `UseEspresso` to force the use, the other is to set the timestamp and it will be activated automatically after the timestamp.
if (l.Config.UseEspresso || l.isEspressoEnabled()) && !isCancel {
goroutineSpawned := daGroup.TryGo(
func() error {
l.sendEspressoTx(txdata, isCancel, candidate, queue, receiptsCh)
Expand Down
3 changes: 2 additions & 1 deletion op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
}
opts = append(optsFromRPC, opts...)

bs.UseEspresso = cfg.UseEspresso
if len(cfg.EspressoUrls) > 0 {
client, err := espressoClient.NewMultipleNodesClient(cfg.EspressoUrls)
if err != nil {
Expand All @@ -157,7 +158,6 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
return fmt.Errorf("failed to create Espresso light client")
}
bs.EspressoLightClient = espressoLightClient
bs.UseEspresso = true
if err := bs.initKeyPair(); err != nil {
return fmt.Errorf("failed to create key pair for batcher: %w", err)
}
Expand Down Expand Up @@ -294,6 +294,7 @@ func (bs *BatcherService) initRollupConfig(ctx context.Context) error {
return fmt.Errorf("failed to retrieve rollup config: %w", err)
}
bs.RollupConfig = rollupConfig

if err := bs.RollupConfig.Check(); err != nil {
return fmt.Errorf("invalid rollup config: %w", err)
}
Expand Down
52 changes: 34 additions & 18 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ type UpgradeScheduleDeployConfig struct {
// L2GenesisInteropTimeOffset is the number of seconds after genesis block that the Interop hard fork activates.
// Set it to 0 to activate at genesis. Nil to disable Interop.
L2GenesisInteropTimeOffset *hexutil.Uint64 `json:"l2GenesisInteropTimeOffset,omitempty"`

// L2GenesisEspressoCeloIntegrationTimeOffset is the number of seconds after genesis block that the EspressoCeloIntegration hard fork activates.
// Set it to 0 to activate at genesis. Nil to disable EspressoCelo.
L2GenesisEspressoCeloIntegrationTimeOffset *hexutil.Uint64 `json:"l2GenesisEspressoCeloIntegrationTimeOffset,omitempty"`
// Optional Forks

// L2GenesisPectraBlobScheduleTimeOffset is the number of seconds after genesis block that the PectraBlobSchedule fix activates.
Expand Down Expand Up @@ -420,6 +422,8 @@ func (d *UpgradeScheduleDeployConfig) ForkTimeOffset(fork rollup.ForkName) *uint
return (*uint64)(d.L2GenesisJovianTimeOffset)
case rollup.Interop:
return (*uint64)(d.L2GenesisInteropTimeOffset)
case rollup.EspressoCeloIntegration:
return (*uint64)(d.L2GenesisEspressoCeloIntegrationTimeOffset)
default:
panic(fmt.Sprintf("unknown fork: %s", fork))
}
Expand Down Expand Up @@ -447,6 +451,8 @@ func (d *UpgradeScheduleDeployConfig) SetForkTimeOffset(fork rollup.ForkName, of
d.L2GenesisJovianTimeOffset = (*hexutil.Uint64)(offset)
case rollup.Interop:
d.L2GenesisInteropTimeOffset = (*hexutil.Uint64)(offset)
case rollup.EspressoCeloIntegration:
d.L2GenesisEspressoCeloIntegrationTimeOffset = (*hexutil.Uint64)(offset)
default:
panic(fmt.Sprintf("unknown fork: %s", fork))
}
Expand Down Expand Up @@ -525,6 +531,10 @@ func (d *UpgradeScheduleDeployConfig) InteropTime(genesisTime uint64) *uint64 {
return offsetToUpgradeTime(d.L2GenesisInteropTimeOffset, genesisTime)
}

func (d *UpgradeScheduleDeployConfig) EspressoCeloIntegrationTime(genesisTime uint64) *uint64 {
return offsetToUpgradeTime(d.L2GenesisEspressoCeloIntegrationTimeOffset, genesisTime)
}

func (d *UpgradeScheduleDeployConfig) AllocMode(genesisTime uint64) L2AllocsMode {
forks := d.forks()
for i := len(forks) - 1; i >= 0; i-- {
Expand Down Expand Up @@ -555,6 +565,7 @@ func (d *UpgradeScheduleDeployConfig) forks() []Fork {
{L2GenesisTimeOffset: d.L2GenesisHoloceneTimeOffset, Name: string(L2AllocsHolocene)},
{L2GenesisTimeOffset: d.L2GenesisIsthmusTimeOffset, Name: string(L2AllocsIsthmus)},
{L2GenesisTimeOffset: d.L2GenesisJovianTimeOffset, Name: string(L2AllocsJovian)},
{L2GenesisTimeOffset: d.L2GenesisEspressoCeloIntegrationTimeOffset, Name: string(L2AllocsEspressoCeloIntegration)},
}
}

Expand All @@ -565,6 +576,10 @@ func (d *UpgradeScheduleDeployConfig) Check(log log.Logger) error {
return nil
}
if a == nil && b != nil {
// Allow espresso_celo_integration to work without jovian as prerequisite
if bName == string(L2AllocsEspressoCeloIntegration) && aName == string(L2AllocsJovian) {
return nil
}
return fmt.Errorf("fork %s set (to %d), but prior fork %s missing", bName, *b, aName)
}
if a != nil && b == nil {
Expand Down Expand Up @@ -1066,23 +1081,24 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *eth.BlockRef, l2GenesisBlockHa
BatchInboxAddress: d.BatchInboxAddress,
BatchAuthenticatorAddress: d.BatchAuthenticatorAddress,

DepositContractAddress: d.OptimismPortalProxy,
L1SystemConfigAddress: d.SystemConfigProxy,
RegolithTime: d.RegolithTime(l1StartTime),
CanyonTime: d.CanyonTime(l1StartTime),
DeltaTime: d.DeltaTime(l1StartTime),
EcotoneTime: d.EcotoneTime(l1StartTime),
FjordTime: d.FjordTime(l1StartTime),
GraniteTime: d.GraniteTime(l1StartTime),
HoloceneTime: d.HoloceneTime(l1StartTime),
PectraBlobScheduleTime: d.PectraBlobScheduleTime(l1StartTime),
IsthmusTime: d.IsthmusTime(l1StartTime),
JovianTime: d.JovianTime(l1StartTime),
InteropTime: d.InteropTime(l1StartTime),
ProtocolVersionsAddress: d.ProtocolVersionsProxy,
AltDAConfig: altDA,
ChainOpConfig: chainOpConfig,
Cel2Time: d.RegolithTime(l1StartTime),
DepositContractAddress: d.OptimismPortalProxy,
L1SystemConfigAddress: d.SystemConfigProxy,
RegolithTime: d.RegolithTime(l1StartTime),
CanyonTime: d.CanyonTime(l1StartTime),
DeltaTime: d.DeltaTime(l1StartTime),
EcotoneTime: d.EcotoneTime(l1StartTime),
FjordTime: d.FjordTime(l1StartTime),
GraniteTime: d.GraniteTime(l1StartTime),
HoloceneTime: d.HoloceneTime(l1StartTime),
PectraBlobScheduleTime: d.PectraBlobScheduleTime(l1StartTime),
IsthmusTime: d.IsthmusTime(l1StartTime),
JovianTime: d.JovianTime(l1StartTime),
InteropTime: d.InteropTime(l1StartTime),
ProtocolVersionsAddress: d.ProtocolVersionsProxy,
AltDAConfig: altDA,
ChainOpConfig: chainOpConfig,
Cel2Time: d.RegolithTime(l1StartTime),
EspressoCeloIntegrationTime: d.EspressoCeloIntegrationTime(l1StartTime),
}, nil
}

Expand Down
15 changes: 8 additions & 7 deletions op-chain-ops/genesis/layer_two.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ type L2AllocsMode string
type L2AllocsModeMap map[L2AllocsMode]*foundry.ForgeAllocs

const (
L2AllocsDelta L2AllocsMode = "delta"
L2AllocsEcotone L2AllocsMode = "ecotone"
L2AllocsFjord L2AllocsMode = "fjord"
L2AllocsGranite L2AllocsMode = "granite"
L2AllocsHolocene L2AllocsMode = "holocene"
L2AllocsIsthmus L2AllocsMode = "isthmus"
L2AllocsJovian L2AllocsMode = "jovian"
L2AllocsDelta L2AllocsMode = "delta"
L2AllocsEcotone L2AllocsMode = "ecotone"
L2AllocsFjord L2AllocsMode = "fjord"
L2AllocsGranite L2AllocsMode = "granite"
L2AllocsHolocene L2AllocsMode = "holocene"
L2AllocsIsthmus L2AllocsMode = "isthmus"
L2AllocsJovian L2AllocsMode = "jovian"
L2AllocsEspressoCeloIntegration L2AllocsMode = "espresso_celo_integration"
)

var (
Expand Down
27 changes: 14 additions & 13 deletions op-chain-ops/interopgen/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,20 @@ func (r *InteropDevL2Recipe) build(l1ChainID uint64, addrs devkeys.Addresses) (*
EIP1559DenominatorCanyon: 250,
},
UpgradeScheduleDeployConfig: genesis.UpgradeScheduleDeployConfig{
L2GenesisRegolithTimeOffset: new(hexutil.Uint64),
L2GenesisCanyonTimeOffset: new(hexutil.Uint64),
L2GenesisDeltaTimeOffset: new(hexutil.Uint64),
L2GenesisEcotoneTimeOffset: new(hexutil.Uint64),
L2GenesisFjordTimeOffset: new(hexutil.Uint64),
L2GenesisGraniteTimeOffset: new(hexutil.Uint64),
L2GenesisHoloceneTimeOffset: new(hexutil.Uint64),
L2GenesisIsthmusTimeOffset: new(hexutil.Uint64),
L2GenesisJovianTimeOffset: nil,
L2GenesisInteropTimeOffset: new(hexutil.Uint64),
L1CancunTimeOffset: new(hexutil.Uint64),
L1PragueTimeOffset: new(hexutil.Uint64),
UseInterop: true,
L2GenesisRegolithTimeOffset: new(hexutil.Uint64),
L2GenesisCanyonTimeOffset: new(hexutil.Uint64),
L2GenesisDeltaTimeOffset: new(hexutil.Uint64),
L2GenesisEcotoneTimeOffset: new(hexutil.Uint64),
L2GenesisFjordTimeOffset: new(hexutil.Uint64),
L2GenesisGraniteTimeOffset: new(hexutil.Uint64),
L2GenesisHoloceneTimeOffset: new(hexutil.Uint64),
L2GenesisIsthmusTimeOffset: new(hexutil.Uint64),
L2GenesisJovianTimeOffset: nil,
L2GenesisInteropTimeOffset: new(hexutil.Uint64),
L2GenesisEspressoCeloIntegrationTimeOffset: new(hexutil.Uint64),
L1CancunTimeOffset: new(hexutil.Uint64),
L1PragueTimeOffset: new(hexutil.Uint64),
UseInterop: true,
},
L2CoreDeployConfig: genesis.L2CoreDeployConfig{
L1ChainID: l1ChainID,
Expand Down
Loading
Loading