Skip to content

Commit

Permalink
feat: new metadata design
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 13, 2025
1 parent d527a1f commit b1b7b52
Show file tree
Hide file tree
Showing 32 changed files with 406 additions and 475 deletions.
4 changes: 2 additions & 2 deletions packages/taiko-client/bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func EncodeBatchParams(params *BatchParams) ([]byte, error) {

// EncodeProveBlockInput performs the solidity `abi.encode` for the given TaikoL1.proveBlock input.
func EncodeProveBlockInput(
meta metadata.TaikoBlockMetaData,
meta metadata.TaikoProposalMetaData,
transition *ontakeBindings.TaikoDataTransition,
tierProof *ontakeBindings.TaikoDataTierProof,
) ([]byte, error) {
Expand All @@ -426,7 +426,7 @@ func EncodeProveBlockInput(

// EncodeProveBlocksInput performs the solidity `abi.encode` for the given TaikoL1.proveBlocks input.
func EncodeProveBlocksInput(
metas []metadata.TaikoBlockMetaData,
metas []metadata.TaikoProposalMetaData,
transitions []ontakeBindings.TaikoDataTransition,
) ([][]byte, error) {
if len(metas) != len(transitions) {
Expand Down
39 changes: 36 additions & 3 deletions packages/taiko-client/bindings/metadata/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import (
"github.com/ethereum/go-ethereum/common"

ontakeBindings "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/ontake"
pacayaBindings "github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/pacaya"
)

// TaikoBlockMetaData defines all the metadata of a Taiko block.
type TaikoBlockMetaData interface {
// TaikoProposalMetaData defines all the metadata of a Taiko block.
type TaikoProposalMetaData interface {
TaikoBlockMetaDataOntake() TaikoBlockMetaDataOntake
TaikoBatchMetaDataPacaya() TaikoBatchMetaDataPacaya
IsPacaya() bool
}

type TaikoBlockMetaDataOntake interface {
GetAnchorBlockHash() common.Hash
GetDifficulty() common.Hash
GetBlobHash() common.Hash
Expand All @@ -35,5 +42,31 @@ type TaikoBlockMetaData interface {
GetRawBlockHash() common.Hash
GetTxIndex() uint
GetTxHash() common.Hash
IsOntakeBlock() bool
}

type TaikoBatchMetaDataPacaya interface {
GetTxListHash() common.Hash
GetExtraData() []byte
GetCoinbase() common.Address
GetBatchID() *big.Int
GetGasLimit() uint32
GetLastBlockTimestamp() uint64
GetParentMetaHash() common.Hash
GetProposer() common.Address
GetLivenessBond() *big.Int
GetProposedAt() uint64
GetProposedIn() uint64
GetTxListOffset() uint32
GetTxListSize() uint32
GetNumBlobs() uint8
GetAnchorBlockID() uint64
GetAnchorBlockHash() common.Hash
GetSignalSlots() [][32]byte
GetBlocks() []pacayaBindings.ITaikoInboxBlockParams
GetAnchorInput() [32]byte
GetBaseFeeConfig() *pacayaBindings.LibSharedDataBaseFeeConfig
GetRawBlockHeight() *big.Int
GetRawBlockHash() common.Hash
GetTxIndex() uint
GetTxHash() common.Hash
}
168 changes: 0 additions & 168 deletions packages/taiko-client/bindings/metadata/metadata_legacy.go

This file was deleted.

22 changes: 16 additions & 6 deletions packages/taiko-client/bindings/metadata/metadata_ontake.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// Ensure TaikoDataBlockMetadataOntake implements TaikoBlockMetaData.
var _ TaikoBlockMetaData = (*TaikoDataBlockMetadataOntake)(nil)
var _ TaikoProposalMetaData = (*TaikoDataBlockMetadataOntake)(nil)

// TaikoDataBlockMetadataOntake is the metadata of an ontake Taiko block.
type TaikoDataBlockMetadataOntake struct {
Expand All @@ -32,6 +32,21 @@ func (m *TaikoDataBlockMetadataOntake) GetAnchorBlockHash() common.Hash {
return m.AnchorBlockHash
}

// TaikoBlockMetaDataOntake implemnts TaikoProposalMetaData interface.
func (m *TaikoDataBlockMetadataOntake) TaikoBlockMetaDataOntake() TaikoBlockMetaDataOntake {
return m
}

// TaikoBatchMetaDataPacaya implemnts TaikoProposalMetaData interface.
func (m *TaikoDataBlockMetadataOntake) TaikoBatchMetaDataPacaya() TaikoBatchMetaDataPacaya {
return nil
}

// IsPacaya implemnts TaikoProposalMetaData interface.
func (m *TaikoDataBlockMetadataOntake) IsPacaya() bool {
return false
}

// GetDifficulty returns the difficulty.
func (m *TaikoDataBlockMetadataOntake) GetDifficulty() common.Hash {
return m.Difficulty
Expand Down Expand Up @@ -153,11 +168,6 @@ func (m *TaikoDataBlockMetadataOntake) GetTxHash() common.Hash {
return m.Log.TxHash
}

// IsOntakeBlock returns whether the block is an ontake block.
func (m *TaikoDataBlockMetadataOntake) IsOntakeBlock() bool {
return true
}

// InnerMetadata returns the inner metadata.
func (m *TaikoDataBlockMetadataOntake) InnerMetadata() *ontakeBindings.TaikoDataBlockMetadataV2 {
return &m.TaikoDataBlockMetadataV2
Expand Down
Loading

0 comments on commit b1b7b52

Please sign in to comment.