preimages

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBlocksPerChunk = 300

MaxBlocksPerChunk is the maximum number of keccak blocks per chunk.

MaxChunkSize is the maximum size of a preimage chunk in bytes. Notice, the max chunk size must be a multiple of the leaf size. The max chunk size is roughly 0.04MB to avoid memory expansion.

Variables

View Source
var ErrChallengePeriodNotOver = errors.New("challenge period not over")

ErrChallengePeriodNotOver is returned when the challenge period is not over.

View Source
var ErrNilPreimageData = fmt.Errorf("cannot upload nil preimage data")

Functions

func NewUUID added in v1.5.1

func NewUUID(sender common.Address, data *types.PreimageOracleData) *big.Int

NewUUID generates a new unique identifier for the preimage by hashing the concatenated preimage data, preimage offset, and sender address.

Types

type DirectPreimageUploader

type DirectPreimageUploader struct {
	// contains filtered or unexported fields
}

DirectPreimageUploader uploads the provided types.PreimageOracleData directly to the PreimageOracle contract in a single transaction.

func NewDirectPreimageUploader

func NewDirectPreimageUploader(logger log.Logger, txSender TxSender, contract PreimageGameContract) *DirectPreimageUploader

func (*DirectPreimageUploader) UploadPreimage

func (d *DirectPreimageUploader) UploadPreimage(ctx context.Context, claimIdx uint64, data *types.PreimageOracleData) error

type LargePreimageUploader

type LargePreimageUploader struct {
	// contains filtered or unexported fields
}

LargePreimageUploader handles uploading large preimages by streaming the merkleized preimage to the PreimageOracle contract, tightly packed across multiple transactions.

func NewLargePreimageUploader

func NewLargePreimageUploader(logger log.Logger, cl types.ClockReader, txSender TxSender, contract PreimageOracleContract) *LargePreimageUploader

func (*LargePreimageUploader) Squeeze

func (p *LargePreimageUploader) Squeeze(ctx context.Context, uuid *big.Int, stateMatrix *matrix.StateMatrix) error

func (*LargePreimageUploader) UploadPreimage

func (p *LargePreimageUploader) UploadPreimage(ctx context.Context, parent uint64, data *types.PreimageOracleData) error

type PreimageGameContract

type PreimageGameContract interface {
	UpdateOracleTx(ctx context.Context, claimIdx uint64, data *types.PreimageOracleData) (txmgr.TxCandidate, error)
}

type PreimageOracleContract

type PreimageOracleContract interface {
	InitLargePreimage(uuid *big.Int, partOffset uint32, claimedSize uint32) (txmgr.TxCandidate, error)
	AddLeaves(uuid *big.Int, startingBlockIndex *big.Int, input []byte, commitments []common.Hash, finalize bool) (txmgr.TxCandidate, error)
	Squeeze(claimant common.Address, uuid *big.Int, prestateMatrix keccakTypes.StateSnapshot, preState keccakTypes.Leaf, preStateProof merkle.Proof, postState keccakTypes.Leaf, postStateProof merkle.Proof) (txmgr.TxCandidate, error)
	CallSqueeze(ctx context.Context, claimant common.Address, uuid *big.Int, prestateMatrix keccakTypes.StateSnapshot, preState keccakTypes.Leaf, preStateProof merkle.Proof, postState keccakTypes.Leaf, postStateProof merkle.Proof) error
	GetProposalMetadata(ctx context.Context, block rpcblock.Block, idents ...keccakTypes.LargePreimageIdent) ([]keccakTypes.LargePreimageMetaData, error)
	ChallengePeriod(ctx context.Context) (uint64, error)
	GetMinBondLPP(ctx context.Context) (*big.Int, error)
}

PreimageOracleContract is the interface for interacting with the PreimageOracle contract.

type PreimageUploader

type PreimageUploader interface {
	// UploadPreimage uploads the provided preimage.
	UploadPreimage(ctx context.Context, claimIdx uint64, data *types.PreimageOracleData) error
}

PreimageUploader is responsible for posting preimages.

type SplitPreimageUploader

type SplitPreimageUploader struct {
	// contains filtered or unexported fields
}

SplitPreimageUploader routes preimage uploads to the appropriate uploader based on the size of the preimage.

func NewSplitPreimageUploader

func NewSplitPreimageUploader(directUploader PreimageUploader, largeUploader PreimageUploader, minLargePreimageSize uint64) *SplitPreimageUploader

func (*SplitPreimageUploader) UploadPreimage

func (s *SplitPreimageUploader) UploadPreimage(ctx context.Context, parent uint64, data *types.PreimageOracleData) error

type TxSender added in v1.7.3

type TxSender interface {
	From() common.Address
	SendAndWaitSimple(txPurpose string, txs ...txmgr.TxCandidate) error
}

Jump to

Keyboard shortcuts

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