precompileconfig

package
v0.0.0-...-9e22ca1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0, LGPL-3.0 Imports: 10 Imported by: 0

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 subnet-evm 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 subnet-evm.

type ChainConfig

type ChainConfig interface {
	// GetFeeConfig returns the original FeeConfig that was set in the genesis.
	GetFeeConfig() commontype.FeeConfig
	// AllowedFeeRecipients returns true if fee recipients are allowed in the genesis.
	AllowedFeeRecipients() bool
	// 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(arg0 *AcceptContext, arg1 common.Hash, arg2 uint64, arg3 common.Hash, arg4 int, arg5 []common.Hash, arg6 []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(arg0, arg1, arg2, arg3, arg4, arg5, arg6 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) AllowedFeeRecipients

func (m *MockChainConfig) AllowedFeeRecipients() bool

AllowedFeeRecipients mocks base method.

func (*MockChainConfig) EXPECT

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

func (*MockChainConfig) GetFeeConfig

func (m *MockChainConfig) GetFeeConfig() commontype.FeeConfig

GetFeeConfig mocks base method.

func (*MockChainConfig) IsDUpgrade

func (m *MockChainConfig) IsDUpgrade(arg0 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) AllowedFeeRecipients

func (mr *MockChainConfigMockRecorder) AllowedFeeRecipients() *gomock.Call

AllowedFeeRecipients indicates an expected call of AllowedFeeRecipients.

func (*MockChainConfigMockRecorder) GetFeeConfig

func (mr *MockChainConfigMockRecorder) GetFeeConfig() *gomock.Call

GetFeeConfig indicates an expected call of GetFeeConfig.

func (*MockChainConfigMockRecorder) IsDUpgrade

func (mr *MockChainConfigMockRecorder) IsDUpgrade(arg0 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(arg0 []byte) (uint64, error)

PredicateGas mocks base method.

func (*MockPredicater) VerifyPredicate

func (m *MockPredicater) VerifyPredicate(arg0 *PredicateContext, arg1 []byte) error

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(arg0 interface{}) *gomock.Call

PredicateGas indicates an expected call of PredicateGas.

func (*MockPredicaterMockRecorder) VerifyPredicate

func (mr *MockPredicaterMockRecorder) VerifyPredicate(arg0, arg1 interface{}) *gomock.Call

VerifyPredicate indicates an expected call of VerifyPredicate.

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(predicateBytes []byte) (uint64, error)
	VerifyPredicate(predicateContext *PredicateContext, predicateBytes []byte) error
}

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 subnet-evm 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 subnet-evm.

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