plasma

package
v0.0.0-...-8cae7ee Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnabledFlagName         = "plasma.enabled"
	DaServerAddressFlagName = "plasma.da-server"
	VerifyOnReadFlagName    = "plasma.verify-on-read"
)

Variables

View Source
var ErrCommitmentMismatch = errors.New("commitment mismatch")

ErrCommitmentMismatch is returned when the server returns the wrong input for the given commitment.

View Source
var ErrInvalidInput = errors.New("invalid input")

ErrInvalidInput is returned when the input is not valid for posting to the DA storage.

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the server could not find the input.

Functions

func CLIFlags

func CLIFlags(envPrefix string, category string) []cli.Flag

Types

type CLIConfig

type CLIConfig struct {
	Enabled      bool
	DAServerURL  string
	VerifyOnRead bool
}

func ReadCLIConfig

func ReadCLIConfig(c *cli.Context) CLIConfig

func (CLIConfig) Check

func (c CLIConfig) Check() error

func (CLIConfig) NewDAClient

func (c CLIConfig) NewDAClient() *DAClient

type DA

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

func NewPlasmaDA

func NewPlasmaDA(log log.Logger, cfg CLIConfig) *DA

NewPlasmaDA creates a new PlasmaDA instance with the given log and CLIConfig.

func NewPlasmaDAWithStorage

func NewPlasmaDAWithStorage(log log.Logger, storage DAStorage) *DA

NewPlasmaDAWithStorage creates a new PlasmaDA instance with the given log and DAStorage interface.

func (*DA) GetInput

func (d *DA) GetInput(ctx context.Context, commitment []byte, blockNumber uint64) (Input, error)

GetInput returns the input data for the given commitment bytes. blockNumber is required to lookup the challenge status in the DataAvailabilityChallenge L1 contract.

type DAClient

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

DAClient is an HTTP client to communicate with a DA storage service. It creates commitments and retrieves input data + verifies if needed. Currently only supports Keccak256 commitments but may be extended eventually.

func NewDAClient

func NewDAClient(url string, verify bool) *DAClient

func (*DAClient) GetInput

func (c *DAClient) GetInput(ctx context.Context, key []byte) ([]byte, error)

GetInput returns the input data for the given commitment bytes.

func (*DAClient) SetInput

func (c *DAClient) SetInput(ctx context.Context, img []byte) ([]byte, error)

SetInput sets the input data and returns the keccak256 hash commitment.

type DAErrFaker

type DAErrFaker struct {
	Client *MockDAClient
	// contains filtered or unexported fields
}

func (*DAErrFaker) ActGetPreImageFail

func (f *DAErrFaker) ActGetPreImageFail()

func (*DAErrFaker) ActSetPreImageFail

func (f *DAErrFaker) ActSetPreImageFail()

func (*DAErrFaker) GetInput

func (f *DAErrFaker) GetInput(ctx context.Context, key []byte) ([]byte, error)

func (*DAErrFaker) SetPreImage

func (f *DAErrFaker) SetPreImage(ctx context.Context, data []byte) ([]byte, error)

type DAStorage

type DAStorage interface {
	GetInput(ctx context.Context, key []byte) ([]byte, error)
	SetInput(ctx context.Context, img []byte) ([]byte, error)
}

type Input

type Input struct {
	Data eth.Data
}

type MockDAClient

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

MockDAClient mocks a DA storage provider to avoid running an HTTP DA server in unit tests.

func NewMockDAClient

func NewMockDAClient(log log.Logger) *MockDAClient

func (*MockDAClient) DeleteData

func (c *MockDAClient) DeleteData(key []byte) error

func (*MockDAClient) GetInput

func (c *MockDAClient) GetInput(ctx context.Context, key []byte) ([]byte, error)

func (*MockDAClient) SetInput

func (c *MockDAClient) SetInput(ctx context.Context, data []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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