Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(l1Origin): remove the reverted l1Origins #355

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions core/rawdb/taiko_l1_origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func WriteL1Origin(db ethdb.KeyValueWriter, blockID *big.Int, l1Origin *L1Origin
}
}

// DeleteL1Origin removes the L1Origin.
func DeleteL1Origin(db ethdb.KeyValueWriter, blockID *big.Int) {
_ = db.Delete(l1OriginKey(blockID))
}

// ReadL1Origin retrieves the L1Origin of the given blockID from the database.
func ReadL1Origin(db ethdb.KeyValueReader, blockID *big.Int) (*L1Origin, error) {
data, _ := db.Get(l1OriginKey(blockID))
Expand Down
5 changes: 5 additions & 0 deletions eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
// generating the payload. It's a special corner case that a few slots are
// missing and we are requested to generate the payload in slot.
} else if isTaiko { // CHANGE(taiko): reorg is allowed in L2.
// After inserting a new canonical head, we delete all L1Origin data of the pending soft blocks.
head := api.eth.BlockChain().CurrentBlock()
for number := head.Number.Uint64(); number > block.NumberU64(); number-- {
rawdb.DeleteL1Origin(api.eth.ChainDb(), new(big.Int).SetUint64(number))
}
if latestValid, err := api.eth.BlockChain().SetCanonical(block); err != nil {
return engine.ForkChoiceResponse{PayloadStatus: engine.PayloadStatusV1{Status: engine.INVALID, LatestValidHash: &latestValid}}, err
}
Expand Down