Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions op-e2e/system/e2esys/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System,
},

BatchAuthenticatorAddress: cfg.DeployConfig.BatchAuthenticatorAddress,
CeloEspressoTimestamp: func() *uint64 { v := uint64(cfg.DeployConfig.L1GenesisBlockTimestamp); return &v }(),
}
}
defaultConfig := makeRollupConfig()
Expand Down
9 changes: 9 additions & 0 deletions op-node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@ var (
Value: "0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797",
Category: OperationsCategory,
}
CeloEspressoTimestamp = &cli.Uint64Flag{
Name: "celo-espresso-timestamp",
Usage: "Unix timestamp for activating Celo Espresso integration features",
EnvVars: prefixEnvVars("CELO_ESPRESSO_TIMESTAMP"),
Category: RollupCategory,
Required: false,
Destination: new(uint64),
}
)

var requiredFlags = []cli.Flag{
Expand Down Expand Up @@ -568,6 +576,7 @@ var optionalFlags = []cli.Flag{
CaffNodeHotShotUrls,
CaffNodeEspressoLightClientAddr,
CaffNodeL1EthRpc,
CeloEspressoTimestamp,
}

var DeprecatedFlags = []cli.Flag{
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/derive/blob_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func dataAndHashesFromTxs(txs types.Transactions, receipts types.Receipts, confi
for i, tx := range txs {
receipt := receipts[i]
// skip any non-batcher transactions
if !isValidBatchTx(tx, receipt, config.l1Signer, config.batchInboxAddress, batcherAddr, logger) {
if !isValidBatchTx(tx, receipt, config.l1Signer, config.batchInboxAddress, batcherAddr, logger, config.celoEspressoTimestamp) {
blobIndex += len(tx.BlobHashes())
continue
}
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/derive/calldata_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (ds *CalldataSource) Next(ctx context.Context) (eth.Data, error) {
func DataFromEVMTransactions(dsCfg DataSourceConfig, batcherAddr common.Address, txs types.Transactions, receipts types.Receipts, log log.Logger) []eth.Data {
out := []eth.Data{}
for i, tx := range txs {
if isValidBatchTx(tx, receipts[i], dsCfg.l1Signer, dsCfg.batchInboxAddress, batcherAddr, log) {
if isValidBatchTx(tx, receipts[i], dsCfg.l1Signer, dsCfg.batchInboxAddress, batcherAddr, log, dsCfg.celoEspressoTimestamp) {
out = append(out, tx.Data())
}
}
Expand Down
2 changes: 1 addition & 1 deletion op-node/rollup/derive/calldata_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestDataFromEVMTransactions(t *testing.T) {
}
}

out := DataFromEVMTransactions(DataSourceConfig{cfg.L1Signer(), cfg.BatchInboxAddress, false}, batcherAddr, txs, receipts, testlog.Logger(t, log.LevelCrit))
out := DataFromEVMTransactions(DataSourceConfig{cfg.L1Signer(), cfg.BatchInboxAddress, false, nil}, batcherAddr, txs, receipts, testlog.Logger(t, log.LevelCrit))
require.ElementsMatch(t, expectedData, out)
}

Expand Down
29 changes: 19 additions & 10 deletions op-node/rollup/derive/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package derive
import (
"context"
"fmt"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -50,9 +51,10 @@ type DataSourceFactory struct {

func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1Fetcher, blobsFetcher L1BlobsFetcher, altDAFetcher AltDAInputFetcher) *DataSourceFactory {
config := DataSourceConfig{
l1Signer: cfg.L1Signer(),
batchInboxAddress: cfg.BatchInboxAddress,
altDAEnabled: cfg.AltDAEnabled(),
l1Signer: cfg.L1Signer(),
batchInboxAddress: cfg.BatchInboxAddress,
altDAEnabled: cfg.AltDAEnabled(),
celoEspressoTimestamp: cfg.CeloEspressoTimestamp,
}
return &DataSourceFactory{
log: log,
Expand Down Expand Up @@ -86,19 +88,26 @@ func (ds *DataSourceFactory) OpenData(ctx context.Context, ref eth.L1BlockRef, b

// DataSourceConfig regroups the mandatory rollup.Config fields needed for DataFromEVMTransactions.
type DataSourceConfig struct {
l1Signer types.Signer
batchInboxAddress common.Address
altDAEnabled bool
l1Signer types.Signer
batchInboxAddress common.Address
altDAEnabled bool
celoEspressoTimestamp *uint64
}

// isValidBatchTx returns true if:
// 1. the transaction is not reverted
// isValidBatchTx validates a transaction against the given configuration
// It returns true if:
// 1. the transaction is not reverted (only checked if CeloEspresso is enabled)
// 2. the transaction type is any of Legacy, ACL, DynamicFee, Blob, or Deposit (for L3s).
// 3. the transaction has a To() address that matches the batch inbox address, and
// 4. the transaction has a valid signature from the batcher address
func isValidBatchTx(tx *types.Transaction, receipt *types.Receipt, l1Signer types.Signer, batchInboxAddr, batcherAddr common.Address, logger log.Logger) bool {
func isValidBatchTx(tx *types.Transaction, receipt *types.Receipt, l1Signer types.Signer, batchInboxAddr, batcherAddr common.Address, logger log.Logger, celoEspressoTimestamp *uint64) bool {
// If CeloEspresso is activated, return false if the transaction is reverted
if receipt.Status != types.ReceiptStatusSuccessful {
return false
logger.Info("tx in inbox with reverted status", "hash", tx.Hash(), "status", receipt.Status)
if celoEspressoTimestamp != nil && time.Now().Unix() >= int64(*celoEspressoTimestamp) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not deterministic. We need to be comparing to the block timestamp, not current time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 71556a2.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, tx.Time() isn't deterministic either, this is time this particular node has first seen the tx, not a part of consensus. I don't think we can get around pushing thorough the L1 block ref to here and checking against that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c0d6688.

logger.Info("tx is dropped since it is reverted")
return false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that receipt has a failed status, but not because the transaction is reverted? Double-checking this so we won't mark a transaction as valid if it fails due to a different reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point. OP or Celo does not have this check and we added it, so I think wrapping it in the EspressoEnabled flag adds minimal overhead and gives us extra safety. But worth tagging @QuentinI to confirm that this logic only applies to reverted transactions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that receipt has a failed status, but not because the transaction is reverted?

No, a failed status necessarily means transaction was reverted

}

// For now, we want to disallow the SetCodeTx type or any future types.
Expand Down
5 changes: 5 additions & 0 deletions op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ type Config struct {
CaffNodeConfig CaffNodeConfig `json:"caff_node_config,omitempty"`

BatchAuthenticatorAddress common.Address `json:"batch_authenticator_address,omitempty,omitzero"`

// CeloEspressoTimestamp is the activation timestamp for Celo Espresso integration
// When this timestamp is reached, additional transaction validation rules in derivation pipeline will be enforced
// If nil, the integration is not active.
CeloEspressoTimestamp *uint64 `json:"celo_espresso_timestamp,omitempty"`
}

// CaffNodeConfig is the config for the Caff Node
Expand Down
4 changes: 4 additions & 0 deletions op-node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ func applyOverrides(ctx *cli.Context, rollupConfig *rollup.Config) {
interop := ctx.Uint64(opflags.InteropOverrideFlagName)
rollupConfig.InteropTime = &interop
}
if ctx.IsSet(flags.CeloEspressoTimestamp.Name) {
celoEspresso := ctx.Uint64(flags.CeloEspressoTimestamp.Name)
rollupConfig.CeloEspressoTimestamp = &celoEspresso
}
}

// applyCeloHardforks modifies the rollupConfig to apply Celo-specific hardforks.
Expand Down