go-ethereum/rollup/da_syncer/da/da.go
Jonas Theis ac8164f5a4
feat: follower node sync from DA (#1098)
* port changes from #1013

* port changes from #1068

* go.mod tidy

* fix compile error

* fix goimports

* fix log

* address review comments

* upgrade golang.org/x/net to 0.23.0

* bump version

* remove unused flag

* update da-codec commit

---------

Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
2024-12-18 17:27:51 +01:00

69 lines
1.5 KiB
Go

package da
import (
"math/big"
"github.com/scroll-tech/go-ethereum/core/types"
)
type Type int
const (
// CommitBatchV0Type contains data of event of CommitBatchV0Type
CommitBatchV0Type Type = iota
// CommitBatchWithBlobType contains data of event of CommitBatchWithBlobType (v1, v2, v3, v4)
CommitBatchWithBlobType
// RevertBatchType contains data of event of RevertBatchType
RevertBatchType
// FinalizeBatchType contains data of event of FinalizeBatchType
FinalizeBatchType
)
// Entry represents a single DA event (commit, revert, finalize).
type Entry interface {
Type() Type
BatchIndex() uint64
L1BlockNumber() uint64
CompareTo(Entry) int
}
type EntryWithBlocks interface {
Entry
Blocks() []*PartialBlock
}
type Entries []Entry
// PartialHeader represents a partial header (from DA) of a block.
type PartialHeader struct {
Number uint64
Time uint64
BaseFee *big.Int
GasLimit uint64
Difficulty uint64
ExtraData []byte
}
func (h *PartialHeader) ToHeader() *types.Header {
return &types.Header{
Number: big.NewInt(0).SetUint64(h.Number),
Time: h.Time,
BaseFee: h.BaseFee,
GasLimit: h.GasLimit,
Difficulty: new(big.Int).SetUint64(h.Difficulty),
Extra: h.ExtraData,
}
}
// PartialBlock represents a partial block (from DA).
type PartialBlock struct {
PartialHeader *PartialHeader
Transactions types.Transactions
}
func NewPartialBlock(partialHeader *PartialHeader, txs types.Transactions) *PartialBlock {
return &PartialBlock{
PartialHeader: partialHeader,
Transactions: txs,
}
}