protocol

package
v2.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 23 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 = state.SystemNamespace
)

Variables

View Source
var (
	// ErrUnimplemented indicates a method is not implemented yet
	ErrUnimplemented = errors.New("method is unimplemented")
	// ErrNoName indicates the name is not found
	ErrNoName = errors.New("name is not found")
)
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 IsEraBoundary

func IsEraBoundary(epochNum, epochsPerEra uint64) bool

IsEraBoundary reports whether the given epoch number falls on an IIP-59 voter reward era boundary. An era boundary is any epoch where epochNum%epochsPerEra == 0. Epoch 0 is never a boundary because the genesis pre-epoch has no rewards to distribute; the first live boundary is at epoch epochsPerEra. epochsPerEra == 0 disables era boundaries entirely (used by tests that opt out of the era cadence).

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
	// Simulate is used for read-only APIs
	Simulate 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
	// GetBlockHash is the function to get block hash by height
	GetBlockHash func(uint64) (hash.Hash256, error)
	// GetBlockTime is the function to get block time by height
	GetBlockTime func(uint64) (time.Time, error)
}

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 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
	SufficentBalanceGuarantee               bool
	TolerateEmptyCandidateName              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
	LimitedStakingContract                  bool
	MigrateNativeStake                      bool
	AddClaimRewardAddress                   bool
	EnforceLegacyEndorsement                bool
	EnableDynamicFeeTx                      bool
	EnableBlobTransaction                   bool
	EnableCancunEVM                         bool
	CorrectValidationOrder                  bool
	UnstakedButNotClearSelfStakeAmount      bool
	CheckStakingDurationUpperLimit          bool
	FixRevertSnapshot                       bool
	TimestampedStakingContract              bool
	PreStateSystemAction                    bool
	CreatePostActionStates                  bool
	NotSlashUnproductiveDelegates           bool
	CandidateBLSPublicKey                   bool
	NotUseMinSelfStakeToBeActive            bool
	StoreVoteOfNFTBucketIntoView            bool
	CandidateSlashByOwner                   bool
	CandidateBLSPublicKeyNotCopied          bool
	OnlyOwnerCanUpdateBLSPublicKey          bool
	PrePectraEVM                            bool
	// AlwaysWriteCachedContract if true, CommitContracts writes back all cached
	// contracts regardless of whether they were modified; if false, only dirty
	// contracts are committed and written back
	AlwaysWriteCachedContract     bool
	NoCandidateExitQueue          bool
	FixInContractTransferLogTopic bool
	// CorrectPrestateForAbsentKeys, when true, makes contract.GetCommittedState
	// return the true tx-start prestate value (zero, via trie.ErrNotExist) for
	// storage slots that were absent in the pre-tx trie. Prior to this gate the
	// contract-level committed[] cache was populated with post-mutation values
	// for such slots, causing EIP-2200 SSTORE dynamic gas to misclassify
	// dirty in-place writes as SSTORE_RESET (100 → 2900 gas overcharge per hit).
	CorrectPrestateForAbsentKeys bool
	// NoVoterRewardDistribution gates IIP-59's protocol-native voter reward
	// distribution. Pre-fork (true) the poll layer does NOT freeze the
	// per-candidate CandidateRewardSnapshot and rewarding stays on the legacy
	// Hermes path. Post-fork (false) the snapshot is written at every
	// PutPollResult and rewarding consumes it. Bound to
	// !g.IsZanzibar(height): default zero-value = active after fork.
	NoVoterRewardDistribution bool
	// FixEpochSettlementFaultHandling corrects how faults raised during
	// epoch settlement are classified, in three places:
	//
	//   - the auto-deposit lookup and the compound bucket read no longer
	//     reroute a voter's share on a fault only some nodes saw; an absent
	//     or withdrawn bucket, which every node reads identically, still
	//     degrades to a direct credit;
	//   - an era boundary reached with no copy-on-write window skips the
	//     drain cursor instead of failing the whole epoch grant, which used
	//     to take that epoch's commissions, foundation bonus and sentinel
	//     down with it;
	//   - a GrantEpochReward error settles a Failure receipt only when it
	//     is derivable from committed state; the rest fail the block rather
	//     than let one node commit "this epoch paid nobody" against
	//     everyone else's full grant.
	//
	// Deliberately separate from NoVoterRewardDistribution. That gate is
	// what turns IIP-59 on, so a chain where it has already activated is
	// executing the pre-correction behaviour; changing it in place would
	// alter blocks that chain has already committed. This flag therefore
	// needs its own height, one fork later than the gate above:
	// Zanzibar Beta.
	FixEpochSettlementFaultHandling bool
	// RequireProfileForHermesMigration makes the activation-block Hermes
	// opt-in migration skip candidates whose DelegateProfile portions are
	// missing or only half set, leaving them on the off-chain Hermes payout
	// instead of moving them into an on-chain path that freezes them at
	// 100% commission and pays their voters nothing.
	//
	// Separate from NoVoterRewardDistribution because the migration is a
	// one-shot that runs in the single block that gate turns on at. A chain
	// where it has already fired has that block committed; changing what it
	// did would alter the block's receipt root and fork any node replaying
	// history. Carried by Zanzibar Beta.
	//
	// Because that migration is a one-shot in the block Zanzibar activates
	// at, this flag only ever has an effect where Zanzibar Beta is not
	// scheduled after Zanzibar. On a chain that activated Zanzibar first
	// the migration has already run unguarded and cannot be re-run, so the
	// flag is inert there by construction -- it exists to protect a chain
	// that activates both together. See ZanzibarBetaBlockHeight.
	RequireProfileForHermesMigration bool
	// EmitEraFreezeLog makes the era freeze emit one DelegateRewardFrozen
	// log per frozen delegate.
	//
	// Freezing is otherwise silent: the freeze block and its neighbours
	// carry the same single untopiced block-reward log, so an event-driven
	// indexer cannot tell an era was frozen, which delegates are in it, or
	// what commission each was frozen at.
	//
	// Receipt logs are part of the receipt root, so this needs its own
	// height rather than riding on the gate that turns IIP-59 on: a chain
	// that has already produced freeze blocks without these logs would
	// recompute different roots for them. Carried by Zanzibar Beta.
	EmitEraFreezeLog bool
	// EnforceBLSPoP gates the BLS proof-of-possession requirement at
	// candidate register / update. The staking handler validates
	// blsPubKey only with BLS12381PublicKeyFromBytes (format +
	// subgroup); without a possession proof, IIP-52's planned
	// FastAggregateVerify path is vulnerable to a rogue-key
	// aggregate-forgery attack (a registered candidate could publish
	// pk_rogue = g^x − Σ(other pubkeys) and, once aggregation goes
	// live, forge a 2/3+ quorum certificate with a single signature).
	// Activating EnforceBLSPoP BEFORE the BLS aggregation fork closes
	// the window for collecting un-attested pubkeys.
	EnforceBLSPoP bool
	// OptionalCandidateBLSPublicKey relaxes the Xingu-era rule that every
	// candidate register / update must carry a BLS public key. Post-fork
	// the key is optional -- nothing consumes it until IIP-52 aggregation
	// activates -- but a proof-of-possession may not arrive without one.
	// An update that omits both leaves any previously registered key
	// untouched.
	OptionalCandidateBLSPublicKey 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.

func (*FeatureCtx) Tolerate added in v2.2.0

func (fCtx *FeatureCtx) Tolerate(err error) bool

type FeatureWithHeightCtx

type FeatureWithHeightCtx struct {
	GetUnproductiveDelegates        CheckFunc
	ReadStateFromDB                 CheckFunc
	UseV2Staking                    CheckFunc
	EnableNativeStaking             CheckFunc
	StakingCorrectGas               CheckFunc
	CalculateProbationList          CheckFunc
	LoadCandidatesLegacy            CheckFunc
	CandCenterHasAlias              CheckFunc
	CandidateWithoutIdentity        CheckFunc
	CandidateWithoutIdentityStorage 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 any) *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 any) *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 any) *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 any) *gomock.Call

CreateGenesisStates indicates an expected call of CreateGenesisStates.

type MockPostActionHandler added in v2.3.0

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

MockPostActionHandler is a mock of PostActionHandler interface.

func NewMockPostActionHandler added in v2.3.0

func NewMockPostActionHandler(ctrl *gomock.Controller) *MockPostActionHandler

NewMockPostActionHandler creates a new mock instance.

func (*MockPostActionHandler) EXPECT added in v2.3.0

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

func (*MockPostActionHandler) HandleReceipt added in v2.3.0

func (m *MockPostActionHandler) HandleReceipt(ctx context.Context, elp action.Envelope, sm StateManager, receipt *action.Receipt) error

HandleReceipt mocks base method.

type MockPostActionHandlerMockRecorder added in v2.3.0

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

MockPostActionHandlerMockRecorder is the mock recorder for MockPostActionHandler.

func (*MockPostActionHandlerMockRecorder) HandleReceipt added in v2.3.0

func (mr *MockPostActionHandlerMockRecorder) HandleReceipt(ctx, elp, sm, receipt any) *gomock.Call

HandleReceipt indicates an expected call of HandleReceipt.

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 any) *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 any) *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 any) *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 any) *gomock.Call

ForceRegister indicates an expected call of ForceRegister.

func (*MockProtocolMockRecorder) Handle

func (mr *MockProtocolMockRecorder) Handle(arg0, arg1, arg2 any) *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 any, arg3 ...any) *gomock.Call

ReadState indicates an expected call of ReadState.

func (*MockProtocolMockRecorder) Register

func (mr *MockProtocolMockRecorder) Register(arg0 any) *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) (View, 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 any) *gomock.Call

Start indicates an expected call of Start.

type MockView added in v2.2.0

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

MockView is a mock of View interface.

func NewMockView added in v2.2.0

func NewMockView(ctrl *gomock.Controller) *MockView

NewMockView creates a new mock instance.

func (*MockView) Commit added in v2.2.0

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

Commit mocks base method.

func (*MockView) EXPECT added in v2.2.0

func (m *MockView) EXPECT() *MockViewMockRecorder

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

func (*MockView) Fork added in v2.3.0

func (m *MockView) Fork() View

Fork mocks base method.

func (*MockView) Revert added in v2.2.0

func (m *MockView) Revert(arg0 int) error

Revert mocks base method.

func (*MockView) Snapshot added in v2.2.0

func (m *MockView) Snapshot() int

Snapshot mocks base method.

type MockViewMockRecorder added in v2.2.0

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

MockViewMockRecorder is the mock recorder for MockView.

func (*MockViewMockRecorder) Commit added in v2.2.0

func (mr *MockViewMockRecorder) Commit(arg0, arg1 any) *gomock.Call

Commit indicates an expected call of Commit.

func (*MockViewMockRecorder) Fork added in v2.3.0

func (mr *MockViewMockRecorder) Fork() *gomock.Call

Fork indicates an expected call of Fork.

func (*MockViewMockRecorder) Revert added in v2.2.0

func (mr *MockViewMockRecorder) Revert(arg0 any) *gomock.Call

Revert indicates an expected call of Revert.

func (*MockViewMockRecorder) Snapshot added in v2.2.0

func (mr *MockViewMockRecorder) Snapshot() *gomock.Call

Snapshot indicates an expected call of Snapshot.

type Parameters

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

Parameters state request parameters

type PostActionHandler added in v2.2.0

type PostActionHandler interface {
	HandleReceipt(ctx context.Context, elp action.Envelope, sm StateManager, receipt *action.Receipt) error
}

PostActionHandler is the interface for the post action handlers. For each incoming action, the assembled actions

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) (Views, 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) (View, error)
}

Starter starts the protocol

type StateConfig

type StateConfig struct {
	Namespace       string // namespace used by state's storage
	Key             []byte
	Keys            [][]byte
	Object          any    // object used by state's storage
	ErigonStoreOnly bool   // whether only read/write from/to erigon store
	ErigonStoreKey  []byte // erigon store key used by state's storage. If nil, use Key field
	// RangeMin/RangeMax bound an ordered States() scan over the half-open
	// interval [RangeMin, RangeMax); nil means unbounded on that side. Limit
	// caps the number of results (<= 0 means unlimited). All three are unset by
	// default, in which case States() behaves exactly as it always has.
	RangeMin []byte
	RangeMax []byte
	Limit    int
}

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, View) error
}

StateManager defines the stateDB interface atop IoTeX blockchain

type StateManagerWithCloser added in v2.3.0

type StateManagerWithCloser interface {
	StateManager
	Close()
}

type StateOption

type StateOption func(*StateConfig) error

StateOption sets parameter for access state

func ErigonStoreKeyOption added in v2.3.3

func ErigonStoreKeyOption(key []byte) StateOption

ErigonStoreKeyOption sets the erigon store key for call

func ErigonStoreOnlyOption added in v2.3.0

func ErigonStoreOnlyOption() StateOption

ErigonStoreOnlyOption sets the option to only read/write from/to erigon store

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 LimitOption

func LimitOption(n int) StateOption

LimitOption caps States() at n results, taken from the start of the ascending key order. n <= 0 means unlimited.

This is mutually exclusive with KeyOption/KeysOption.

func NamespaceOption

func NamespaceOption(ns string) StateOption

NamespaceOption creates an option for given namesapce

func ObjectOption added in v2.3.0

func ObjectOption(obj any) StateOption

ObjectOption sets the object for call

func RangeOption

func RangeOption(min, max []byte) StateOption

RangeOption sets an ordered, half-open key range [min, max) for States().

min == nil means "from the start of the namespace", max == nil means "to the end of the namespace"; a key equal to max is NOT returned, so adjacent ranges can be tiled without overlap. Results come back ascending by bytes.Compare(key).

This is mutually exclusive with KeyOption/KeysOption.

type StateReader

type StateReader interface {
	Height() (uint64, error)
	State(interface{}, ...StateOption) (uint64, error)
	States(...StateOption) (uint64, state.Iterator, error)
	ReadView(string) (View, 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 interface {
	Fork() View
	Snapshot() int
	Revert(int) error
	Commit(context.Context, StateManager) error
}

type Views added in v2.2.0

type Views interface {
	Snapshot() int
	Revert(id int) error
	Fork() Views
	Commit(ctx context.Context, sm StateManager) error
	Read(name string) (View, error)
	Write(name string, v View)
}

Views stores the view for all protocols

func NewLazyViews added in v2.3.3

func NewLazyViews(loader func() Views) Views

NewLazyViews creates a lazy-loaded Views

func NewViews added in v2.2.0

func NewViews() Views

Directories

Path Synopsis
evm
autodeposit
Package autodeposit bridges the on-chain AutoDeposit contract into the IIP-59 protocol-native voter reward drain path.
Package autodeposit bridges the on-chain AutoDeposit contract into the IIP-59 protocol-native voter reward drain path.
delegateprofile
Package delegateprofile bridges the on-chain DelegateProfile contract into the IIP-59 protocol-native voter reward path.
Package delegateprofile bridges the on-chain DelegateProfile contract into the IIP-59 protocol-native voter reward path.
distributedlog
Package distributedlog encodes the IIP-59 §3.2 DelegateVoterRewardsDistributed receipt event.
Package distributedlog encodes the IIP-59 §3.2 DelegateVoterRewardsDistributed receipt event.
Package staking is a generated GoMock package.
Package staking is a generated GoMock package.
eracow
Package eracow implements the IIP-59 era copy-on-write layer.
Package eracow implements the IIP-59 era copy-on-write layer.
ethabi/v4
Package v4 historically hosts versioned bundled-struct getters (candidateByAddressV4, candidatesV4, ...).
Package v4 historically hosts versioned bundled-struct getters (candidateByAddressV4, candidatesV4, ...).
freezelog
Package freezelog encodes the event emitted when an IIP-59 era freezes a delegate's reward configuration.
Package freezelog encodes the event emitted when an IIP-59 era freezes a delegate's reward configuration.

Jump to

Keyboard shortcuts

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