precompileconfig

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: GPL-3.0, LGPL-3.0 Imports: 10 Imported by: 3

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 added in v0.5.0

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

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

type Accepter added in v0.5.0

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 added in v0.5.4

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 added in v0.5.3

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

MockAccepter is a mock of Accepter interface.

func NewMockAccepter added in v0.5.3

func NewMockAccepter(ctrl *gomock.Controller) *MockAccepter

NewMockAccepter creates a new mock instance.

func (*MockAccepter) Accept added in v0.5.3

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 added in v0.5.3

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

type MockAccepterMockRecorder added in v0.5.3

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

MockAccepterMockRecorder is the mock recorder for MockAccepter.

func (*MockAccepterMockRecorder) Accept added in v0.5.3

func (mr *MockAccepterMockRecorder) Accept(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call

Accept indicates an expected call of Accept.

type MockChainConfig added in v0.5.4

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

MockChainConfig is a mock of ChainConfig interface.

func NewMockChainConfig added in v0.5.4

func NewMockChainConfig(ctrl *gomock.Controller) *MockChainConfig

NewMockChainConfig creates a new mock instance.

func (*MockChainConfig) AllowedFeeRecipients added in v0.5.4

func (m *MockChainConfig) AllowedFeeRecipients() bool

AllowedFeeRecipients mocks base method.

func (*MockChainConfig) EXPECT added in v0.5.4

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

func (*MockChainConfig) GetFeeConfig added in v0.5.4

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

GetFeeConfig mocks base method.

func (*MockChainConfig) IsDUpgrade added in v0.5.6

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

IsDUpgrade mocks base method.

type MockChainConfigMockRecorder added in v0.5.4

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

MockChainConfigMockRecorder is the mock recorder for MockChainConfig.

func (*MockChainConfigMockRecorder) AllowedFeeRecipients added in v0.5.4

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

AllowedFeeRecipients indicates an expected call of AllowedFeeRecipients.

func (*MockChainConfigMockRecorder) GetFeeConfig added in v0.5.4

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

GetFeeConfig indicates an expected call of GetFeeConfig.

func (*MockChainConfigMockRecorder) IsDUpgrade added in v0.5.6

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

IsDUpgrade indicates an expected call of IsDUpgrade.

type MockConfig added in v0.5.4

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

MockConfig is a mock of Config interface.

func NewMockConfig added in v0.5.4

func NewMockConfig(ctrl *gomock.Controller) *MockConfig

NewMockConfig creates a new mock instance.

func (*MockConfig) EXPECT added in v0.5.4

func (m *MockConfig) EXPECT() *MockConfigMockRecorder

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

func (*MockConfig) Equal added in v0.5.4

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

Equal mocks base method.

func (*MockConfig) IsDisabled added in v0.5.4

func (m *MockConfig) IsDisabled() bool

IsDisabled mocks base method.

func (*MockConfig) Key added in v0.5.4

func (m *MockConfig) Key() string

Key mocks base method.

func (*MockConfig) Timestamp added in v0.5.4

func (m *MockConfig) Timestamp() *uint64

Timestamp mocks base method.

func (*MockConfig) Verify added in v0.5.4

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

Verify mocks base method.

type MockConfigMockRecorder added in v0.5.4

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

MockConfigMockRecorder is the mock recorder for MockConfig.

func (*MockConfigMockRecorder) Equal added in v0.5.4

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

Equal indicates an expected call of Equal.

func (*MockConfigMockRecorder) IsDisabled added in v0.5.4

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

IsDisabled indicates an expected call of IsDisabled.

func (*MockConfigMockRecorder) Key added in v0.5.4

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

Key indicates an expected call of Key.

func (*MockConfigMockRecorder) Timestamp added in v0.5.4

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

Timestamp indicates an expected call of Timestamp.

func (*MockConfigMockRecorder) Verify added in v0.5.4

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

Verify indicates an expected call of Verify.

type MockPredicater added in v0.5.6

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

MockPredicater is a mock of Predicater interface.

func NewMockPredicater added in v0.5.6

func NewMockPredicater(ctrl *gomock.Controller) *MockPredicater

NewMockPredicater creates a new mock instance.

func (*MockPredicater) EXPECT added in v0.5.6

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

func (*MockPredicater) PredicateGas added in v0.5.6

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

PredicateGas mocks base method.

func (*MockPredicater) VerifyPredicate added in v0.5.6

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

VerifyPredicate mocks base method.

type MockPredicaterMockRecorder added in v0.5.6

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

MockPredicaterMockRecorder is the mock recorder for MockPredicater.

func (*MockPredicaterMockRecorder) PredicateGas added in v0.5.6

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

PredicateGas indicates an expected call of PredicateGas.

func (*MockPredicaterMockRecorder) VerifyPredicate added in v0.5.6

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

VerifyPredicate indicates an expected call of VerifyPredicate.

type PredicateContext added in v0.5.4

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 added in v0.5.4

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 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 added in v0.5.0

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 added in v0.5.0

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