Skip to content

Commit

Permalink
feat: updates based on feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Feb 4, 2025
1 parent 07295e8 commit 820ee14
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func createPayloadAndSetHead(
return encoding.ToExecutableData(header), nil
}
}

payload, err := createExecutionPayloads(
ctx,
rpc,
meta.createExecutionPayloadsMetaData,
anchorTx,
)
if err != nil {
return nil, fmt.Errorf("failed to create execution payloads: %w", err)
}

var lastVerifiedBlockHash common.Hash
lastVerifiedTS, err := rpc.GetLastVerifiedTransitionPacaya(ctx)
if err != nil {
Expand All @@ -78,17 +89,6 @@ func createPayloadAndSetHead(
}
}

payload, err := createExecutionPayloads(
ctx,
rpc,
meta.createExecutionPayloadsMetaData,
anchorTx,
lastVerifiedBlockHash,
)
if err != nil {
return nil, fmt.Errorf("failed to create execution payloads: %w", err)
}

fc := &engine.ForkchoiceStateV1{
HeadBlockHash: payload.BlockHash,
SafeBlockHash: lastVerifiedBlockHash,
Expand All @@ -114,7 +114,6 @@ func createExecutionPayloads(
rpc *rpc.Client,
meta *createExecutionPayloadsMetaData,
anchorTx *types.Transaction,
lastVerfiiedBlockHash common.Hash,
) (payloadData *engine.ExecutableData, err error) {
// Insert a TaikoL2.anchor / TaikoL2.anchorV2 transaction at transactions list head
txListBytes, err := rlp.EncodeToBytes(append([]*types.Transaction{anchorTx}, meta.Txs...))
Expand All @@ -123,11 +122,6 @@ func createExecutionPayloads(
return nil, err
}

fc := &engine.ForkchoiceStateV1{
HeadBlockHash: meta.ParentHash,
SafeBlockHash: lastVerfiiedBlockHash,
FinalizedBlockHash: lastVerfiiedBlockHash,
}
attributes := &engine.PayloadAttributes{
Timestamp: meta.Timestamp,
Random: meta.Difficulty,
Expand Down Expand Up @@ -162,7 +156,11 @@ func createExecutionPayloads(
)

// Step 1, prepare a payload
fcRes, err := rpc.L2Engine.ForkchoiceUpdate(ctx, fc, attributes)
fcRes, err := rpc.L2Engine.ForkchoiceUpdate(
ctx,
&engine.ForkchoiceStateV1{HeadBlockHash: meta.ParentHash},
attributes,
)
if err != nil {
return nil, fmt.Errorf("failed to update fork choice: %w", err)
}
Expand Down

0 comments on commit 820ee14

Please sign in to comment.