Skip to content

Commit

Permalink
Revert "feat: update l1Origin"
Browse files Browse the repository at this point in the history
This reverts commit 1337b37.
  • Loading branch information
davidtaikocha committed Jan 18, 2025
1 parent 1337b37 commit db376ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
6 changes: 0 additions & 6 deletions core/rawdb/gen_taiko_l1_origin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 2 additions & 26 deletions core/rawdb/taiko_l1_origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,8 @@ func l1OriginKey(blockID *big.Int) []byte {

//go:generate go run github.com/fjl/gencodec -type L1Origin -field-override l1OriginMarshaling -out gen_taiko_l1_origin.go

// L1Origin represents a pacaya L1Origin of a L2 block.
// L1Origin represents a L1Origin of a L2 block.
type L1Origin struct {
BlockID *big.Int `json:"blockID" gencodec:"required"`
BatchID *big.Int `json:"batchID" rlp:"optional"`
L2BlockHash common.Hash `json:"l2BlockHash"`
L1BlockHeight *big.Int `json:"l1BlockHeight" gencodec:"required"`
L1BlockHash common.Hash `json:"l1BlockHash" gencodec:"required"`
}

// L1OriginLegacy represents a legacy L1Origin of a L2 block.
type L1OriginLegacy struct {
BlockID *big.Int `json:"blockID" gencodec:"required"`
L2BlockHash common.Hash `json:"l2BlockHash"`
L1BlockHeight *big.Int `json:"l1BlockHeight" gencodec:"required"`
Expand Down Expand Up @@ -70,22 +61,7 @@ func ReadL1Origin(db ethdb.KeyValueReader, blockID *big.Int) (*L1Origin, error)

l1Origin := new(L1Origin)
if err := rlp.Decode(bytes.NewReader(data), l1Origin); err != nil {
// If decoding the new version fails, try to decode the legacy version (without new fields).
l1OriginLegacy := new(L1OriginLegacy)
if err := rlp.Decode(bytes.NewReader(data), &l1OriginLegacy); err != nil {
return nil, fmt.Errorf("invalid legacy L1Origin RLP bytes: %w", err)
}

// If decoding legacy version succeeds, manually
// construct the new L1Origin with default values for the new fields.
l1Origin = &L1Origin{
BlockID: l1OriginLegacy.BlockID,
L2BlockHash: l1OriginLegacy.L2BlockHash,
L1BlockHeight: l1OriginLegacy.L1BlockHeight,
L1BlockHash: l1OriginLegacy.L1BlockHash,
// default value, as the new fields are not present in the legacy version.
BatchID: nil,
}
return nil, fmt.Errorf("invalid L1Origin RLP bytes: %w", err)
}

return l1Origin, nil
Expand Down

0 comments on commit db376ba

Please sign in to comment.