Skip to content

Commit d6963ce

Browse files
QuentinIOpenCode
andcommitted
op-node: rename EspressoEnforcementTime to EspressoTime
Matches upstream Optimism hardfork naming convention (RegolithTime, EcotoneTime, IsthmusTime, ...). All hardforks enforce a new set of rules, so the "Enforcement" qualifier was redundant. Renames: EspressoEnforcementTime -> EspressoTime (rollup.Config field) IsEspressoEnforcement -> IsEspresso (rollup.Config method) espressoEnforcementTime -> espressoTime (DataSourceConfig field) isEspressoEnforcement -> isEspresso (DataSourceConfig method) espresso_enforcement_time -> espresso_time (JSON tag, forEachFork log key) "Espresso Enforcement" -> "Espresso" (forEachFork display name) Also rewords prose docstrings: "EspressoEnforcement" -> "Espresso", "Pre/Post-EspressoEnforcement" -> "Pre/Post-Espresso". Addresses PR feedback: celo-org#445 (comment) Co-authored-by: OpenCode <noreply@opencode.ai>
1 parent 6679a2b commit d6963ce

7 files changed

Lines changed: 64 additions & 65 deletions

File tree

op-node/rollup/derive/blob_data_source.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,20 @@ func (ds *BlobDataSource) open(ctx context.Context) ([]blobOrCalldata, error) {
119119
// creates a placeholder blobOrCalldata element for each returned blob hash that must be populated
120120
// by fillBlobPointers after blob bodies are retrieved.
121121
//
122-
// Pre-EspressoEnforcement (the L1 origin time of `ref` is < *EspressoEnforcementTime,
123-
// or unset), this runs upstream Optimism semantics: filter by batch inbox + sender ==
122+
// Pre-Espresso (the L1 origin time of `ref` is < *EspressoTime, or unset),
123+
// this runs upstream Optimism semantics: filter by batch inbox + sender ==
124124
// batcher.
125125
//
126-
// Post-EspressoEnforcement, it collects all authenticated batch hashes from a
127-
// lookback window once and rejects any batch whose commitment hash is not in the
128-
// authenticated set. For blob transactions, the batch hash is computed from the
129-
// concatenated blob versioned hashes.
126+
// Post-Espresso, it collects all authenticated batch hashes from a lookback
127+
// window once and rejects any batch whose commitment hash is not in the
128+
// authenticated set. For blob transactions, the batch hash is computed from
129+
// the concatenated blob versioned hashes.
130130
func dataAndHashesFromTxs(ctx context.Context, txs types.Transactions, config *DataSourceConfig, batcherAddr common.Address, fetcher L1Fetcher, ref eth.L1BlockRef, logger log.Logger) ([]blobOrCalldata, []common.Hash, error) {
131-
// Only collect authenticated batch hashes when the Espresso enforcement fork
132-
// is active at the L1 origin time of the block we're scanning. Pre-fork, the
133-
// upstream sender-based authorization path is used and authenticatedHashes is
134-
// unused.
131+
// Only collect authenticated batch hashes when the Espresso fork is active
132+
// at the L1 origin time of the block we're scanning. Pre-fork, the upstream
133+
// sender-based authorization path is used and authenticatedHashes is unused.
135134
var authenticatedHashes map[common.Hash]bool
136-
if config.isEspressoEnforcement(ref.Time) {
135+
if config.isEspresso(ref.Time) {
137136
var err error
138137
authenticatedHashes, err = CollectAuthenticatedBatches(
139138
ctx, fetcher, ref, config.batchAuthenticatorAddress, config.batchAuthLookbackWindow, logger,

op-node/rollup/derive/blob_data_source_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ func TestDataAndHashesFromTxs(t *testing.T) {
123123
// TestDataAndHashesFromTxsEventAuth tests event-based batch authentication for both
124124
// calldata and blob transactions in the blob data source path.
125125
//
126-
// Event-based authentication is only active post-EspressoEnforcement; the fixture
126+
// Event-based authentication is only active post-Espresso; the fixture
127127
// activates the fork at L1 origin time 0 (genesis) so all test refs satisfy
128-
// ref.Time >= *EspressoEnforcementTime.
128+
// ref.Time >= *EspressoTime.
129129
func TestDataAndHashesFromTxsEventAuth(t *testing.T) {
130130
rng := rand.New(rand.NewSource(9999))
131131
privateKey := testutils.InsecureRandomKey(rng)
@@ -137,13 +137,13 @@ func TestDataAndHashesFromTxsEventAuth(t *testing.T) {
137137

138138
chainId := new(big.Int).SetUint64(rng.Uint64())
139139
signer := types.NewPragueSigner(chainId)
140-
enforcementTime := uint64(0)
140+
espressoTime := uint64(0)
141141
config := DataSourceConfig{
142142
l1Signer: signer,
143143
batchInboxAddress: batchInboxAddr,
144144
batchAuthenticatorAddress: authenticatorAddr,
145145
batchAuthLookbackWindow: espresso.DefaultBatchAuthLookbackWindow,
146-
espressoEnforcementTime: &enforcementTime,
146+
espressoTime: &espressoTime,
147147
}
148148

149149
ctx := context.Background()

op-node/rollup/derive/calldata_source.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ func (ds *CalldataSource) Next(ctx context.Context) (eth.Data, error) {
8686
// that are sent to the batch inbox address from the batch sender address.
8787
// This will return an empty array if no valid transactions are found.
8888
//
89-
// Pre-EspressoEnforcement (the L1 origin time of `ref` is < *EspressoEnforcementTime,
90-
// or unset), this runs upstream Optimism semantics: filter by batch inbox + sender ==
89+
// Pre-Espresso (the L1 origin time of `ref` is < *EspressoTime, or unset),
90+
// this runs upstream Optimism semantics: filter by batch inbox + sender ==
9191
// batcher.
9292
//
93-
// Post-EspressoEnforcement, it collects all authenticated batch hashes from a
94-
// lookback window once and rejects any batch whose commitment hash is not in the
93+
// Post-Espresso, it collects all authenticated batch hashes from a lookback
94+
// window once and rejects any batch whose commitment hash is not in the
9595
// authenticated set.
9696
func DataFromEVMTransactions(ctx context.Context, dsCfg DataSourceConfig, batcherAddr common.Address, txs types.Transactions, fetcher L1Fetcher, ref eth.L1BlockRef, log log.Logger) ([]eth.Data, error) {
97-
// Only collect authenticated batch hashes when the Espresso enforcement fork
98-
// is active at the L1 origin time of the block we're scanning. Pre-fork, the
99-
// upstream sender-based authorization path inside isBatchTxAuthorized is used
100-
// and the authenticatedHashes map is unused.
97+
// Only collect authenticated batch hashes when the Espresso fork is active
98+
// at the L1 origin time of the block we're scanning. Pre-fork, the upstream
99+
// sender-based authorization path inside isBatchTxAuthorized is used and
100+
// the authenticatedHashes map is unused.
101101
var authenticatedHashes map[common.Hash]bool
102-
if dsCfg.isEspressoEnforcement(ref.Time) {
102+
if dsCfg.isEspresso(ref.Time) {
103103
var err error
104104
authenticatedHashes, err = CollectAuthenticatedBatches(
105105
ctx, fetcher, ref, dsCfg.batchAuthenticatorAddress, dsCfg.batchAuthLookbackWindow, log,

op-node/rollup/derive/calldata_source_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func mockAuthEvents(l1F *testutils.MockL1Source, rng *rand.Rand, ref eth.L1Block
125125
// TestDataFromEVMTransactionsEventAuth tests event-based batch authentication
126126
// where a BatchInfoAuthenticated event in the lookback window authorizes a batch.
127127
//
128-
// Event-based authentication is only active post-EspressoEnforcement; the fixture
128+
// Event-based authentication is only active post-Espresso; the fixture
129129
// activates the fork at L1 origin time 0 (genesis) so all test refs satisfy
130-
// ref.Time >= *EspressoEnforcementTime.
130+
// ref.Time >= *EspressoTime.
131131
func TestDataFromEVMTransactionsEventAuth(t *testing.T) {
132132
rng := rand.New(rand.NewSource(42))
133133
batcherPriv := testutils.RandomKey()
@@ -137,13 +137,13 @@ func TestDataFromEVMTransactionsEventAuth(t *testing.T) {
137137
batcherAddr := crypto.PubkeyToAddress(batcherPriv.PublicKey)
138138
signer := types.NewCancunSigner(big.NewInt(100))
139139

140-
enforcementTime := uint64(0)
140+
espressoTime := uint64(0)
141141
dsCfg := DataSourceConfig{
142142
l1Signer: signer,
143143
batchInboxAddress: batchInboxAddr,
144144
batchAuthenticatorAddress: authenticatorAddr,
145145
batchAuthLookbackWindow: espresso.DefaultBatchAuthLookbackWindow,
146-
espressoEnforcementTime: &enforcementTime,
146+
espressoTime: &espressoTime,
147147
}
148148

149149
ctx := context.Background()
@@ -374,7 +374,7 @@ func TestDataFromEVMTransactions(t *testing.T) {
374374
}
375375
}
376376

377-
// Legacy mode (no batch authenticator, EspressoEnforcement inactive) — uses sender-based auth
377+
// Legacy mode (no batch authenticator, Espresso inactive) — uses sender-based auth
378378
dsCfg := DataSourceConfig{
379379
l1Signer: cfg.L1Signer(),
380380
batchInboxAddress: cfg.BatchInboxAddress,

op-node/rollup/derive/data_source.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1Fetcher,
5454
altDAEnabled: cfg.AltDAEnabled(),
5555
batchAuthenticatorAddress: cfg.BatchAuthenticatorAddress,
5656
batchAuthLookbackWindow: cfg.BatchAuthLookbackWindowOrDefault(),
57-
espressoEnforcementTime: cfg.EspressoEnforcementTime,
57+
espressoTime: cfg.EspressoTime,
5858
}
5959
return &DataSourceFactory{
6060
log: log,
@@ -68,12 +68,12 @@ func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1Fetcher,
6868

6969
// OpenData returns the appropriate data source for the L1 block `ref`.
7070
//
71-
// The Espresso enforcement gate is evaluated against the L1 origin time
72-
// (ref.Time), mirroring the upstream pattern used for ecotoneTime: the
73-
// data-source layer is per-L1-block, so it gates on L1 time. The fork timestamp
74-
// itself is conceptually an L2 timestamp but the per-L1-block decision is
75-
// stable as long as L1 origin time and L2 block time are within
76-
// MaxSequencerDrift of each other (always true on a healthy chain).
71+
// The Espresso gate is evaluated against the L1 origin time (ref.Time),
72+
// mirroring the upstream pattern used for ecotoneTime: the data-source layer
73+
// is per-L1-block, so it gates on L1 time. The fork timestamp itself is
74+
// conceptually an L2 timestamp but the per-L1-block decision is stable as
75+
// long as L1 origin time and L2 block time are within MaxSequencerDrift of
76+
// each other (always true on a healthy chain).
7777
func (ds *DataSourceFactory) OpenData(ctx context.Context, ref eth.L1BlockRef, batcherAddr common.Address) (DataIter, error) {
7878
// Creates a data iterator from blob or calldata source so we can forward it to the altDA source
7979
// if enabled as it still requires an L1 data source for fetching input commmitments.
@@ -99,25 +99,25 @@ type DataSourceConfig struct {
9999
batchInboxAddress common.Address
100100
altDAEnabled bool
101101
// batchAuthenticatorAddress is the L1 address of the BatchAuthenticator contract.
102-
// Event-based authentication via this contract is required only post-EspressoEnforcement
102+
// Event-based authentication via this contract is required only post-Espresso
103103
// activation; pre-fork the data source uses upstream sender-based authorization.
104104
batchAuthenticatorAddress common.Address
105105
// batchAuthLookbackWindow is the number of L1 blocks to scan for BatchInfoAuthenticated events.
106106
batchAuthLookbackWindow uint64
107-
// espressoEnforcementTime is the activation timestamp of the Espresso enforcement
108-
// hardfork. When the L1 origin time of the block being scanned is >=
109-
// *espressoEnforcementTime (and this pointer is non-nil), batches must be
110-
// authenticated by emitted BatchInfoAuthenticated events. Otherwise upstream
111-
// sender-based authorization applies.
112-
espressoEnforcementTime *uint64
107+
// espressoTime is the activation timestamp of the Espresso hardfork. When the
108+
// L1 origin time of the block being scanned is >= *espressoTime (and this
109+
// pointer is non-nil), batches must be authenticated by emitted
110+
// BatchInfoAuthenticated events. Otherwise upstream sender-based
111+
// authorization applies.
112+
espressoTime *uint64
113113
}
114114

115-
// isEspressoEnforcement returns true if Espresso enforcement is active for the
116-
// given L1 origin time. The fork is conceptually an L2-timestamp hardfork but
117-
// the per-L1-block data-source decision is gated on L1 origin time, mirroring
115+
// isEspresso returns true if the Espresso hardfork is active for the given L1
116+
// origin time. The fork is conceptually an L2-timestamp hardfork but the
117+
// per-L1-block data-source decision is gated on L1 origin time, mirroring
118118
// upstream's ecotoneTime treatment.
119-
func (c DataSourceConfig) isEspressoEnforcement(l1OriginTime uint64) bool {
120-
return c.espressoEnforcementTime != nil && l1OriginTime >= *c.espressoEnforcementTime
119+
func (c DataSourceConfig) isEspresso(l1OriginTime uint64) bool {
120+
return c.espressoTime != nil && l1OriginTime >= *c.espressoTime
121121
}
122122

123123
// isValidBatchTx checks basic transaction validity for batch submission:
@@ -142,7 +142,7 @@ func isValidBatchTx(tx *types.Transaction, batchInboxAddr common.Address, logger
142142

143143
// isAuthorizedBatchSender performs upstream-style sender-based authorization: it
144144
// recovers the L1 sender of the transaction and checks it matches the configured
145-
// batcher address. This is the pre-EspressoEnforcement authorization path.
145+
// batcher address. This is the pre-Espresso authorization path.
146146
func isAuthorizedBatchSender(tx *types.Transaction, l1Signer types.Signer, batcherAddr common.Address, logger log.Logger) bool {
147147
sender, err := l1Signer.Sender(tx)
148148
if err != nil {
@@ -162,12 +162,12 @@ func isAuthorizedBatchSender(tx *types.Transaction, l1Signer types.Signer, batch
162162
// block (passed as l1OriginTime), mirroring the data-source layer's ecotoneTime
163163
// treatment.
164164
//
165-
// Pre-EspressoEnforcement (l1OriginTime < *EspressoEnforcementTime, or unset):
165+
// Pre-Espresso (l1OriginTime < *EspressoTime, or unset):
166166
//
167167
// upstream behavior — the L1 sender of the transaction must match the configured
168168
// batcher address. The authenticatedHashes map is unused.
169169
//
170-
// Post-EspressoEnforcement:
170+
// Post-Espresso:
171171
//
172172
// the batch's commitment hash must appear in authenticatedHashes (i.e. a
173173
// BatchInfoAuthenticated event was emitted for this commitment within the
@@ -181,7 +181,7 @@ func isBatchTxAuthorized(
181181
l1OriginTime uint64,
182182
logger log.Logger,
183183
) bool {
184-
if !dsCfg.isEspressoEnforcement(l1OriginTime) {
184+
if !dsCfg.isEspresso(l1OriginTime) {
185185
// Pre-fork: upstream sender-based authorization.
186186
return isAuthorizedBatchSender(tx, dsCfg.l1Signer, batcherAddr, logger)
187187
}

op-node/rollup/espresso_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package rollup
22

3-
// IsEspressoEnforcement returns true if the Espresso enforcement upgrade is
4-
// active at or past the given L2 block timestamp. When active, the derivation
5-
// pipeline runs all Espresso-specific semantics (event-based batch
6-
// authentication via the BatchAuthenticator contract). When inactive, the
7-
// pipeline behaves exactly as upstream Optimism.
8-
func (c *Config) IsEspressoEnforcement(timestamp uint64) bool {
9-
return c.EspressoEnforcementTime != nil && timestamp >= *c.EspressoEnforcementTime
3+
// IsEspresso returns true if the Espresso upgrade is active at or past the
4+
// given L2 block timestamp. When active, the derivation pipeline runs all
5+
// Espresso-specific semantics (event-based batch authentication via the
6+
// BatchAuthenticator contract). When inactive, the pipeline behaves exactly
7+
// as upstream Optimism.
8+
func (c *Config) IsEspresso(timestamp uint64) bool {
9+
return c.EspressoTime != nil && timestamp >= *c.EspressoTime
1010
}

op-node/rollup/types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,16 @@ type Config struct {
170170
// epoch.
171171
PectraBlobScheduleTime *uint64 `json:"pectra_blob_schedule_time,omitempty"`
172172

173-
// EspressoEnforcementTime sets the activation time of the Espresso enforcement upgrade.
173+
// EspressoTime sets the activation time of the Espresso upgrade.
174174
// Pre-fork, the derivation pipeline behaves exactly as upstream Optimism: batches are
175175
// accepted based on the L1 transaction sender matching the SystemConfig batcher address.
176176
// Post-fork, batches must be authenticated via BatchInfoAuthenticated events emitted by
177177
// the BatchAuthenticator contract; sender-based authorization is rejected.
178-
// Active if EspressoEnforcementTime != nil && L2 block timestamp >= *EspressoEnforcementTime.
179-
EspressoEnforcementTime *uint64 `json:"espresso_enforcement_time,omitempty"`
178+
// Active if EspressoTime != nil && L2 block timestamp >= *EspressoTime.
179+
EspressoTime *uint64 `json:"espresso_time,omitempty"`
180180

181181
// BatchAuthenticatorAddress is the L1 address of the BatchAuthenticator contract whose
182-
// BatchInfoAuthenticated(bytes32) events the derivation pipeline scans post-EspressoEnforcement.
182+
// BatchInfoAuthenticated(bytes32) events the derivation pipeline scans post-Espresso.
183183
BatchAuthenticatorAddress common.Address `json:"batch_authenticator_address,omitempty,omitzero"`
184184

185185
// BatchAuthLookbackWindow is the number of L1 blocks to scan for BatchInfoAuthenticated events.
@@ -890,9 +890,9 @@ func (c *Config) forEachFork(callback func(name string, logName string, time *ui
890890
callback("Jovian", "jovian_time", c.JovianTime)
891891
callback("Karst", "karst_time", c.KarstTime)
892892
callback("Interop", "interop_time", c.InteropTime)
893-
if c.EspressoEnforcementTime != nil {
893+
if c.EspressoTime != nil {
894894
// only report if config is set
895-
callback("Espresso Enforcement", "espresso_enforcement_time", c.EspressoEnforcementTime)
895+
callback("Espresso", "espresso_time", c.EspressoTime)
896896
}
897897
}
898898

0 commit comments

Comments
 (0)