producer

package
v0.0.0-...-5c248f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2025 License: MIT, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProofTypeSgx = "sgx"
	ProofTypeCPU = "native"
)
View Source
const (
	ZKProofTypeR0       = "risc0"
	ZKProofTypeSP1      = "sp1"
	RecursionPlonk      = "plonk"
	RecursionCompressed = "compressed"
)

Variables

View Source
var (
	ErrProofInProgress = errors.New("work_in_progress")
	ErrRetry           = errors.New("retry")
	StatusRegistered   = "registered"
)
View Source
var (
	ErrInvalidLength = errors.New("invalid items length")
)

Functions

This section is empty.

Types

type BatchProofs

type BatchProofs struct {
	Proofs     []*ProofWithHeader
	BatchProof []byte
	Tier       uint16
	BlockIDs   []*big.Int
}

type ContestRequestBody

type ContestRequestBody struct {
	BlockID    *big.Int
	ProposedIn *big.Int
	ParentHash common.Hash
	Meta       metadata.TaikoBlockMetaData
	Tier       uint16
}

ContestRequestBody represents a request body to generate a proof for contesting.

type DummyProofProducer

type DummyProofProducer struct{}

DummyProofProducer always returns a dummy proof.

func (*DummyProofProducer) RequestBatchProofs

func (o *DummyProofProducer) RequestBatchProofs(
	proofs []*ProofWithHeader,
	tier uint16,
) (*BatchProofs, error)

RequestBatchProofs returns a dummy proof aggregation to the result channel.

func (*DummyProofProducer) RequestProof

func (o *DummyProofProducer) RequestProof(
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta metadata.TaikoBlockMetaData,
	header *types.Header,
	tier uint16,
	_ time.Time,
) (*ProofWithHeader, error)

RequestProof returns a dummy proof to the result channel.

type GuardianProofProducer

type GuardianProofProducer struct {
	DummyProofProducer
	// contains filtered or unexported fields
}

GuardianProofProducer always returns an optimistic (dummy) proof.

func NewGuardianProofProducer

func NewGuardianProofProducer(
	tier uint16,
	returnLivenessBond bool,
) *GuardianProofProducer

func (*GuardianProofProducer) Aggregate

Aggregate implements the ProofProducer interface to aggregate a batch of proofs.

func (*GuardianProofProducer) RequestCancel

func (g *GuardianProofProducer) RequestCancel(
	_ context.Context,
	_ *ProofRequestOptions,
) error

RequestCancel implements the ProofProducer interface to cancel the proof generating progress.

func (*GuardianProofProducer) RequestProof

func (g *GuardianProofProducer) RequestProof(
	_ context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta metadata.TaikoBlockMetaData,
	header *types.Header,
	requestAt time.Time,
) (*ProofWithHeader, error)

RequestProof implements the ProofProducer interface.

func (*GuardianProofProducer) Tier

func (g *GuardianProofProducer) Tier() uint16

Tier implements the ProofProducer interface.

type OptimisticProofProducer

type OptimisticProofProducer struct{ DummyProofProducer }

OptimisticProofProducer always returns an optimistic (dummy) proof.

func (*OptimisticProofProducer) Aggregate

func (o *OptimisticProofProducer) Aggregate(
	_ context.Context,
	items []*ProofWithHeader,
	_ time.Time,
) (*BatchProofs, error)

Aggregate implements the ProofProducer interface to aggregate a batch of proofs.

func (*OptimisticProofProducer) RequestCancel

RequestCancel implements the ProofProducer interface to cancel the proof generating progress.

func (*OptimisticProofProducer) RequestProof

func (o *OptimisticProofProducer) RequestProof(
	_ context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta metadata.TaikoBlockMetaData,
	header *types.Header,
	requestAt time.Time,
) (*ProofWithHeader, error)

RequestProof implements the ProofProducer interface.

func (*OptimisticProofProducer) Tier

func (o *OptimisticProofProducer) Tier() uint16

Tier implements the ProofProducer interface.

type ProofDataV2

type ProofDataV2 struct {
	KzgProof string `json:"kzg_proof"`
	Proof    string `json:"proof"`
	Quote    string `json:"quote"`
}

type ProofProducer

type ProofProducer interface {
	RequestProof(
		ctx context.Context,
		opts *ProofRequestOptions,
		blockID *big.Int,
		meta metadata.TaikoBlockMetaData,
		header *types.Header,
		requestAt time.Time,
	) (*ProofWithHeader, error)
	Aggregate(
		ctx context.Context,
		items []*ProofWithHeader,
		requestAt time.Time,
	) (*BatchProofs, error)
	RequestCancel(
		ctx context.Context,
		opts *ProofRequestOptions,
	) error
	Tier() uint16
}

type ProofRequestBody

type ProofRequestBody struct {
	Tier uint16
	Meta metadata.TaikoBlockMetaData
}

ProofRequestBody represents a request body to generate a proof.

type ProofRequestOptions

type ProofRequestOptions struct {
	BlockID            *big.Int
	ProverAddress      common.Address
	ProposeBlockTxHash common.Hash
	TaikoL2            common.Address
	MetaHash           common.Hash
	BlockHash          common.Hash
	ParentHash         common.Hash
	StateRoot          common.Hash
	EventL1Hash        common.Hash
	Graffiti           string
	GasUsed            uint64
	ParentGasUsed      uint64
	Compressed         bool
}

ProofRequestOptions contains all options that need to be passed to a backend proof producer service.

type ProofWithHeader

type ProofWithHeader struct {
	BlockID *big.Int
	Meta    metadata.TaikoBlockMetaData
	Header  *types.Header
	Proof   []byte
	Opts    *ProofRequestOptions
	Tier    uint16
}

type RISC0RequestProofBodyParam

type RISC0RequestProofBodyParam struct {
	Bonsai       bool     `json:"bonsai"`
	Snark        bool     `json:"snark"`
	Profile      bool     `json:"profile"`
	ExecutionPo2 *big.Int `json:"execution_po2"`
}

RISC0RequestProofBodyParam represents the JSON body of RaikoRequestProofBody's `risc0` field.

type RaikoProofData

type RaikoProofData struct {
	Proof  string `json:"proof"` //nolint:revive,stylecheck
	Status string `json:"status"`
}

type RaikoProofDataV2

type RaikoProofDataV2 struct {
	Proof  *ProofDataV2 `json:"proof"` //nolint:revive,stylecheck
	Status string       `json:"status"`
}

type RaikoRequestProofBody

type RaikoRequestProofBody struct {
	Block    *big.Int                    `json:"block_number"`
	Prover   string                      `json:"prover"`
	Graffiti string                      `json:"graffiti"`
	Type     string                      `json:"proof_type"`
	SGX      *SGXRequestProofBodyParam   `json:"sgx"`
	RISC0    *RISC0RequestProofBodyParam `json:"risc0"`
	SP1      *SP1RequestProofBodyParam   `json:"sp1"`
}

RaikoRequestProofBody represents the JSON body for requesting the proof.

type RaikoRequestProofBodyResponse

type RaikoRequestProofBodyResponse struct {
	Data         *RaikoProofData `json:"data"`
	ErrorMessage string          `json:"message"`
}

RaikoRequestProofBodyResponse represents the JSON body of the response of the proof requests.

type RaikoRequestProofBodyResponseV2

type RaikoRequestProofBodyResponseV2 struct {
	Data         *RaikoProofDataV2 `json:"data"`
	ErrorMessage string            `json:"message"`
	Error        string            `json:"error"`
}

RaikoRequestProofBodyResponseV2 represents the JSON body of the response of the proof requests.

type RaikoRequestProofBodyV3

type RaikoRequestProofBodyV3 struct {
	Blocks   [][2]*big.Int               `json:"block_numbers"`
	Prover   string                      `json:"prover"`
	Graffiti string                      `json:"graffiti"`
	Type     string                      `json:"proof_type"`
	SGX      *SGXRequestProofBodyParam   `json:"sgx"`
	RISC0    *RISC0RequestProofBodyParam `json:"risc0"`
	SP1      *SP1RequestProofBodyParam   `json:"sp1"`
}

RaikoRequestProofBodyV3 represents the JSON body for requesting the proof.

type SGXProofProducer

type SGXProofProducer struct {
	RaikoHostEndpoint   string // a proverd RPC endpoint
	ProofType           string // Proof type
	JWT                 string // JWT provided by Raiko
	Dummy               bool
	RaikoRequestTimeout time.Duration
	DummyProofProducer
}

SGXProofProducer generates a SGX proof for the given block.

func (*SGXProofProducer) Aggregate

func (s *SGXProofProducer) Aggregate(
	ctx context.Context,
	items []*ProofWithHeader,
	requestAt time.Time,
) (*BatchProofs, error)

Aggregate implements the ProofProducer interface to aggregate a batch of proofs.

func (*SGXProofProducer) RequestCancel

func (s *SGXProofProducer) RequestCancel(
	ctx context.Context,
	opts *ProofRequestOptions,
) error

RequestCancel implements the ProofProducer interface to cancel the proof generating progress.

func (*SGXProofProducer) RequestProof

func (s *SGXProofProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta metadata.TaikoBlockMetaData,
	header *types.Header,
	requestAt time.Time,
) (*ProofWithHeader, error)

RequestProof implements the ProofProducer interface.

func (*SGXProofProducer) Tier

func (s *SGXProofProducer) Tier() uint16

Tier implements the ProofProducer interface.

type SGXRequestProofBodyParam

type SGXRequestProofBodyParam struct {
	Setup     bool `json:"setup"`
	Bootstrap bool `json:"bootstrap"`
	Prove     bool `json:"prove"`
}

SGXRequestProofBodyParam represents the JSON body of RaikoRequestProofBody's `sgx` field.

type SP1RequestProofBodyParam

type SP1RequestProofBodyParam struct {
	Recursion string `json:"recursion"`
	Prover    string `json:"prover"`
	Verify    bool   `json:"verify"`
}

SP1RequestProofBodyParam represents the JSON body of RaikoRequestProofBody's `sp1` field.

type ZKvmProofProducer

type ZKvmProofProducer struct {
	ZKProofType         string // ZK Proof type
	RaikoHostEndpoint   string
	RaikoRequestTimeout time.Duration
	JWT                 string // JWT provided by Raiko
	Dummy               bool
	DummyProofProducer
}

ZKvmProofProducer generates a ZK proof for the given block.

func (*ZKvmProofProducer) Aggregate

func (s *ZKvmProofProducer) Aggregate(
	ctx context.Context,
	items []*ProofWithHeader,
	requestAt time.Time,
) (*BatchProofs, error)

Aggregate implements the ProofProducer interface to aggregate a batch of proofs.

func (*ZKvmProofProducer) RequestCancel

func (s *ZKvmProofProducer) RequestCancel(
	ctx context.Context,
	opts *ProofRequestOptions,
) error

RequestCancel implements the ProofProducer interface to cancel the proof generating progress.

func (*ZKvmProofProducer) RequestProof

func (s *ZKvmProofProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta metadata.TaikoBlockMetaData,
	header *types.Header,
	requestAt time.Time,
) (*ProofWithHeader, error)

RequestProof implements the ProofProducer interface.

func (*ZKvmProofProducer) Tier

func (s *ZKvmProofProducer) Tier() uint16

Tier implements the ProofProducer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL