protocol

package
v2.1.0-rc19 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package protocol is a generated GoMock package.

Index

Constants

View Source
const (
	// SystemNamespace is the namespace to store system information such as candidates/probationList/unproductiveDelegates
	SystemNamespace = "System"
)

Variables

View Source
var (
	ErrNoName = errors.New("name does not exist")
)

Errors

View Source
var (
	// ErrUnimplemented indicates a method is not implemented yet
	ErrUnimplemented = errors.New("method is unimplemented")
)
View Source
var (
	// MinTipCap is the minimum tip cap
	MinTipCap = big.NewInt(1)
)

Functions

func CalcBaseFee

func CalcBaseFee(g genesis.Blockchain, parent *TipInfo) *big.Int

CalcBaseFee calculates the basefee of the header.

func CalcBlobFee

func CalcBlobFee(excessBlobGas uint64) *big.Int

CalcBlobFee calculates the blobfee from the header's excess blob gas field.

func CalcExcessBlobGas

func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uint64

CalcExcessBlobGas calculates the excess blob gas after applying the set of blobs on top of the excess blob gas.

func EffectiveGasPrice

func EffectiveGasPrice(ctx context.Context, tx action.TxDynamicGas) *big.Int

func GetVMConfigCtx

func GetVMConfigCtx(ctx context.Context) (vm.Config, bool)

GetVMConfigCtx returns the vm config from context

func HashStringToAddress

func HashStringToAddress(str string) address.Address

HashStringToAddress generates the contract address from the protocolID of each protocol

func NewKVStoreForTrieWithStateManager

func NewKVStoreForTrieWithStateManager(ns string, sm StateManager) trie.KVStore

NewKVStoreForTrieWithStateManager creates a trie.KVStore with state manager

func NewKVStoreForTrieWithStateReader

func NewKVStoreForTrieWithStateReader(ns string, sr StateReader) trie.KVStore

NewKVStoreForTrieWithStateReader creates a trie.KVStore with state reader

func SplitGas

func SplitGas(ctx context.Context, tx action.TxDynamicGas, usedGas uint64) (*big.Int, *big.Int, error)

func VerifyEIP1559Header

func VerifyEIP1559Header(g genesis.Blockchain, parent *TipInfo, header blockHeader) error

func VerifyEIP4844Header

func VerifyEIP4844Header(parent *TipInfo, header blockHeader) error

VerifyEIP4844Header verifies the presence of the excessBlobGas field and that if the current block contains no transactions, the excessBlobGas is updated accordingly.

func WithActionCtx

func WithActionCtx(ctx context.Context, ac ActionCtx) context.Context

WithActionCtx add ActionCtx into context.

func WithBlockCtx

func WithBlockCtx(ctx context.Context, blk BlockCtx) context.Context

WithBlockCtx add BlockCtx into context.

func WithBlockchainCtx

func WithBlockchainCtx(ctx context.Context, bc BlockchainCtx) context.Context

WithBlockchainCtx add BlockchainCtx into context.

func WithFeatureCtx

func WithFeatureCtx(ctx context.Context) context.Context

WithFeatureCtx add FeatureCtx into context.

func WithFeatureWithHeightCtx

func WithFeatureWithHeightCtx(ctx context.Context) context.Context

WithFeatureWithHeightCtx add FeatureWithHeightCtx into context.

func WithRegistry

func WithRegistry(ctx context.Context, reg *Registry) context.Context

WithRegistry adds registry to context

func WithVMConfigCtx

func WithVMConfigCtx(ctx context.Context, vmConfig vm.Config) context.Context

WithVMConfigCtx adds vm config to context

Types

type AccountState

type AccountState func(context.Context, StateReader, address.Address) (*state.Account, error)

AccountState defines a function to return the account state of a given address

type ActionCtx

type ActionCtx struct {
	// Caller is the address of whom issues this action
	Caller address.Address
	// ActionHash is the hash of the action with the sealed envelope
	ActionHash hash.Hash256
	// GasPrice is the action gas price
	GasPrice *big.Int
	// IntrinsicGas is the action intrinsic gas
	IntrinsicGas uint64
	// Nonce is the nonce of the action
	Nonce uint64
	// ReadOnly indicates two scenarios: eth_estimateGas and eth_call
	ReadOnly bool
}

ActionCtx provides action auxiliary information.

func GetActionCtx

func GetActionCtx(ctx context.Context) (ActionCtx, bool)

GetActionCtx gets ActionCtx

func MustGetActionCtx

func MustGetActionCtx(ctx context.Context) ActionCtx

MustGetActionCtx must get ActionCtx . If context doesn't exist, this function panic.

type ActionHandler

type ActionHandler interface {
	Handle(context.Context, action.Envelope, StateManager) (*action.Receipt, error)
}

ActionHandler is the interface for the action handlers. For each incoming action, the assembled actions will be called one by one to process it. ActionHandler implementation is supposed to parse the sub-type of the action to decide if it wants to handle this action or not.

type ActionValidator

type ActionValidator interface {
	Validate(context.Context, action.Envelope, StateReader) error
}

ActionValidator is the interface of validating an action

type BaseStateContext

type BaseStateContext struct {
	Parameter *Parameters
	Method    *abi.Method
}

BaseStateContext base state context

func (*BaseStateContext) Parameters

func (r *BaseStateContext) Parameters() *Parameters

Parameters base state parameters

type BlockCtx

type BlockCtx struct {
	// height of block containing those actions
	BlockHeight uint64
	// timestamp of block containing those actions
	BlockTimeStamp time.Time
	// gas Limit for perform those actions
	GasLimit uint64
	// Producer is the address of whom composes the block containing this action
	Producer address.Address
	// AccumTips is the accumulated tips of the block
	AccumulatedTips big.Int
	// BaseFee is the base fee of the block
	BaseFee *big.Int
	// ExcessBlobGas is the excess blob gas of the block
	ExcessBlobGas uint64
	// SkipSidecarValidation dictates to validate sidecar (for blob tx) or not
	SkipSidecarValidation bool
}

BlockCtx provides block auxiliary information.

func GetBlockCtx

func GetBlockCtx(ctx context.Context) (BlockCtx, bool)

GetBlockCtx gets BlockCtx

func MustGetBlockCtx

func MustGetBlockCtx(ctx context.Context) BlockCtx

MustGetBlockCtx must get BlockCtx . If context doesn't exist, this function panic.

type BlockchainCtx

type BlockchainCtx struct {
	// Tip is the information of tip block
	Tip TipInfo
	//ChainID is the native chain ID
	ChainID uint32
	// EvmNetworkID is the EVM network ID
	EvmNetworkID uint32
}

BlockchainCtx provides blockchain auxiliary information.

func GetBlockchainCtx

func GetBlockchainCtx(ctx context.Context) (BlockchainCtx, bool)

GetBlockchainCtx gets BlockchainCtx

func MustGetBlockchainCtx

func MustGetBlockchainCtx(ctx context.Context) BlockchainCtx

MustGetBlockchainCtx must get BlockchainCtx. If context doesn't exist, this function panic.

type CheckFunc

type CheckFunc func(height uint64) bool

CheckFunc is function type to check by height.

type Committer

type Committer interface {
	Commit(context.Context, StateManager) error
}

Committer performs commit action of the protocol

type DepositGas

DepositGas deposits gas to rewarding pool and burns baseFee

type DepositOption

type DepositOption func(*DepositOptionCfg)

func BlobGasFeeOption

func BlobGasFeeOption(blobGasFee *big.Int) DepositOption

func PriorityFeeOption

func PriorityFeeOption(priorityFee *big.Int) DepositOption

type DepositOptionCfg

type DepositOptionCfg struct {
	PriorityFee *big.Int
	BlobGasFee  *big.Int
}

type Dock

type Dock interface {
	ProtocolDirty(string) bool
	Load(string, string, interface{}) error
	Unload(string, string, interface{}) error
	Reset()
}

Dock defines an interface for protocol to read/write their private data in StateReader/Manager data are stored as interface{}, user needs to type-assert on their own upon Unload()

func NewDock

func NewDock() Dock

NewDock returns a new dock

type FeatureCtx

type FeatureCtx struct {
	FixDoubleChargeGas                      bool
	SystemWideActionGasLimit                bool
	NotFixTopicCopyBug                      bool
	SetRevertMessageToReceipt               bool
	FixGetHashFnHeight                      bool
	FixSortCacheContractsAndUsePendingNonce bool
	AsyncContractTrie                       bool
	AddOutOfGasToTransactionLog             bool
	AddChainIDToConfig                      bool
	UseV2Storage                            bool
	CannotUnstakeAgain                      bool
	SkipStakingIndexer                      bool
	ReturnFetchError                        bool
	CannotTranferToSelf                     bool
	NewStakingReceiptFormat                 bool
	UpdateBlockMeta                         bool
	CurrentEpochProductivity                bool
	FixSnapshotOrder                        bool
	AllowCorrectDefaultChainID              bool
	CorrectGetHashFn                        bool
	CorrectTxLogIndex                       bool
	RevertLog                               bool
	TolerateLegacyAddress                   bool
	CreateLegacyNonceAccount                bool
	FixGasAndNonceUpdate                    bool
	FixUnproductiveDelegates                bool
	CorrectGasRefund                        bool
	SkipSystemActionNonce                   bool
	ValidateSystemAction                    bool
	AllowCorrectChainIDOnly                 bool
	AddContractStakingVotes                 bool
	FixContractStakingWeightedVotes         bool
	ExecutionSizeLimit32KB                  bool
	UseZeroNonceForFreshAccount             bool
	CandidateRegisterMustWithStake          bool
	DisableDelegateEndorsement              bool
	RefactorFreshAccountConversion          bool
	SuicideTxLogMismatchPanic               bool
	PanicUnrecoverableError                 bool
	CandidateIdentifiedByOwner              bool
	UseTxContainer                          bool
	LimitedStakingContract                  bool
	MigrateNativeStake                      bool
	AddClaimRewardAddress                   bool
	EnforceLegacyEndorsement                bool
	EnableAccessListTx                      bool
	EnableDynamicFeeTx                      bool
	EnableBlobTransaction                   bool
	SufficentBalanceGuarantee               bool
	EnableCancunEVM                         bool
	UnfoldContainerBeforeValidate           bool
	CorrectValidationOrder                  bool
	UnstakedButNotClearSelfStakeAmount      bool
	EnableNewTxTypes                        bool
	VerifyNotContainerBeforeRun             bool
	ValidateActionWithState                 bool
	CheckStakingDurationUpperLimit          bool
	DisallowSpecialAddressInTx              bool
	FixRevertSnapshot                       bool
}

FeatureCtx provides features information.

func GetFeatureCtx

func GetFeatureCtx(ctx context.Context) (FeatureCtx, bool)

GetFeatureCtx gets FeatureCtx.

func MustGetFeatureCtx

func MustGetFeatureCtx(ctx context.Context) FeatureCtx

MustGetFeatureCtx must get FeatureCtx. If context doesn't exist, this function panic.

type FeatureWithHeightCtx

type FeatureWithHeightCtx struct {
	GetUnproductiveDelegates CheckFunc
	ReadStateFromDB          CheckFunc
	UseV2Staking             CheckFunc
	EnableNativeStaking      CheckFunc
	StakingCorrectGas        CheckFunc
	CalculateProbationList   CheckFunc
	LoadCandidatesLegacy     CheckFunc
	CandCenterHasAlias       CheckFunc
}

FeatureWithHeightCtx provides feature check functions.

func GetFeatureWithHeightCtx

func GetFeatureWithHeightCtx(ctx context.Context) (FeatureWithHeightCtx, bool)

GetFeatureWithHeightCtx gets FeatureWithHeightCtx.

func MustGetFeatureWithHeightCtx

func MustGetFeatureWithHeightCtx(ctx context.Context) FeatureWithHeightCtx

MustGetFeatureWithHeightCtx must get FeatureWithHeightCtx. If context doesn't exist, this function panic.

type GenericValidator

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

GenericValidator is the validator for generic action verification

func NewGenericValidator

func NewGenericValidator(sr StateReader, accountState AccountState) *GenericValidator

NewGenericValidator constructs a new genericValidator

func (*GenericValidator) Validate

func (v *GenericValidator) Validate(ctx context.Context, selp *action.SealedEnvelope) error

Validate validates a generic action

func (*GenericValidator) ValidateWithState added in v2.1.0

func (v *GenericValidator) ValidateWithState(ctx context.Context, selp *action.SealedEnvelope) error

type GenesisStateCreator

type GenesisStateCreator interface {
	CreateGenesisStates(context.Context, StateManager) error
}

GenesisStateCreator creates some genesis states

type MockActionHandler

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

MockActionHandler is a mock of ActionHandler interface.

func NewMockActionHandler

func NewMockActionHandler(ctrl *gomock.Controller) *MockActionHandler

NewMockActionHandler creates a new mock instance.

func (*MockActionHandler) EXPECT

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

func (*MockActionHandler) Handle

Handle mocks base method.

type MockActionHandlerMockRecorder

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

MockActionHandlerMockRecorder is the mock recorder for MockActionHandler.

func (*MockActionHandlerMockRecorder) Handle

func (mr *MockActionHandlerMockRecorder) Handle(arg0, arg1, arg2 interface{}) *gomock.Call

Handle indicates an expected call of Handle.

type MockActionValidator

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

MockActionValidator is a mock of ActionValidator interface.

func NewMockActionValidator

func NewMockActionValidator(ctrl *gomock.Controller) *MockActionValidator

NewMockActionValidator creates a new mock instance.

func (*MockActionValidator) EXPECT

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

func (*MockActionValidator) Validate

func (m *MockActionValidator) Validate(arg0 context.Context, arg1 action.Envelope, arg2 StateReader) error

Validate mocks base method.

type MockActionValidatorMockRecorder

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

MockActionValidatorMockRecorder is the mock recorder for MockActionValidator.

func (*MockActionValidatorMockRecorder) Validate

func (mr *MockActionValidatorMockRecorder) Validate(arg0, arg1, arg2 interface{}) *gomock.Call

Validate indicates an expected call of Validate.

type MockCommitter

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

MockCommitter is a mock of Committer interface.

func NewMockCommitter

func NewMockCommitter(ctrl *gomock.Controller) *MockCommitter

NewMockCommitter creates a new mock instance.

func (*MockCommitter) Commit

func (m *MockCommitter) Commit(arg0 context.Context, arg1 StateManager) error

Commit mocks base method.

func (*MockCommitter) EXPECT

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

type MockCommitterMockRecorder

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

MockCommitterMockRecorder is the mock recorder for MockCommitter.

func (*MockCommitterMockRecorder) Commit

func (mr *MockCommitterMockRecorder) Commit(arg0, arg1 interface{}) *gomock.Call

Commit indicates an expected call of Commit.

type MockGenesisStateCreator

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

MockGenesisStateCreator is a mock of GenesisStateCreator interface.

func NewMockGenesisStateCreator

func NewMockGenesisStateCreator(ctrl *gomock.Controller) *MockGenesisStateCreator

NewMockGenesisStateCreator creates a new mock instance.

func (*MockGenesisStateCreator) CreateGenesisStates

func (m *MockGenesisStateCreator) CreateGenesisStates(arg0 context.Context, arg1 StateManager) error

CreateGenesisStates mocks base method.

func (*MockGenesisStateCreator) EXPECT

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

type MockGenesisStateCreatorMockRecorder

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

MockGenesisStateCreatorMockRecorder is the mock recorder for MockGenesisStateCreator.

func (*MockGenesisStateCreatorMockRecorder) CreateGenesisStates

func (mr *MockGenesisStateCreatorMockRecorder) CreateGenesisStates(arg0, arg1 interface{}) *gomock.Call

CreateGenesisStates indicates an expected call of CreateGenesisStates.

type MockPostSystemActionsCreator

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

MockPostSystemActionsCreator is a mock of PostSystemActionsCreator interface.

func NewMockPostSystemActionsCreator

func NewMockPostSystemActionsCreator(ctrl *gomock.Controller) *MockPostSystemActionsCreator

NewMockPostSystemActionsCreator creates a new mock instance.

func (*MockPostSystemActionsCreator) CreatePostSystemActions

func (m *MockPostSystemActionsCreator) CreatePostSystemActions(arg0 context.Context, arg1 StateReader) ([]action.Envelope, error)

CreatePostSystemActions mocks base method.

func (*MockPostSystemActionsCreator) EXPECT

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

type MockPostSystemActionsCreatorMockRecorder

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

MockPostSystemActionsCreatorMockRecorder is the mock recorder for MockPostSystemActionsCreator.

func (*MockPostSystemActionsCreatorMockRecorder) CreatePostSystemActions

func (mr *MockPostSystemActionsCreatorMockRecorder) CreatePostSystemActions(arg0, arg1 interface{}) *gomock.Call

CreatePostSystemActions indicates an expected call of CreatePostSystemActions.

type MockPreCommitter

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

MockPreCommitter is a mock of PreCommitter interface.

func NewMockPreCommitter

func NewMockPreCommitter(ctrl *gomock.Controller) *MockPreCommitter

NewMockPreCommitter creates a new mock instance.

func (*MockPreCommitter) EXPECT

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

func (*MockPreCommitter) PreCommit

func (m *MockPreCommitter) PreCommit(arg0 context.Context, arg1 StateManager) error

PreCommit mocks base method.

type MockPreCommitterMockRecorder

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

MockPreCommitterMockRecorder is the mock recorder for MockPreCommitter.

func (*MockPreCommitterMockRecorder) PreCommit

func (mr *MockPreCommitterMockRecorder) PreCommit(arg0, arg1 interface{}) *gomock.Call

PreCommit indicates an expected call of PreCommit.

type MockPreStatesCreator

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

MockPreStatesCreator is a mock of PreStatesCreator interface.

func NewMockPreStatesCreator

func NewMockPreStatesCreator(ctrl *gomock.Controller) *MockPreStatesCreator

NewMockPreStatesCreator creates a new mock instance.

func (*MockPreStatesCreator) CreatePreStates

func (m *MockPreStatesCreator) CreatePreStates(arg0 context.Context, arg1 StateManager) error

CreatePreStates mocks base method.

func (*MockPreStatesCreator) EXPECT

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

type MockPreStatesCreatorMockRecorder

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

MockPreStatesCreatorMockRecorder is the mock recorder for MockPreStatesCreator.

func (*MockPreStatesCreatorMockRecorder) CreatePreStates

func (mr *MockPreStatesCreatorMockRecorder) CreatePreStates(arg0, arg1 interface{}) *gomock.Call

CreatePreStates indicates an expected call of CreatePreStates.

type MockProtocol

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

MockProtocol is a mock of Protocol interface.

func NewMockProtocol

func NewMockProtocol(ctrl *gomock.Controller) *MockProtocol

NewMockProtocol creates a new mock instance.

func (*MockProtocol) EXPECT

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

func (*MockProtocol) ForceRegister

func (m *MockProtocol) ForceRegister(arg0 *Registry) error

ForceRegister mocks base method.

func (*MockProtocol) Handle

func (m *MockProtocol) Handle(arg0 context.Context, arg1 action.Envelope, arg2 StateManager) (*action.Receipt, error)

Handle mocks base method.

func (*MockProtocol) Name

func (m *MockProtocol) Name() string

Name mocks base method.

func (*MockProtocol) ReadState

func (m *MockProtocol) ReadState(arg0 context.Context, arg1 StateReader, arg2 []byte, arg3 ...[]byte) ([]byte, uint64, error)

ReadState mocks base method.

func (*MockProtocol) Register

func (m *MockProtocol) Register(arg0 *Registry) error

Register mocks base method.

type MockProtocolMockRecorder

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

MockProtocolMockRecorder is the mock recorder for MockProtocol.

func (*MockProtocolMockRecorder) ForceRegister

func (mr *MockProtocolMockRecorder) ForceRegister(arg0 interface{}) *gomock.Call

ForceRegister indicates an expected call of ForceRegister.

func (*MockProtocolMockRecorder) Handle

func (mr *MockProtocolMockRecorder) Handle(arg0, arg1, arg2 interface{}) *gomock.Call

Handle indicates an expected call of Handle.

func (*MockProtocolMockRecorder) Name

func (mr *MockProtocolMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockProtocolMockRecorder) ReadState

func (mr *MockProtocolMockRecorder) ReadState(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call

ReadState indicates an expected call of ReadState.

func (*MockProtocolMockRecorder) Register

func (mr *MockProtocolMockRecorder) Register(arg0 interface{}) *gomock.Call

Register indicates an expected call of Register.

type MockStarter

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

MockStarter is a mock of Starter interface.

func NewMockStarter

func NewMockStarter(ctrl *gomock.Controller) *MockStarter

NewMockStarter creates a new mock instance.

func (*MockStarter) EXPECT

func (m *MockStarter) EXPECT() *MockStarterMockRecorder

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

func (*MockStarter) Start

func (m *MockStarter) Start(arg0 context.Context, arg1 StateReader) (interface{}, error)

Start mocks base method.

type MockStarterMockRecorder

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

MockStarterMockRecorder is the mock recorder for MockStarter.

func (*MockStarterMockRecorder) Start

func (mr *MockStarterMockRecorder) Start(arg0, arg1 interface{}) *gomock.Call

Start indicates an expected call of Start.

type Parameters

type Parameters struct {
	MethodName []byte
	Arguments  [][]byte
}

Parameters state request parameters

type PostSystemActionsCreator

type PostSystemActionsCreator interface {
	CreatePostSystemActions(context.Context, StateReader) ([]action.Envelope, error)
}

PostSystemActionsCreator creates a list of system actions to be appended to block actions

type PreCommitter

type PreCommitter interface {
	PreCommit(context.Context, StateManager) error
}

PreCommitter performs pre-commit action of the protocol

type PreStatesCreator

type PreStatesCreator interface {
	CreatePreStates(context.Context, StateManager) error
}

PreStatesCreator creates preliminary states for state manager

type Protocol

type Protocol interface {
	ActionHandler
	ReadState(context.Context, StateReader, []byte, ...[]byte) ([]byte, uint64, error)
	Register(*Registry) error
	ForceRegister(*Registry) error
	Name() string
}

Protocol defines the protocol interfaces atop IoTeX blockchain

type Registry

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

Registry is the hub of all protocols deployed on the chain

func GetRegistry

func GetRegistry(ctx context.Context) (*Registry, bool)

GetRegistry returns the registry from context

func MustGetRegistry

func MustGetRegistry(ctx context.Context) *Registry

MustGetRegistry returns the registry from context

func NewRegistry

func NewRegistry() *Registry

NewRegistry create a new Registry

func (*Registry) All

func (r *Registry) All() []Protocol

All returns all protocols

func (*Registry) Find

func (r *Registry) Find(id string) (Protocol, bool)

Find finds a protocol by ID

func (*Registry) ForceRegister

func (r *Registry) ForceRegister(id string, p Protocol) error

ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists

func (*Registry) Register

func (r *Registry) Register(id string, p Protocol) error

Register registers the protocol with a unique ID

func (*Registry) StartAll

func (r *Registry) StartAll(ctx context.Context, sr StateReader) (View, error)

StartAll starts all protocols which are startable

type SerializableBytes

type SerializableBytes []byte

SerializableBytes defines a type of serializable bytes

func (*SerializableBytes) Deserialize

func (sb *SerializableBytes) Deserialize(data []byte) error

Deserialize copies data into bytes

func (SerializableBytes) Serialize

func (sb SerializableBytes) Serialize() ([]byte, error)

Serialize copies and return bytes

type SimulateOption

type SimulateOption func(*SimulateOptionConfig)

func WithSimulatePreOpt

func WithSimulatePreOpt(fn func(StateManager) error) SimulateOption

type SimulateOptionConfig

type SimulateOptionConfig struct {
	PreOpt     func(StateManager) error
	Nonce, Gas uint64
	GasPrice   *big.Int
}

type Starter

type Starter interface {
	Start(context.Context, StateReader) (interface{}, error)
}

Starter starts the protocol

type StateConfig

type StateConfig struct {
	Namespace string // namespace used by state's storage
	Key       []byte
	Keys      [][]byte
}

StateConfig is the config for accessing stateDB

func CreateStateConfig

func CreateStateConfig(opts ...StateOption) (*StateConfig, error)

CreateStateConfig creates a config for accessing stateDB

type StateContext

type StateContext interface {
	Parameters() *Parameters
	EncodeToEth(*iotexapi.ReadStateResponse) (string, error)
}

StateContext context for ReadState

type StateManager

type StateManager interface {
	StateReader
	// Accounts
	Snapshot() int
	Revert(int) error
	// General state
	PutState(interface{}, ...StateOption) (uint64, error)
	DelState(...StateOption) (uint64, error)
	WriteView(string, interface{}) error
	Dock
}

StateManager defines the stateDB interface atop IoTeX blockchain

type StateOption

type StateOption func(*StateConfig) error

StateOption sets parameter for access state

func KeyOption

func KeyOption(key []byte) StateOption

KeyOption sets the key for call

func KeysOption

func KeysOption(f func() ([][]byte, error)) StateOption

KeysOption sets the key for call

func LegacyKeyOption

func LegacyKeyOption(key hash.Hash160) StateOption

LegacyKeyOption sets the key for call with legacy key

func NamespaceOption

func NamespaceOption(ns string) StateOption

NamespaceOption creates an option for given namesapce

type StateReader

type StateReader interface {
	Height() (uint64, error)
	State(interface{}, ...StateOption) (uint64, error)
	States(...StateOption) (uint64, state.Iterator, error)
	ReadView(string) (interface{}, error)
}

StateReader defines an interface to read stateDB

type TipInfo

type TipInfo struct {
	Height        uint64
	GasUsed       uint64
	Hash          hash.Hash256
	Timestamp     time.Time
	BaseFee       *big.Int
	BlobGasUsed   uint64
	ExcessBlobGas uint64
}

TipInfo contains the tip block information

type View

type View map[string]interface{}

View stores the view for all protocols

func (View) Read

func (view View) Read(name string) (interface{}, error)

func (View) Write

func (view View) Write(name string, v interface{}) error

Directories

Path Synopsis
evm
Package staking is a generated GoMock package.
Package staking is a generated GoMock package.

Jump to

Keyboard shortcuts

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