Commit 72c11daa authored by Sebastian Stammler's avatar Sebastian Stammler Committed by GitHub

op-node/rollup: Promote all attributes to safe post-Holocene (#12724)

Also renames fields `IsLastInSpan` to `Safe` because that's semantically
clearer. That a last batch in a span batch is pre-Holocene the indicator
for a safe block promotion is an implementation detail. It's better to
name the effect rather than the reason.
parent 1d3b29fc
...@@ -190,8 +190,7 @@ func TestHoloceneInvalidPayload(gt *testing.T) { ...@@ -190,8 +190,7 @@ func TestHoloceneInvalidPayload(gt *testing.T) {
env.Seq.ActL1HeadSignal(t) env.Seq.ActL1HeadSignal(t)
env.Seq.ActL2PipelineFull(t) env.Seq.ActL2PipelineFull(t)
// TODO(12695): need to properly update safe after completed L1 block derivation l2Safe := env.Seq.L2Safe()
l2Safe := env.Seq.L2PendingSafe()
require.EqualValues(t, invalidNum, l2Safe.Number) require.EqualValues(t, invalidNum, l2Safe.Number)
require.NotEqual(t, l2Safe.Hash, l2Unsafe.Hash, // old L2Unsafe above require.NotEqual(t, l2Safe.Hash, l2Unsafe.Hash, // old L2Unsafe above
"block-3 should have been replaced by deposit-only version") "block-3 should have been replaced by deposit-only version")
......
...@@ -194,7 +194,7 @@ func (eq *AttributesHandler) consolidateNextSafeAttributes(attributes *derive.At ...@@ -194,7 +194,7 @@ func (eq *AttributesHandler) consolidateNextSafeAttributes(attributes *derive.At
} }
eq.emitter.Emit(engine.PromotePendingSafeEvent{ eq.emitter.Emit(engine.PromotePendingSafeEvent{
Ref: ref, Ref: ref,
Safe: attributes.IsLastInSpan, Concluding: attributes.Concluding,
DerivedFrom: attributes.DerivedFrom, DerivedFrom: attributes.DerivedFrom,
}) })
} }
......
...@@ -117,9 +117,9 @@ func TestAttributesHandler(t *testing.T) { ...@@ -117,9 +117,9 @@ func TestAttributesHandler(t *testing.T) {
NoTxPool: false, NoTxPool: false,
GasLimit: &payloadA1.ExecutionPayload.GasLimit, GasLimit: &payloadA1.ExecutionPayload.GasLimit,
}, },
Parent: refA0, Parent: refA0,
IsLastInSpan: true, Concluding: true,
DerivedFrom: refB, DerivedFrom: refB,
} }
refA1, err := derive.PayloadToBlockRef(cfg, payloadA1.ExecutionPayload) refA1, err := derive.PayloadToBlockRef(cfg, payloadA1.ExecutionPayload)
require.NoError(t, err) require.NoError(t, err)
...@@ -154,9 +154,9 @@ func TestAttributesHandler(t *testing.T) { ...@@ -154,9 +154,9 @@ func TestAttributesHandler(t *testing.T) {
NoTxPool: false, NoTxPool: false,
GasLimit: &payloadA1Alt.ExecutionPayload.GasLimit, GasLimit: &payloadA1Alt.ExecutionPayload.GasLimit,
}, },
Parent: refA0, Parent: refA0,
IsLastInSpan: true, Concluding: true,
DerivedFrom: refBAlt, DerivedFrom: refBAlt,
} }
refA1Alt, err := derive.PayloadToBlockRef(cfg, payloadA1Alt.ExecutionPayload) refA1Alt, err := derive.PayloadToBlockRef(cfg, payloadA1Alt.ExecutionPayload)
...@@ -272,7 +272,7 @@ func TestAttributesHandler(t *testing.T) { ...@@ -272,7 +272,7 @@ func TestAttributesHandler(t *testing.T) {
require.Nil(t, ah.attributes, "drop when attributes are successful") require.Nil(t, ah.attributes, "drop when attributes are successful")
}) })
t.Run("consolidation passes", func(t *testing.T) { t.Run("consolidation passes", func(t *testing.T) {
fn := func(t *testing.T, lastInSpan bool) { fn := func(t *testing.T, concluding bool) {
logger := testlog.Logger(t, log.LevelInfo) logger := testlog.Logger(t, log.LevelInfo)
l2 := &testutils.MockL2Client{} l2 := &testutils.MockL2Client{}
emitter := &testutils.MockEmitter{} emitter := &testutils.MockEmitter{}
...@@ -280,10 +280,10 @@ func TestAttributesHandler(t *testing.T) { ...@@ -280,10 +280,10 @@ func TestAttributesHandler(t *testing.T) {
ah.AttachEmitter(emitter) ah.AttachEmitter(emitter)
attr := &derive.AttributesWithParent{ attr := &derive.AttributesWithParent{
Attributes: attrA1.Attributes, // attributes will match, passing consolidation Attributes: attrA1.Attributes, // attributes will match, passing consolidation
Parent: attrA1.Parent, Parent: attrA1.Parent,
IsLastInSpan: lastInSpan, Concluding: concluding,
DerivedFrom: refB, DerivedFrom: refB,
} }
emitter.ExpectOnce(derive.ConfirmReceivedAttributesEvent{}) emitter.ExpectOnce(derive.ConfirmReceivedAttributesEvent{})
emitter.ExpectOnce(engine.PendingSafeRequestEvent{}) emitter.ExpectOnce(engine.PendingSafeRequestEvent{})
...@@ -296,7 +296,7 @@ func TestAttributesHandler(t *testing.T) { ...@@ -296,7 +296,7 @@ func TestAttributesHandler(t *testing.T) {
emitter.ExpectOnce(engine.PromotePendingSafeEvent{ emitter.ExpectOnce(engine.PromotePendingSafeEvent{
Ref: refA1, Ref: refA1,
Safe: lastInSpan, // last in span becomes safe instantaneously Concluding: concluding,
DerivedFrom: refB, DerivedFrom: refB,
}) })
ah.OnEvent(engine.PendingSafeUpdateEvent{ ah.OnEvent(engine.PendingSafeUpdateEvent{
...@@ -340,7 +340,7 @@ func TestAttributesHandler(t *testing.T) { ...@@ -340,7 +340,7 @@ func TestAttributesHandler(t *testing.T) {
require.NotNil(t, ah.attributes, "queued up derived attributes") require.NotNil(t, ah.attributes, "queued up derived attributes")
// sanity check test setup // sanity check test setup
require.True(t, attrA1Alt.IsLastInSpan, "must be last in span for attributes to become safe") require.True(t, attrA1Alt.Concluding, "must be concluding attributes")
// attrA1Alt will fit right on top of A0 // attrA1Alt will fit right on top of A0
emitter.ExpectOnce(engine.BuildStartEvent{Attributes: attrA1Alt}) emitter.ExpectOnce(engine.BuildStartEvent{Attributes: attrA1Alt})
...@@ -396,5 +396,4 @@ func TestAttributesHandler(t *testing.T) { ...@@ -396,5 +396,4 @@ func TestAttributesHandler(t *testing.T) {
l2.AssertExpectations(t) l2.AssertExpectations(t)
emitter.AssertExpectations(t) emitter.AssertExpectations(t)
}) })
} }
...@@ -29,9 +29,9 @@ type AttributesBuilder interface { ...@@ -29,9 +29,9 @@ type AttributesBuilder interface {
} }
type AttributesWithParent struct { type AttributesWithParent struct {
Attributes *eth.PayloadAttributes Attributes *eth.PayloadAttributes
Parent eth.L2BlockRef Parent eth.L2BlockRef
IsLastInSpan bool Concluding bool // Concluding indicates that the attributes conclude the pending safe phase
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
...@@ -54,9 +54,9 @@ type AttributesQueue struct { ...@@ -54,9 +54,9 @@ type AttributesQueue struct {
builder AttributesBuilder builder AttributesBuilder
prev SingularBatchProvider prev SingularBatchProvider
batch *SingularBatch batch *SingularBatch
isLastInSpan bool concluding bool
lastAttribs *AttributesWithParent lastAttribs *AttributesWithParent
} }
type SingularBatchProvider interface { type SingularBatchProvider interface {
...@@ -82,12 +82,12 @@ func (aq *AttributesQueue) Origin() eth.L1BlockRef { ...@@ -82,12 +82,12 @@ func (aq *AttributesQueue) Origin() eth.L1BlockRef {
func (aq *AttributesQueue) NextAttributes(ctx context.Context, parent eth.L2BlockRef) (*AttributesWithParent, error) { func (aq *AttributesQueue) NextAttributes(ctx context.Context, parent eth.L2BlockRef) (*AttributesWithParent, error) {
// Get a batch if we need it // Get a batch if we need it
if aq.batch == nil { if aq.batch == nil {
batch, isLastInSpan, err := aq.prev.NextBatch(ctx, parent) batch, concluding, err := aq.prev.NextBatch(ctx, parent)
if err != nil { if err != nil {
return nil, err return nil, err
} }
aq.batch = batch aq.batch = batch
aq.isLastInSpan = isLastInSpan aq.concluding = concluding
} }
// Actually generate the next attributes // Actually generate the next attributes
...@@ -96,14 +96,14 @@ func (aq *AttributesQueue) NextAttributes(ctx context.Context, parent eth.L2Bloc ...@@ -96,14 +96,14 @@ func (aq *AttributesQueue) NextAttributes(ctx context.Context, parent eth.L2Bloc
} else { } else {
// Clear out the local state once we will succeed // Clear out the local state once we will succeed
attr := AttributesWithParent{ attr := AttributesWithParent{
Attributes: attrs, Attributes: attrs,
Parent: parent, Parent: parent,
IsLastInSpan: aq.isLastInSpan, Concluding: aq.concluding,
DerivedFrom: aq.Origin(), DerivedFrom: aq.Origin(),
} }
aq.lastAttribs = &attr aq.lastAttribs = &attr
aq.batch = nil aq.batch = nil
aq.isLastInSpan = false aq.concluding = false
return &attr, nil return &attr, nil
} }
} }
...@@ -138,7 +138,7 @@ func (aq *AttributesQueue) createNextAttributes(ctx context.Context, batch *Sing ...@@ -138,7 +138,7 @@ func (aq *AttributesQueue) createNextAttributes(ctx context.Context, batch *Sing
func (aq *AttributesQueue) reset() { func (aq *AttributesQueue) reset() {
aq.batch = nil aq.batch = nil
aq.isLastInSpan = false // overwritten later, but set for consistency aq.concluding = false // overwritten later, but set for consistency
aq.lastAttribs = nil aq.lastAttribs = nil
} }
......
...@@ -70,7 +70,7 @@ func (bs *BatchStage) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si ...@@ -70,7 +70,7 @@ func (bs *BatchStage) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si
// We only consider empty batch generation after we've drained all batches from the local // We only consider empty batch generation after we've drained all batches from the local
// span batch queue and the previous stage. // span batch queue and the previous stage.
empty, err := bs.deriveNextEmptyBatch(ctx, true, parent) empty, err := bs.deriveNextEmptyBatch(ctx, true, parent)
// An empty batch always advances the safe head. // An empty batch always advances the (local) safe head.
return empty, true, err return empty, true, err
} else if err != nil { } else if err != nil {
return nil, false, err return nil, false, err
...@@ -81,7 +81,8 @@ func (bs *BatchStage) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si ...@@ -81,7 +81,8 @@ func (bs *BatchStage) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si
switch validity { switch validity {
case BatchAccept: // continue case BatchAccept: // continue
batch.LogContext(bs.Log()).Debug("Found next singular batch") batch.LogContext(bs.Log()).Debug("Found next singular batch")
return batch, len(bs.nextSpan) == 0, nil // BatchStage is only used with Holocene, where blocks immediately become (local) safe
return batch, true, nil
case BatchPast: case BatchPast:
batch.LogContext(bs.Log()).Warn("Dropping past singular batch") batch.LogContext(bs.Log()).Warn("Dropping past singular batch")
// NotEnoughData to read in next batch until we're through all past batches // NotEnoughData to read in next batch until we're through all past batches
......
...@@ -14,8 +14,8 @@ type PayloadSealInvalidEvent struct { ...@@ -14,8 +14,8 @@ type PayloadSealInvalidEvent struct {
Info eth.PayloadInfo Info eth.PayloadInfo
Err error Err error
IsLastInSpan bool Concluding bool
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
func (ev PayloadSealInvalidEvent) String() string { func (ev PayloadSealInvalidEvent) String() string {
...@@ -30,8 +30,8 @@ type PayloadSealExpiredErrorEvent struct { ...@@ -30,8 +30,8 @@ type PayloadSealExpiredErrorEvent struct {
Info eth.PayloadInfo Info eth.PayloadInfo
Err error Err error
IsLastInSpan bool Concluding bool
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
func (ev PayloadSealExpiredErrorEvent) String() string { func (ev PayloadSealExpiredErrorEvent) String() string {
...@@ -42,7 +42,7 @@ type BuildSealEvent struct { ...@@ -42,7 +42,7 @@ type BuildSealEvent struct {
Info eth.PayloadInfo Info eth.PayloadInfo
BuildStarted time.Time BuildStarted time.Time
// if payload should be promoted to safe (must also be pending safe, see DerivedFrom) // if payload should be promoted to safe (must also be pending safe, see DerivedFrom)
IsLastInSpan bool Concluding bool
// payload is promoted to pending-safe if non-zero // payload is promoted to pending-safe if non-zero
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
...@@ -69,10 +69,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) { ...@@ -69,10 +69,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) {
// same attributes with a new block-building job from here to recover from this error. // same attributes with a new block-building job from here to recover from this error.
// We name it "expired", as this generally identifies a timeout, unknown job, or otherwise invalidated work. // We name it "expired", as this generally identifies a timeout, unknown job, or otherwise invalidated work.
eq.emitter.Emit(PayloadSealExpiredErrorEvent{ eq.emitter.Emit(PayloadSealExpiredErrorEvent{
Info: ev.Info, Info: ev.Info,
Err: fmt.Errorf("failed to seal execution payload (ID: %s): %w", ev.Info.ID, err), Err: fmt.Errorf("failed to seal execution payload (ID: %s): %w", ev.Info.ID, err),
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
}) })
return return
} }
...@@ -82,8 +82,8 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) { ...@@ -82,8 +82,8 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) {
Info: ev.Info, Info: ev.Info,
Err: fmt.Errorf("failed sanity-check of execution payload contents (ID: %s, blockhash: %s): %w", Err: fmt.Errorf("failed sanity-check of execution payload contents (ID: %s, blockhash: %s): %w",
ev.Info.ID, envelope.ExecutionPayload.BlockHash, err), ev.Info.ID, envelope.ExecutionPayload.BlockHash, err),
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
}) })
return return
} }
...@@ -91,10 +91,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) { ...@@ -91,10 +91,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) {
ref, err := derive.PayloadToBlockRef(eq.cfg, envelope.ExecutionPayload) ref, err := derive.PayloadToBlockRef(eq.cfg, envelope.ExecutionPayload)
if err != nil { if err != nil {
eq.emitter.Emit(PayloadSealInvalidEvent{ eq.emitter.Emit(PayloadSealInvalidEvent{
Info: ev.Info, Info: ev.Info,
Err: fmt.Errorf("failed to decode L2 block ref from payload: %w", err), Err: fmt.Errorf("failed to decode L2 block ref from payload: %w", err),
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
}) })
return return
} }
...@@ -112,10 +112,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) { ...@@ -112,10 +112,10 @@ func (eq *EngDeriver) onBuildSeal(ev BuildSealEvent) {
"txs", txnCount, "time", ref.Time, "seal_time", sealTime, "build_time", buildTime) "txs", txnCount, "time", ref.Time, "seal_time", sealTime, "build_time", buildTime)
eq.emitter.Emit(BuildSealedEvent{ eq.emitter.Emit(BuildSealedEvent{
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
Info: ev.Info, Info: ev.Info,
Envelope: envelope, Envelope: envelope,
Ref: ref, Ref: ref,
}) })
} }
...@@ -7,8 +7,8 @@ import ( ...@@ -7,8 +7,8 @@ import (
// BuildSealedEvent is emitted by the engine when a payload finished building, // BuildSealedEvent is emitted by the engine when a payload finished building,
// but is not locally inserted as canonical block yet // but is not locally inserted as canonical block yet
type BuildSealedEvent struct { type BuildSealedEvent struct {
// if payload should be promoted to safe (must also be pending safe, see DerivedFrom) // if payload should be promoted to (local) safe (must also be pending safe, see DerivedFrom)
IsLastInSpan bool Concluding bool
// payload is promoted to pending-safe if non-zero // payload is promoted to pending-safe if non-zero
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
...@@ -25,10 +25,10 @@ func (eq *EngDeriver) onBuildSealed(ev BuildSealedEvent) { ...@@ -25,10 +25,10 @@ func (eq *EngDeriver) onBuildSealed(ev BuildSealedEvent) {
// If a (pending) safe block, immediately process the block // If a (pending) safe block, immediately process the block
if ev.DerivedFrom != (eth.L1BlockRef{}) { if ev.DerivedFrom != (eth.L1BlockRef{}) {
eq.emitter.Emit(PayloadProcessEvent{ eq.emitter.Emit(PayloadProcessEvent{
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
Envelope: ev.Envelope, Envelope: ev.Envelope,
Ref: ev.Ref, Ref: ev.Ref,
}) })
} }
} }
...@@ -68,7 +68,7 @@ func (eq *EngDeriver) onBuildStart(ev BuildStartEvent) { ...@@ -68,7 +68,7 @@ func (eq *EngDeriver) onBuildStart(ev BuildStartEvent) {
eq.emitter.Emit(BuildStartedEvent{ eq.emitter.Emit(BuildStartedEvent{
Info: eth.PayloadInfo{ID: id, Timestamp: uint64(ev.Attributes.Attributes.Timestamp)}, Info: eth.PayloadInfo{ID: id, Timestamp: uint64(ev.Attributes.Attributes.Timestamp)},
BuildStarted: buildStartTime, BuildStarted: buildStartTime,
IsLastInSpan: ev.Attributes.IsLastInSpan, Concluding: ev.Attributes.Concluding,
DerivedFrom: ev.Attributes.DerivedFrom, DerivedFrom: ev.Attributes.DerivedFrom,
Parent: ev.Attributes.Parent, Parent: ev.Attributes.Parent,
}) })
......
...@@ -13,8 +13,8 @@ type BuildStartedEvent struct { ...@@ -13,8 +13,8 @@ type BuildStartedEvent struct {
Parent eth.L2BlockRef Parent eth.L2BlockRef
// if payload should be promoted to safe (must also be pending safe, see DerivedFrom) // if payload should be promoted to (local) safe (must also be pending safe, see DerivedFrom)
IsLastInSpan bool Concluding bool
// payload is promoted to pending-safe if non-zero // payload is promoted to pending-safe if non-zero
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
...@@ -29,7 +29,7 @@ func (eq *EngDeriver) onBuildStarted(ev BuildStartedEvent) { ...@@ -29,7 +29,7 @@ func (eq *EngDeriver) onBuildStarted(ev BuildStartedEvent) {
eq.emitter.Emit(BuildSealEvent{ eq.emitter.Emit(BuildSealEvent{
Info: ev.Info, Info: ev.Info,
BuildStarted: ev.BuildStarted, BuildStarted: ev.BuildStarted,
IsLastInSpan: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
}) })
} }
......
...@@ -109,7 +109,7 @@ func (ev InteropPendingSafeChangedEvent) String() string { ...@@ -109,7 +109,7 @@ func (ev InteropPendingSafeChangedEvent) String() string {
// PromotePendingSafeEvent signals that a block can be marked as pending-safe, and/or safe. // PromotePendingSafeEvent signals that a block can be marked as pending-safe, and/or safe.
type PromotePendingSafeEvent struct { type PromotePendingSafeEvent struct {
Ref eth.L2BlockRef Ref eth.L2BlockRef
Safe bool Concluding bool // Concludes the pending phase, so can be promoted to (local) safe
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
} }
...@@ -407,7 +407,7 @@ func (d *EngDeriver) OnEvent(ev event.Event) bool { ...@@ -407,7 +407,7 @@ func (d *EngDeriver) OnEvent(ev event.Event) bool {
Unsafe: d.ec.UnsafeL2Head(), Unsafe: d.ec.UnsafeL2Head(),
}) })
} }
if x.Safe && x.Ref.Number > d.ec.LocalSafeL2Head().Number { if x.Concluding && x.Ref.Number > d.ec.LocalSafeL2Head().Number {
d.emitter.Emit(PromoteLocalSafeEvent{ d.emitter.Emit(PromoteLocalSafeEvent{
Ref: x.Ref, Ref: x.Ref,
DerivedFrom: x.DerivedFrom, DerivedFrom: x.DerivedFrom,
......
...@@ -9,8 +9,8 @@ import ( ...@@ -9,8 +9,8 @@ import (
) )
type PayloadProcessEvent struct { type PayloadProcessEvent struct {
// if payload should be promoted to safe (must also be pending safe, see DerivedFrom) // if payload should be promoted to (local) safe (must also be pending safe, see DerivedFrom)
IsLastInSpan bool Concluding bool
// payload is promoted to pending-safe if non-zero // payload is promoted to pending-safe if non-zero
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
......
...@@ -5,8 +5,8 @@ import ( ...@@ -5,8 +5,8 @@ import (
) )
type PayloadSuccessEvent struct { type PayloadSuccessEvent struct {
// if payload should be promoted to safe (must also be pending safe, see DerivedFrom) // if payload should be promoted to (local) safe (must also be pending safe, see DerivedFrom)
IsLastInSpan bool Concluding bool
// payload is promoted to pending-safe if non-zero // payload is promoted to pending-safe if non-zero
DerivedFrom eth.L1BlockRef DerivedFrom eth.L1BlockRef
...@@ -25,7 +25,7 @@ func (eq *EngDeriver) onPayloadSuccess(ev PayloadSuccessEvent) { ...@@ -25,7 +25,7 @@ func (eq *EngDeriver) onPayloadSuccess(ev PayloadSuccessEvent) {
if ev.DerivedFrom != (eth.L1BlockRef{}) { if ev.DerivedFrom != (eth.L1BlockRef{}) {
eq.emitter.Emit(PromotePendingSafeEvent{ eq.emitter.Emit(PromotePendingSafeEvent{
Ref: ev.Ref, Ref: ev.Ref,
Safe: ev.IsLastInSpan, Concluding: ev.Concluding,
DerivedFrom: ev.DerivedFrom, DerivedFrom: ev.DerivedFrom,
}) })
} }
...@@ -34,7 +34,7 @@ func (eq *EngDeriver) onPayloadSuccess(ev PayloadSuccessEvent) { ...@@ -34,7 +34,7 @@ func (eq *EngDeriver) onPayloadSuccess(ev PayloadSuccessEvent) {
eq.log.Info("Inserted block", "hash", payload.BlockHash, "number", uint64(payload.BlockNumber), eq.log.Info("Inserted block", "hash", payload.BlockHash, "number", uint64(payload.BlockNumber),
"state_root", payload.StateRoot, "timestamp", uint64(payload.Timestamp), "parent", payload.ParentHash, "state_root", payload.StateRoot, "timestamp", uint64(payload.Timestamp), "parent", payload.ParentHash,
"prev_randao", payload.PrevRandao, "fee_recipient", payload.FeeRecipient, "prev_randao", payload.PrevRandao, "fee_recipient", payload.FeeRecipient,
"txs", len(payload.Transactions), "last_in_span", ev.IsLastInSpan, "derived_from", ev.DerivedFrom) "txs", len(payload.Transactions), "concluding", ev.Concluding, "derived_from", ev.DerivedFrom)
eq.emitter.Emit(TryUpdateEngineEvent{}) eq.emitter.Emit(TryUpdateEngineEvent{})
} }
...@@ -281,10 +281,10 @@ func (d *Sequencer) onBuildSealed(x engine.BuildSealedEvent) { ...@@ -281,10 +281,10 @@ func (d *Sequencer) onBuildSealed(x engine.BuildSealedEvent) {
d.asyncGossip.Gossip(x.Envelope) d.asyncGossip.Gossip(x.Envelope)
// Now after having gossiped the block, try to put it in our own canonical chain // Now after having gossiped the block, try to put it in our own canonical chain
d.emitter.Emit(engine.PayloadProcessEvent{ d.emitter.Emit(engine.PayloadProcessEvent{
IsLastInSpan: x.IsLastInSpan, Concluding: x.Concluding,
DerivedFrom: x.DerivedFrom, DerivedFrom: x.DerivedFrom,
Envelope: x.Envelope, Envelope: x.Envelope,
Ref: x.Ref, Ref: x.Ref,
}) })
d.latest.Ref = x.Ref d.latest.Ref = x.Ref
d.latestSealed = x.Ref d.latestSealed = x.Ref
...@@ -334,7 +334,7 @@ func (d *Sequencer) onPayloadSuccess(x engine.PayloadSuccessEvent) { ...@@ -334,7 +334,7 @@ func (d *Sequencer) onPayloadSuccess(x engine.PayloadSuccessEvent) {
d.asyncGossip.Clear() d.asyncGossip.Clear()
} }
func (d *Sequencer) onSequencerAction(x SequencerActionEvent) { func (d *Sequencer) onSequencerAction(SequencerActionEvent) {
d.log.Debug("Sequencer action") d.log.Debug("Sequencer action")
payload := d.asyncGossip.Get() payload := d.asyncGossip.Get()
if payload != nil { if payload != nil {
...@@ -356,10 +356,10 @@ func (d *Sequencer) onSequencerAction(x SequencerActionEvent) { ...@@ -356,10 +356,10 @@ func (d *Sequencer) onSequencerAction(x SequencerActionEvent) {
// meaning that we have seen BuildSealedEvent already. // meaning that we have seen BuildSealedEvent already.
// We can retry processing to make it canonical. // We can retry processing to make it canonical.
d.emitter.Emit(engine.PayloadProcessEvent{ d.emitter.Emit(engine.PayloadProcessEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Envelope: payload, Envelope: payload,
Ref: ref, Ref: ref,
}) })
d.latest.Ref = ref d.latest.Ref = ref
} else { } else {
...@@ -371,7 +371,7 @@ func (d *Sequencer) onSequencerAction(x SequencerActionEvent) { ...@@ -371,7 +371,7 @@ func (d *Sequencer) onSequencerAction(x SequencerActionEvent) {
d.emitter.Emit(engine.BuildSealEvent{ d.emitter.Emit(engine.BuildSealEvent{
Info: d.latest.Info, Info: d.latest.Info,
BuildStarted: d.latest.Started, BuildStarted: d.latest.Started,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
} else if d.latest == (BuildingState{}) { } else if d.latest == (BuildingState{}) {
...@@ -416,7 +416,7 @@ func (d *Sequencer) onReset(x rollup.ResetEvent) { ...@@ -416,7 +416,7 @@ func (d *Sequencer) onReset(x rollup.ResetEvent) {
d.nextActionOK = false d.nextActionOK = false
} }
func (d *Sequencer) onEngineResetConfirmedEvent(x engine.EngineResetConfirmedEvent) { func (d *Sequencer) onEngineResetConfirmedEvent(engine.EngineResetConfirmedEvent) {
d.nextActionOK = d.active.Load() d.nextActionOK = d.active.Load()
// Before sequencing we can wait a block, // Before sequencing we can wait a block,
// assuming the execution-engine just churned through some work for the reset. // assuming the execution-engine just churned through some work for the reset.
...@@ -552,10 +552,10 @@ func (d *Sequencer) startBuildingBlock() { ...@@ -552,10 +552,10 @@ func (d *Sequencer) startBuildingBlock() {
// Start a payload building process. // Start a payload building process.
withParent := &derive.AttributesWithParent{ withParent := &derive.AttributesWithParent{
Attributes: attrs, Attributes: attrs,
Parent: l2Head, Parent: l2Head,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, // zero, not going to be pending-safe / safe DerivedFrom: eth.L1BlockRef{}, // zero, not going to be pending-safe / safe
} }
// Don't try to start building a block again, until we have heard back from this attempt // Don't try to start building a block again, until we have heard back from this attempt
......
...@@ -91,7 +91,7 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool { ...@@ -91,7 +91,7 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool {
Info: c.currentPayloadInfo, Info: c.currentPayloadInfo,
BuildStarted: c.clock.Now(), BuildStarted: c.clock.Now(),
Parent: x.Attributes.Parent, Parent: x.Attributes.Parent,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
} }
...@@ -124,10 +124,10 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool { ...@@ -124,10 +124,10 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool {
if c.currentPayloadInfo == (eth.PayloadInfo{}) { if c.currentPayloadInfo == (eth.PayloadInfo{}) {
c.emitter.Emit(engine.PayloadSealExpiredErrorEvent{ c.emitter.Emit(engine.PayloadSealExpiredErrorEvent{
Info: x.Info, Info: x.Info,
Err: errors.New("job was cancelled"), Err: errors.New("job was cancelled"),
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
return true return true
} }
...@@ -142,17 +142,17 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool { ...@@ -142,17 +142,17 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool {
switch { switch {
case p < 0.03: // 3% case p < 0.03: // 3%
c.emitter.Emit(engine.PayloadSealInvalidEvent{ c.emitter.Emit(engine.PayloadSealInvalidEvent{
Info: x.Info, Info: x.Info,
Err: errors.New("mock invalid seal"), Err: errors.New("mock invalid seal"),
IsLastInSpan: x.IsLastInSpan, Concluding: x.Concluding,
DerivedFrom: x.DerivedFrom, DerivedFrom: x.DerivedFrom,
}) })
case p < 0.08: // 5% case p < 0.08: // 5%
c.emitter.Emit(engine.PayloadSealExpiredErrorEvent{ c.emitter.Emit(engine.PayloadSealExpiredErrorEvent{
Info: x.Info, Info: x.Info,
Err: errors.New("mock temp engine error"), Err: errors.New("mock temp engine error"),
IsLastInSpan: x.IsLastInSpan, Concluding: x.Concluding,
DerivedFrom: x.DerivedFrom, DerivedFrom: x.DerivedFrom,
}) })
default: default:
payloadEnvelope := &eth.ExecutionPayloadEnvelope{ payloadEnvelope := &eth.ExecutionPayloadEnvelope{
...@@ -178,11 +178,11 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool { ...@@ -178,11 +178,11 @@ func (c *ChaoticEngine) OnEvent(ev event.Event) bool {
SequenceNumber: 0, // ignored SequenceNumber: 0, // ignored
} }
c.emitter.Emit(engine.BuildSealedEvent{ c.emitter.Emit(engine.BuildSealedEvent{
Info: x.Info, Info: x.Info,
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
IsLastInSpan: x.IsLastInSpan, Concluding: x.Concluding,
DerivedFrom: x.DerivedFrom, DerivedFrom: x.DerivedFrom,
}) })
} }
c.currentPayloadInfo = eth.PayloadInfo{} c.currentPayloadInfo = eth.PayloadInfo{}
......
...@@ -46,7 +46,8 @@ func decodeID(data []byte) eth.BlockID { ...@@ -46,7 +46,8 @@ func decodeID(data []byte) eth.BlockID {
} }
func (m *FakeAttributesBuilder) PreparePayloadAttributes(ctx context.Context, func (m *FakeAttributesBuilder) PreparePayloadAttributes(ctx context.Context,
l2Parent eth.L2BlockRef, epoch eth.BlockID) (attrs *eth.PayloadAttributes, err error) { l2Parent eth.L2BlockRef, epoch eth.BlockID,
) (attrs *eth.PayloadAttributes, err error) {
gasLimit := eth.Uint64Quantity(30_000_000) gasLimit := eth.Uint64Quantity(30_000_000)
attrs = &eth.PayloadAttributes{ attrs = &eth.PayloadAttributes{
Timestamp: eth.Uint64Quantity(l2Parent.Time + m.cfg.BlockTime), Timestamp: eth.Uint64Quantity(l2Parent.Time + m.cfg.BlockTime),
...@@ -315,7 +316,7 @@ func TestSequencer_StaleBuild(t *testing.T) { ...@@ -315,7 +316,7 @@ func TestSequencer_StaleBuild(t *testing.T) {
Info: payloadInfo, Info: payloadInfo,
BuildStarted: startedTime, BuildStarted: startedTime,
Parent: head, Parent: head,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
...@@ -325,7 +326,7 @@ func TestSequencer_StaleBuild(t *testing.T) { ...@@ -325,7 +326,7 @@ func TestSequencer_StaleBuild(t *testing.T) {
emitter.ExpectOnce(engine.BuildSealEvent{ emitter.ExpectOnce(engine.BuildSealEvent{
Info: payloadInfo, Info: payloadInfo,
BuildStarted: startedTime, BuildStarted: startedTime,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
seq.OnEvent(SequencerActionEvent{}) seq.OnEvent(SequencerActionEvent{})
...@@ -355,18 +356,18 @@ func TestSequencer_StaleBuild(t *testing.T) { ...@@ -355,18 +356,18 @@ func TestSequencer_StaleBuild(t *testing.T) {
SequenceNumber: 0, SequenceNumber: 0,
} }
emitter.ExpectOnce(engine.PayloadProcessEvent{ emitter.ExpectOnce(engine.PayloadProcessEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
}) })
// And report back the sealing result to the engine // And report back the sealing result to the engine
seq.OnEvent(engine.BuildSealedEvent{ seq.OnEvent(engine.BuildSealedEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Info: payloadInfo, Info: payloadInfo,
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
}) })
// The sequencer should start processing the payload // The sequencer should start processing the payload
emitter.AssertExpectations(t) emitter.AssertExpectations(t)
...@@ -521,7 +522,7 @@ func TestSequencerBuild(t *testing.T) { ...@@ -521,7 +522,7 @@ func TestSequencerBuild(t *testing.T) {
Info: payloadInfo, Info: payloadInfo,
BuildStarted: startedTime, BuildStarted: startedTime,
Parent: head, Parent: head,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
// The sealing should now be scheduled as next action. // The sealing should now be scheduled as next action.
...@@ -535,7 +536,7 @@ func TestSequencerBuild(t *testing.T) { ...@@ -535,7 +536,7 @@ func TestSequencerBuild(t *testing.T) {
emitter.ExpectOnce(engine.BuildSealEvent{ emitter.ExpectOnce(engine.BuildSealEvent{
Info: payloadInfo, Info: payloadInfo,
BuildStarted: startedTime, BuildStarted: startedTime,
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
}) })
seq.OnEvent(SequencerActionEvent{}) seq.OnEvent(SequencerActionEvent{})
...@@ -564,18 +565,18 @@ func TestSequencerBuild(t *testing.T) { ...@@ -564,18 +565,18 @@ func TestSequencerBuild(t *testing.T) {
SequenceNumber: 0, SequenceNumber: 0,
} }
emitter.ExpectOnce(engine.PayloadProcessEvent{ emitter.ExpectOnce(engine.PayloadProcessEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
}) })
// And report back the sealing result to the engine // And report back the sealing result to the engine
seq.OnEvent(engine.BuildSealedEvent{ seq.OnEvent(engine.BuildSealedEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Info: payloadInfo, Info: payloadInfo,
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
}) })
// The sequencer should start processing the payload // The sequencer should start processing the payload
emitter.AssertExpectations(t) emitter.AssertExpectations(t)
...@@ -587,10 +588,10 @@ func TestSequencerBuild(t *testing.T) { ...@@ -587,10 +588,10 @@ func TestSequencerBuild(t *testing.T) {
// Mock that the processing was successful // Mock that the processing was successful
seq.OnEvent(engine.PayloadSuccessEvent{ seq.OnEvent(engine.PayloadSuccessEvent{
IsLastInSpan: false, Concluding: false,
DerivedFrom: eth.L1BlockRef{}, DerivedFrom: eth.L1BlockRef{},
Envelope: payloadEnvelope, Envelope: payloadEnvelope,
Ref: payloadRef, Ref: payloadRef,
}) })
require.Nil(t, deps.asyncGossip.payload, "async gossip should have cleared,"+ require.Nil(t, deps.asyncGossip.payload, "async gossip should have cleared,"+
" after previous publishing and now having persisted the block ourselves") " after previous publishing and now having persisted the block ourselves")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment