precompileconfig

package
v0.12.9-rc.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: GPL-3.0, LGPL-3.0 Imports: 9 Imported by: 8

Documentation

Overview

Defines the stateless interface for unmarshalling an arbitrary config of a precompile

Package precompileconfig is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptContext

type AcceptContext struct {
	SnowCtx      *snow.Context
	SharedMemory SharedMemoryWriter
	Warp         WarpMessageWriter
}

AcceptContext defines the context passed in to a precompileconfig's Accepter

type Accepter

type Accepter interface {
	Accept(acceptCtx *AcceptContext, blockHash common.Hash, blockNumber uint64, txHash common.Hash, logIndex int, topics []common.Hash, logData []byte) error
}

Accepter is an optional interface for StatefulPrecompiledContracts to implement. If implemented, Accept will be called for every log with the address of the precompile when the block is accepted. WARNING: If you are implementing a custom precompile, beware that coreth will not maintain backwards compatibility of this interface and your code should not rely on this. Designed for use only by precompiles that ship with coreth.

type ChainConfig

type ChainConfig interface {
	// IsDUpgrade returns true if the time is after the DUpgrade.
	IsDUpgrade(time uint64) bool
}

ChainContext defines an interface that provides information to a stateful precompile about the chain configuration. The precompile can access this information to initialize its state.

type Config

type Config interface {
	// Key returns the unique key for the stateful precompile.
	Key() string
	// Timestamp returns the timestamp at which this stateful precompile should be enabled.
	// 1) 0 indicates that the precompile should be enabled from genesis.
	// 2) n indicates that the precompile should be enabled in the first block with timestamp >= [n].
	// 3) nil indicates that the precompile is never enabled.
	Timestamp() *uint64
	// IsDisabled returns true if this network upgrade should disable the precompile.
	IsDisabled() bool
	// Equal returns true if the provided argument configures the same precompile with the same parameters.
	Equal(Config) bool
	// Verify is called on startup and an error is treated as fatal. Configure can assume the Config has passed verification.
	Verify(ChainConfig) error
}

StatefulPrecompileConfig defines the interface for a stateful precompile to be enabled via a network upgrade.

type MockAccepter

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

MockAccepter is a mock of Accepter interface.

func NewMockAccepter

func NewMockAccepter(ctrl *gomock.Controller) *MockAccepter

NewMockAccepter creates a new mock instance.

func (*MockAccepter) Accept

func (m *MockAccepter) Accept(acceptCtx *AcceptContext, blockHash common.Hash, blockNumber uint64, txHash common.Hash, logIndex int, topics []common.Hash, logData []byte) error

Accept mocks base method.

func (*MockAccepter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAccepterMockRecorder

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

MockAccepterMockRecorder is the mock recorder for MockAccepter.

func (*MockAccepterMockRecorder) Accept

func (mr *MockAccepterMockRecorder) Accept(acceptCtx, blockHash, blockNumber, txHash, logIndex, topics, logData interface{}) *gomock.Call

Accept indicates an expected call of Accept.

type MockChainConfig

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

MockChainConfig is a mock of ChainConfig interface.

func NewMockChainConfig

func NewMockChainConfig(ctrl *gomock.Controller) *MockChainConfig

NewMockChainConfig creates a new mock instance.

func (*MockChainConfig) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockChainConfig) IsDUpgrade

func (m *MockChainConfig) IsDUpgrade(time uint64) bool

IsDUpgrade mocks base method.

type MockChainConfigMockRecorder

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

MockChainConfigMockRecorder is the mock recorder for MockChainConfig.

func (*MockChainConfigMockRecorder) IsDUpgrade

func (mr *MockChainConfigMockRecorder) IsDUpgrade(time interface{}) *gomock.Call

IsDUpgrade indicates an expected call of IsDUpgrade.

type MockConfig

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

MockConfig is a mock of Config interface.

func NewMockConfig

func NewMockConfig(ctrl *gomock.Controller) *MockConfig

NewMockConfig creates a new mock instance.

func (*MockConfig) EXPECT

func (m *MockConfig) EXPECT() *MockConfigMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConfig) Equal

func (m *MockConfig) Equal(arg0 Config) bool

Equal mocks base method.

func (*MockConfig) IsDisabled

func (m *MockConfig) IsDisabled() bool

IsDisabled mocks base method.

func (*MockConfig) Key

func (m *MockConfig) Key() string

Key mocks base method.

func (*MockConfig) Timestamp

func (m *MockConfig) Timestamp() *uint64

Timestamp mocks base method.

func (*MockConfig) Verify

func (m *MockConfig) Verify(arg0 ChainConfig) error

Verify mocks base method.

type MockConfigMockRecorder

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

MockConfigMockRecorder is the mock recorder for MockConfig.

func (*MockConfigMockRecorder) Equal

func (mr *MockConfigMockRecorder) Equal(arg0 interface{}) *gomock.Call

Equal indicates an expected call of Equal.

func (*MockConfigMockRecorder) IsDisabled

func (mr *MockConfigMockRecorder) IsDisabled() *gomock.Call

IsDisabled indicates an expected call of IsDisabled.

func (*MockConfigMockRecorder) Key

func (mr *MockConfigMockRecorder) Key() *gomock.Call

Key indicates an expected call of Key.

func (*MockConfigMockRecorder) Timestamp

func (mr *MockConfigMockRecorder) Timestamp() *gomock.Call

Timestamp indicates an expected call of Timestamp.

func (*MockConfigMockRecorder) Verify

func (mr *MockConfigMockRecorder) Verify(arg0 interface{}) *gomock.Call

Verify indicates an expected call of Verify.

type MockPredicater

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

MockPredicater is a mock of Predicater interface.

func NewMockPredicater

func NewMockPredicater(ctrl *gomock.Controller) *MockPredicater

NewMockPredicater creates a new mock instance.

func (*MockPredicater) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPredicater) PredicateGas

func (m *MockPredicater) PredicateGas(storageSlots []byte) (uint64, error)

PredicateGas mocks base method.

func (*MockPredicater) VerifyPredicate

func (m *MockPredicater) VerifyPredicate(predicateContext *PredicateContext, predicates [][]byte) []byte

VerifyPredicate mocks base method.

type MockPredicaterMockRecorder

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

MockPredicaterMockRecorder is the mock recorder for MockPredicater.

func (*MockPredicaterMockRecorder) PredicateGas

func (mr *MockPredicaterMockRecorder) PredicateGas(storageSlots interface{}) *gomock.Call

PredicateGas indicates an expected call of PredicateGas.

func (*MockPredicaterMockRecorder) VerifyPredicate

func (mr *MockPredicaterMockRecorder) VerifyPredicate(predicateContext, predicates interface{}) *gomock.Call

VerifyPredicate indicates an expected call of VerifyPredicate.

type MockSharedMemoryWriter

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

MockSharedMemoryWriter is a mock of SharedMemoryWriter interface.

func NewMockSharedMemoryWriter

func NewMockSharedMemoryWriter(ctrl *gomock.Controller) *MockSharedMemoryWriter

NewMockSharedMemoryWriter creates a new mock instance.

func (*MockSharedMemoryWriter) AddSharedMemoryRequests

func (m *MockSharedMemoryWriter) AddSharedMemoryRequests(chainID ids.ID, requests *atomic.Requests)

AddSharedMemoryRequests mocks base method.

func (*MockSharedMemoryWriter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockSharedMemoryWriterMockRecorder

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

MockSharedMemoryWriterMockRecorder is the mock recorder for MockSharedMemoryWriter.

func (*MockSharedMemoryWriterMockRecorder) AddSharedMemoryRequests

func (mr *MockSharedMemoryWriterMockRecorder) AddSharedMemoryRequests(chainID, requests interface{}) *gomock.Call

AddSharedMemoryRequests indicates an expected call of AddSharedMemoryRequests.

type MockWarpMessageWriter

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

MockWarpMessageWriter is a mock of WarpMessageWriter interface.

func NewMockWarpMessageWriter

func NewMockWarpMessageWriter(ctrl *gomock.Controller) *MockWarpMessageWriter

NewMockWarpMessageWriter creates a new mock instance.

func (*MockWarpMessageWriter) AddMessage

func (m *MockWarpMessageWriter) AddMessage(unsignedMessage *warp.UnsignedMessage) error

AddMessage mocks base method.

func (*MockWarpMessageWriter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockWarpMessageWriterMockRecorder

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

MockWarpMessageWriterMockRecorder is the mock recorder for MockWarpMessageWriter.

func (*MockWarpMessageWriterMockRecorder) AddMessage

func (mr *MockWarpMessageWriterMockRecorder) AddMessage(unsignedMessage interface{}) *gomock.Call

AddMessage indicates an expected call of AddMessage.

type PredicateContext

type PredicateContext struct {
	SnowCtx *snow.Context
	// ProposerVMBlockCtx defines the ProposerVM context the predicate is verified within
	ProposerVMBlockCtx *block.Context
}

PredicateContext is the context passed in to the Predicater interface to verify a precompile predicate within a specific ProposerVM wrapper.

type Predicater

type Predicater interface {
	PredicateGas(storageSlots []byte) (uint64, error)
	VerifyPredicate(predicateContext *PredicateContext, predicates [][]byte) []byte
}

Predicater is an optional interface for StatefulPrecompileContracts to implement. If implemented, the predicate will be enforced on every transaction in a block, prior to the block's execution. If VerifyPredicate returns an error, the block will fail verification with no further processing. WARNING: If you are implementing a custom precompile, beware that coreth will not maintain backwards compatibility of this interface and your code should not rely on this. Designed for use only by precompiles that ship with coreth.

type SharedMemoryWriter

type SharedMemoryWriter interface {
	AddSharedMemoryRequests(chainID ids.ID, requests *atomic.Requests)
}

SharedMemoryWriter defines an interface to allow a precompile's Accepter to write operations into shared memory to be committed atomically on block accept.

type Upgrade

type Upgrade struct {
	BlockTimestamp *uint64 `json:"blockTimestamp"`
	Disable        bool    `json:"disable,omitempty"`
}

Upgrade contains the timestamp for the upgrade along with a boolean [Disable]. If [Disable] is set, the upgrade deactivates the precompile and clears its storage.

func (*Upgrade) Equal

func (u *Upgrade) Equal(other *Upgrade) bool

Equal returns true iff [other] has the same blockTimestamp and has the same on value for the Disable flag.

func (*Upgrade) IsDisabled

func (u *Upgrade) IsDisabled() bool

IsDisabled returns true if the network upgrade deactivates the precompile.

func (*Upgrade) Timestamp

func (u *Upgrade) Timestamp() *uint64

Timestamp returns the timestamp this network upgrade goes into effect.

type WarpMessageWriter

type WarpMessageWriter interface {
	AddMessage(unsignedMessage *warp.UnsignedMessage) error
}

Jump to

Keyboard shortcuts

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