Documentation ¶
Overview ¶
Defines the stateless interface for unmarshalling an arbitrary config of a precompile
TODO: replace with gomock
Package precompileconfig is a generated GoMock package.
Index ¶
- func NewNoopStatefulPrecompileConfig() *noopStatefulPrecompileConfig
- type AcceptContext
- type Accepter
- type Config
- type MockAccepter
- type MockAccepterMockRecorder
- type PrecompilePredicateContext
- type PrecompilePredicater
- type ProposerPredicateContext
- type ProposerPredicater
- type SharedMemoryWriter
- type Upgrade
- type WarpMessageWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNoopStatefulPrecompileConfig ¶
func NewNoopStatefulPrecompileConfig() *noopStatefulPrecompileConfig
Types ¶
type AcceptContext ¶ added in v0.5.0
type AcceptContext struct { SnowCtx *snow.Context 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, 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 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() 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 int, arg3 []common.Hash, arg4 []byte) error
Accept mocks base method.
func (*MockAccepter) EXPECT ¶ added in v0.5.3
func (m *MockAccepter) EXPECT() *MockAccepterMockRecorder
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 interface{}) *gomock.Call
Accept indicates an expected call of Accept.
type PrecompilePredicateContext ¶ added in v0.5.0
PrecompilePredicateContext is the context passed in to the PrecompilePredicater interface.
type PrecompilePredicater ¶ added in v0.5.0
type PrecompilePredicater interface { PredicateGas(storageSlots []byte) (uint64, error) VerifyPredicate(predicateContext *PrecompilePredicateContext, storageSlots []byte) error }
PrecompilePredicater 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 ProposerPredicateContext ¶ added in v0.5.0
type ProposerPredicateContext struct { PrecompilePredicateContext // ProposerVMBlockCtx defines the ProposerVM context the predicate is verified within ProposerVMBlockCtx *block.Context }
ProposerPredicateContext is the context passed in to the ProposerPredicater interface to verify a precompile predicate within a specific ProposerVM wrapper.
type ProposerPredicater ¶ added in v0.5.0
type ProposerPredicater interface { PredicateGas(storageSlots []byte) (uint64, error) VerifyPredicate(proposerPredicateContext *ProposerPredicateContext, storageSlots []byte) error }
ProposerPredicater is an optional interface for StatefulPrecompiledContracts 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. Note: ProposerVMBlockCtx is guaranteed to be non-nil. Precompiles should use ProposerPredicater instead of PrecompilePredicater iff their execution depends on the ProposerVM Block Context. 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 {
}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 ¶
Equal returns true iff [other] has the same blockTimestamp and has the same on value for the Disable flag.
func (*Upgrade) IsDisabled ¶
IsDisabled returns true if the network upgrade deactivates the precompile.
type WarpMessageWriter ¶ added in v0.5.0
type WarpMessageWriter interface {
AddMessage(unsignedMessage *warp.UnsignedMessage) error
}