Documentation
¶
Index ¶
- Variables
- type ETBuffer
- type ETBufferOption
- type GenericTxSystem
- func (m *GenericTxSystem) BeginBlock(roundNo uint64) error
- func (m *GenericTxSystem) Commit(uc *types.UnicityCertificate) error
- func (m *GenericTxSystem) CommittedUC() *types.UnicityCertificate
- func (m *GenericTxSystem) CurrentRound() uint64
- func (m *GenericTxSystem) EndBlock() (*StateSummary, error)
- func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (tr *types.TransactionRecord, err error)
- func (m *GenericTxSystem) GetUnit(id types.UnitID, committed bool) (state.Unit, error)
- func (m *GenericTxSystem) IsFeelessMode() bool
- func (m *GenericTxSystem) IsPermissionedMode() bool
- func (m *GenericTxSystem) Revert()
- func (m *GenericTxSystem) SerializeState(writer io.Writer) error
- func (m *GenericTxSystem) State() StateReader
- func (m *GenericTxSystem) StateSize() (uint64, error)
- func (m *GenericTxSystem) StateSummary() (*StateSummary, error)
- func (m *GenericTxSystem) TypeID() types.PartitionTypeID
- type Observability
- type Option
- func WithBeginBlockFunctions(funcs ...func(blockNumber uint64) error) Option
- func WithEndBlockFunctions(funcs ...func(blockNumber uint64) error) Option
- func WithExecutedTransactions(executedTransactions map[string]uint64) Option
- func WithFeeCredits(f txtypes.FeeCreditModule) Option
- func WithHashAlgorithm(hashAlgorithm crypto.Hash) Option
- func WithState(s *state.State) Option
- type Options
- type StateReader
- type StateSummary
- type StateUnlockProof
- type StateUnlockProofKind
- type TransactionExecutor
- type TransactionSystem
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ETBuffer ¶
type ETBuffer struct {
// contains filtered or unexported fields
}
ETBuffer Executed Transactions Buffer. It is used to avoid processing the same transaction multiple times which would allow someone else to drain your fee credit by re-broadcasting the already processed transaction, since fees would still be charged for the duplicate transaction for verifying the fee predicate.
func NewETBuffer ¶
func NewETBuffer(opts ...ETBufferOption) *ETBuffer
func (*ETBuffer) ClearExpired ¶
ClearExpired deletes expired transactions from the buffer.
type ETBufferOption ¶
type ETBufferOption func(*ETBuffer)
func WithExecutedTxs ¶
func WithExecutedTxs(txs map[string]uint64) ETBufferOption
type GenericTxSystem ¶
type GenericTxSystem struct {
// contains filtered or unexported fields
}
func NewGenericTxSystem ¶
func NewGenericTxSystem(shardConf types.PartitionDescriptionRecord, modules []txtypes.Module, observe Observability, opts ...Option) (*GenericTxSystem, error)
func (*GenericTxSystem) BeginBlock ¶
func (m *GenericTxSystem) BeginBlock(roundNo uint64) error
func (*GenericTxSystem) Commit ¶
func (m *GenericTxSystem) Commit(uc *types.UnicityCertificate) error
func (*GenericTxSystem) CommittedUC ¶
func (m *GenericTxSystem) CommittedUC() *types.UnicityCertificate
func (*GenericTxSystem) CurrentRound ¶
func (m *GenericTxSystem) CurrentRound() uint64
func (*GenericTxSystem) EndBlock ¶
func (m *GenericTxSystem) EndBlock() (*StateSummary, error)
func (*GenericTxSystem) Execute ¶
func (m *GenericTxSystem) Execute(tx *types.TransactionOrder) (tr *types.TransactionRecord, err error)
func (*GenericTxSystem) IsFeelessMode ¶
func (m *GenericTxSystem) IsFeelessMode() bool
func (*GenericTxSystem) IsPermissionedMode ¶
func (m *GenericTxSystem) IsPermissionedMode() bool
func (*GenericTxSystem) Revert ¶
func (m *GenericTxSystem) Revert()
func (*GenericTxSystem) SerializeState ¶
func (m *GenericTxSystem) SerializeState(writer io.Writer) error
func (*GenericTxSystem) State ¶
func (m *GenericTxSystem) State() StateReader
func (*GenericTxSystem) StateSize ¶
func (m *GenericTxSystem) StateSize() (uint64, error)
func (*GenericTxSystem) StateSummary ¶
func (m *GenericTxSystem) StateSummary() (*StateSummary, error)
func (*GenericTxSystem) TypeID ¶
func (m *GenericTxSystem) TypeID() types.PartitionTypeID
type Observability ¶
type Option ¶
func WithBeginBlockFunctions ¶
func WithEndBlockFunctions ¶
func WithFeeCredits ¶
func WithFeeCredits(f txtypes.FeeCreditModule) Option
func WithHashAlgorithm ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func DefaultOptions ¶
func DefaultOptions(observe Observability) (*Options, error)
type StateReader ¶
type StateReader interface {
GetUnit(id types.UnitID, committed bool) (state.Unit, error)
CreateUnitStateProof(id types.UnitID, logIndex int) (*types.UnitStateProof, error)
CreateIndex(state.KeyExtractor[string]) (state.Index[string], error)
// Serialize writes the serialized state to the given writer.
Serialize(writer io.Writer, committed bool, executedTransactions map[string]uint64) error
GetUnits(unitTypeID *uint32, pdr *types.PartitionDescriptionRecord) ([]types.UnitID, error)
}
type StateSummary ¶
type StateSummary struct {
// contains filtered or unexported fields
}
StateSummary represents aggregate state hashes of the transaction system.
func NewStateSummary ¶
func NewStateSummary(rootHash []byte, summary []byte, etHash []byte) *StateSummary
func (StateSummary) ETHash ¶
func (s StateSummary) ETHash() []byte
func (StateSummary) Root ¶
func (s StateSummary) Root() []byte
func (StateSummary) Summary ¶
func (s StateSummary) Summary() []byte
type StateUnlockProof ¶
type StateUnlockProof struct {
Kind StateUnlockProofKind
Proof []byte
}
type StateUnlockProofKind ¶
type StateUnlockProofKind byte
const ( StateUnlockRollback StateUnlockProofKind = iota StateUnlockExecute )
type TransactionExecutor ¶
type TransactionExecutor interface {
// Execute method executes the transaction order. An error must be returned if the transaction order execution
// was not successful.
Execute(order *types.TransactionOrder) (*types.TransactionRecord, error)
}
type TransactionSystem ¶
type TransactionSystem interface {
TransactionExecutor
// StateSummary returns the summary of the current state of the transaction system or an ErrStateContainsUncommittedChanges if
// current state contains uncommitted changes.
StateSummary() (*StateSummary, error)
StateSize() (uint64, error)
// BeginBlock signals the start of a new block and is invoked before any Execute method calls.
BeginBlock(uint64) error
// EndBlock signals the end of the block and is called after all transactions have been delivered to the
// transaction system.
EndBlock() (*StateSummary, error)
// Revert signals the unsuccessful consensus round. When called the transaction system must revert all the changes
// made during the BeginBlock, EndBlock, and Execute method calls.
Revert()
// Commit signals the successful consensus round. Called after the block was approved by the root chain. When called
// the transaction system must commit all the changes made during the BeginBlock,
// EndBlock, and Execute method calls.
Commit(uc *types.UnicityCertificate) error
// CommittedUC returns the unicity certificate of the latest commit.
CommittedUC() *types.UnicityCertificate
// State returns clone of transaction system state
State() StateReader
// IsPermissionedMode returns true if permissioned mode is enabled and only transactions from approved parties
// are executed.
IsPermissionedMode() bool
// IsFeelessMode returns true if feeless mode is enabled and the cost of executing transactions is 0.
IsFeelessMode() bool
// TypeID returns the type identifier of the transaction system.
TypeID() types.PartitionTypeID
SerializeState(writer io.Writer) error
}
TransactionSystem is a set of rules and logic for defining units and performing transactions with them. The following sequence of methods is executed for each block: BeginBlock, Execute (called once for each transaction in the block), EndBlock, and Commit (consensus round was successful) or Revert (consensus round was unsuccessful).