Skip to content

Commit ada430d

Browse files
committed
init espresso activaion timestamp
1 parent ef4be47 commit ada430d

File tree

12 files changed

+118
-48
lines changed

12 files changed

+118
-48
lines changed

op-batcher/batcher/driver.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ func (l *BatchSubmitter) EspressoStreamer() *espresso.EspressoStreamer[derive.Es
140140
return &l.streamer
141141
}
142142

143+
// isEspressoEnabled returns true if Espresso integration is currently active based on the timestamp.
144+
// It checks both that Espresso client is configured and that the activation timestamp has been reached.
145+
func (l *BatchSubmitter) isEspressoEnabled() bool {
146+
// First check if Espresso is configured (we need the client and the authenticator address)
147+
if l.Espresso == nil || l.RollupConfig.BatchAuthenticatorAddress == (common.Address{}) {
148+
return false
149+
}
150+
// Check if the EspressoCeloIntegration fork is active based on current timestamp
151+
currentTime := uint64(time.Now().Unix())
152+
return l.RollupConfig.IsEspressoCeloIntegration(currentTime)
153+
}
154+
143155
// NewBatchSubmitter initializes the BatchSubmitter driver from a preconfigured DriverSetup
144156
func NewBatchSubmitter(setup DriverSetup) *BatchSubmitter {
145157
state := NewChannelManager(setup.Log, setup.Metr, setup.ChannelConfig, setup.RollupConfig)
@@ -212,7 +224,7 @@ func (l *BatchSubmitter) StartBatchSubmitting() error {
212224
l.Log.Warn("Throttling loop is DISABLED due to 0 throttle-threshold. This should not be disabled in prod.")
213225
}
214226

215-
if l.Config.UseEspresso {
227+
if l.isEspressoEnabled() {
216228

217229
err := l.registerBatcher(l.killCtx)
218230
if err != nil {
@@ -778,7 +790,7 @@ func (l *BatchSubmitter) clearState(ctx context.Context) {
778790
l.channelMgrMutex.Lock()
779791
defer l.channelMgrMutex.Unlock()
780792
l.channelMgr.Clear(l1SafeOrigin)
781-
if l.Config.UseEspresso {
793+
if l.isEspressoEnabled() {
782794
l.streamer.Reset()
783795
}
784796
return true
@@ -978,7 +990,7 @@ type TxSender[T any] interface {
978990
// sendTx uses the txmgr queue to send the given transaction candidate after setting its
979991
// gaslimit. It will block if the txmgr queue has reached its MaxPendingTransactions limit.
980992
func (l *BatchSubmitter) sendTx(txdata txData, isCancel bool, candidate *txmgr.TxCandidate, queue TxSender[txRef], receiptsCh chan txmgr.TxReceipt[txRef], daGroup *errgroup.Group) {
981-
if l.Config.UseEspresso && !isCancel {
993+
if l.isEspressoEnabled() && !isCancel {
982994
goroutineSpawned := daGroup.TryGo(
983995
func() error {
984996
l.sendEspressoTx(txdata, isCancel, candidate, queue, receiptsCh)

op-batcher/batcher/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
153153
return fmt.Errorf("failed to create Espresso light client")
154154
}
155155
bs.EspressoLightClient = espressoLightClient
156-
bs.UseEspresso = true
156+
// Note: UseEspresso is now determined dynamically by isEspressoEnabled() based on activation timestamp
157157
if err := bs.initKeyPair(); err != nil {
158158
return fmt.Errorf("failed to create key pair for batcher: %w", err)
159159
}

op-chain-ops/genesis/config.go

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ type UpgradeScheduleDeployConfig struct {
369369
// L2GenesisInteropTimeOffset is the number of seconds after genesis block that the Interop hard fork activates.
370370
// Set it to 0 to activate at genesis. Nil to disable Interop.
371371
L2GenesisInteropTimeOffset *hexutil.Uint64 `json:"l2GenesisInteropTimeOffset,omitempty"`
372-
372+
// L2GenesisEspressoCeloIntegrationTimeOffset is the number of seconds after genesis block that the EspressoCeloIntegration hard fork activates.
373+
// Set it to 0 to activate at genesis. Nil to disable EspressoCelo.
374+
L2GenesisEspressoCeloIntegrationTimeOffset *hexutil.Uint64 `json:"l2GenesisEspressoCeloIntegrationTimeOffset,omitempty"`
373375
// Optional Forks
374376

375377
// L2GenesisPectraBlobScheduleTimeOffset is the number of seconds after genesis block that the PectraBlobSchedule fix activates.
@@ -420,6 +422,8 @@ func (d *UpgradeScheduleDeployConfig) ForkTimeOffset(fork rollup.ForkName) *uint
420422
return (*uint64)(d.L2GenesisJovianTimeOffset)
421423
case rollup.Interop:
422424
return (*uint64)(d.L2GenesisInteropTimeOffset)
425+
case rollup.EspressoCeloIntegration:
426+
return (*uint64)(d.L2GenesisEspressoCeloIntegrationTimeOffset)
423427
default:
424428
panic(fmt.Sprintf("unknown fork: %s", fork))
425429
}
@@ -447,6 +451,8 @@ func (d *UpgradeScheduleDeployConfig) SetForkTimeOffset(fork rollup.ForkName, of
447451
d.L2GenesisJovianTimeOffset = (*hexutil.Uint64)(offset)
448452
case rollup.Interop:
449453
d.L2GenesisInteropTimeOffset = (*hexutil.Uint64)(offset)
454+
case rollup.EspressoCeloIntegration:
455+
d.L2GenesisEspressoCeloIntegrationTimeOffset = (*hexutil.Uint64)(offset)
450456
default:
451457
panic(fmt.Sprintf("unknown fork: %s", fork))
452458
}
@@ -525,6 +531,10 @@ func (d *UpgradeScheduleDeployConfig) InteropTime(genesisTime uint64) *uint64 {
525531
return offsetToUpgradeTime(d.L2GenesisInteropTimeOffset, genesisTime)
526532
}
527533

534+
func (d *UpgradeScheduleDeployConfig) EspressoCeloIntegrationTime(genesisTime uint64) *uint64 {
535+
return offsetToUpgradeTime(d.L2GenesisEspressoCeloIntegrationTimeOffset, genesisTime)
536+
}
537+
528538
func (d *UpgradeScheduleDeployConfig) AllocMode(genesisTime uint64) L2AllocsMode {
529539
forks := d.forks()
530540
for i := len(forks) - 1; i >= 0; i-- {
@@ -555,6 +565,7 @@ func (d *UpgradeScheduleDeployConfig) forks() []Fork {
555565
{L2GenesisTimeOffset: d.L2GenesisHoloceneTimeOffset, Name: string(L2AllocsHolocene)},
556566
{L2GenesisTimeOffset: d.L2GenesisIsthmusTimeOffset, Name: string(L2AllocsIsthmus)},
557567
{L2GenesisTimeOffset: d.L2GenesisJovianTimeOffset, Name: string(L2AllocsJovian)},
568+
{L2GenesisTimeOffset: d.L2GenesisEspressoCeloIntegrationTimeOffset, Name: string(L2AllocsEspressoCeloIntegration)},
558569
}
559570
}
560571

@@ -1066,23 +1077,24 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *eth.BlockRef, l2GenesisBlockHa
10661077
BatchInboxAddress: d.BatchInboxAddress,
10671078
BatchAuthenticatorAddress: d.BatchAuthenticatorAddress,
10681079

1069-
DepositContractAddress: d.OptimismPortalProxy,
1070-
L1SystemConfigAddress: d.SystemConfigProxy,
1071-
RegolithTime: d.RegolithTime(l1StartTime),
1072-
CanyonTime: d.CanyonTime(l1StartTime),
1073-
DeltaTime: d.DeltaTime(l1StartTime),
1074-
EcotoneTime: d.EcotoneTime(l1StartTime),
1075-
FjordTime: d.FjordTime(l1StartTime),
1076-
GraniteTime: d.GraniteTime(l1StartTime),
1077-
HoloceneTime: d.HoloceneTime(l1StartTime),
1078-
PectraBlobScheduleTime: d.PectraBlobScheduleTime(l1StartTime),
1079-
IsthmusTime: d.IsthmusTime(l1StartTime),
1080-
JovianTime: d.JovianTime(l1StartTime),
1081-
InteropTime: d.InteropTime(l1StartTime),
1082-
ProtocolVersionsAddress: d.ProtocolVersionsProxy,
1083-
AltDAConfig: altDA,
1084-
ChainOpConfig: chainOpConfig,
1085-
Cel2Time: d.RegolithTime(l1StartTime),
1080+
DepositContractAddress: d.OptimismPortalProxy,
1081+
L1SystemConfigAddress: d.SystemConfigProxy,
1082+
RegolithTime: d.RegolithTime(l1StartTime),
1083+
CanyonTime: d.CanyonTime(l1StartTime),
1084+
DeltaTime: d.DeltaTime(l1StartTime),
1085+
EcotoneTime: d.EcotoneTime(l1StartTime),
1086+
FjordTime: d.FjordTime(l1StartTime),
1087+
GraniteTime: d.GraniteTime(l1StartTime),
1088+
HoloceneTime: d.HoloceneTime(l1StartTime),
1089+
PectraBlobScheduleTime: d.PectraBlobScheduleTime(l1StartTime),
1090+
IsthmusTime: d.IsthmusTime(l1StartTime),
1091+
JovianTime: d.JovianTime(l1StartTime),
1092+
InteropTime: d.InteropTime(l1StartTime),
1093+
ProtocolVersionsAddress: d.ProtocolVersionsProxy,
1094+
AltDAConfig: altDA,
1095+
ChainOpConfig: chainOpConfig,
1096+
Cel2Time: d.RegolithTime(l1StartTime),
1097+
EspressoCeloIntegrationTime: d.EspressoCeloIntegrationTime(l1StartTime),
10861098
}, nil
10871099
}
10881100

op-chain-ops/genesis/layer_two.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ type L2AllocsMode string
2323
type L2AllocsModeMap map[L2AllocsMode]*foundry.ForgeAllocs
2424

2525
const (
26-
L2AllocsDelta L2AllocsMode = "delta"
27-
L2AllocsEcotone L2AllocsMode = "ecotone"
28-
L2AllocsFjord L2AllocsMode = "fjord"
29-
L2AllocsGranite L2AllocsMode = "granite"
30-
L2AllocsHolocene L2AllocsMode = "holocene"
31-
L2AllocsIsthmus L2AllocsMode = "isthmus"
32-
L2AllocsJovian L2AllocsMode = "jovian"
26+
L2AllocsDelta L2AllocsMode = "delta"
27+
L2AllocsEcotone L2AllocsMode = "ecotone"
28+
L2AllocsFjord L2AllocsMode = "fjord"
29+
L2AllocsGranite L2AllocsMode = "granite"
30+
L2AllocsHolocene L2AllocsMode = "holocene"
31+
L2AllocsIsthmus L2AllocsMode = "isthmus"
32+
L2AllocsJovian L2AllocsMode = "jovian"
33+
L2AllocsEspressoCeloIntegration L2AllocsMode = "espresso_celo_integration"
3334
)
3435

3536
var (

op-chain-ops/interopgen/recipe.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ func (r *InteropDevL2Recipe) build(l1ChainID uint64, addrs devkeys.Addresses) (*
258258
L2GenesisIsthmusTimeOffset: new(hexutil.Uint64),
259259
L2GenesisJovianTimeOffset: nil,
260260
L2GenesisInteropTimeOffset: new(hexutil.Uint64),
261+
L2GenesisEspressoCeloIntegrationTimeOffset: new(hexutil.Uint64),
261262
L1CancunTimeOffset: new(hexutil.Uint64),
262263
L1PragueTimeOffset: new(hexutil.Uint64),
263264
UseInterop: true,

op-e2e/actions/upgrades/helpers/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,13 @@ func ApplyDeltaTimeOffset(dp *e2eutils.DeployParams, deltaTimeOffset *hexutil.Ui
6161
dp.DeployConfig.L2GenesisJovianTimeOffset = deltaTimeOffset
6262
}
6363
}
64+
65+
// configure Espresso Celo Integration to not be before Delta accidentally
66+
if dp.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset != nil {
67+
if deltaTimeOffset == nil {
68+
dp.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset = nil
69+
} else if *dp.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset < *deltaTimeOffset {
70+
dp.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset = deltaTimeOffset
71+
}
72+
}
6473
}

op-e2e/config/init.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,15 @@ func initAllocType(root string, allocType AllocType) {
297297
}
298298

299299
baseUpgradeSchedule := map[string]any{
300-
"l2GenesisRegolithTimeOffset": nil,
301-
"l2GenesisCanyonTimeOffset": nil,
302-
"l2GenesisDeltaTimeOffset": nil,
303-
"l2GenesisEcotoneTimeOffset": nil,
304-
"l2GenesisFjordTimeOffset": nil,
305-
"l2GenesisGraniteTimeOffset": nil,
306-
"l2GenesisHoloceneTimeOffset": nil,
307-
"l2GenesisIsthmusTimeOffset": nil,
300+
"l2GenesisRegolithTimeOffset": nil,
301+
"l2GenesisCanyonTimeOffset": nil,
302+
"l2GenesisDeltaTimeOffset": nil,
303+
"l2GenesisEcotoneTimeOffset": nil,
304+
"l2GenesisFjordTimeOffset": nil,
305+
"l2GenesisGraniteTimeOffset": nil,
306+
"l2GenesisHoloceneTimeOffset": nil,
307+
"l2GenesisIsthmusTimeOffset": nil,
308+
"l2GenesisEspressoCeloIntegrationTimeOffset": nil,
308309
}
309310

310311
upgradeSchedule := new(genesis.UpgradeScheduleDeployConfig)

op-e2e/e2eutils/setup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ func ApplyDeployConfigForks(deployConfig *genesis.DeployConfig) {
250250
isFjord := isGranite || os.Getenv("OP_E2E_USE_FJORD") == "true"
251251
isEcotone := isFjord || os.Getenv("OP_E2E_USE_ECOTONE") == "true"
252252
isDelta := isEcotone || os.Getenv("OP_E2E_USE_DELTA") == "true"
253+
isEspressoCeloIntegration := os.Getenv("OP_E2E_USE_ESPRESSO_CELO_INTEGRATION") == "true"
253254
if isDelta {
254255
deployConfig.L2GenesisDeltaTimeOffset = new(hexutil.Uint64)
255256
}
@@ -271,6 +272,9 @@ func ApplyDeployConfigForks(deployConfig *genesis.DeployConfig) {
271272
if isJovian {
272273
deployConfig.L2GenesisJovianTimeOffset = new(hexutil.Uint64)
273274
}
275+
if isEspressoCeloIntegration {
276+
deployConfig.L2GenesisEspressoCeloIntegrationTimeOffset = new(hexutil.Uint64)
277+
}
274278
// Canyon and lower is activated by default
275279
deployConfig.L2GenesisCanyonTimeOffset = new(hexutil.Uint64)
276280
deployConfig.L2GenesisRegolithTimeOffset = new(hexutil.Uint64)

op-e2e/faultproofs/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func WithLatestFork() faultDisputeConfigOpts {
5656
cfg.DeployConfig.L2GenesisGraniteTimeOffset = &genesisActivation
5757
cfg.DeployConfig.L2GenesisHoloceneTimeOffset = &genesisActivation
5858
cfg.DeployConfig.L2GenesisIsthmusTimeOffset = &genesisActivation
59+
cfg.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset = &genesisActivation
5960
})
6061
}
6162
}

op-e2e/system/e2esys/setup.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ func RegolithSystemConfig(t *testing.T, regolithTimeOffset *hexutil.Uint64, opts
213213
cfg.DeployConfig.L2GenesisHoloceneTimeOffset = nil
214214
cfg.DeployConfig.L2GenesisIsthmusTimeOffset = nil
215215
cfg.DeployConfig.L2GenesisJovianTimeOffset = nil
216+
cfg.DeployConfig.L2GenesisEspressoCeloIntegrationTimeOffset = nil
216217
// ADD NEW FORKS HERE!
217218
return cfg
218219
}
@@ -732,6 +733,7 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System,
732733
JovianTime: cfg.DeployConfig.JovianTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)),
733734
InteropTime: cfg.DeployConfig.InteropTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)),
734735
Cel2Time: cfg.DeployConfig.RegolithTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)),
736+
EspressoCeloIntegrationTime: cfg.DeployConfig.EspressoCeloIntegrationTime(uint64(cfg.DeployConfig.L1GenesisBlockTimestamp)),
735737
ProtocolVersionsAddress: cfg.L1Deployments.ProtocolVersionsProxy,
736738
AltDAConfig: rollupAltDAConfig,
737739
ChainOpConfig: &params.OptimismConfig{

0 commit comments

Comments
 (0)