Documentation ¶
Index ¶
Constants ¶
const MaxBlocksPerChunk = 300
MaxBlocksPerChunk is the maximum number of keccak blocks per chunk.
const MaxChunkSize = MaxBlocksPerChunk * keccakTypes.BlockSize
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 ¶
var ErrChallengePeriodNotOver = errors.New("challenge period not over")
ErrChallengePeriodNotOver is returned when the challenge period is not over.
var ErrNilPreimageData = fmt.Errorf("cannot upload nil preimage data")
Functions ¶
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 gameTypes.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 gameTypes.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 batching.Block, idents ...keccakTypes.LargePreimageIdent) ([]keccakTypes.LargePreimageMetaData, error) ChallengePeriod(ctx context.Context) (uint64, 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