Skip to content

Commit

Permalink
Merge pull request #15 from flashbots/no-tx-pool-attr
Browse files Browse the repository at this point in the history
Handle noTxPool correctly
  • Loading branch information
jinmel authored Aug 16, 2024
2 parents 6e022c9 + dbeebf4 commit 292bdee
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions op-node/rollup/clsync/clsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type L1OriginSelector interface {
type CLSync struct {
log log.Logger
cfg *rollup.Config
spec *rollup.ChainSpec
metrics Metrics
ec Engine
n Network
Expand All @@ -52,6 +53,7 @@ func NewCLSync(log log.Logger, cfg *rollup.Config, metrics Metrics, ec Engine, n
return &CLSync{
log: log,
cfg: cfg,
spec: rollup.NewChainSpec(cfg),
metrics: metrics,
ec: ec,
n: n,
Expand Down Expand Up @@ -162,6 +164,12 @@ func (eq *CLSync) PublishAttributes(ctx context.Context, l2head eth.L2BlockRef)
return fmt.Errorf("error preparing payload attributes: %w", err)
}

derive.SetNoTxPool(eq.cfg, eq.spec, attrs, l1Origin, l2head)

eq.log.Debug("prepared attributes for new block",
"num", l2head.Number+1, "time", uint64(attrs.Timestamp),
"origin", l1Origin, "origin_time", l1Origin.Time, "noTxPool", attrs.NoTxPool)

withParent := &derive.AttributesWithParent{
Attributes: attrs,
Parent: l2head,
Expand Down
19 changes: 19 additions & 0 deletions op-node/rollup/derive/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,22 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex
ParentBeaconBlockRoot: parentBeaconRoot,
}, nil
}

// Sets NoTxPool according to config and spec.
func SetNoTxPool(config *rollup.Config, spec *rollup.ChainSpec, attrs *eth.PayloadAttributes, l1Origin eth.L1BlockRef, l2head eth.L2BlockRef) {
// If our next L2 block timestamp is beyond the Sequencer drift threshold, then we must produce
// empty blocks (other than the L1 info deposit and any user deposits). We handle this by
// setting NoTxPool to true, which will cause the Sequencer to not include any transactions
// from the transaction pool.
attrs.NoTxPool = uint64(attrs.Timestamp) > l1Origin.Time+spec.MaxSequencerDrift(l1Origin.Time)

// For the Ecotone activation block we shouldn't include any sequencer transactions.
if config.IsEcotoneActivationBlock(uint64(attrs.Timestamp)) {
attrs.NoTxPool = true
}

// For the Fjord activation block we shouldn't include any sequencer transactions.
if config.IsFjordActivationBlock(uint64(attrs.Timestamp)) {
attrs.NoTxPool = true
}
}
1 change: 1 addition & 0 deletions op-node/rollup/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func NewDriver(
sequencerActive: make(chan chan bool, 10),
sequencerNotifs: sequencerStateListener,
config: cfg,
spec: rollup.NewChainSpec(cfg),
syncCfg: syncCfg,
driverConfig: driverCfg,
driverCtx: driverCtx,
Expand Down
7 changes: 7 additions & 0 deletions op-node/rollup/driver/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Driver struct {

// Rollup config: rollup chain configuration
config *rollup.Config
spec *rollup.ChainSpec

sequencerConductor conductor.SequencerConductor

Expand Down Expand Up @@ -493,6 +494,12 @@ func (d *Driver) PublishL2Attributes(ctx context.Context, l2head eth.L2BlockRef)
return err
}

derive.SetNoTxPool(d.config, d.spec, attrs, l1Origin, l2head)

d.log.Debug("prepared attributes for new block",
"num", l2head.Number+1, "time", uint64(attrs.Timestamp),
"origin", l1Origin, "origin_time", l1Origin.Time, "noTxPool", attrs.NoTxPool)

withParent := &derive.AttributesWithParent{
Attributes: attrs,
Parent: l2head,
Expand Down

0 comments on commit 292bdee

Please sign in to comment.